GLOBAL KNOWLEDGE ARK

Electronics · Measurements, simulation and systematic fault-finding

Compare a circuit model with a SPICE simulation

A simulator can solve the circuit you entered while the circuit you intended is still wrong. Begin with a small network whose answer you can predict. Preserve the connections, analysis and settings, then compare several independent quantities before trusting a more complicated model.

Lesson preparation and course links

Use the network-laws introduction and loaded-network investigation. You need divider algebra, current direction and resistor power. The optional transient extension introduces its own exponential model and initial state. A simulator run is optional, and no hardware is required.

Back to the Electronics chapter

After reading, you can

Turn a checked node list into a documented small SPICE model, predict its DC and optional transient results, and design a meaningful comparison. Separate a changed circuit, a changed initial state and a numerical-accuracy check from evidence about physical parts.

01

Write the intended network before opening a solver

For this investigation use an ideal 5.00 V source, a 2.00 kΩ resistor from node in to node out, and a 3.00 kΩ resistor from out to reference node 0. Output means out relative to 0. The source is positive at in. All nominal values are exact model parameters; no lead resistance, tolerance, temperature drift or measuring input is included yet.

Predict the DC result first: series current is 5.00/(2000+3000)=1.00 mA and output is 3.00 V. The upper resistor dissipates 2.00 mW and the lower 3.00 mW, matching 5.00 mW delivered by the source. A result near 5 V at out would therefore require investigation of the model or assumptions.

The default route uses calculated predictions and explicitly hypothetical solver records. No SPICE engine was run to produce this lesson. Two complete optional Ngspice input decks are included as plain-text line tables. Their commands were checked against official documentation; actual parsing, execution and numerical agreement still require a retained run.

The cited official Ngspice manual is the rolling 47+ development edition dated 2026-09-28. It is a documentation anchor, not a claim that this engine version is installed or was tested here. Record the engine and exact version you actually use; a different SPICE dialect needs its own command and model checks.

The intended DC network and optional capacitorThe ideal 5 V source feeds a 2 kΩ resistor from in to out. A 3 kΩ resistor joins out to reference node 0. A separately optional 1 microfarad capacitor also joins out to 0.Intended nodes: in → out → reference 0inRtop 2.00 kΩout+−VS 5.00 VRload3.00 kΩC11.00 µFoptional0: reference and returnDC: 3.00 V output; optional transient needs a declared initial state.
An ideal 5.00 V source connects positive node in to reference 0. A 2.00 kΩ resistor connects in to out, and a 3.00 kΩ load connects out to 0. Output voltage is out relative to 0. An optional capacitor connects out to 0 for the separately declared transient experiment.
02

Map each netlist line to a connection or an analysis

In this Ngspice deck, the first line is the circuit title. VS connects its positive terminal in to its negative terminal 0 and sets DC voltage to 5 V. Rtop joins in to out; Rload joins out to 0. The suffix k means 1000 in these resistor values. Check those node pairs against the drawing rather than relying on a visually familiar component order.

The .op command requests a DC operating point. The .dc command requests a resistor sweep: Rload takes 2 kΩ, 3 kΩ and 4 kΩ. The .print line requests output voltage and current through VS for that sweep. Each table row is one complete netlist line; preserve their order and line boundaries if you copy the deck to a plain-text file.

The supplied deck is an optional starting file, not an executed result. These .print decks require documented batch mode in Ngspice. For example, after saving the first deck as comparison-dc.cir, an optional command is ngspice -b comparison-dc.cir. Use your trusted installation’s documented batch workflow; the command has not been executed here. Save the exact input bytes, model files, engine/version, analysis request, warnings and output. A successful command alone would still need the numerical and topology comparisons below.

Complete optional Ngspice DC/sweep deck; unexecuted
Netlist line
Ark comparison: documented Ngspice DC model, not executed
* Rload sweep is a Ngspice feature. Node0 is the reference.
VS in 0 DC 5
Rtop in out 2k
Rload out 0 3k
.op
.dc Rload 2k 4k 1k
.print dc v(out) i(VS)
.end
03

Compare a response curve and the current sign

The sweep deliberately changes a circuit parameter. At Rload=2.00 kΩ, expect 2.50 V output and 1.25 mA delivered by the source. At 3.00 kΩ, expect 3.00 V and 1.00 mA. At 4.00 kΩ, expect 10/3 V≈3.333333 V and 0.833333… mA. Comparing all three points can expose a wrong node or omitted load that one matched point might conceal.

The voltage-source current convention is important. In this deck i(VS) is positive into the source’s positive terminal. While VS delivers energy, that current is negative: nominally −1.00 mA at the 3.00 kΩ point. Source absorbed power is 5.00 V×(−1.00 mA)=−5.00 mW, meaning 5.00 mW delivered. A negative printed source current is consistent with this declared direction.

