The previous fix for Bug #467 - ".OPTION INTERP has accuracy issue"

(359e3d46) updated variable timeold inside a loop so that
all interpolations after the first caused division by zero.
That caused the xspice/delta-sigma example to fail.
Set the variable once at the end of the function.
This commit is contained in:
Giles Atkinson 2023-12-18 18:14:28 +00:00 committed by Holger Vogt
parent 81351555da
commit af31904f99
1 changed files with 2 additions and 14 deletions

View File

@ -1469,21 +1469,18 @@ InterpFileAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
if (run->refIndex != -1) {
/* Save first time step */
if (refValue->rValue == run->circuit->CKTinitTime) {
timeold = refValue->rValue;
fileStartPoint(run->fp, run->binary, run->pointCount);
fileAddRealValue(run->fp, run->binary, run->circuit->CKTinitTime);
interpolatenow = nodata = FALSE;
}
/* Save last time step */
else if (refValue->rValue == run->circuit->CKTfinalTime) {
timeold = refValue->rValue;
fileStartPoint(run->fp, run->binary, run->pointCount);
fileAddRealValue(run->fp, run->binary, run->circuit->CKTfinalTime);
interpolatenow = nodata = FALSE;
}
/* Save exact point */
else if (refValue->rValue == timestep) {
timeold = refValue->rValue;
fileStartPoint(run->fp, run->binary, run->pointCount);
fileAddRealValue(run->fp, run->binary, timestep);
timestep += run->circuit->CKTstep;
@ -1501,7 +1498,6 @@ InterpFileAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
else {
/* Do not save this step */
run->pointCount--;
timeold = refValue->rValue;
nodata = TRUE;
interpolatenow = FALSE;
}
@ -1542,7 +1538,6 @@ InterpFileAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
newval = (timestep - run->circuit->CKTstep - timeold)/(timenew - timeold) * (valuenew[i] - valueold[i]) + valueold[i];
fileAddRealValue(run->fp, run->binary, newval);
valueold[i] = valuenew[i];
timeold = refValue->rValue;
}
else if (nodata)
/* Just keep the transient output value corresponding to timeold,
@ -1574,7 +1569,6 @@ InterpFileAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
newval = (timestep - run->circuit->CKTstep - timeold)/(timenew - timeold) * (valuenew[i] - valueold[i]) + valueold[i];
fileAddRealValue(run->fp, run->binary, newval);
valueold[i] = valuenew[i];
timeold = refValue->rValue;
}
else if (nodata)
/* Just keep the transient output value corresponding to timeold,
@ -1587,7 +1581,7 @@ InterpFileAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
#endif
}
timeold = refValue->rValue;
fileEndPoint(run->fp, run->binary);
/* Check that the write to disk completed successfully, otherwise abort */
@ -1634,19 +1628,16 @@ InterpPlotAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
/* Save first time step */
if (refValue->rValue == run->circuit->CKTinitTime) {
timeold = refValue->rValue;
plotAddRealValue(&run->data[iscale], refValue->rValue);
interpolatenow = nodata = FALSE;
}
/* Save last time step */
else if (refValue->rValue == run->circuit->CKTfinalTime) {
timeold = refValue->rValue;
plotAddRealValue(&run->data[iscale], run->circuit->CKTfinalTime);
interpolatenow = nodata = FALSE;
}
/* Save exact point */
else if (refValue->rValue == timestep) {
timeold = refValue->rValue;
plotAddRealValue(&run->data[iscale], timestep);
timestep += run->circuit->CKTstep;
interpolatenow = nodata = FALSE;
@ -1662,7 +1653,6 @@ InterpPlotAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
else {
/* Do not save this step */
run->pointCount--;
timeold = refValue->rValue;
nodata = TRUE;
interpolatenow = FALSE;
}
@ -1707,7 +1697,6 @@ InterpPlotAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
newval = (timestep - run->circuit->CKTstep - timeold)/(timenew - timeold) * (valuenew[i] - valueold[i]) + valueold[i];
plotAddRealValue(&run->data[i], newval);
valueold[i] = valuenew[i];
timeold = refValue->rValue;
}
else if (nodata)
/* Just keep the transient output value corresponding to timeold,
@ -1730,7 +1719,6 @@ InterpPlotAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
newval = (timestep - run->circuit->CKTstep - timeold)/(timenew - timeold) * (valuenew[i] - valueold[i]) + valueold[i];
plotAddRealValue(&run->data[i], newval);
valueold[i] = valuenew[i];
timeold = refValue->rValue;
}
else if (nodata)
/* Just keep the transient output value corresponding to timeold,
@ -1744,7 +1732,7 @@ InterpPlotAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
#endif
}
timeold = refValue->rValue;
gr_iplot(run->runPlot);
if (ft_bpcheck(run->runPlot, run->pointCount) == FALSE)