The similie::physics module provides Hamiltonian equations, constitutive laws, and quantities for scalar fields, magnetostatics, and elasticity. SymPy definitions in src/similie/physics/ generate C++ functors during the CMake build. The elasticity and magnetostatics directories also contain their physical quantities and constitutive laws.
scalar_field::ScalarFieldWithPowerCouplingHamiltonian is generated from the scalar field \(\phi\) and its moment components \(\pi_i\):
\[ \mathcal H(\phi,\pi) = \frac{1}{2}\left(-m^2\phi^2-\pi_0^2+\sum_{i=1}^{d-1}\pi_i^2\right) - \frac{g\phi^p}{\Gamma(p+1)}. \]
Here \(d\) is the number of dimensions, \(m\) is mass, \(g\) is coupling_constant, and \(p\) is coupling_power. The generator uses a negative sign for the first moment component and positive signs for the others. There is no separate scalar-field constitutive-law class. The generated Hamiltonian supplies \(\partial\mathcal H/\partial\pi_0=-\pi_0\), \(\partial\mathcal H/\partial\pi_i=\pi_i\) for \(i>0\), and \(\partial\mathcal H/\partial\phi=-m^2\phi-gp\phi^{p-1}/\Gamma(p+1)\).
Steady potential flow reuses the free scalar field Hamiltonian with zero mass and coupling. Its spatial moment derivative is the identity, so HamiltonEquations maps reconstructed potential gradients to velocity:
\[ \mathbf v = \nabla\phi, \qquad \nabla\cdot(\rho\mathbf v)=0. \]
The ONELAB example binds these physics to each structured patch, puts density in the constitutive Hodge flux, and solves a scalar multidomain Laplacian. Circulation is represented by a jump in potential across the wake cut. The multidomains and potential flow documentation describes the boundary conditions, circulation response solve, and Gmsh exports.
For magnetic vector potential \(A\), induction \(B\), current density \(j\), and permeability \(\mu\), magnetostatics::LinearMagnetostaticsHamiltonian implements
\[ \mathcal H(A,B)=\frac{B\cdot B}{2\mu}-j\cdot A. \]
LinearMagneticInductionToMagneticField implements the corresponding discrete constitutive map \(H_i=(\star_i/\mu)B_i\), where \(\star_i\) is the supplied Hodge-star factor. The nonlinear model instead uses an interpolated \(B\)– \(H\) curve. NonlinearMagnetostaticsHamiltonian has \(\mathcal H(A,B)=W(|B|^2)-j\cdot A\), with \(W\) obtained by integrating the curve. NonlinearMagneticInductionToMagneticField applies its radial law \(H_i=\star_i\,h(|B|)B_i/|B|\) (with a zero-field limit). The curve also provides derivatives used by the nonlinear solver.
elasticity::DisplacementToStrain::from_gradient computes the symmetric strain from a displacement gradient. Strain2D::xy stores tensorial shear strain, \(\varepsilon_{xy}=(\partial_y u_x+\partial_x u_y)/2\). The generated LinearElasticityHamiltonian describes isotropic linear elasticity:
\[ \mathcal H(u,\varepsilon) = \mu\,\varepsilon:\varepsilon + \frac{\lambda}{2}(\mathrm{tr}\,\varepsilon)^2-f\cdot u, \qquad \mu=\frac{E}{2(1+\nu)},\quad \lambda=\frac{E\nu}{(1+\nu)(1-(d-1)\nu)}. \]
\(E\) is Young's modulus, \(\nu\) is Poisson's ratio, and \(f\) is the body force. The generated 2D form uses plane stress; the 3D form uses the three-dimensional Lamé coefficient. The generated LinearElasticStrainToStress law has the component form \(\sigma_{ij}=2\mu\varepsilon_{ij}+\lambda\mathrm{tr}(\varepsilon)\delta_{ij}\); its stiffness and trace_coupling parameters represent \(2\mu\) and \(\lambda\). CauchyStress2D stores the resulting stress and provides von_mises().
elasticity::ElasticMaterialHodge2D is a local map for one oriented quadrilateral cell. Construct it from four vertex positions in bit-mask order (0, 1, 2, 3) and a callable stress_law(Strain2D) returning CauchyStress2D. edge_differences<SpatialX, SpatialY>(nodal) uses the exterior covariant derivative with identity transport to collect both displacement components on the four edges 0→1, 2→3, 0→2, and 1→3. matrix() returns the 8×8 material map from these edge differences to integrated forces on the corresponding dual half-segments. Its affine part reproduces constant-strain tractions, while a complementary term stabilizes the remaining edge modes. The constructor rejects folded or degenerate cells and a material law with nonpositive shear modulus.
recover_gradient(differences) returns the four affine displacement-gradient components used for diagnostics. The ONELAB elasticity example shows how the local map contributes to a nodal force balance.