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:
parent
81351555da
commit
af31904f99
|
|
@ -1469,21 +1469,18 @@ InterpFileAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
|
||||||
if (run->refIndex != -1) {
|
if (run->refIndex != -1) {
|
||||||
/* Save first time step */
|
/* Save first time step */
|
||||||
if (refValue->rValue == run->circuit->CKTinitTime) {
|
if (refValue->rValue == run->circuit->CKTinitTime) {
|
||||||
timeold = refValue->rValue;
|
|
||||||
fileStartPoint(run->fp, run->binary, run->pointCount);
|
fileStartPoint(run->fp, run->binary, run->pointCount);
|
||||||
fileAddRealValue(run->fp, run->binary, run->circuit->CKTinitTime);
|
fileAddRealValue(run->fp, run->binary, run->circuit->CKTinitTime);
|
||||||
interpolatenow = nodata = FALSE;
|
interpolatenow = nodata = FALSE;
|
||||||
}
|
}
|
||||||
/* Save last time step */
|
/* Save last time step */
|
||||||
else if (refValue->rValue == run->circuit->CKTfinalTime) {
|
else if (refValue->rValue == run->circuit->CKTfinalTime) {
|
||||||
timeold = refValue->rValue;
|
|
||||||
fileStartPoint(run->fp, run->binary, run->pointCount);
|
fileStartPoint(run->fp, run->binary, run->pointCount);
|
||||||
fileAddRealValue(run->fp, run->binary, run->circuit->CKTfinalTime);
|
fileAddRealValue(run->fp, run->binary, run->circuit->CKTfinalTime);
|
||||||
interpolatenow = nodata = FALSE;
|
interpolatenow = nodata = FALSE;
|
||||||
}
|
}
|
||||||
/* Save exact point */
|
/* Save exact point */
|
||||||
else if (refValue->rValue == timestep) {
|
else if (refValue->rValue == timestep) {
|
||||||
timeold = refValue->rValue;
|
|
||||||
fileStartPoint(run->fp, run->binary, run->pointCount);
|
fileStartPoint(run->fp, run->binary, run->pointCount);
|
||||||
fileAddRealValue(run->fp, run->binary, timestep);
|
fileAddRealValue(run->fp, run->binary, timestep);
|
||||||
timestep += run->circuit->CKTstep;
|
timestep += run->circuit->CKTstep;
|
||||||
|
|
@ -1501,7 +1498,6 @@ InterpFileAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
|
||||||
else {
|
else {
|
||||||
/* Do not save this step */
|
/* Do not save this step */
|
||||||
run->pointCount--;
|
run->pointCount--;
|
||||||
timeold = refValue->rValue;
|
|
||||||
nodata = TRUE;
|
nodata = TRUE;
|
||||||
interpolatenow = FALSE;
|
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];
|
newval = (timestep - run->circuit->CKTstep - timeold)/(timenew - timeold) * (valuenew[i] - valueold[i]) + valueold[i];
|
||||||
fileAddRealValue(run->fp, run->binary, newval);
|
fileAddRealValue(run->fp, run->binary, newval);
|
||||||
valueold[i] = valuenew[i];
|
valueold[i] = valuenew[i];
|
||||||
timeold = refValue->rValue;
|
|
||||||
}
|
}
|
||||||
else if (nodata)
|
else if (nodata)
|
||||||
/* Just keep the transient output value corresponding to timeold,
|
/* 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];
|
newval = (timestep - run->circuit->CKTstep - timeold)/(timenew - timeold) * (valuenew[i] - valueold[i]) + valueold[i];
|
||||||
fileAddRealValue(run->fp, run->binary, newval);
|
fileAddRealValue(run->fp, run->binary, newval);
|
||||||
valueold[i] = valuenew[i];
|
valueold[i] = valuenew[i];
|
||||||
timeold = refValue->rValue;
|
|
||||||
}
|
}
|
||||||
else if (nodata)
|
else if (nodata)
|
||||||
/* Just keep the transient output value corresponding to timeold,
|
/* Just keep the transient output value corresponding to timeold,
|
||||||
|
|
@ -1587,7 +1581,7 @@ InterpFileAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
timeold = refValue->rValue;
|
||||||
fileEndPoint(run->fp, run->binary);
|
fileEndPoint(run->fp, run->binary);
|
||||||
|
|
||||||
/* Check that the write to disk completed successfully, otherwise abort */
|
/* 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 */
|
/* Save first time step */
|
||||||
if (refValue->rValue == run->circuit->CKTinitTime) {
|
if (refValue->rValue == run->circuit->CKTinitTime) {
|
||||||
timeold = refValue->rValue;
|
|
||||||
plotAddRealValue(&run->data[iscale], refValue->rValue);
|
plotAddRealValue(&run->data[iscale], refValue->rValue);
|
||||||
interpolatenow = nodata = FALSE;
|
interpolatenow = nodata = FALSE;
|
||||||
}
|
}
|
||||||
/* Save last time step */
|
/* Save last time step */
|
||||||
else if (refValue->rValue == run->circuit->CKTfinalTime) {
|
else if (refValue->rValue == run->circuit->CKTfinalTime) {
|
||||||
timeold = refValue->rValue;
|
|
||||||
plotAddRealValue(&run->data[iscale], run->circuit->CKTfinalTime);
|
plotAddRealValue(&run->data[iscale], run->circuit->CKTfinalTime);
|
||||||
interpolatenow = nodata = FALSE;
|
interpolatenow = nodata = FALSE;
|
||||||
}
|
}
|
||||||
/* Save exact point */
|
/* Save exact point */
|
||||||
else if (refValue->rValue == timestep) {
|
else if (refValue->rValue == timestep) {
|
||||||
timeold = refValue->rValue;
|
|
||||||
plotAddRealValue(&run->data[iscale], timestep);
|
plotAddRealValue(&run->data[iscale], timestep);
|
||||||
timestep += run->circuit->CKTstep;
|
timestep += run->circuit->CKTstep;
|
||||||
interpolatenow = nodata = FALSE;
|
interpolatenow = nodata = FALSE;
|
||||||
|
|
@ -1662,7 +1653,6 @@ InterpPlotAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
|
||||||
else {
|
else {
|
||||||
/* Do not save this step */
|
/* Do not save this step */
|
||||||
run->pointCount--;
|
run->pointCount--;
|
||||||
timeold = refValue->rValue;
|
|
||||||
nodata = TRUE;
|
nodata = TRUE;
|
||||||
interpolatenow = FALSE;
|
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];
|
newval = (timestep - run->circuit->CKTstep - timeold)/(timenew - timeold) * (valuenew[i] - valueold[i]) + valueold[i];
|
||||||
plotAddRealValue(&run->data[i], newval);
|
plotAddRealValue(&run->data[i], newval);
|
||||||
valueold[i] = valuenew[i];
|
valueold[i] = valuenew[i];
|
||||||
timeold = refValue->rValue;
|
|
||||||
}
|
}
|
||||||
else if (nodata)
|
else if (nodata)
|
||||||
/* Just keep the transient output value corresponding to timeold,
|
/* 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];
|
newval = (timestep - run->circuit->CKTstep - timeold)/(timenew - timeold) * (valuenew[i] - valueold[i]) + valueold[i];
|
||||||
plotAddRealValue(&run->data[i], newval);
|
plotAddRealValue(&run->data[i], newval);
|
||||||
valueold[i] = valuenew[i];
|
valueold[i] = valuenew[i];
|
||||||
timeold = refValue->rValue;
|
|
||||||
}
|
}
|
||||||
else if (nodata)
|
else if (nodata)
|
||||||
/* Just keep the transient output value corresponding to timeold,
|
/* Just keep the transient output value corresponding to timeold,
|
||||||
|
|
@ -1744,7 +1732,7 @@ InterpPlotAdd(runDesc *run, IFvalue *refValue, IFvalue *valuePtr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
timeold = refValue->rValue;
|
||||||
gr_iplot(run->runPlot);
|
gr_iplot(run->runPlot);
|
||||||
|
|
||||||
if (ft_bpcheck(run->runPlot, run->pointCount) == FALSE)
|
if (ft_bpcheck(run->runPlot, run->pointCount) == FALSE)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue