pub struct ArrayCompiled { /* private fields */ }Expand description
Compiled, parameter-sweep-ready ODE model for array-op models.
Implementations§
Source§impl ArrayCompiled
impl ArrayCompiled
pub fn from_file(file: &EsmFile) -> Result<Self, CompileError>
Sourcepub fn from_file_owned(file: EsmFile) -> Result<Self, CompileError>
pub fn from_file_owned(file: EsmFile) -> Result<Self, CompileError>
Self::from_file, consuming the file. The peak-memory-lean build for
a large expanded discretization: the single model is MOVED out of the
file (nothing is cloned), the rest of the document is dropped here, and
Self::compile_pipeline then moves each observed body into its
compiled rule instead of deep-copying it. For simpleclimate.esm at
the production grid the borrowed from_file holds three ~1 GiB copies
live at once (the caller’s file, the compile’s private model clone, the
compiled rules); this path holds ~one. Same build stages, same result.
Sourcepub fn from_flattened(flat: &FlattenedSystem) -> Result<Self, CompileError>
pub fn from_flattened(flat: &FlattenedSystem) -> Result<Self, CompileError>
Build from a FlattenedSystem.
crate::flatten::flatten already merges a coupled, multi-component
file into a single dot-namespaced system (coupling rules applied, every
variable reference namespaced). The array path historically only had
Self::from_file, which rejects models.len() != 1 outright because
it operates on a raw Model and has no coupling machinery of its own.
This constructor closes that seam: it consumes the already-coupled
flatten output directly, so a discretized coupled spatial model
compiles + evaluates through the vectorized array runtime, reusing
flatten.rs’s coupling verbatim (no new coupling logic here). The raw
single-model from_file guard is intentionally left intact — the real
pipeline flattens first and reaches the array runtime through here
(ess-14f.8).
The flattened system splits variables into typed maps; Self::from_model
expects a single registry discriminated by ModelVariable::var_type.
We merge them back into one synthetic Model (each variable already
carries its var_type) and delegate, so every downstream stage — shape
inference, faq lowering, the diffsol RHS build — is shared bit-for-bit
with the single-model path.
Sourcepub fn from_model(
model: &Model,
index_sets: &HashMap<String, IndexSet>,
) -> Result<Self, CompileError>
pub fn from_model( model: &Model, index_sets: &HashMap<String, IndexSet>, ) -> Result<Self, CompileError>
Build from a single Model and the document-scoped index_sets
registry (RFC semiring-faq-unified-ir §5.2, v0.8.0). The registry lives
on the top-level document and is shared by all models, so it is passed in
explicitly; pass an empty map for a model with no { "from": <set> }
range references.
Sourcepub fn from_model_with_arrays(
model: &Model,
index_sets: &HashMap<String, IndexSet>,
vi_arrays: Option<&HashMap<String, ArrayD<f64>>>,
) -> Result<Self, CompileError>
pub fn from_model_with_arrays( model: &Model, index_sets: &HashMap<String, IndexSet>, vi_arrays: Option<&HashMap<String, ArrayD<f64>>>, ) -> Result<Self, CompileError>
from_model with a caller-supplied factor-array
channel for the build-time value-invention engine.
vi_arrays is overlaid on the const-literal factors the document
carries (caller wins on a name collision — see vi_factor_arrays) and
handed to the relational engine. Supply it whenever a producer’s factors
arrive from OUTSIDE the document: ISRM’s overlap gate reads its envelopes
from type: "parameter" variables that data loaders fill through
coupling param_to_var edges, which the const scan cannot see, so
without this channel the gate has no envelopes to build and the producer
invents nothing.
None is exactly from_model — every existing
caller is unaffected.
Source§impl ArrayCompiled
impl ArrayCompiled
Sourcepub fn forcing_handle(&self) -> Rc<RefCell<HashMap<String, ArrayD<f64>>>>
pub fn forcing_handle(&self) -> Rc<RefCell<HashMap<String, ArrayD<f64>>>>
A clonable handle to the external forcing buffer (PR-1, ess-14f.7). A
driver that integrates this model in discrete-cadence segments holds the
returned Rc and, at each cadence boundary, refreshes a loader-fed
field: compiled.forcing_handle().borrow_mut().insert(var, regridded).
The captured RHS/Jacobian closures read the same buffer live on the
next step(), so the refresh is reflected without rebuilding the
problem. The buffer is shared (the handle and the closures clone one
Rc); mutate it only between segments, never inside a solver step, to
keep the RHS pure within a segment.
Whoever holds the handle may write the buffer at any later point, so
taking one also retires the field initial conditions construction
resolved from it ([FieldIcMemo]): the next solve resolves them from
the buffer as it then stands.
Sourcepub fn has_differential_equations(&self) -> bool
pub fn has_differential_equations(&self) -> bool
Whether this model has anything for the ODE solver to integrate — at
least one D(var, t) = … rule.
An array model whose every equation is ALGEBRAIC compiles to observed
rules and no RhsRule, so it evaluates without the integrator ever
touching a value. That distinction is what
problem::reject_f32_integration needs: a Float32 declaration is
honourable for such a model and not for one with real dynamics.
Sourcepub fn observed_variable_names(&self) -> Vec<String>
pub fn observed_variable_names(&self) -> Vec<String>
The OBSERVED variables this model declares, in dependency order.
What crate::problem::observed_trajectories resolves a caller’s name
against, with the §5.8 precedence.
Sourcepub fn state_variable_names(&self) -> &[String]
pub fn state_variable_names(&self) -> &[String]
Every state slot’s name (u[2,3], or a 0-D state’s bare name), in
flat state-vector order. Built from the slot layout the first time it
is asked for, then kept.
pub fn parameter_names(&self) -> &[String]
pub fn solve( &self, tspan: (f64, f64), params: &HashMap<String, f64>, initial_conditions: &HashMap<String, f64>, opts: &SolveOptions, ) -> Result<Solution, SimulateError>
Sourcepub fn solve_inspect(
&self,
tspan: (f64, f64),
params: &HashMap<String, f64>,
initial_conditions: &HashMap<String, f64>,
opts: &SolveOptions,
inspect: Option<&mut BuildInspection>,
) -> Result<Solution, SimulateError>
pub fn solve_inspect( &self, tspan: (f64, f64), params: &HashMap<String, f64>, initial_conditions: &HashMap<String, f64>, opts: &SolveOptions, inspect: Option<&mut BuildInspection>, ) -> Result<Solution, SimulateError>
Self::solve with an optional build-observability sink (see
BuildInspection). When inspect is Some, the sink is filled —
after the initial state vector is assembled and before the solver runs —
with the state-free observed arrays materialized at u0/t0 and every
observed rule’s resolved body expression. The integration itself is
byte-identical with or without a sink.
Source§impl ArrayCompiled
impl ArrayCompiled
Sourcepub fn debug_build_tape_report(&self) -> TapeBuildReport
pub fn debug_build_tape_report(&self) -> TapeBuildReport
Build the tape and return the diagnostic report (see
TapeBuildReport). Evaluation is unchanged: this is a build-and-
discard entry for inspection tooling (examples/tape_report.rs).
Sourcepub fn debug_dump_fuse_stats(&self)
pub fn debug_dump_fuse_stats(&self)
Step 4 diagnostic: dump per-group shape statistics of the fused
program to stderr (examples/fuse_stats.rs).
Auto Trait Implementations§
impl !Freeze for ArrayCompiled
impl !RefUnwindSafe for ArrayCompiled
impl !Send for ArrayCompiled
impl !Sync for ArrayCompiled
impl !UnwindSafe for ArrayCompiled
impl Unpin for ArrayCompiled
impl UnsafeUnpin for ArrayCompiled
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.