Skip to content
Open
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
13 changes: 13 additions & 0 deletions src/com/lushprojects/circuitjs1/client/OpAmpElm.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,19 @@ void getInfo(String arr[]) {

double lastvd;

// Initialize lastvd with a tiny offset to break metastable equilibrium.
// Without this, a positive-feedback buffer (output wired to non-inverting
// input) will unrealistically track the input perfectly because the
// Newton-Raphson solver finds the exact metastable solution. A real
// opamp has an input offset voltage (~1 mV) that would immediately push
// the output to a supply rail. This small perturbation mimics that
// behavior and is orders of magnitude too small to affect normal
// negative-feedback circuits.
void reset() {
super.reset();
lastvd = 1e-6;
}

void stamp() {
sim.stampNonLinear(voltSource);
sim.stampMatrix(nodes[2], voltSource, 1);
Expand Down
Loading