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

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 19 of file indask.c.

26 {
27  INDinstance *here = (INDinstance*)inst;
28  static char *msg = "Current and power not available for ac analysis";
29 
30  switch (which) {
31 
32  case IND_FLUX:
33  if (ckt->CKTstate0)
34  value->rValue = *(ckt->CKTstate0+here->INDflux);
35  break;
36  case IND_VOLT:
37  if (ckt->CKTstate0)
38  value->rValue = *(ckt->CKTstate0+here->INDvolt);
39  break;
40  case IND_IND:
41  value->rValue = here->INDinduct;
42  break;
43  case IND_IC:
44  value->rValue = here->INDinitCond;
45  break;
46  case IND_CURRENT :
47  if (ckt->CKTcurrentAnalysis & DOING_AC) {
48  errMsg = MALLOC(strlen(msg)+1);
49  errRtn = "INDask";
50  strcpy(errMsg,msg);
51  return (E_ASKCURRENT);
52  }
53  if (ckt->CKTrhsOld)
54  value->rValue = *(ckt->CKTrhsOld + here->INDbrEq);
55  break;
56  case IND_POWER :
57  if (ckt->CKTcurrentAnalysis & DOING_AC) {
58  errMsg = MALLOC(strlen(msg)+1);
59  errRtn = "INDask";
60  strcpy(errMsg,msg);
61  return (E_ASKPOWER);
62  }
63  if (ckt->CKTstate0 && ckt->CKTrhsOld)
64  value->rValue = *(ckt->CKTrhsOld + here->INDbrEq) *
65  *(ckt->CKTstate0+here->INDvolt);
66  break;
67  default:
68  return (E_BADPARM);
69  }
70  return (OK);
71 }
#define IND_CURRENT
Definition: inddefs.h:116
#define E_ASKCURRENT
Definition: sperror.h:26
char * strcpy()
#define IND_VOLT
Definition: inddefs.h:115
char * errMsg
Definition: main.c:42
#define IND_IND
Definition: inddefs.h:112
#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
#define MALLOC(x)
Definition: util.h:9
#define IND_POWER
Definition: inddefs.h:117
#define IND_FLUX
Definition: inddefs.h:114
#define IND_IC
Definition: inddefs.h:113
char * errRtn
Definition: main.c:41
#define E_ASKPOWER
Definition: sperror.h:27
double INDinitCond
Definition: inddefs.h:54
int CKTcurrentAnalysis
Definition: cktdefs.h:130
int INDbrEq
Definition: inddefs.h:42
double INDinduct
Definition: inddefs.h:51