validate_units
Stable function · Units
Tier: stable · Kind: function · Topic: Units
| Julia | TypeScript | Python | Rust | Go |
|---|---|---|---|---|
| not exported | validateUnits | validate_units | not exported | not exported |
Julia
Julia does not export this function.
TypeScript
function validateUnits(file: EsmFile): UnitWarning[]
Validate dimensional consistency of equations in an ESM file.
SCOPE: every real inline component — each top-level model / reaction system
AND their inline subsystems (walked via forEachComponent(..., {recurse: true}); reference-stub and data-loader subsystems are opaque leaves and are
skipped). For each, forEachEquation covers a model’s dynamic equations
and a reaction system’s constraint_equations; models additionally have
their observed variable expressions checked.
BINDINGS: the shared top-level environment (top-level models’ variables +
reaction systems’ species/parameters, bare first-wins) is used
for EVERY component, including subsystems. Subsystem-local declarations are
deliberately NOT added, so a name defined only inside a subsystem stays an
“Unknown variable” and keeps the mismatch-suppression in checkAndReport.
This is the conservative scope required to broaden coverage without
introducing cross-language divergence: binding a subsystem’s own variables
would un-suppress equation-level mismatches for nondimensionalized subsystem
ODEs (e.g. D(u,t) = k*u with a dimensionless u), which the other bindings
— none of which run a full per-equation dimensional check — never flag. A
top-level reaction system’s constraint_equations still resolve fully,
because that system’s species/parameters ARE in the shared environment.
SPATIAL-CALCULUS SUGAR: grad/div/laplacian (and integral, and any user
op) are ordinary open-tier rewrite-target ops with NO dimensional rule
(esm-spec §4.2 / §4.8.3 “any other op”): their dimension is UNDETERMINABLE
until a discretization rule lowers them to a D stencil, so checkDimensions
reports UNKNOWN and skips the enclosing check (§4.8.4). There is no coordinate
table and no op-name special case — the checker never divides an operand by a
coordinate’s units. Unparseable variable-unit DECLARATIONS are still a defect;
reportUnparseableVariableUnits flags them per component (the only pass
that sees inline-subsystem variables).
Python
validate_units(target: EsmFile | Model | ReactionSystem) -> UnitValidationResult
Convenience function to validate units of an ESM structure.
Parameters
target(EsmFile | Model | ReactionSystem) — The ESM file, model, or reaction system to validate
Returns
UnitValidationResult— UnitValidationResult with validation status and issues
Rust
Rust does not export this function.
Go
Go does not export this function.