Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/com/lushprojects/circuitjs1/client/CCCSElm.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ void doStep() {
sim.stampCurrentSource(nodes[inputCount+1], nodes[inputCount], rs);
}

// add gmin stepping to aid convergence, same as VCCSElm
if (sim.subIterations > 100) {
double gmin = Math.exp(-9*Math.log(10)*(1-sim.subIterations/3000.));
if (gmin > .1)
gmin = .1;
sim.stampResistor(nodes[inputCount], nodes[inputCount+1], 1.0/gmin);
}

for (i = 0; i != inputPairCount; i++)
lastCurrents[i] = pins[i*2+1].current;
}
Expand Down
12 changes: 12 additions & 0 deletions src/com/lushprojects/circuitjs1/client/VCCSElm.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ void doStep() {
pins[inputCount+1].current = v0;
}

// add gmin stepping to aid convergence, similar to Diode and
// TransistorElm. Without this, circuits with controlled sources
// in positive feedback loops (e.g., optocoupler Schmitt triggers)
// can fail to converge because the Newton-Raphson iteration
// oscillates between two states with no damping.
if (sim.subIterations > 100) {
double gmin = Math.exp(-9*Math.log(10)*(1-sim.subIterations/3000.));
if (gmin > .1)
gmin = .1;
sim.stampResistor(nodes[inputCount], nodes[inputCount+1], 1.0/gmin);
}

for (i = 0; i != inputCount; i++)
lastVolts[i] = volts[i];
}
Expand Down
Loading