Installing the delivered wheel? The Quickstart has the commands for macOS, Linux and Windows. This chapter describes the notebook environment in general.
1.1 Install and select the kernel
Use the interpreter and wheel specified by the release you are running. The first example notebooks were written for the earlier preview build 0.2.1a2. The source checkout declares Python 3.13 or later in implementation/pyproject.toml and has its own package metadata. The distribution is onesimulation; Python imports use onesim. In a development checkout, use the repository root as the working directory for these shell commands.
python3.13 -m venv .venv
source .venv/bin/activate
python -m pip install -e './implementation[notebook]'
python -m ipykernel install --user --name onesim
python -m jupyter lab
For a delivered wheel, install the platform-specific wheel with the extras described in its accompanying README_DE.md. Select that environment as the notebook kernel. The notebook extra includes JupyterLab, plotting libraries, widgets and the tetrahedral mesher for the source installation. Record the actual interpreter and distribution version near the top of your notebook.
import sys
from importlib.metadata import version
print(sys.executable)
print("OneSimulation", version("onesimulation"))
The plot examples load the shared Matplotlib theme from onesimulation_plot_theme.py. Keep this file beside your notebook and call theme.use_theme() before creating figures.
1.2 Separate the scientific choices
| Object | Choose or declare | Inspect |
|---|---|---|
| Geometry and selections | Dimensions, regions and named boundaries. | World coordinates, boundary ownership and mesh markers. |
Problem | Models, materials, loads, initial conditions, constraints and field links. | Units, unknowns, source signs and conditions for uniqueness. |
Mesh and Numerics | Spatial carrier, schemes, integration, solvers and tolerances. | Actual mesh size, admissible options, convergence and time-step limits. |
Simulation | Bind the problem, mesh and numerics. Choose a stationary solve or a transient run. | Validation issues, result fields, solver report and accepted output times. |
| Figure and data | Samples, components, units, color scale, view and exports. | Axes, physical support, reference errors and reproducibility. |
Use LumpedDomain().system for global balances, Line(...).line for the supplied one-dimensional models and Box(...).volume or Cylinder(...).volume for volume models. A line is embedded in world space. Its local arclength can differ from the world \(x\) coordinate. To combine boundary selections, use union |, intersection & and difference - on selections from the same geometry. Generate the mesh from the geometry that owns those selections. Recreate the model and its conditions together when making a parameter variant that changes geometry or physics ownership.
A model provides typed references such as model.temperature. Use model.fields() to inspect the declared fields and their field_id, unit and role. Differential fields require a consistent initial state for transient runs. Algebraic fields satisfy a constraint or a stationary equation. Derived fields are computed from the solution. Coupling targets are model input references. Use InitialValue(ref, value) to set an initial condition. For stationary nonlinear iteration, Numerics(initial_guess=...) serves a separate purpose. Check the contract of each callable source or condition. The volume examples below use vectorized f(x, y, z), while some boundary conditions use f(time, coordinate). A numerical array must match the carrier shape and component order expected by the receiving field.
1.3 Make the notebook tell a scientific story
Open with one question, a diagram or description of the geometry, assumptions, and the measured output. Use a short, editable parameter cell with units. Put the complete solve in a function when you will compare meshes or parameter settings. Keep the extraction cell separate so its outputs can drive a plot, a CSV table and a verification summary. Restart the kernel and run all cells in order before sharing the notebook.
Start the verification cell with a check that would fail if you plotted the wrong result. Examples include the sign of the deflection, the units and shape of a field, the final accepted output time or the total integrated source. Then compare with an independent solution, a balance, a symmetry, or a refinement run. State the expected approximation error and use a tolerance scaled to the observable. A solver residual measures how well the algebraic equations were solved. A refinement comparison measures sensitivity to the chosen mesh or step size.
The recirculation notebook exposes a fast profile and a finer profile. The cantilever compares two meshes in one run. Record the profile, mesh cells, element order, step size, solver and tolerances. Save native values separately from display conversions. A table headed stress_Pa stays in pascals even if the plot colorbar displays MPa. Use the same color limits when comparing two plots of one quantity. Center a difference plot's diverging scale at zero. For field slices, label the physical plane, maintain equal spatial aspect, and identify any visual deformation scale. A denser display grid samples the same solution. A finer solver mesh requires a second solve.