Physical¶
The physics domain model: region tags and their materials, boundary and body conditions, and the property functions their values come from.
femforge.physical
¶
The physics domain model: per-region tags and their materials, the boundary/body conditions, and the property functions those values are written as.
Modules:
-
conditions–Conditions attached to a region, each carrying its physics, its body or boundary target and its own Elmer sif emission.
-
domain–The simulation domain: the materials and per-region tag overrides shared by the mesh and FEA backends.
-
expressions–Typed expression AST over bare SI magnitudes for variable-dependent material properties: evaluates in Python, renders to Elmer MATC or Lua, serializes to JSON.
-
property_functions–Material properties as pint-aware callables (Static, Calibration, ClosedForm, Expression) behind the
PropertyFunctionprotocol. -
readout–Short readouts of quantities and directions, at three significant figures on fixed unit ladders.
-
units–The shared pint unit registry, its typed quantity facades and the dimensionality-constrained quantity field types.
Classes:
-
BoundarySite–The boundary group a boundary condition lands on, as the condition sees it when it emits.
-
CalculateMagneticForce–Lumps the magnetic force, and optionally the torque, over the bodies its tag matches into one Elmer
Component. -
CoilDrive–A driven massive coil: the bodies that share one
CoilDriveform one coil that carriescurrent. -
CoilTerminal–One end of an open coil, its start or end electrode.
-
Condition–A source or constraint of one physics on the bodies or boundaries a tag selects; each subclass is one shipped condition.
-
ConditionGlyph–The kind of scene glyph and legend row a condition draws as.
-
ConditionTarget–Whether a condition attaches to a 3D body or a 2D boundary.
-
Convection–Newton cooling of an outer surface to an ambient temperature.
-
CurrentDensity–A uniform signed out-of-plane current density J = N·I/A over a winding window, the homogenized drive of a stranded coil in a 2D solve.
-
FixedDisplacement–A prescribed displacement on a boundary, clamped to zero in every direction by default.
-
FixedTemperature–A fixed temperature on a boundary.
-
FixedVoltage–A fixed voltage potential on an electrode, one end of a phase's terminal pair.
-
HeatFlux–A prescribed heat flux through a boundary.
-
HeatSource–A volumetric heat source in a body.
-
JouleHeat–Heats a body with the Joule losses of its solved current.
-
Magnetization–The magnetization direction of a permanent magnet.
-
SummaryPart–One value of a condition as the Setup tab reads it, with the glyph or word read before it.
-
SurfaceForce–A total force spread uniformly over a named face as a traction.
-
DomainConfig–The materials the mesher matches to STEP parts, plus the per-region
EntityTagoverrides (conditions / mesh refinement). -
EntityTag–A per-region override matched to a mesh entity by its authored tags; carries the region's self-describing
conditions. -
Add–The sum of two subexpressions.
-
Const–A literal SI magnitude.
-
Div–The quotient of two subexpressions.
-
ExprNode–Base node: shared config + Python operator composition, so laws are authored as plain arithmetic.
-
Mul–The product of two subexpressions.
-
Neg–The negation of a subexpression.
-
Param–A named parameter (e.g.
temperature), bound at evaluation/render time. -
Pow–One subexpression raised to the power of another.
-
Sub–The difference of two subexpressions.
-
BasePropertyFunction–Pydantic base implementing parameter checking once; subclasses declare
parameters/result_dimensionalityand implement_evaluate. -
Calibration–A property defined by sample points and interpolated between them (1-D only for now).
-
CalibrationPoint–One measured sample: input quantities by name and the resulting output.
-
ClosedForm–A property defined by an explicit Python callable, pint-in / pint-out; the callable is code, not JSON-serializable.
-
Expression–A property defined by a serializable typed expression AST (
physical.expressions) —ClosedFormas data instead of code. -
PropertyDimensionError–A supplied parameter had the wrong dimensionality.
-
PropertyError–Base class for every property-function error.
-
PropertyFunction–A material property as a function of zero or more named pint quantities, returning a pint Quantity.
-
PropertyFunctionField–Annotated metadata for a
PropertyFunctionconstrained todimensionality. -
PropertyParameterError–A required parameter was not supplied when evaluating a property.
-
PropertyRangeError–A parameter fell outside the calibrated range and extrapolation is off.
-
Static–A constant property: zero parameters, always returns
value. -
Quantity–A pint quantity with a float magnitude.
-
Unit–A pint unit, typed so that arithmetic with units and numbers keeps its type.
-
VectorQuantity–A pint quantity with a
Vec3magnitude.
Functions:
-
shipped_conditions–The condition classes
ConditionUnionadmits, in its order. -
conditions_for–The conditions on
tagsthat belong tophysicsand attach totarget. -
as_expr–Wrap a bare number into
Const; pass nodes through (the operator-composition coercion point). -
evaluate–Module-level convenience mirroring
expr.evaluate. -
render–Backend source for
exprwith parameter references substituted (e.g.{"temperature": "tx(0)"}). -
property_function_type–A
PropertyFunctionconstrained todimensionality, usable as a Pydantic field. -
quantity–Statically-typed face of
U.Quantity(...): afloatmagnitude yieldsQuantity, a Vec3 yieldsVectorQuantity.
Attributes:
-
ConditionUnion–Any concrete condition, discriminated by its
kind. -
Expr–Any expression node, discriminated by its
op. -
U–The shared pint unit registry, as in
5 * U.mmorU.Quantity(1.2, "T").
ConditionUnion
module-attribute
¶
ConditionUnion = Union[Magnetization, CurrentDensity, FixedTemperature, HeatFlux, Convection, HeatSource, FixedVoltage, JouleHeat, CoilDrive, CoilTerminal, CalculateMagneticForce, FixedDisplacement, SurfaceForce]
Any concrete condition, discriminated by its kind.
Expr
module-attribute
¶
Any expression node, discriminated by its op.
U
module-attribute
¶
U = cast('_TypedRegistry', pint.UnitRegistry(autoconvert_offset_to_baseunit=True))
The shared pint unit registry, as in 5 * U.mm or U.Quantity(1.2, "T").
BoundarySite
dataclass
¶
The boundary group a boundary condition lands on, as the condition sees it when it emits.
Attributes:
CalculateMagneticForce
pydantic-model
¶
Bases: Condition
Lumps the magnetic force, and optionally the torque, over the bodies its tag matches into one Elmer Component.
Fields:
-
kind(Literal['calculate_magnetic_force']) -
physics(Physics) -
target(ConditionTarget) -
label(str | None) -
calculate_magnetic_force(bool) -
calculate_magnetic_torque(bool) -
torque_origin(Vec3Field | None) -
torque_axis(DirectionField | None)
kind
pydantic-field
¶
kind: Literal['calculate_magnetic_force'] = 'calculate_magnetic_force'
Discriminator that names this condition type in a serialized config.
physics
pydantic-field
¶
physics: Physics = Physics.MAGNETOSTATICS
The physics whose solve this condition feeds.
target
pydantic-field
¶
target: ConditionTarget = ConditionTarget.BODY
Whether the condition attaches to a body or a boundary.
label
pydantic-field
¶
label: str | None = None
The Component's Name; None uses the authoring tag's name.
calculate_magnetic_force
pydantic-field
¶
calculate_magnetic_force: bool = True
Lump the nodal magnetic force over the master bodies.
calculate_magnetic_torque
pydantic-field
¶
calculate_magnetic_torque: bool = False
Also lump the magnetic torque (requires torque_origin/torque_axis).
to_elmer
¶
The CalcFields force and torque flags, plus the torque origin and axis when set.
Source code in src/femforge/physical/conditions.py
check_frame
¶
check_frame(frame: Frame) -> None
Raise when torque is requested under a frame whose force lumping yields none.
Source code in src/femforge/physical/conditions.py
summary
¶
summary(emitted: Mapping[str, float | str] | None = None, *, frame: Frame | None = None) -> tuple[SummaryLine, ...]
That the condition is an output the scene draws no glyph for; emitted and frame are ignored.
Parameters:
-
emitted(Mapping[str, float | str] | None, default:None) –The keywords the force Component received, by name.
-
frame(Frame | None, default:None) –The frame the run solved in.
Source code in src/femforge/physical/conditions.py
CoilDrive
pydantic-model
¶
Bases: Condition
A driven massive coil: the bodies that share one CoilDrive form one coil that carries current.
Reverse the drive by swapping the terminal roles, not with a negative current.
Fields:
kind
pydantic-field
¶
kind: Literal['coil_drive'] = 'coil_drive'
Discriminator that names this condition type in a serialized config.
physics
pydantic-field
¶
physics: Physics = Physics.COIL_MAGNETOSTATICS
The physics whose solve this condition feeds.
target
pydantic-field
¶
target: ConditionTarget = ConditionTarget.BODY
Whether the condition attaches to a body or a boundary.
current
pydantic-field
¶
I_coil [A]: The total coil current CoilSolver normalizes this coil's solved distribution to.
to_elmer
¶
The Desired Coil Current and the massive Coil Type.
Source code in src/femforge/physical/conditions.py
CoilTerminal
pydantic-model
¶
Bases: Condition
One end of an open coil, its start or end electrode.
The electrode's end face must lie on the domain boundary (GeometryConfig.terminate_electrodes); positive coil current flows from start to end.
Fields:
-
kind(Literal['coil_terminal']) -
physics(Physics) -
target(ConditionTarget) -
role(Literal['start', 'end'])
kind
pydantic-field
¶
kind: Literal['coil_terminal'] = 'coil_terminal'
Discriminator that names this condition type in a serialized config.
physics
pydantic-field
¶
physics: Physics = Physics.COIL_MAGNETOSTATICS
The physics whose solve this condition feeds.
target
pydantic-field
¶
target: ConditionTarget = ConditionTarget.BOUNDARY
Whether the condition attaches to a body or a boundary.
role
pydantic-field
¶
role: Literal['start', 'end']
Which end of the coil this electrode is; CoilSolver's normalized current flows start -> end.
to_elmer
¶
summary
¶
summary(emitted: Mapping[str, float | str] | None = None, *, frame: Frame | None = None) -> tuple[SummaryLine, ...]
The role, Start or End; emitted and frame are ignored.
Parameters:
-
emitted(Mapping[str, float | str] | None, default:None) –The keywords the electrode's sif block received, by name.
-
frame(Frame | None, default:None) –The frame the run solved in.
Source code in src/femforge/physical/conditions.py
Condition
pydantic-model
¶
Bases: BaseModel
A source or constraint of one physics on the bodies or boundaries a tag selects; each subclass is one shipped condition.
Config:
arbitrary_types_allowed:Trueuse_attribute_docstrings:True
Fields:
external_only
class-attribute
¶
external_only: bool = False
Boundary-target conditions with this set land only on a body's external (domain-boundary) surface groups, not its interfaces — e.g. a coil terminal is the electrode's exposed end face, not its interior contacts.
section
class-attribute
¶
section: SifSection
The sif section this condition's keywords land in; BOUNDARY_CONDITION exactly when target is BOUNDARY.
glyph
class-attribute
¶
glyph: ConditionGlyph | None
The scene glyph this condition draws as; None for an output that draws nothing.
combine
class-attribute
¶
How its keywords combine with another condition's in the same sif block.
target
pydantic-field
¶
target: ConditionTarget
Whether the condition attaches to a body or a boundary.
to_elmer
¶
This condition's Elmer sif keyword dict, reflected from each field's ElmerKeyword metadata; an unset field emits nothing.
Source code in src/femforge/physical/conditions.py
on_boundary
¶
on_boundary(site: BoundarySite) -> dict[str, float | str]
This condition's keywords on the boundary group site; the default ignores the site.
yields_to
¶
Each load keyword in emitted paired with the fixed-value keyword that makes Elmer ignore it in the same block; the default yields to none.
Source code in src/femforge/physical/conditions.py
solve_components
¶
The 1-based solve coordinates and values of this condition's vector in frame; the default has none.
dropped_fields
¶
summary
¶
summary(emitted: Mapping[str, float | str] | None = None, *, frame: Frame | None = None) -> tuple[SummaryLine, ...]
How the Setup tab reads this condition: one line of its sif-keyword fields, each after its glyph when there are several; the default ignores emitted and frame.
Parameters:
-
emitted(Mapping[str, float | str] | None, default:None) –The keywords the condition's sif block received, by name.
-
frame(Frame | None, default:None) –The frame the run solved in; None reads the authored axes as the solve axes.
Source code in src/femforge/physical/conditions.py
ConditionGlyph
¶
Bases: StrEnum
The kind of scene glyph and legend row a condition draws as.
Attributes:
-
SURFACE_FORCE–A load arrow on a face.
-
FIXED_DISPLACEMENT–A held face.
-
MAGNETIZATION–A magnet's direction arrow.
-
CURRENT_DENSITY–A coil drive's current marker.
-
THERMAL–A thermal source or boundary value.
-
VOLTAGE–A fixed voltage potential.
-
COIL_TERMINAL–A coil's start or end electrode.
SURFACE_FORCE
class-attribute
instance-attribute
¶
A load arrow on a face.
FIXED_DISPLACEMENT
class-attribute
instance-attribute
¶
A held face.
MAGNETIZATION
class-attribute
instance-attribute
¶
A magnet's direction arrow.
CURRENT_DENSITY
class-attribute
instance-attribute
¶
A coil drive's current marker.
THERMAL
class-attribute
instance-attribute
¶
A thermal source or boundary value.
COIL_TERMINAL
class-attribute
instance-attribute
¶
A coil's start or end electrode.
ConditionTarget
¶
Convection
pydantic-model
¶
Bases: Condition
Newton cooling of an outer surface to an ambient temperature.
It lands on the outer shell only, since a film coefficient on an interior interface would bypass the conduction path.
Fields:
-
kind(Literal['convection']) -
physics(Physics) -
target(ConditionTarget) -
coefficient(HeatTransferCoefficient) -
ext_temperature(Temperature)
kind
pydantic-field
¶
kind: Literal['convection'] = 'convection'
Discriminator that names this condition type in a serialized config.
physics
pydantic-field
¶
The physics whose solve this condition feeds.
target
pydantic-field
¶
target: ConditionTarget = ConditionTarget.BOUNDARY
Whether the condition attaches to a body or a boundary.
coefficient
pydantic-field
¶
h [W/(m²·K)]: Convective heat-transfer coefficient.
ext_temperature
pydantic-field
¶
T_amb [K]: External (ambient) temperature the boundary exchanges with.
yields_to
¶
The film exchange, which a fixed temperature on the same boundary overrides.
Source code in src/femforge/physical/conditions.py
CurrentDensity
pydantic-model
¶
Bases: Condition
A uniform signed out-of-plane current density J = N·I/A over a winding window, the homogenized drive of a stranded coil in a 2D solve.
Fields:
kind
pydantic-field
¶
kind: Literal['current_density'] = 'current_density'
Discriminator that names this condition type in a serialized config.
physics
pydantic-field
¶
physics: Physics = Physics.MAGNETOSTATICS_2D
The physics whose solve this condition feeds.
target
pydantic-field
¶
target: ConditionTarget = ConditionTarget.BODY
Whether the condition attaches to a body or a boundary.
value
pydantic-field
¶
J [A/m²]: Signed out-of-plane current density imposed uniformly over the body: azimuthal under Axisymmetric, along +normal under Cartesian2D.
check_frame
¶
check_frame(frame: Frame) -> None
Raise when frame has no 2D magnetostatic solve for this drive to feed.
Source code in src/femforge/physical/conditions.py
FixedDisplacement
pydantic-model
¶
Bases: Condition
A prescribed displacement on a boundary, clamped to zero in every direction by default.
Fields:
-
kind(Literal['fixed_displacement']) -
physics(Physics) -
target(ConditionTarget) -
x(Length | None) -
y(Length | None) -
z(Length | None)
kind
pydantic-field
¶
kind: Literal['fixed_displacement'] = 'fixed_displacement'
Discriminator that names this condition type in a serialized config.
physics
pydantic-field
¶
physics: Physics = Physics.LINEAR_ELASTICITY
The physics whose solve this condition feeds.
target
pydantic-field
¶
target: ConditionTarget = ConditionTarget.BOUNDARY
Whether the condition attaches to a body or a boundary.
x
pydantic-field
¶
u_x [m]: Prescribed displacement along the authored X axis; None leaves it free.
y
pydantic-field
¶
u_y [m]: Prescribed displacement along the authored Y axis; None leaves it free.
z
pydantic-field
¶
u_z [m]: Prescribed displacement along the authored Z axis; None leaves it free.
solve_components
¶
Each 1-based solve coordinate the constrained axes run along in frame, with its signed prescribed value; raises when the mapping is ill posed.
Source code in src/femforge/physical/conditions.py
to_elmer
¶
Raise: the keywords depend on the frame, which only on_boundary knows.
Source code in src/femforge/physical/conditions.py
on_boundary
¶
on_boundary(site: BoundarySite) -> dict[str, float | str]
The Displacement i keywords of the solve coordinates the constrained axes run along in the frame of site, signed by their alignment; an axis off the solve plane adds none.
Source code in src/femforge/physical/conditions.py
check_frame
¶
check_frame(frame: Frame) -> None
Raise when a nonzero component leaves the solve plane or a constrained axis runs oblique to a free one in frame.
dropped_fields
¶
The constrained authored axes that run along no solve coordinate of frame, such as ("z",) under a Cartesian 2D frame normal to Z.
Source code in src/femforge/physical/conditions.py
summary
¶
summary(emitted: Mapping[str, float | str] | None = None, *, frame: Frame | None = None) -> tuple[SummaryLine, ...]
X 0 · Y Free · Z –: each authored axis in order, held at the value its solve coordinate received, Free, or – when frame drops it.
Parameters:
-
emitted(Mapping[str, float | str] | None, default:None) –The keywords the boundary's sif block received, by name; None reads the authored values.
-
frame(Frame | None, default:None) –The frame the boundary's model solved in; None reads the authored axes as the solve axes.
Source code in src/femforge/physical/conditions.py
FixedTemperature
pydantic-model
¶
Bases: Condition
A fixed temperature on a boundary.
Fields:
kind
pydantic-field
¶
kind: Literal['fixed_temperature'] = 'fixed_temperature'
Discriminator that names this condition type in a serialized config.
physics
pydantic-field
¶
The physics whose solve this condition feeds.
target
pydantic-field
¶
target: ConditionTarget = ConditionTarget.BOUNDARY
Whether the condition attaches to a body or a boundary.
FixedVoltage
pydantic-model
¶
Bases: Condition
A fixed voltage potential on an electrode, one end of a phase's terminal pair.
The run also integrates the current through the electrode.
Fields:
kind
pydantic-field
¶
kind: Literal['fixed_voltage'] = 'fixed_voltage'
Discriminator that names this condition type in a serialized config.
physics
pydantic-field
¶
physics: Physics = Physics.CURRENT_CONDUCTION
The physics whose solve this condition feeds.
target
pydantic-field
¶
target: ConditionTarget = ConditionTarget.BOUNDARY
Whether the condition attaches to a body or a boundary.
to_elmer
¶
The electrode potential plus the Save Scalars flag that makes SaveScalars integrate the electrode current.
Source code in src/femforge/physical/conditions.py
HeatFlux
pydantic-model
¶
Bases: Condition
A prescribed heat flux through a boundary.
Fields:
kind
pydantic-field
¶
kind: Literal['heat_flux'] = 'heat_flux'
Discriminator that names this condition type in a serialized config.
physics
pydantic-field
¶
The physics whose solve this condition feeds.
target
pydantic-field
¶
target: ConditionTarget = ConditionTarget.BOUNDARY
Whether the condition attaches to a body or a boundary.
yields_to
¶
The heat flux, which a fixed temperature on the same boundary overrides.
HeatSource
pydantic-model
¶
Bases: Condition
A volumetric heat source in a body.
With temperature_coefficient set, the source scales linearly with the local temperature, the σ(T) Joule feedback of a prescribed-current winding.
Fields:
-
kind(Literal['heat_source']) -
physics(Physics) -
target(ConditionTarget) -
power_density(PowerDensity) -
temperature_coefficient(float | None) -
reference_temperature(Temperature | None)
kind
pydantic-field
¶
kind: Literal['heat_source'] = 'heat_source'
Discriminator that names this condition type in a serialized config.
physics
pydantic-field
¶
The physics whose solve this condition feeds.
target
pydantic-field
¶
target: ConditionTarget = ConditionTarget.BODY
Whether the condition attaches to a body or a boundary.
power_density
pydantic-field
¶
q [W/m³]: Heat generation density at reference_temperature when a coefficient is set, else the constant source.
temperature_coefficient
pydantic-field
¶
temperature_coefficient: float | None = None
α [1/K]: Linear coefficient in q(T) = power_density·(1 + α·(T − reference_temperature)); None emits the constant.
reference_temperature
pydantic-field
¶
T_ref [K]: The temperature power_density holds at; required with temperature_coefficient.
to_elmer
¶
The Volumetric Heat Source keyword, a MATC expression in temperature when temperature_coefficient is set.
Source code in src/femforge/physical/conditions.py
JouleHeat
pydantic-model
¶
Bases: Condition
Heats a body with the Joule losses of its solved current.
It takes no value: HeatSolve integrates the loss density StatCurrentSolve solves for.
Fields:
kind
pydantic-field
¶
kind: Literal['joule_heat'] = 'joule_heat'
Discriminator that names this condition type in a serialized config.
physics
pydantic-field
¶
physics: Physics = Physics.JOULE_HEATING
The physics whose solve this condition feeds.
target
pydantic-field
¶
target: ConditionTarget = ConditionTarget.BODY
Whether the condition attaches to a body or a boundary.
Magnetization
pydantic-model
¶
Bases: Condition
The magnetization direction of a permanent magnet.
The magnitude |M| = Bᵣ/μ₀ comes from the magnet's material.
Fields:
-
kind(Literal['magnetization']) -
physics(Physics) -
target(ConditionTarget) -
direction(DirectionField | None)
kind
pydantic-field
¶
kind: Literal['magnetization'] = 'magnetization'
Discriminator that names this condition type in a serialized config.
physics
pydantic-field
¶
physics: Physics = Physics.MAGNETOSTATICS
The physics whose solve this condition feeds.
target
pydantic-field
¶
target: ConditionTarget = ConditionTarget.BODY
Whether the condition attaches to a body or a boundary.
direction
pydantic-field
¶
direction: DirectionField | None
Magnetization direction in the authored model's frame, None for an unmagnetized body; magnitude comes from the material.
to_elmer
¶
The Magnetization components of magnitude (A/m) along the direction, in frame's solve coordinates.
Source code in src/femforge/physical/conditions.py
check_frame
¶
check_frame(frame: Frame) -> None
Raise when frame has no form for the direction.
Source code in src/femforge/physical/conditions.py
solve_components
¶
The solve components of the unit direction in frame; none without a direction.
Source code in src/femforge/physical/conditions.py
summary
¶
summary(emitted: Mapping[str, float | str] | None = None, *, frame: Frame | None = None) -> tuple[SummaryLine, ...]
The authored direction, then the remanence Br = μ₀·M of the emitted Magnetization i components in solve order; frame is ignored.
Parameters:
-
emitted(Mapping[str, float | str] | None, default:None) –The keywords the magnet's Material block received, by name.
-
frame(Frame | None, default:None) –The frame the run solved in.
Source code in src/femforge/physical/conditions.py
SummaryPart
dataclass
¶
One value of a condition as the Setup tab reads it, with the glyph or word read before it.
Attributes:
-
value(str) –The value as read, such as
100 N Along (1, 0, 0). -
label(str) –The glyph or word read before the value, such as
horTraction; empty for none. -
component(Component | None) –The authored axis the part reads, so the Setup tab can mark an axis the frame drops; None for any other part.
-
tip(str) –What a placeholder in the value stands for, such as the expression an
exprreplaces; empty for none.
SurfaceForce
pydantic-model
¶
Bases: Condition
A total force spread uniformly over a named face as a traction.
Attach it to a TaggedFace's tag: the traction is the force over the face's measured area, which an adjacency group does not carry.
Fields:
kind
pydantic-field
¶
kind: Literal['surface_force'] = 'surface_force'
Discriminator that names this condition type in a serialized config.
physics
pydantic-field
¶
physics: Physics = Physics.LINEAR_ELASTICITY
The physics whose solve this condition feeds.
target
pydantic-field
¶
target: ConditionTarget = ConditionTarget.BOUNDARY
Whether the condition attaches to a body or a boundary.
force
pydantic-field
¶
F⃗ [N]: Total force spread uniformly over the face, in the authored frame.
yields_to
¶
Each nonzero Force i, which a fixed Displacement i on the same boundary overrides.
Source code in src/femforge/physical/conditions.py
to_elmer
¶
Raise: the traction needs the face area, which only on_boundary knows.
Source code in src/femforge/physical/conditions.py
on_boundary
¶
on_boundary(site: BoundarySite) -> dict[str, float | str]
The Force i traction components, the solve-frame force share over the measured area of site.
Source code in src/femforge/physical/conditions.py
check_frame
¶
check_frame(frame: Frame) -> None
Raise when frame has no form for the force direction.
Source code in src/femforge/physical/conditions.py
solve_components
¶
The solve components, in N, of the share of the force the solve domain carries in frame: per metre of depth in Cartesian 2D.
Source code in src/femforge/physical/conditions.py
summary
¶
summary(emitted: Mapping[str, float | str] | None = None, *, frame: Frame | None = None) -> tuple[SummaryLine, ...]
The authored total and its direction, then the signed traction the emitted Force i components hold on the face, in solve order; frame is ignored.
Parameters:
-
emitted(Mapping[str, float | str] | None, default:None) –The keywords the face's sif block received, by name.
-
frame(Frame | None, default:None) –The frame the run solved in.
Source code in src/femforge/physical/conditions.py
DomainConfig
pydantic-model
¶
Bases: ConfigArea
The materials the mesher matches to STEP parts, plus the per-region EntityTag overrides (conditions / mesh refinement).
Fields:
materials
pydantic-field
¶
materials: list[MaterialProperties]
The candidate materials; the mesher matches each STEP entity to one by tag.
tags
pydantic-field
¶
The per-region overrides, matched to mesh entities by name; each carries its conditions and optional mesh_size.
EntityTag
pydantic-model
¶
Bases: ConfigArea
A per-region override matched to a mesh entity by its authored tags; carries the region's self-describing conditions.
Fields:
-
selector(TagDict) -
conditions(list[ConditionUnion]) -
mesh_size(Length | None)
selector
pydantic-field
¶
selector: TagDict
Compound-key selector: a mesh entity matches when its tag dict contains ALL of these key=value pairs (an empty selector matches every entity).
conditions
pydantic-field
¶
conditions: list[ConditionUnion]
Composable, self-describing conditions (body forces / boundary conditions) this region carries.
mesh_size
pydantic-field
¶
h [mm]: Target mesh size for this region, such as a finer air gap; None inherits MeshConfig.global_mesh_size.
name
property
¶
name: str
Stable human-readable stem shared with gmsh/Elmer names: the uppercased part name for a lone Name selector, else sorted KeyValue pairs (CurrentDirEntry_Phase2).
matches
¶
Whether an entity's tag dict satisfies every selector pair.
print_tree
¶
Add this tag and its conditions to tree.
Source code in src/femforge/physical/domain.py
Add
pydantic-model
¶
Const
pydantic-model
¶
Div
pydantic-model
¶
ExprNode
pydantic-model
¶
Mul
pydantic-model
¶
Neg
pydantic-model
¶
Param
pydantic-model
¶
Bases: ExprNode
A named parameter (e.g. temperature), bound at evaluation/render time.
Fields:
op
pydantic-field
¶
op: Literal['param'] = 'param'
Discriminator that names this node type in serialized JSON.
evaluate
¶
The value env binds to this parameter.
Source code in src/femforge/physical/expressions.py
render
¶
The backend reference refs binds to this parameter.
Source code in src/femforge/physical/expressions.py
Pow
pydantic-model
¶
Bases: ExprNode
One subexpression raised to the power of another.
Fields:
Sub
pydantic-model
¶
BasePropertyFunction
pydantic-model
¶
Bases: BaseModel
Pydantic base implementing parameter checking once; subclasses declare parameters / result_dimensionality and implement _evaluate.
Extra keyword arguments are ignored, so an operating point may carry more quantities than a property needs.
Config:
arbitrary_types_allowed:Trueuse_attribute_docstrings:True
Calibration
pydantic-model
¶
Bases: BasePropertyFunction
A property defined by sample points and interpolated between them (1-D only for now).
Point inputs are validated against param_dims at construction; out-of-range raises unless extrapolate=True.
Fields:
-
kind(Literal['calibration']) -
param_dims(dict[str, str]) -
points(list[CalibrationPoint]) -
method(Literal['linear', 'nearest', 'cubic']) -
extrapolate(bool)
Validators:
-
_validate_points
kind
pydantic-field
¶
kind: Literal['calibration'] = 'calibration'
Discriminator that names this property kind in serialized JSON.
param_dims
pydantic-field
¶
The single parameter name and its expected dimensionality, as a pint string.
method
pydantic-field
¶
method: Literal['linear', 'nearest', 'cubic'] = 'linear'
Interpolation between samples: linear, nearest, or monotone cubic (PCHIP).
CalibrationPoint
pydantic-model
¶
Bases: BaseModel
One measured sample: input quantities by name and the resulting output.
Config:
arbitrary_types_allowed:Trueuse_attribute_docstrings:True
Fields:
Validators:
ClosedForm
pydantic-model
¶
Bases: BasePropertyFunction
A property defined by an explicit Python callable, pint-in / pint-out; the callable is code, not JSON-serializable.
Fields:
-
param_dims(dict[str, str]) -
result_dim(str) -
expression(Callable[..., Quantity])
Expression
pydantic-model
¶
Bases: BasePropertyFunction
A property defined by a serializable typed expression AST (physical.expressions) — ClosedForm as data instead of code.
body computes the result's SI magnitude in result_units from parameters bound as SI-base magnitudes, matching Elmer's tx.
Fields:
-
kind(Literal['expression']) -
param_dims(dict[str, str]) -
result_units(str) -
body(Expr)
Validators:
-
_validate_body_parameters
PropertyDimensionError
¶
Bases: PropertyError
A supplied parameter had the wrong dimensionality.
Parameters:
-
fn('PropertyFunction') –The property that rejected the call.
-
name(str) –The offending parameter, or
<result>for a closed form's return value. -
expected(str) –The dimensionality the parameter needs.
-
got(object) –The dimensionality, or the type, that was supplied.
Source code in src/femforge/physical/property_functions.py
PropertyFunction
¶
Bases: Protocol
A material property as a function of zero or more named pint quantities, returning a pint Quantity.
Methods:
-
__call__–Evaluate. Raises a typed error if a required parameter is missing or has the wrong dimensionality.
Attributes:
-
parameters(Mapping[str, str]) –Required parameter name -> expected dimensionality (pint string); this IS the call schema.
-
result_dimensionality(str) –Dimensionality of the returned quantity, e.g.
'[power]/[length]/[temperature]'.
parameters
property
¶
Required parameter name -> expected dimensionality (pint string); this IS the call schema.
result_dimensionality
property
¶
result_dimensionality: str
Dimensionality of the returned quantity, e.g. '[power]/[length]/[temperature]'.
__call__
¶
Evaluate. Raises a typed error if a required parameter is missing or has the wrong dimensionality.
PropertyFunctionField
¶
PropertyFunctionField(dimensionality: str)
Annotated metadata for a PropertyFunction constrained to dimensionality.
Coerces bare quantities/strings into Static, validates result dimensionality, and exports quantity_type's unit-annotated JSON schema.
Source code in src/femforge/physical/property_functions.py
PropertyParameterError
¶
Bases: PropertyError
A required parameter was not supplied when evaluating a property.
Source code in src/femforge/physical/property_functions.py
PropertyRangeError
¶
Bases: PropertyError
A parameter fell outside the calibrated range and extrapolation is off.
Parameters:
-
fn('PropertyFunction') –The calibration that rejected the call.
-
name(str) –The out-of-range parameter.
-
value(object) –The supplied value.
-
low(object) –The lowest calibrated value.
-
high(object) –The highest calibrated value.
Source code in src/femforge/physical/property_functions.py
Static
pydantic-model
¶
Bases: BasePropertyFunction
A constant property: zero parameters, always returns value.
Authored as Static(value="8.7 W/(m*K)"); ignores any operating-point arguments.
Fields:
Validators:
-
_coerce_value→value
Quantity
¶
Bases: PlainQuantity[float]
A pint quantity with a float magnitude.
Methods:
-
to–This quantity converted to the units
othernames.
to
¶
This quantity converted to the units other names.
Parameters:
-
other(object, default:None) –The target units, as a unit, a quantity or a unit string.
-
contexts(object, default:()) –The pint contexts, by name or object, that enable the conversion.
-
ctx_kwargs(object, default:{}) –The parameters those contexts take.
Source code in src/femforge/physical/units.py
Unit
¶
Bases: PlainUnit
A pint unit, typed so that arithmetic with units and numbers keeps its type.
VectorQuantity
¶
Bases: PlainQuantity[Vec3]
A pint quantity with a Vec3 magnitude.
Methods:
-
to–This vector quantity converted to the units
othernames.
to
¶
to(other: object = None, *contexts: object, **ctx_kwargs: object) -> VectorQuantity
This vector quantity converted to the units other names.
Parameters:
-
other(object, default:None) –The target units, as a unit, a quantity or a unit string.
-
contexts(object, default:()) –The pint contexts, by name or object, that enable the conversion.
-
ctx_kwargs(object, default:{}) –The parameters those contexts take.
Source code in src/femforge/physical/units.py
shipped_conditions
¶
The condition classes ConditionUnion admits, in its order.
Source code in src/femforge/physical/conditions.py
conditions_for
¶
conditions_for(tags: Iterable[EntityTag], physics: Physics | Iterable[Physics], target: ConditionTarget) -> list[Condition]
The conditions on tags that belong to physics and attach to target.
Parameters:
-
tags(Iterable[EntityTag]) –The region overrides that match the region.
-
physics(Physics | Iterable[Physics]) –One
Physics, or several, such as a coupled preset's constituents. -
target(ConditionTarget) –Whether to collect body or boundary conditions.
Source code in src/femforge/physical/domain.py
as_expr
¶
Wrap a bare number into Const; pass nodes through (the operator-composition coercion point).
Source code in src/femforge/physical/expressions.py
evaluate
¶
render
¶
Backend source for expr with parameter references substituted (e.g. {"temperature": "tx(0)"}).
property_function_type
¶
A PropertyFunction constrained to dimensionality, usable as a Pydantic field.
quantity
¶
quantity(value: Vec3, units: Unit | str | None = None) -> VectorQuantity
Statically-typed face of U.Quantity(...): a float magnitude yields Quantity, a Vec3 yields VectorQuantity.
Prefer a string for composite units ("newton * meter").
Source code in src/femforge/physical/units.py
femforge.physical.readout
¶
Short readouts of quantities and directions, at three significant figures on fixed unit ladders.
Classes:
-
Rung–One unit a ladder can read a quantity in: its pint expression and the label it prints.
-
Ladder–The units one dimensionality reads in, smallest first.
Functions:
-
readout–valueat three significant figures in the largest rung of its ladder that reads at least 1, or inunitwhen given. -
along–The unit direction of
directionas its three components at three significant figures, such as(0.6, 0.8, 0). -
vector_readout–The magnitude of
valueand the direction it points along, such as100 N Along (1, 0, 0). -
components_readout–Signed
componentsin the SIunitas one tuple in the rung their largest reads in, such as(500, -0.2) kPa; a text component reads as itself.
Attributes:
-
LENGTH–Lengths in mm or m.
-
AREA–Areas in mm² or m².
-
FORCE–Forces in N, kN or MN.
-
PRESSURE–Pressures and tractions in Pa up to GPa.
-
CURRENT_DENSITY–Current densities in A/m² or A/mm².
-
VOLTAGE–Voltages in V or kV.
-
TEMPERATURE–Temperatures in K.
-
HEAT_FLUX–Heat fluxes in W/m² up to MW/m².
-
HEAT_TRANSFER–Heat-transfer coefficients in W/(m²·K).
-
POWER_DENSITY–Power densities in W/m³ up to GW/m³.
-
CURRENT–Currents in A or kA.
-
FLUX_DENSITY–Flux densities in mT or T.
-
LADDERS(tuple[Ladder, ...]) –Every ladder, scanned in order for the first that matches a quantity.
AREA
module-attribute
¶
Areas in mm² or m².
FORCE
module-attribute
¶
Forces in N, kN or MN.
PRESSURE
module-attribute
¶
Pressures and tractions in Pa up to GPa.
CURRENT_DENSITY
module-attribute
¶
Current densities in A/m² or A/mm².
VOLTAGE
module-attribute
¶
Voltages in V or kV.
HEAT_FLUX
module-attribute
¶
Heat fluxes in W/m² up to MW/m².
HEAT_TRANSFER
module-attribute
¶
Heat-transfer coefficients in W/(m²·K).
POWER_DENSITY
module-attribute
¶
POWER_DENSITY = Ladder((Rung('W/m**3', 'W/m³'), Rung('kW/m**3', 'kW/m³'), Rung('MW/m**3', 'MW/m³'), Rung('GW/m**3', 'GW/m³')))
Power densities in W/m³ up to GW/m³.
CURRENT
module-attribute
¶
Currents in A or kA.
FLUX_DENSITY
module-attribute
¶
Flux densities in mT or T.
LADDERS
module-attribute
¶
LADDERS: tuple[Ladder, ...] = (LENGTH, AREA, FORCE, PRESSURE, CURRENT_DENSITY, VOLTAGE, TEMPERATURE, HEAT_FLUX, HEAT_TRANSFER, POWER_DENSITY, CURRENT, FLUX_DENSITY)
Every ladder, scanned in order for the first that matches a quantity.
Rung
dataclass
¶
One unit a ladder can read a quantity in: its pint expression and the label it prints.
Attributes:
Ladder
dataclass
¶
The units one dimensionality reads in, smallest first.
Methods:
-
matches–Whether
valuehas this ladder's dimensionality.
Attributes:
readout
¶
value at three significant figures in the largest rung of its ladder that reads at least 1, or in unit when given.
Source code in src/femforge/physical/readout.py
along
¶
The unit direction of direction as its three components at three significant figures, such as (0.6, 0.8, 0).
Source code in src/femforge/physical/readout.py
vector_readout
¶
vector_readout(value: VectorQuantity) -> str
The magnitude of value and the direction it points along, such as 100 N Along (1, 0, 0).
Source code in src/femforge/physical/readout.py
components_readout
¶
Signed components in the SI unit as one tuple in the rung their largest reads in, such as (500, -0.2) kPa; a text component reads as itself.
Parameters:
-
components(Sequence[float | str]) –The components, in solve order.
-
unit(str) –The pint unit the components are in, such as
Pa.