Jspice3
swpzload.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3e2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1985 Gordon M. Jacobs
5  1992 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 #include "spice.h"
9 #include <stdio.h>
10 #include "swdefs.h"
11 #include "sperror.h"
12 
13 
14 /* ARGSUSED */
15 int
16 SWpzLoad(inModel,ckt,s)
17 
18 GENmodel *inModel;
19 CKTcircuit *ckt;
20 SPcomplex *s;
21 /* load the current values into the
22  * sparse matrix previously provided
23  * during AC analysis.
24  */
25 {
26  SWmodel *model = (SWmodel *)inModel;
27  SWinstance *here;
28  double g_now;
29  int current_state;
30 
31  /* loop through all the switch models */
32  for ( ; model != NULL; model = model->SWnextModel) {
33 
34  /* loop through all the instances of the model */
35  for (here = model->SWinstances; here != NULL;
36  here = here->SWnextInstance) {
37 
38  /* In AC analysis, just propogate the state... */
39 
40  current_state = (int)*(ckt->CKTstate0 + here->SWstate);
41 
42  g_now = current_state?(model->SWonConduct):(model->SWoffConduct);
43 
44  *(here->SWposPosptr) += g_now;
45  *(here->SWposNegptr) -= g_now;
46  *(here->SWnegPosptr) -= g_now;
47  *(here->SWnegNegptr) += g_now;
48  }
49  }
50  return (OK);
51 }
Definition: cddefs.h:119
#define OK
Definition: iferrmsg.h:17
double * SWposNegptr
Definition: swdefs.h:36
#define NULL
Definition: spdefs.h:121
double SWonConduct
Definition: swdefs.h:72
struct sSWinstance * SWnextInstance
Definition: swdefs.h:20
int SWstate
Definition: swdefs.h:23
double * SWnegPosptr
Definition: swdefs.h:34
double * SWnegNegptr
Definition: swdefs.h:38
static char model[32]
Definition: subckt.c:76
SWinstance * SWinstances
Definition: swdefs.h:62
double * SWposPosptr
Definition: swdefs.h:32
double SWoffConduct
Definition: swdefs.h:73
int SWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
Definition: swpzload.c:16
struct sSWmodel * SWnextModel
Definition: swdefs.h:60