sharpie7 / circuitjs1

Electronic Circuit Simulator in the Browser
GNU General Public License v2.0
2.29k stars 633 forks source link

The variable 'goodIteration' in runCircuit is always true, it will never be set to false. #765

Closed Mervill closed 2 years ago

Mervill commented 2 years ago

If I had to guess, I'd say that it's supposed to be set to false when runCircuit false to converge:

if (subiter == subiterCount) {
    // convergence failed
    goodIterations = 0;
    goodIteration = false; // I think this line needs to be added.
    ...
pfalstad commented 2 years ago

I don't remember but I would guess goodIteration should just be removed. It seems to be dead code. I can't think of a reason why we need it.

Mervill commented 2 years ago

Just that value on it's own would be removed, correct? There's also an integer goodIterations (plural) that I think is involved in the scaling timestep i.e.

if (goodIterations >= 3 && timeStep < maxTimeStep && goodIteration) {
    // things are going well, double the time step
    timeStep = Math.min(timeStep * 2, maxTimeStep);
    console("timestep up = " + timeStep + " at " + t);
    stampCircuit();
    goodIterations = 0;
}

So we'd keep all that, but just ax the Boolean, correct?

pfalstad commented 2 years ago

yes