Jspice3
capask.c File Reference
#include "spice.h"
#include <stdio.h>
#include <math.h>
#include "capdefs.h"
#include "tskdefs.h"
#include "sperror.h"
#include "util.h"
Include dependency graph for capask.c:

Go to the source code of this file.

Functions

int CAPask (CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *select)
 

Function Documentation

int CAPask ( CKTcircuit ckt,
GENinstance inst,
int  which,
IFvalue value,
IFvalue select 
)

Definition at line 19 of file capask.c.

26 {
27  CAPinstance *here = (CAPinstance *)inst;
28  static char *msg = "Current and power not available for ac analysis";
29 
30  switch (which) {
31 
32  case CAP_CAP:
33  value->rValue = here->CAPcapac;
34  break;
35  case CAP_IC:
36  value->rValue = here->CAPinitCond;
37  break;
38  case CAP_WIDTH:
39  value->rValue = here->CAPwidth;
40  break;
41  case CAP_LENGTH:
42  value->rValue = here->CAPlength;
43  break;
44  case CAP_CURRENT:
45  if (ckt->CKTcurrentAnalysis & DOING_AC) {
46  errMsg = MALLOC(strlen(msg)+1);
47  errRtn = "CAPask";
48  strcpy(errMsg,msg);
49  return (E_ASKCURRENT);
50  }
51  if (ckt->CKTcurrentAnalysis & DOING_TRAN) {
52  if (!(ckt->CKTmode & MODETRANOP)) {
53  if (ckt->CKTstate0)
54  value->rValue = *(ckt->CKTstate0 + here->CAPccap);
55  }
56  }
57  break;
58  case CAP_POWER:
59  if (ckt->CKTcurrentAnalysis & DOING_AC) {
60  errMsg = MALLOC(strlen(msg)+1);
61  errRtn = "CAPask";
62  strcpy(errMsg,msg);
63  return (E_ASKPOWER);
64  }
65  if (ckt->CKTcurrentAnalysis & DOING_TRAN) {
66  if (!(ckt->CKTmode & MODETRANOP)) {
67  if (ckt->CKTstate0 && ckt->CKTrhsOld)
68  value->rValue = *(ckt->CKTstate0 + here->CAPccap) *
69  (*(ckt->CKTrhsOld + here->CAPposNode) -
70  *(ckt->CKTrhsOld + here->CAPnegNode));
71  }
72  }
73  break;
74  default:
75  return (E_BADPARM);
76  }
77  return (OK);
78 }
int CAPnegNode
Definition: capdefs.h:26
#define E_ASKCURRENT
Definition: sperror.h:26
#define CAP_CURRENT
Definition: capdefs.h:80
#define CAP_POWER
Definition: capdefs.h:81
char * strcpy()
#define CAP_CAP
Definition: capdefs.h:76
char * errMsg
Definition: main.c:42
#define E_BADPARM
Definition: iferrmsg.h:26
double rValue
Definition: ifsim.h:233
#define DOING_AC
Definition: tskdefs.h:24
#define OK
Definition: iferrmsg.h:17
double * CKTrhsOld
Definition: cktdefs.h:98
double CAPwidth
Definition: capdefs.h:31
#define CAP_LENGTH
Definition: capdefs.h:79
#define MALLOC(x)
Definition: util.h:9
int CAPposNode
Definition: capdefs.h:25
double CAPinitCond
Definition: capdefs.h:28
double CAPlength
Definition: capdefs.h:32
#define MODETRANOP
Definition: cktdefs.h:151
#define DOING_TRAN
Definition: tskdefs.h:25
char * errRtn
Definition: main.c:41
#define E_ASKPOWER
Definition: sperror.h:27
int CKTcurrentAnalysis
Definition: cktdefs.h:130
#define CAP_IC
Definition: capdefs.h:77
double CAPcapac
Definition: capdefs.h:27
long CKTmode
Definition: cktdefs.h:139
#define CAP_WIDTH
Definition: capdefs.h:78