Choose a comparison rule before inspecting output. For example, a learner may choose a 1 mV absolute output difference for these ideal DC points and check current balance independently. That is a proposed educational acceptance target. It is not an achieved result, a manufacturer tolerance or a statement about a physical resistor.

Analytical DC predictions; no simulator output
RloadV(out)Expected i(VS)
2.00 kΩ2.50 V−1.25 mA
3.00 kΩ3.00 V−1.00 mA
4.00 kΩ3.333333… V−0.833333… mA
04

Specify an initial state for the optional transient extension

Add a 1.00 µF ideal capacitor from out to 0. Its voltage is out relative to 0. At DC the capacitor carries no current in this ideal model, so the operating point is still 3.00 V. The resistance seen by the capacitor with the ideal voltage source zeroed is 2.00 kΩ || 3.00 kΩ=1.20 kΩ, giving time constant τ=1.20 ms.

A transient analysis of a constant-source circuit normally prepared at its DC operating point can remain flat at 3.00 V. That is compatible with a present capacitor already at equilibrium. It is not automatically evidence that the capacitor is missing or that the solver failed to model charging.

For a different experiment, explicitly prepare capacitor voltage at 0 V. The deck below uses the capacitor’s IC=0 together with UIC, deliberately skipping the normal initial operating-point preparation. With finite connecting resistance, the state evolves from the declared initial voltage. These controls change the experiment, not merely the plot.

For this exact RC model, v(t)=3+(v0−3)exp(−t/τ). With v0=0 and τ=1.20 ms, expect approximately 1.8963617 V at 1.20 ms, approximately 2.5939942 V at 2.40 ms and approximately 2.9797862 V at 6.00 ms. These are calculated values. A curve approaches its final value; five time constants do not make it exactly equal to 3.00 V.

Complete optional Ngspice prepared-state deck; unexecuted
Netlist line
Ark comparison: declared zero capacitor state, not executed
* UIC deliberately skips the normal initial operating point.
VS in 0 DC 5
Rtop in out 2k
Rload out 0 3k
C1 out 0 1u IC=0
.tran 10u 8m 0 5u uic
.print tran v(out) i(VS)
.end
05

Separate a model change from a numerical check

First change only the capacitor initial state: replace its line by C1 out 0 1u IC=1 while retaining UIC. Now v0=1.00 V, so the exact prediction at 1.20 ms is 3−2exp(−1)≈2.2642411 V, with the same 3.00 V final value. Different initial states can give different transients without changing the circuit’s DC divider.

Next restore one fixed initial state and vary only the maximum internal timestep. In the shown .tran command, 5u is the maximum timestep ceiling. Compare separate runs using 5 µs, 2.5 µs and 1.25 µs with source, elements, initial state and all other settings fixed. A maximum is not proof that the solver takes uniform steps or that its output is accurate.

One proposed transient target is less than 1 mV change between refinements at both 1.20 ms and 6.00 ms, and less than 1 mV difference from the exact model at those times. Record actual output times and any interpolation used, because the requested comparison time may not coincide with a saved point. The lesson has not executed these checks or established that a particular setting passes.

Numerical agreement cannot validate the intended topology by itself. Two well-converged runs of a model missing Rload may both approach 5 V. Check netlist connections, DC current and energy against the intended 3 V network before treating timestep agreement as useful evidence. Different simulation engines may require different initial-condition or sweep syntax; porting a deck is a new qualification step.

06

Add a tolerance model without confusing it with solver error

Now make a deliberate component-model change: let each resistor vary independently within ±1% of its nominal value while the ideal source remains exactly 5.00 V. For this positive divider, minimum output uses the largest upper resistor and smallest lower resistor; maximum output uses the smallest upper and largest lower.

The minimum is 5×2970/(2020+2970)≈2.9759519 V. The maximum is 5×3030/(1980+3030)≈3.0239521 V. These are deterministic corners of the stated interval model. They do not define a probability distribution, say how likely a manufactured value is, or include source, temperature, loading and measurement errors.

A 20 mV difference from the nominal 3 V may fit a changed-resistor model while exceeding a chosen 1 mV numerical comparison target. Those targets answer different questions. Keep the actual element values and intended experiment beside every result rather than calling every difference a solver inaccuracy.

Calculated ±1% resistor corners with an exact 5.00 V source
CaseUpper resistorLower resistorOutput
Minimum2020 Ω2970 Ω≈2.9759519 V
Nominal2000 Ω3000 Ω3.0000000 V
Maximum1980 Ω3030 Ω≈3.0239521 V
07

Finish with a claim the evidence actually supports

A useful run record identifies the question, node list, exact netlist and model versions, engine/version, analysis, source preparation, initial state, numerical settings, units, warnings and retained output. It also states the independent prediction and the selected comparison points or acceptance limits.

