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: UCB CAD Group
5          1993 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 #include "spice.h"
9 #include <stdio.h>
10 #include "cktdefs.h"
11 #include "sensdefs.h"
12 #include "jobdefs.h"
13 #include "iferrmsg.h"
14 
15 
16 /* ARGSUSED */
17 int
SENSsetParm(cktp,anal,which,value)18 SENSsetParm(cktp,anal,which,value)
19 
20 GENERIC *cktp;
21 GENERIC *anal;
22 int which;
23 IFvalue *value;
24 {
25     SENSAN *job = (SENSAN *) anal;
26 
27     switch (which) {
28 
29         case SENS_DEFTOL:
30             job->SENSdefTol = value->rValue;
31             break;
32 
33         case SENS_DEFPERTURB:
34             job->SENSdefPert = value->rValue;
35             break;
36 
37         case SENS_POS:
38             job->SENSoutPos = (CKTnode *) value->nValue;
39             break;
40 
41         case SENS_NEG:
42             job->SENSoutNeg = (CKTnode *) value->nValue;
43             break;
44 
45         case SENS_SRC:
46             job->SENSoutSrc = value->uValue;
47             break;
48 
49         case SENS_NAME:
50             job->SENSoutName = value->sValue;
51             break;
52 
53         default:
54             if (ACsetp(&job->AC,which,value) == OK)
55                 return (OK);
56             if (DCTsetp(&job->DC,which,value) == OK)
57                 return (OK);
58             return (E_BADPARM);
59     }
60     return (OK);
61 }
62 
63 
64 static IFparm SENSparms[] = {
65  { "deftol",   SENS_DEFTOL, IFP|IF_REAL,   "default tolerance" },
66  { "defperturb",SENS_DEFPERTURB, IFP|IF_REAL, "default perterbation" },
67  { "outpos",   SENS_POS,  IFP|IF_NODE,     "output positive node" },
68  { "outneg",   SENS_NEG,  IFP|IF_NODE,     "output negative node" },
69  { "outsrc",   SENS_SRC,  IFP|IF_INSTANCE, "output current" },
70  { "outname",  SENS_NAME, IFP|IF_STRING,   "output variable name" },
71  { "start",    AC_START,  IFP|IF_REAL,     "starting frequency" },
72  { "stop",     AC_STOP,   IFP|IF_REAL,     "ending frequency" },
73  { "numsteps", AC_STEPS,  IFP|IF_INTEGER,  "number of frequencies"},
74  { "dec",      AC_DEC,    IFP|IF_FLAG,     "step by decades" },
75  { "oct",      AC_OCT,    IFP|IF_FLAG,     "step by octaves" },
76  { "lin",      AC_LIN,    IFP|IF_FLAG,     "step linearly" },
77  { "name1",    DC_NAME1,  IFP|IF_INSTANCE, "name of source to step" },
78  { "start1",   DC_START1, IFP|IF_REAL,     "starting voltage/current"},
79  { "stop1",    DC_STOP1,  IFP|IF_REAL,     "ending voltage/current" },
80  { "step1",    DC_STEP1,  IFP|IF_REAL,     "voltage/current step" },
81  { "name2",    DC_NAME2,  IFP|IF_INSTANCE, "name of source to step" },
82  { "start2",   DC_START2, IFP|IF_REAL,     "starting voltage/current"},
83  { "stop2",    DC_STOP2,  IFP|IF_REAL,     "ending voltage/current" },
84  { "step2",    DC_STEP2,  IFP|IF_REAL,     "voltage/current step" }
85 
86 #ifdef notdef
87  /* Future coding */
88  /* perturbation limits */
89  /* defaults for the analysis */
90  { "type",       SENS_TYPE, IF_SET|IF_INTEGER,
91      "describe device, model or element parameters" },
92 
93  { "device",     SENS_DEVICE, IF_STRING, "type of model or device" },
94  { "devdeftol",  SENS_DEVDEFTOL, IF_SET|IF_REAL,
95      "default tolerance (device type)" },
96  { "devdefperturb",SENS_DEVDEFPERT, IF_SET|IF_REAL,
97      "default perturbation (device type)" },
98  { "moddeftol",  SENS_DEVDEFTOL, IF_SET|IF_REAL,
99      "default tolerance (model)" },
100  { "moddefperturb",SENS_DEVDEFPERT, IF_SET|IF_REAL,
101      "default perturbation (model)" },
102 
103  /*{ "name",       SENS_NAME, IF_SET|IF_STRING,
104      "name of model or element" }, */
105  { "param",      SENS_PARAM,IF_SET|IF_STRING, "name of parameter" },
106  { "tol",        SENS_TOL, IF_SET|IF_REAL, "tolerance" },
107  { "perturb",    SENS_PERT, IF_SET|IF_REAL, "perturbation" }
108 #endif
109 
110 };
111 
112 SPICEanalysis SENSinfo  = {
113     {
114         "SENS",
115         "Sensitivity analysis",
116         sizeof(SENSparms)/sizeof(IFparm),
117         SENSparms
118     },
119     sizeof(SENSAN),
120     FREQUENCYDOMAIN,
121     SENSparse,
122     SENSsetParm,
123     SENSaskQuest,
124     SENSan
125 };
126