@ -23,13 +23,13 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
for ( ; model ; model = CSWnextModel ( model ) )
for ( ; model ; model = CSWnextModel ( model ) )
for ( here = CSWinstances ( model ) ; here ; here = CSWnextInstance ( here ) ) {
for ( here = CSWinstances ( model ) ; here ; here = CSWnextInstance ( here ) ) {
lastChange =
lastChange =
ckt - > CKTstates [ 0 ] [ here - > CSWstate + 1 ] -
ckt - > CKTstates [ 1 ] [ here - > CSWstate + 1 ] ;
if ( ckt - > CKTstates [ 0 ] [ here - > CSWstate + 0 ] = = 0 ) {
ckt - > CKTstate0 [ here - > CSWctrlvalue ] -
ckt - > CKTstate1 [ here - > CSWctrlvalue ] ;
if ( ckt - > CKTstate0 [ here - > CSWswitchs tate ] = = 0 ) {
ref = model - > CSWiThreshold + model - > CSWiHysteresis ;
ref = model - > CSWiThreshold + model - > CSWiHysteresis ;
if ( ckt - > CKTstates [ 0 ] [ here - > CSWstate + 1 ] < ref & & lastChange > 0 ) {
if ( ckt - > CKTstate0 [ here - > CSWctrlvalue ] < ref & & lastChange > 0 ) {
maxChange =
maxChange =
( ref - ckt - > CKTstates [ 0 ] [ here - > CSWstate + 1 ] ) * 0.75
( ref - ckt - > CKTstate0 [ here - > CSWctrlvalue ] ) * 0.75
+ 0.00005 ;
+ 0.00005 ;
maxStep = maxChange / lastChange * ckt - > CKTdeltaOld [ 0 ] ;
maxStep = maxChange / lastChange * ckt - > CKTdeltaOld [ 0 ] ;
if ( * timeStep > maxStep )
if ( * timeStep > maxStep )
@ -37,9 +37,9 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
}
}
} else {
} else {
ref = model - > CSWiThreshold - model - > CSWiHysteresis ;
ref = model - > CSWiThreshold - model - > CSWiHysteresis ;
if ( ckt - > CKTstates [ 0 ] [ here - > CSWstate + 1 ] > ref & & lastChange < 0 ) {
if ( ckt - > CKTstate0 [ here - > CSWctrlvalue ] > ref & & lastChange < 0 ) {
maxChange =
maxChange =
( ref - ckt - > CKTstates [ 0 ] [ here - > CSWstate + 1 ] ) * 0.75
( ref - ckt - > CKTstate0 [ here - > CSWctrlvalue ] ) * 0.75
- 0.00005 ;
- 0.00005 ;
maxStep = maxChange / lastChange * ckt - > CKTdeltaOld [ 0 ] ;
maxStep = maxChange / lastChange * ckt - > CKTdeltaOld [ 0 ] ;
if ( * timeStep > maxStep )
if ( * timeStep > maxStep )