Jspice3
swacload.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 int
15 SWacLoad(inModel,ckt)
16 
17 GENmodel *inModel;
18 CKTcircuit *ckt;
19 /* load the current values into the
20  * sparse matrix previously provided
21  * during AC analysis.
22  */
23 {
24  SWmodel *model = (SWmodel *)inModel;
25  SWinstance *here;
26  double g_now;
27  int current_state;
28 
29  /* loop through all the switch models */
30  for ( ; model != NULL; model = model->SWnextModel) {
31 
32  /* loop through all the instances of the model */
33  for (here = model->SWinstances; here != NULL;
34  here = here->SWnextInstance) {
35 
36  /* In AC analysis, just propogate the state... */
37 
38  current_state = (int)*(ckt->CKTstate0 + here->SWstate);
39 
40  g_now = current_state?(model->SWonConduct):(model->SWoffConduct);
41 
42  *(here->SWposPosptr) += g_now;
43  *(here->SWposNegptr) -= g_now;
44  *(here->SWnegPosptr) -= g_now;
45  *(here->SWnegNegptr) += g_now;
46  }
47  }
48  return (OK);
49 }
#define OK
Definition: iferrmsg.h:17
double * SWposNegptr
Definition: swdefs.h:36
int SWacLoad(GENmodel *inModel, CKTcircuit *ckt)
Definition: swacload.c:15
#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
struct sSWmodel * SWnextModel
Definition: swdefs.h:60