Docs › Build a first case in each physics package › Systems and networks
5.17 Systems and networks
onesim.physics.systems
Start with a compact lumped balance such as ResistorCapacitor, ThermalCapacitance, HydraulicAccumulator, FirstOrderControl, WellMixedTank, or SealedGasChamber. State the initial voltage, temperature, pressure or other stored state. Set the forcing directly or connect the typed input. For a network service, build the topology using the matching node and branch contracts. Examples include ElectricalNode and ElectricalBranch, ThermalNode and ThermalLink, or ProcessUnit and ProcessStream. SignalBlock is the corresponding control declaration. Pass them to the configuration for that family, validate node IDs, port orientation and reference conditions, then execute the matching facade. Plot node histories and signed branch rates. Check that internal transfers cancel in the whole-network balance.
# Use run_lumped and scalar_series from the cooling chapter.
from onesim.physics.systems import ResistorCapacitor
domain = LumpedDomain()
rc = ResistorCapacitor(
domain=domain.system, resistance=2.0, capacitance=0.5, supply_voltage=3.0,
)
_, samples, time = run_lumped(
domain, rc, ((rc.voltage, 0.0),), (rc.voltage, rc.current),
end=2.0, dt=0.01, interval=0.1,
)
np.testing.assert_allclose(
scalar_series(samples, rc.voltage), 3*(1 - np.exp(-time)), atol=1e-8,
)