Jspice3
capask.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 "capdefs.h"
12 #include "tskdefs.h"
13 #include "sperror.h"
14 #include "util.h"
15 
16 
17 /* ARGSUSED */
18 int
19 CAPask(ckt,inst, which, value, select)
20 
21 CKTcircuit *ckt;
22 GENinstance *inst;
23 int which;
24 IFvalue *value;
25 IFvalue *select;
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 }
79 
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
int CAPask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *select)
Definition: capask.c:19
#define DOING_AC
Definition: tskdefs.h:24
#define OK
Definition: iferrmsg.h:17
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
#define CAP_IC
Definition: capdefs.h:77
double CAPcapac
Definition: capdefs.h:27
#define CAP_WIDTH
Definition: capdefs.h:78