Python API
Browse the modules below for classes, functions, and signatures. Use Get started for installation and a first model.
Compile and run
Section titled “Compile and run”This example needs only Eqiora and NumPy, which Eqiora installs.
import eqiora
model = eqiora.compile(source="""model decay(parameter rate: 1 / s = 1) { state x: 1; initial { x = 1; } relation flow { derivative(x) + rate * x = 0; }}""", filename="decay.eqi")x = model.field("x")plan = eqiora.resolve( model, temporal=eqiora.time.Tsitouras45( initial_step_s=0.01, relative_tolerance=1e-9, absolute_tolerances={(x, 0, 0, False): 1e-11}, ),)result = eqiora.run( plan, state=eqiora.State.initial(plan), until_s=1.0, output_times_s=(0.25, 0.5, 1.0),)series = result.series(x)for time_s, value in series: print(f"{time_s:.2f} s: {value:.6f}")The three values are approximately 0.778801, 0.606531, and 0.367879:
x is dimensionless, time is in seconds, and the equation gives exponential
decay. compile defines the mathematics, resolve chooses its numerical method,
and run computes the requested observations.
Inspect, edit, and save
Section titled “Inspect, edit, and save”Continue with the objects above:
print(model.parameter("rate").value)print(model.render_equations("flow", profile="plain")[0].text)
faster = model.commit(model.preview_value_edit("rate", 2.0))print(model.parameter("rate").value, faster.parameter("rate").value)
import numpy as npnp.savetxt( "decay.csv", np.column_stack((series.time.numpy(), series.values.numpy())), delimiter=",", header="time_s,x", comments="",)The original rate remains 1.0; the new Model has rate 2.0. Resolve the new
Model to simulate it. The CSV contains the observations from the original run,
and render_equations prints the model’s equations in readable form.
For spatial models, continue with geometry, meshing, and the complete modeling examples. For gradients, see differentiation.
Modules
Section titled “Modules”| Module | Summary |
|---|---|
eqiora |
Model authoring, numerical plans, execution, and results. |
eqiora.geometry |
Build geometry and select its regions and boundaries. |
eqiora.lang |
Author Eqiora Modules, Components, expressions, and equations in Python. |
eqiora.units |
Shared units for input quantities and explicit presentation. |
eqiora.data |
Explicit numeric adapters and canonical resolved-array artifacts. |
eqiora.meshing |
Plan and generate meshes from geometry. |
eqiora.formulation |
Choose a mathematical formulation and inspect the resolved choice. |
eqiora.fem |
Finite-element discretization policies. |
eqiora.fvm |
Finite-volume discretization policies. |
eqiora.solve |
Linear, nonlinear, and eigenvalue solver settings. |
eqiora.time |
Time-integration methods and related settings. |
eqiora.fluid |
Configure incompressible flow and inspect its results. |
eqiora.trajectory |
Read spatial trajectories and derived fields. |
eqiora.solid |
Configure linear elasticity and inspect structural results. |
eqiora.viewer |
Interactive, read-only views of geometry, meshes, and fields. |
eqiora.colab |
Prepare a Google Colab runtime for Eqiora’s notebook viewer. |
eqiora.jupyter |
IPython extension that compiles %%eqiora notebook cells. |
eqiora.matplotlib |
Plot Eqiora results with Matplotlib. |
eqiora.diff |
Implicit differentiation of Eqiora programs. |
eqiora.torch |
Use Eqiora differentiable programs with PyTorch autograd. |
eqiora.jax |
Use Eqiora differentiable programs with JAX. |