Without an actual run, report that you built a documented proposed deck and checked its analytical predictions. After a retained successful run and comparison, you may report that the executed numerical model agreed within the measured comparison limits. Neither statement establishes the behaviour of hardware that was never built or observed.

For physical validation later, include actual source behaviour, component values and conditions, instrument loading and uncertainty, and a documented measurement record. A DC operating point for a more complicated nonlinear circuit also does not by itself prove uniqueness, startup success or stability. Keep the scope of the conclusion as explicit as the model.

Explain a flat 3 V transient before changing solver tolerances

A hypothetical run record says VS is constant at 5 V, the divider resistors are 2 kΩ and 3 kΩ, a 1 µF capacitor is connected out-to-0, and there is no declared non-equilibrium initial state. The trace is flat at 3 V. First calculate the DC operating point: it is exactly 3 V for this model.

If the transient was initialized at that operating point, capacitor voltage and current are already consistent with equilibrium. A flat trace is therefore an expected possibility. Its appearance alone does not identify a missing capacitor.

To test the state-preparation explanation, choose the separately documented IC=0/UIC experiment and preserve all other circuit values. The exact model predicts about 1.89636 V at 1.20 ms and 2.97979 V at 6.00 ms. An actual new run could compare those points and the initial record; this lesson supplies predictions rather than such a run.

Only after topology, source and state agree with the intended experiment should you assess numerical refinement. Changing an initial condition and a timestep simultaneously would mix a physical/model question with a numerical one.

Try the reasoning

  1. Predict nominal output, source-delivery current and both resistor powers before any run.

    Show the answer and reasoning

    Output is 3.00 V, source-delivery current is 1.00 mA, upper-resistor power is 2.00 mW and lower-resistor power is 3.00 mW. The 5.00 mW total equals source delivery. These are exact nominal-model calculations.

  2. Why should nominal i(VS) be negative in the shown deck?

    Show the answer and reasoning

    The source current is defined into its positive terminal. VS supplies current out of that terminal, so i(VS)=−1.00 mA. Multiplying by +5.00 V gives −5.00 mW absorbed power, or +5.00 mW delivered.

  3. What does the resistor sweep change, and why is it different from a timestep refinement?

    Show the answer and reasoning

    It changes the circuit parameter Rload from 2 kΩ through 3 kΩ to 4 kΩ, changing the intended solution. A numerical refinement keeps the circuit/source/state fixed while checking the numerical approximation. They test different things.

  4. A constant-source RC transient is flat at 3 V. Does that prove the capacitor is missing?

    Show the answer and reasoning

    No. The stated circuit initialized at its DC operating point has capacitor voltage 3 V and can remain at equilibrium. Inspect the source and state preparation, then compare an explicitly non-equilibrium experiment if that is the intended question.

  5. For the prepared 0 V capacitor, find τ and v at one time constant. What changes if v0=1 V instead?

    Show the answer and reasoning

    τ=(2 kΩ || 3 kΩ)×1 µF=1.20 ms. For v0=0, v(τ)=3(1−e^−1)≈1.8963617 V. For v0=1 V, v(τ)=3−2e^−1≈2.2642411 V. Both approach 3 V.

  6. Two timestep runs agree closely but both approach 5 V. Has the intended model been verified?

    Show the answer and reasoning

    No. A wrong topology, such as an omitted load, can be solved consistently. Recheck node pairs, the intended DC divider and source current before using numerical agreement as evidence.

  7. For independently bounded ±1% resistors, which corner gives maximum output and what is it?

    Show the answer and reasoning

    Use the smallest upper resistor, 1980 Ω, and largest lower resistor, 3030 Ω. Output is 5×3030/(1980+3030)≈3.0239521 V. This is a deterministic bound for the stated ideal-source tolerance model, not a probability or hardware observation.

  8. What can you claim after reading the supplied predictions without executing a solver?

    Show the answer and reasoning

    You can claim an analytical prediction and a documented proposed netlist/analysis. You cannot claim SPICE parsing, a successful run, achieved numerical error or hardware validation. Those require the corresponding retained evidence.

What to carry forward

Preserve the intended nodes, model and experiment before running a solver. Compare several predicted quantities, state the current convention and initial condition, and refine numerics with the circuit held fixed. A simulated model, a tolerance model and a physical measurement support different conclusions.

References

Sources supporting this lesson’s explanations and examples.

  1. Ngspice User’s Manual, Version 47+ development edition, 2026-09-28Ngspice projectReference guide · PDFngspice.sourceforge.ioRead source
  2. LTspice: Speed Up Your SimulationsGabino Alonso; Analog DevicesReference guideanalog.comRead source
  3. University Physics Volume 2, 10.5: RC CircuitsSamuel J. Ling, Jeff Sanny and William Moebs; OpenStax/Rice UniversityTextbook chapteropenstax.orgRead source