Multi-domain simulation: how the simulator computes
The multi-domain simulator puts circuits, motors, heaters, tanks, sensors and control blocks in the same schematic and solves them all at once in time. It has no detailed PDF solution because there is no «hand solution»: it is a numerical integrator. This topic explains what it does inside, so you can read its results, trust them and recognize its limits.
One language for several domains
Every physical system it simulates is described with two kinds of variables: an effort or difference variable (voltage, angular speed, temperature, level or pressure) and a flow variable (current, torque, heat flow, flow rate). With them, the elements of each domain look like those of an electric circuit, and their equations have the same form:
| Domain | Effort · flow | Resistance | Stores (capacity) | Storage equation |
|---|---|---|---|---|
| Electrical | V · i | : | capacitor | |
| Mechanical (rotation) | ω · T | friction : | inertia | |
| Thermal | T · q | : | heat capacity | |
| Hydraulic | h · Q | outlet (nonlinear) | tank area |
That is why an RC circuit, a heater that warms up and a tank that fills respond alike, with an exponential of time constant (or , or ). The components that convert energy join two domains: the DC motor produces a torque and at the same time generates a back-EMF :
How it builds the system of equations
The unknowns are the voltages of the nodes of the schematic and the state variables of the components that store energy (a capacitor's voltage, an inductor's current, a motor's current, speed and angle, a heater's temperature, a tank's level…). They all go into a vector . Each component contributes two things:
- The currents that enter or leave through its terminals. At each node their sum must be zero (Kirchhoff's current law): that is nodal analysis.
- Its internal equations, written as «residual = 0»: for a capacitor ; for an inductor ; for a heater .
Putting everything together gives a system of algebraic and differential equations with the general form
This format accepts any component without special treatment: a diode (Shockley equation), a transistor, an op-amp with saturation or a sensor with its own delay are just more equations in . Voltage sources have a small internal resistance (0.01 Ω by default), like real ones, and a tiny conductance from every node to ground ( S) is added so that an isolated node does not leave the system without a solution.
Time integration: BDF2 and Newton
Time advances in steps . In each step the derivatives are replaced by a formula with the values of the previous steps, and what remains is an algebraic system in . The simulator uses the second-order backward differentiation formula (BDF2), which takes the slope at the new point of the parabola through the last three:
BDF2 is implicit: the unknown appears on both sides, so must be solved in every step. It is done with Newton's method: the residual is evaluated, its Jacobian is computed (by differentiating each component numerically), is solved and is corrected until the correction is negligible. Implicit methods are stable even when the system has very fast dynamics (a circuit with microsecond constants inside a thermal process of minutes): the step does not have to be smaller than the fastest constant.
The step size. By default it is the simulation length divided by 2000, and it is reduced if there are fast sources, sampling or delays. It is also adjusted to the circuit's oscillations: BDF2 damps an oscillation of frequency by a factor of about per step and delays it by about radians, so the simulator chooses so that, over the whole run, that numerical damping stays under 1% and the phase lag under 0.01 rad. Digital components (clocks, counters, the 555, comparators with hysteresis) change through events at the end of each accepted step.
Linearization: poles, stability and G(s)
At the end of the simulation (or at the chosen instant) the simulator linearizes the system around the state it ended in: it differentiates the equations numerically with respect to the states and the input, and obtains a linear model
The eigenvalues of A are the poles of the whole system; if they all have negative real part, that operating point is stable. The same matrix gives the own poles of each subsystem (the network of capacitors and inductors, a motor, a PID…), the transfer function between the input and output you choose, its step response, the Bode diagram and the root locus with respect to any parameter (it is relinearized for each value).
How to read and check the results
- Units and order of magnitude: before looking at decimals, check with a quick calculation (V/R, , ) that the result makes sense.
- Duration: simulate at least 5 time constants of the slowest dynamics to see the final value; the poles card gives you those constants ().
- Step: if you doubt a fine detail (a peak, a ripple), repeat with a smaller step; if the result does not change, it comes from the model and not from the numerical method.
- Warnings: the simulator warns about components beyond their limits (a resistor that would burn, a stalled motor, a tank that overflows) and about badly posed schematics (shorted sources or sources in parallel with different values).
Common mistakes
- Forgetting the ground: without a reference node the voltages are not defined.
- Reading a «final» value before the system settles: look at the whole response or lengthen the simulation.
- Using the transfer function far from the operating point of a nonlinear system.
- Expecting the accuracy of an exact calculation at the instant of a switching event: right after a jump in the source, BDF2 mixes the pre-jump history for a couple of steps.
- Confusing the pole of an integrator (at 0, «marginal») with an instability: what matters is the closed loop.
Worked examples
Example 1Charging and discharging a capacitor
Solution
- s; the pole is at s⁻¹ and .
- Each half period lasts 0.25 s = 2.5τ. In the periodic regime, the charge goes from to and the discharge comes back: and .
- Solving: V and V.
- Step response of the linear model: 10–90% rise in ms and 2% settling in ms.
Solve it in Simuveliq
- In Engineering → Multi-domain simulation, in Examples, «Load example» → Capacitor charge and discharge (RC). The Oscilloscope shows the source wave and the capacitor's (peaks of 4.62 V and minima of 0.38 V with the 1 ms step).
- Stability: whole system and subsystems gives the pole −10 with τ = 100 ms and «Follows the periodic source»; Control analysis gives G(s) = 10/(s + 10) and, for the linear model, rise 220 ms, settling 392 ms and final value 1.
Example 2Underdamped RLC circuit
Solution
- Loop: , so .
- rad/s. With Ω (10 + 0.01 from the source): s⁻¹, and rad/s. Poles: .
- : the capacitor reaches 1.163 V; ms. The oscillation has Hz.
Solve it in Simuveliq
- «Load example» → Underdamped RLC circuit (complex poles). The dominant pole is −500.5 ± 866j with ζ = 0.5 and ωn = 1000 rad/s; on the oscilloscope the capacitor voltage reaches 1.163 V after each rising edge.
- Change the source's internal resistance to 0 or R to 20 Ω and watch the poles move (with R = 20 Ω, ζ ≈ 1: there is no overshoot anymore).
Example 3DC motor at 12 V
Solution
- In steady state the derivatives are zero: and . With Ω: rad/s rpm, and A.
- At start and there is no back-EMF: the current rises toward A, held back by the inductance (the simulated peak is 5.83 A). That is why motors are protected at start-up.
- Poles: → → (mechanical, τ = 74 ms) and (electrical, 0.5 ms). The slow one dominates: the speed reaches 63% in about 74 ms.
- Voltage-to-speed gain: rpm/V.
Solve it in Simuveliq
- The button opens a motor M1 with a 12 V battery. The oscilloscope shows the speed, which reaches about 2120 rpm at 0.5 s, and the current, with its 5.83 A start-up peak dropping to 0.45 A.
- Stability: poles −13.52 and −1997 in the «DC motor» subsystem (the angle θ only accumulates and does not count). Control analysis from V1 to the speed: G(s) = 4 775 000/(s² + 2011s + 27 010), DC gain 176.8 and final value of the linear model 176.8.
Example 4Heater: a first-order thermal system
Solution
- Voltage across the heater: V, so W.
- Energy balance: . It is a first-order system with s and final °C.
- °C.
- The power depends on (nonlinear). Linearizing at 12 V: °C/V: one more volt would raise it about 10 °C.
Solve it in Simuveliq
- The button opens heater H1 with its battery; the run lasts 600 s (6τ) and ends at 84.75 °C, about to reach 84.9. The oscilloscope gives the power, 11.98 W.
- Stability: pole −0.01 with τ = 100 s, «Thermal time constant τ = C·Rth». Control analysis from V1 to the temperature: G(s) = 0.09983/(s + 0.01), DC gain 9.983.
Example 5Tank: linearizing a nonlinear outlet
Solution
- Volume balance: . It is nonlinear because of the root.
- Near the curve is replaced by its tangent: . With : .
- Pole: . At the level the simulation reaches, m: s⁻¹, s. At another level the pole changes: the tank is slower the fuller it is.
- That is why the linear model and the simulation do not fully agree: the reference step starts with the tank far from 0.5 m (overshoot 15.6% in the linear model and 5.31% in the simulation).
Solve it in Simuveliq
- «Load example» → Tank level control with a pressure sensor. In the subsystem table, «TK1 Tank — Level (linearized k√h) and valve» has the poles −0.02831 (level) and −2 (the valve, with a 0.5 s response).
- In Control analysis, the table compares the nonlinear simulation with the linear model: overshoot 5.31% versus 15.6%.