1#![cfg_attr(not(feature = "solve"), allow(dead_code, unused_imports))]
45#![allow(rustdoc::private_intra_doc_links)]
52
53#[doc(hidden)]
56pub mod adapter_support;
57pub(crate) mod analysis;
59pub(crate) mod broad_phase;
62pub(crate) mod cadence;
63pub(crate) mod canonicalize;
64pub(crate) mod classification;
65#[doc(hidden)]
69pub mod compiled_rhs_adapter;
70#[cfg(feature = "solve")]
79#[doc(hidden)]
80pub mod compiler_agreement_adapter;
81pub(crate) mod coupling;
82pub(crate) mod coupling_imports;
83pub(crate) mod dae;
84#[cfg(not(target_arch = "wasm32"))]
87pub(crate) mod data_fed;
88pub(crate) mod data_output;
92pub(crate) mod data_source_urls;
95pub(crate) mod diagnostic;
96pub(crate) mod display;
97pub(crate) mod document;
100pub(crate) mod edit;
101pub(crate) mod elementwise_lift;
102pub(crate) mod error;
103pub(crate) mod faq;
104pub(crate) mod expression;
109pub mod extension;
110pub(crate) mod flatten;
111pub(crate) mod graph;
112pub(crate) mod inline_test_checks;
113pub mod intern;
114pub(crate) mod join;
115pub(crate) mod json_visit;
116pub(crate) mod lower_enums;
117pub(crate) mod lower_expression_templates;
118pub(crate) mod migration;
119pub(crate) mod observed_cone;
120pub(crate) mod op_registry;
121pub(crate) mod parse;
122pub mod precision;
127pub mod precision_infer;
128pub mod provider;
129pub(crate) mod reactions;
130pub(crate) mod ref_loading;
131pub(crate) mod reference_resolution;
132pub(crate) mod relational;
133pub(crate) mod serialize;
134pub(crate) mod solver;
135pub(crate) mod stdlib;
136pub(crate) mod structural;
137pub(crate) mod substitute;
138pub(crate) mod template_imports;
139#[cfg(test)]
140pub(crate) mod test_support;
141pub(crate) mod types;
142pub(crate) mod unit_conversion;
143pub(crate) mod units;
144pub(crate) mod validate;
145pub(crate) mod variable_bounds;
146
147#[cfg(feature = "wasm")]
148pub mod wasm;
149
150pub mod performance;
151
152pub(crate) mod compile_error;
155
156pub(crate) mod simulate;
159
160pub mod simulate_array;
163
164#[cfg(feature = "solve")]
170pub(crate) mod inline_tests;
171#[cfg(all(not(target_arch = "wasm32"), feature = "solve"))]
181#[doc(hidden)]
182pub mod inline_tests_adapter;
183
184#[cfg(not(target_arch = "wasm32"))]
185mod determinism_adapter;
186pub(crate) mod row_dedup;
187
188pub(crate) mod value_invention;
191
192pub(crate) mod pushdown_rewrite;
197
198#[cfg(not(target_arch = "wasm32"))]
205pub(crate) mod prepare;
206
207pub(crate) mod problem;
211pub(crate) mod strip;
213
214#[cfg(feature = "esio")]
219pub mod esio_provider;
220
221#[cfg(feature = "xla")]
224pub mod xla_runtime;
225
226pub use cadence::{
228 Cadence, CadenceError, ClassSummary, MaterializationPoint, Partition, classify, compute_fold,
229 partition_model,
230};
231pub use canonicalize::{
232 CanonicalizeError, canonical_json, canonicalize, canonicalize_document, format_canonical_float,
233};
234pub use document::{
237 ConstructSource, DocumentFormat, MathError, expression_names, parse_document,
238 parse_document_with_sources, parse_markdown, parse_math, parse_typst, print_document,
239 print_markdown, print_math, print_typst,
240};
241pub use classification::{
246 Classification, LhsForm, SystemKind, algebraic_unknowns, brownian_parameters,
247 constant_parameters, discrete_parameters, is_ode_state, observed_definition_json,
248 observed_definitions, observed_unknowns, ode_states, sampled_parameters, system_kind,
249};
250pub use coupling_imports::{
251 CouplingImportOptions, expand_coupling_imports, has_coupling_import, is_coupling_library_doc,
252};
253pub use dae::{DaeError, DiscretizeOptions, apply_dae_contract, default_dae_support, discretize};
254pub use data_output::{
255 CoordPlan, GridPlan, OutputError, OutputMeta, OutputPlan, VarGridding, VarPlan,
256 derive_output_gridding, derive_output_meta, derive_output_plan, group_gridding_by_grid,
257 parse_cell_key, plan_dimension_coordinates,
258};
259#[cfg(not(target_arch = "wasm32"))]
260pub use expression::evaluate;
261pub use expression::{contains, free_parameters, free_variables, simplify};
262pub use flatten::{
263 Contribution, DimensionPromotionRecord, FlattenError, FlattenMetadata, FlattenedSystem,
264 LoaderField, TermOrigin, capture_coupling_diagnostics, flatten, flatten_model,
265 flatten_with_options,
266};
267pub use graph::{
268 ComponentGraph, ComponentMetadata, ComponentNode, ComponentType, CouplingEdge, DependencyEdge,
269 DependencyRelationship, ExpressionGraph, ExpressionGraphInput, ExpressionGraphOptions, Graph,
270 VariableKind, VariableNode, component_exists, component_graph, expression_graph,
271 expression_graph_with_options, get_component_type, to_dot, to_json_graph, to_mermaid,
272};
273pub use parse::{
274 LoadOptions, load_document, load_document_with_options, load_path, load_path_with_options,
275 load_string, load_string_with_options,
276};
277pub use reactions::{
278 DeriveError, derive_odes, lower_reactions_to_equations, stoichiometric_matrix,
279};
280pub use ref_loading::{
281 resolve_subsystem_refs, resolve_subsystem_refs_raw, resolve_subsystem_refs_with_metaparameters,
282};
283pub use reference_resolution::{
284 EdgeKind, ReferenceEdge, ReferenceGraph, ReferenceResolutionError, ReferenceVertex, VertexKind,
285 build_reference_graph, resolve_references,
286};
287#[allow(deprecated)]
290pub use reference_resolution::build_reference_graph_with_index_sets;
291#[allow(deprecated)]
295pub use reference_resolution::ReferenceError;
296pub use relational::{
297 FloatKeyError, Key, Num, SemiringOp, canonical_index_set_json, distinct, group_aggregate,
298 serialize_keys, serialize_pairs,
299};
300pub use serialize::{to_json, to_json_compact, write_path};
301pub use structural::deprecated_records_per_sample_sites;
305pub use substitute::{
306 ScopedContext, substitute, substitute_in_model, substitute_in_model_with_context,
307 substitute_in_reaction_system, substitute_in_reaction_system_with_context,
308 substitute_with_context,
309};
310pub use template_imports::{
311 apply_scope_injections, is_template_library_doc, reject_template_imports_pre_v08,
312 resolve_template_machinery,
313};
314pub use solver::{
319 TimeOriginSource, reject_solver_external_pre_v13, reject_solver_pre_v11,
320 reject_solver_time_span_pre_v13, resolve_time_span, resolve_tolerances,
321 solver_external_location, time_origin, timestamp_to_seconds,
322};
323pub use types::{
324 AffectEquation, AutoRecords, ContinuousEvent, Coordinate, CouplingEntry, CouplingRole,
325 CovarianceMatrix, DaeInfo, DataSource, DataSourceBinding, DataSourceDeterminism,
326 DataSourceKind, DataSourceLocation, DataSourceMetadata, DataSourceTemporal, DiscreteEvent,
327 DiscreteEventTrigger, DiscretizedFrom, Distribution, DistributionParam, Domain, Equation,
328 EsmFile, Expr, ExpressionNode, FunctionalUpdate, InlineValue, Metadata, Model, ModelAnalysis,
329 ModelTest, ModelTestAssertion, ModelVariable, Operator, ParameterSweep, ParameterUpdate,
330 ParameterUpdateSpec, Plot, PlotAxis, PlotSeries, PlotValue, PlotY, Reaction, ReactionSystem,
331 RecordsPerFile, RegionBound, Solver, SolverTimeSpan, Species, StoichiometricEntry,
332 SweepDimension, SweepRange, TimePoint, TimeSpan, Tolerance, UnitConversion, UpdateValue,
333 VariableBound, VariableMapTransform, VariableType,
334};
335pub use validate::{
336 SchemaError, StructuralError, StructuralErrorCode, UnitWarning, ValidationResult, validate,
337 validate_text,
338};
339#[allow(deprecated)]
342pub use validate::validate_complete;
343pub use value_invention::{
344 BoundaryKind, ValueInventionError, ValueInventionResult, apply_value_invention,
345 materialize_value_invention,
346};
347
348pub use pushdown_rewrite::{
349 GateAxis, ProviderGate, PushdownRewriteError, desugar_pushdown, pushdown_coupling_pairs,
350 pushdown_provider_gates, pushdown_record,
351};
352#[cfg(not(target_arch = "wasm32"))]
358pub use prepare::{
359 AxisSel, PrepareError, PreparePhase, PrepareProgress, PrepareProgressFn, PrepareProvider,
360};
361
362pub use edit::{
363 EditError, add_coupling, add_equation, add_model, add_reaction, add_reaction_system,
364 add_species, add_variable, remove_coupling, remove_equation, remove_model, remove_reaction,
365 remove_species, remove_variable, replace_coupling, replace_equation, update_model_metadata,
366};
367pub use error::EsmError;
368pub use diagnostic::{ERROR_CODES, error_code_names};
373pub use lower_enums::{EnumLoweringError, lower_enums, lower_enums_mut, lower_enums_raw};
374pub use migration::{MigrationError, can_migrate, migrate, supported_migration_targets};
375#[allow(deprecated)]
378pub use migration::get_supported_migration_targets;
379
380pub use compile_error::CompileError;
381
382#[cfg(feature = "solve")]
383pub use inline_tests::{
384 AssertionResult, BuildProviderFactory, InlineTestOptions, check_assertion,
385 ephemeral_injected_file, evaluate_cellwise, field_reduce, resolve_tolerance, run_inline_tests,
386 run_inline_tests_filtered, run_inline_tests_paths, run_inline_tests_with_base_dir,
387 run_inline_tests_with_options, run_inline_tests_with_providers, state_cells,
388};
389pub use performance::{CompactExpr, PerformanceError};
390#[cfg(feature = "parallel")]
391pub use reactions::stoichiometric_matrix_parallel;
392pub use simulate::{
393 Alg, DEFAULT_ABSTOL, DEFAULT_RELTOL, Flow, Progress, ProgressFn, ReturnCode, SimulateError,
394 Solution, SolutionMetadata, SolveOptions, compile_array,
395};
396
397#[allow(deprecated)]
399pub use problem::Compile;
400pub use problem::{
401 CallbackFn, CallbackSet, Compiler, CompilerReport, CompilerRuleReport, EnsembleProblem,
402 EsmProblem, ProblemInput, ProblemOptions, Remake, Rhs, callbacks, compose, esm_problem,
403 observed_field, remake,
404};
405#[cfg(feature = "solve")]
406pub use problem::{
407 Integrator, StepStatus, init, initial_state, observed_trajectories, observed_trajectory, solve,
408 solve_ensemble, solve_to_completion, step,
409};
410pub use simulate_array::range::{
412 AxisCut, Decomposition, ForcingSet, ForcingSlot, HaloReport, LaneBlock, LaneInputs, LaneKind,
413 LaneLayout, LaneProgram, ParamSlot, RhsError, RhsProgram, RhsSelection, RhsWorkspace, SlotKind,
414 StateBlock, TileBlock, TileBox, TileLayout, TileProgram, forcing_from_sample, rhs_program,
415};
416pub use problem::stripped;
418pub use simulate_array::range::{
419 Kernel, KernelBlock, KernelOutput, KernelSet, KernelSpec, KernelWorkspace, compile_kernels,
420};
421pub use strip::{
422 EventKind, StripSet, StrippedConstructs, StrippedEvent, StrippedResidual, StrippedUpdate,
423 ZBlock,
424};
425pub use units::{
426 Dimension, EquationDimensionVerdict, ExactScale, Rational, ScaleFactor, UNIT_FINDING_ANALYSIS,
427 UNIT_FINDING_DIMENSIONAL_MISMATCH, UNIT_FINDING_DIMENSIONLESS_LITERAL,
428 UNIT_FINDING_UNPARSEABLE, Unit, UnitError, UnitFinding, UnitParseFailure, UnitSeverity,
429 build_unit_env, check_dimensional_consistency, check_equation_dimensions,
430 check_expression_dimensions, convert_units, equation_dimension_verdict, model_unit_env,
431 parse_unit, validate_equation_dimensions,
432};
433
434#[cfg(feature = "parallel")]
435pub use performance::ParallelEvaluator;
436
437#[cfg(feature = "custom_alloc")]
438pub use performance::ModelAllocator;
439
440pub const LIBRARY_VERSION: &str = env!("CARGO_PKG_VERSION");
444pub const SCHEMA_VERSION: &str = "2.3.0";
449
450#[cfg(test)]
451mod version_tests {
452 #[test]
455 fn schema_version_matches_bundled_schema() {
456 let schema: serde_json::Value =
457 serde_json::from_str(include_str!("esm-schema.json")).expect("bundled schema parses");
458 let id = schema["$id"].as_str().expect("schema has an $id");
459 assert!(
460 id.contains(&format!("/{}/", crate::SCHEMA_VERSION)),
461 "SCHEMA_VERSION {} does not match schema $id {}",
462 crate::SCHEMA_VERSION,
463 id
464 );
465 }
466}