Skip to main content

ArrayCompiled

Struct ArrayCompiled 

Source
pub struct ArrayCompiled { /* private fields */ }
Expand description

Compiled, parameter-sweep-ready ODE model for array-op models.

Implementations§

Source§

impl ArrayCompiled

Source

pub fn from_file(file: &EsmFile) -> Result<Self, CompileError>

Source

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.

Source

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.

Source

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.

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn n_states(&self) -> usize

The length of the flat state vector.

Source

pub fn parameter_names(&self) -> &[String]

Source

pub fn solve( &self, tspan: (f64, f64), params: &HashMap<String, f64>, initial_conditions: &HashMap<String, f64>, opts: &SolveOptions, ) -> Result<Solution, SimulateError>

Source

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

Source

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).

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V