Jspice3
indask.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3f2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1985 Thomas L. Quarles
5  1992 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 #include "spice.h"
9 #include <stdio.h>
10 #include <math.h>
11 #include "inddefs.h"
12 #include "tskdefs.h"
13 #include "sperror.h"
14 #include "util.h"
15 
16 
17 /*ARGSUSED*/
18 int
19 INDask(ckt,inst,which,value,select)
20 
21 CKTcircuit *ckt;
22 GENinstance *inst;
23 int which;
24 IFvalue *value;
25 IFvalue *select;
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
int INDask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *select)
Definition: indask.c:19
#define OK
Definition: iferrmsg.h:17
#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 INDbrEq
Definition: inddefs.h:42
double INDinduct
Definition: inddefs.h:51