OneSimulation docs Website Free books Plans on Gumroad

Docs › Build a first case in each physics package › Biophysics

5.3 Biophysics

onesim.physics.biophysics

PassiveMembrane models an electrical compartment, OrganClearance a well-mixed amount and elimination balance, CompliantVessels two pressure compartments linked by a VesselSegment, and AxialTissue a mechanical mass connected through a TissueElement. These use global degrees of freedom. Set the initial voltage, amount, pressures or mechanical state before a transient solve. Choose a small explicit step for a first linear comparison and use a supported implicit method for stiff relaxation. The Bioheat provider is a separate thermal result and provider route. For a coupled example, test_biophysics_input_flexibility.py exchanges global typed outputs and inputs and compares with a matrix exponential.

# Use run_lumped and scalar_series from the cooling chapter.
from onesim.physics.biophysics import OrganClearance

domain = LumpedDomain()
organ = OrganClearance(domain=domain.system, volume=2.0, clearance=1.0)
_, samples, time = run_lumped(
    domain, organ, ((organ.amount, 1.0),),
    (organ.amount, organ.concentration), end=1.0, dt=0.01, interval=0.1,
)
np.testing.assert_allclose(
    scalar_series(samples, organ.amount), np.exp(-0.5*time), atol=1e-9,
)