Added some file I forgot to add in the previous commit (was rather big)
This commit is contained in:
parent
0875108157
commit
b3c950634f
|
|
@ -0,0 +1,53 @@
|
|||
/**********
|
||||
Copyright 1990 Regents of the University of California. All rights reserved.
|
||||
Author: 1985 Thomas L. Quarles
|
||||
Modified: 2000 AlansFixes
|
||||
**********/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "spice.h"
|
||||
#include <stdio.h>
|
||||
#include "cktdefs.h"
|
||||
#include "csw\cswdefs.h"
|
||||
#include "sperror.h"
|
||||
#include "suffix.h"
|
||||
|
||||
|
||||
int
|
||||
CSWtrunc(inModel,ckt,timeStep)
|
||||
GENmodel *inModel;
|
||||
register CKTcircuit *ckt;
|
||||
register double *timeStep;
|
||||
{
|
||||
register CSWmodel *model = (CSWmodel*)inModel;
|
||||
register CSWinstance *here;
|
||||
|
||||
double lastChange, maxChange, maxStep, ref;
|
||||
|
||||
for( ; model!= NULL; model = model->CSWnextModel) {
|
||||
for(here = model->CSWinstances ; here != NULL ;
|
||||
here = here->CSWnextInstance) {
|
||||
lastChange = *(ckt->CKTstate0+(here->CSWstate+1)) -
|
||||
*(ckt->CKTstate1+(here->CSWstate+1));
|
||||
if (*(ckt->CKTstate0+(here->CSWstate))==0) {
|
||||
ref = (model->CSWiThreshold + model->CSWiHysteresis);
|
||||
if ((*(ckt->CKTstate0+(here->CSWstate+1))<ref) && (lastChange>0)) {
|
||||
maxChange = (ref - *(ckt->CKTstate0+(here->CSWstate+1))) *
|
||||
0.75 + 0.00005;
|
||||
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep) { *timeStep = maxStep; }
|
||||
}
|
||||
} else {
|
||||
ref = (model->CSWiThreshold - model->CSWiHysteresis);
|
||||
if ((*(ckt->CKTstate0+(here->CSWstate+1))>ref) && (lastChange<0)) {
|
||||
maxChange = (ref - *(ckt->CKTstate0+(here->CSWstate+1))) *
|
||||
0.75 - 0.00005;
|
||||
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep) { *timeStep = maxStep; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/**********
|
||||
Copyright 1990 Regents of the University of California. All rights reserved.
|
||||
Author: 1985 Thomas L. Quarles
|
||||
Modified: 2000 AlansFixes
|
||||
**********/
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "spice.h"
|
||||
#include <stdio.h>
|
||||
#include "cktdefs.h"
|
||||
#include "sw\swdefs.h"
|
||||
#include "sperror.h"
|
||||
#include "suffix.h"
|
||||
|
||||
|
||||
int
|
||||
SWtrunc(inModel,ckt,timeStep)
|
||||
GENmodel *inModel;
|
||||
register CKTcircuit *ckt;
|
||||
register double *timeStep;
|
||||
{
|
||||
register SWmodel *model = (SWmodel*)inModel;
|
||||
register SWinstance *here;
|
||||
|
||||
double lastChange, maxChange, maxStep, ref;
|
||||
|
||||
for( ; model!= NULL; model = model->SWnextModel) {
|
||||
for(here = model->SWinstances ; here != NULL ;
|
||||
here = here->SWnextInstance) {
|
||||
lastChange = *(ckt->CKTstate0+(here->SWstate+1)) -
|
||||
*(ckt->CKTstate1+(here->SWstate+1));
|
||||
if (*(ckt->CKTstate0+(here->SWstate))==0) {
|
||||
ref = (model->SWvThreshold + model->SWvHysteresis);
|
||||
if ((*(ckt->CKTstate0+(here->SWstate+1))<ref) && (lastChange>0)) {
|
||||
maxChange = (ref - *(ckt->CKTstate0+(here->SWstate+1))) *
|
||||
0.75 + 0.05;
|
||||
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep) { *timeStep = maxStep; }
|
||||
}
|
||||
} else {
|
||||
ref = (model->SWvThreshold - model->SWvHysteresis);
|
||||
if ((*(ckt->CKTstate0+(here->SWstate+1))>ref) && (lastChange<0)) {
|
||||
maxChange = (ref - *(ckt->CKTstate0+(here->SWstate+1))) *
|
||||
0.75 - 0.05;
|
||||
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep) { *timeStep = maxStep; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/**********
|
||||
Copyright 1990 Regents of the University of California. All rights reserved.
|
||||
Author: 1985 Thomas L. Quarles
|
||||
Modified: 2000 AlansFixes
|
||||
**********/
|
||||
|
||||
/* INPdoOpts(ckt,option card)
|
||||
* parse the options off of the given option card and add them to
|
||||
* the given circuit
|
||||
*/
|
||||
|
||||
#include "ngspice.h"
|
||||
#include <stdio.h>
|
||||
#include "inpdefs.h"
|
||||
#include "ifsim.h"
|
||||
#include "cpdefs.h"
|
||||
#include "fteext.h"
|
||||
|
||||
|
||||
void
|
||||
INPdoOpts(ckt,anal,optCard,tab)
|
||||
void *ckt;
|
||||
void *anal;
|
||||
card *optCard;
|
||||
INPtables *tab;
|
||||
{
|
||||
char *line;
|
||||
char *token;
|
||||
char *errmsg;
|
||||
IFvalue *val;
|
||||
int error;
|
||||
int i;
|
||||
int which;
|
||||
IFanalysis *prm;
|
||||
|
||||
which = -1;
|
||||
i=0;
|
||||
for(i=0;i<ft_sim->numAnalyses;i++) {
|
||||
prm = ft_sim->analyses[i];
|
||||
if(strcmp(prm->name,"options")==0) {
|
||||
which = i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if(which == -1) {
|
||||
optCard->error = INPerrCat(optCard->error,INPmkTemp(
|
||||
"errr: analysis options table not found\n"));
|
||||
return;
|
||||
}
|
||||
line = optCard->line;
|
||||
INPgetTok(&line,&token,1); /* throw away '.option' */
|
||||
while (*line) {
|
||||
INPgetTok(&line,&token,1);
|
||||
for(i=0;i<prm->numParms;i++) {
|
||||
if(strcmp(token,prm->analysisParms[i].keyword) == 0) {
|
||||
if(!(prm->analysisParms[i].dataType & IF_UNIMP_MASK)) {
|
||||
errmsg = (char *)MALLOC((45+strlen(token)) * sizeof(char));
|
||||
(void) sprintf(errmsg,
|
||||
" Warning: %s not yet implemented - ignored \n",token);
|
||||
optCard->error = INPerrCat(optCard->error,errmsg);
|
||||
val = INPgetValue(ckt,&line,
|
||||
prm->analysisParms[i].dataType, tab);
|
||||
break;
|
||||
}
|
||||
if(prm->analysisParms[i].dataType & IF_SET) {
|
||||
val = INPgetValue(ckt,&line,
|
||||
prm->analysisParms[i].dataType&IF_VARTYPES, tab);
|
||||
error = (*(ft_sim->setAnalysisParm))(ckt,anal,
|
||||
prm->analysisParms[i].id,val,(IFvalue*)NULL);
|
||||
if(error) {
|
||||
errmsg =(char *)MALLOC((35+strlen(token))*sizeof(char));
|
||||
(void) sprintf(errmsg,
|
||||
"Warning: can't set optione %s\n", token);
|
||||
optCard->error = INPerrCat(optCard->error, errmsg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(i == prm->numParms) {
|
||||
errmsg = (char *)MALLOC(100 * sizeof(char));
|
||||
(void) strcpy(errmsg," Error: unknown option - ignored\n");
|
||||
optCard->error = INPerrCat(optCard->error,errmsg);
|
||||
fprintf(stderr, "%s\n", optCard->error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/**********
|
||||
Copyright 1990 Regents of the University of California. All rights reserved.
|
||||
Author: 1985 Thomas L. Quarles
|
||||
Modified: AlansFixes
|
||||
**********/
|
||||
|
||||
#include <config.h>
|
||||
#include <ngspice.h>
|
||||
#include <iferrmsg.h>
|
||||
#include <inpmacs.h>
|
||||
|
||||
#include "inppas3.h"
|
||||
|
||||
|
||||
/* pass 3 - Read all nodeset and IC lines. All circuit nodes will have been
|
||||
* created by now, (except for internal device nodes), so any nodeset or IC
|
||||
* nodes which have to be created are flagged with a warning.
|
||||
*/
|
||||
|
||||
void
|
||||
INPpas3(void *ckt, card *data, INPtables *tab, void *task)
|
||||
{
|
||||
|
||||
card *current;
|
||||
int error; /* used by the macros defined above */
|
||||
char *line; /* the part of the current line left to parse */
|
||||
char *name; /* the node's name */
|
||||
char *token; /* a token from the line */
|
||||
IFparm *prm; /* pointer to parameter to search through array */
|
||||
IFvalue ptemp; /* a value structure to package resistance into */
|
||||
int which; /* which analysis we are performing */
|
||||
int length; /* length of a name */
|
||||
void *node1; /* the first node's node pointer */
|
||||
|
||||
for(current = data; current != NULL; current = current->nextcard) {
|
||||
|
||||
line = current->line;
|
||||
INPgetTok(&line,&token,1);
|
||||
|
||||
if (strcmp(token,".nodeset")==0) {
|
||||
which = -1;
|
||||
for(prm=ft_sim->nodeParms;
|
||||
prm<ft_sim->nodeParms+ft_sim->numNodeParms;prm++) {
|
||||
if(strcmp(prm->keyword,"nodeset")==0) {
|
||||
which=prm->id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(which == -1) {
|
||||
LITERR("nodeset unknown to simulator. \n")
|
||||
return;
|
||||
}
|
||||
for(;;) { /* loop until we run out of data */
|
||||
INPgetTok(&line,&name,1);
|
||||
/* check to see if in the form V(xxx) and grab the xxx */
|
||||
if( *name == (char)NULL) break; /* end of line */
|
||||
length = strlen(name);
|
||||
if( (*name == 'V' || *(name) == 'v') && (length == 1)){
|
||||
/* looks like V - must be V(xx) - get xx now*/
|
||||
INPgetTok(&line,&name,1);
|
||||
if (INPtermInsert(ckt,&name,tab,&node1)!=E_EXISTS)
|
||||
fprintf(stderr,
|
||||
"Warning : Nodeset on non-existant node - %s\n", name);
|
||||
ptemp.rValue = INPevaluate(&line,&error,1);
|
||||
IFC(setNodeParm,(ckt,node1,which,&ptemp,(IFvalue*)NULL))
|
||||
continue;
|
||||
}
|
||||
LITERR(" Error: .nodeset syntax error.\n")
|
||||
break;
|
||||
}
|
||||
} else if ( (strcmp(token,".ic")==0)){
|
||||
/* .ic */
|
||||
which = -1;
|
||||
for(prm=ft_sim->nodeParms;
|
||||
prm<ft_sim->nodeParms+ft_sim->numNodeParms;prm++) {
|
||||
if(strcmp(prm->keyword,"ic")==0) {
|
||||
which=prm->id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(which==-1) {
|
||||
LITERR("ic unknown to simulator. \n")
|
||||
return;
|
||||
}
|
||||
for(;;) { /* loop until we run out of data */
|
||||
INPgetTok(&line,&name,1);
|
||||
/* check to see if in the form V(xxx) and grab the xxx */
|
||||
if( *name == 0) break; /* end of line */
|
||||
length = strlen(name);
|
||||
if( (*name == 'V' || *(name) == 'v') && (length == 1)){
|
||||
/* looks like V - must be V(xx) - get xx now*/
|
||||
INPgetTok(&line,&name,1);
|
||||
if (INPtermInsert(ckt,&name,tab,&node1)!=E_EXISTS)
|
||||
fprintf(stderr,
|
||||
"Warning : IC on non-existant node - %s\n", name);
|
||||
ptemp.rValue = INPevaluate(&line,&error,1);
|
||||
IFC(setNodeParm,(ckt,node1,which,&ptemp,(IFvalue*)NULL))
|
||||
continue;
|
||||
}
|
||||
LITERR(" Error: .ic syntax error.\n")
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
/* AlansFixes */
|
||||
#ifndef _INPPAS3_H
|
||||
#define _INPPAS3_H
|
||||
|
||||
#include <inpdefs.h>
|
||||
|
||||
void INPpas3(void *ckt, card *data, INPtables *tab, void *task);
|
||||
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue