API reference

Direct model construction

ModelDefinition is the scientific model-definition container. Direct construction realizes intrinsic component size structure, resolves process-owned parameter slots and required drivers, and compiles runtime tracer equations during setup.

Agate.Construction.construct — Function
construct(family::AbstractModelFamily;
          plankton_pfts, parameter_overrides=(;),
          sinking_tracers=nothing, open_bottom=true, grid=nothing,
          arch=nothing, scalar_type=nothing) -> bgc

Construct a registered model family from its resolved family realization. This is the supported construction seam for external family packages after their own user-facing constructor syntax has been translated into the nested plankton_pfts mapping and parameter overrides. Runtime grid, architecture, and scalar precision remain execution choices.

source
construct(definition::ModelDefinition; kwargs...) -> bgc

Construct a model directly from authored components, named processes, and parameter definitions. plankton_pfts optionally replaces each logical plankton component's intrinsic size structure with the same named PFT realization vocabulary used by registered families. Process participation determines interaction axes and required auxiliary drivers, and runtime tracer equations are compiled during setup.

parameter_overrides supplies concrete parameter values over the defaults declared in definition.parameters, including explicit axis-sized interaction matrices. Runtime grid, architecture, and scalar precision remain execution choices rather than part of the scientific definition.

source

Replay a versioned family recipe in the supplied execution environment.

source

Backend lifecycle

Construction separates scientific meaning, realized topology, labelled parameter storage, and runtime execution. After ParameterPlan, parameter-value realization and equation compilation are independent setup branches: compilation uses canonical bindings plus the realized layout and plan, not the materialized parameter values. The branches meet when AgateBGC is assembled.

                       ModelDefinition
        authored components / processes / parameters
                              |
                              v
                 CanonicalModelDefinition
            validated scientific semantics
                              |
                              v
                       ModelLayout
            realized entities / tracers / topology
                              |
                              v
                      ParameterPlan
          axes / labels / parameter storage plan
                       /             \
                      /               \
                     v                 v
       resolved parameter values    CompileContext
                     |                 |
                     v                 v
       runtime parameter values     FluxSpec tuple
                     |                 |
                     |                 v
                     |          static tendency IR
                     |                 |
                      \               /
                       \             /
                        v           v
                           AgateBGC

Canonicalization establishes scientific meaning. Model realization establishes named topology. Parameter planning establishes labelled storage. Runtime indices and array positions implement those named structures; they do not define scientific identity.

Components

Agate.Components.Plankton — Type

Plankton state described by intrinsic component properties.

Ecological function is supplied by process participation. states declares each prognostic state together with the conserved Element it represents, using nothing for non-elemental states. reference_state identifies the state used as the biological reference basis.

For example, states=(biomass=:carbon, chlorophyll=nothing) declares a carbon inventory named :biomass plus a non-elemental chlorophyll state. Element identity is therefore independent of state spelling and is queried centrally through state_element. Each conserved Element may currently be represented by at most one state.

source
Agate.Components.state_element — Function

Return the conserved Element represented by state, or nothing for a non-elemental state.

Element identity is the additive elemental inventory represented by the state's numerical value, not the chemical composition of the represented material. State identity and Element identity are independent: any declared state name may map explicitly to an Element Symbol.

source
Agate.Components.component_diameters — Function

Return SizeClass diameter metadata for one component.

Every PFT contributes at least one SizeClass. Implicit singleton SizeClasses have no diameter metadata; returns nothing when all classes are implicit.

source

Processes and factors

Formulations are authored as concrete scientific objects, for example Light(Smith(); driver=:PAR) and Consumption(HeterotrophicConsumption(); ...). Numerical scientific parameters belong to the model parameter system rather than the formulation object; for example NutrientLimitation(FrankTNorm(); ...) uses the Frank t-norm's declared sharpness parameter slot. FrankTNorm() names the formulation; Agate.Library.Nutrients.frank_tnorm is the numerical kernel. Parameterized nodes bind their formulation-local slots directly to model-level parameter names with bindings=(...). Omitted slots bind by the same name; a Symbol explicitly renames or shares one parameter, while a one-level qualifier map handles repeated slots such as source-specific remineralization. Formulation and factor authoring is method-based rather than registry-based. Custom process topologies can extend Agate through the narrow Processes.process_facts and Compilation.process_fluxes hooks, keeping custom topology in the same validation, canonicalization, and construction pipeline as built-in processes. Durable recipes identify a registered family and its version rather than serializing process or formulation objects.

Formulations

Agate.Processes.Geider — Type

Geider light-response formulation.

This factor regulates Growth rate using chlorophyll-to-carbon information; it does not itself synthesize a prognostic non-elemental state such as :chlorophyll.

source
Agate.Processes.PreferentialGrazing — Type

Living-prey grazing with one consumer-level ingestion capacity shared across prey.

switching_exponent=1 allocates grazing proportionally to palatable prey biomass, while larger positive integer exponents increasingly favor abundant palatable prey. palatability is a nonnegative interaction weight, not a probability.

source
Agate.Processes.HeterotrophicConsumption — Type

Heterotrophic consumption of substitutable substrates with shared consumer capacity.

maximum_rate is one per-consumer uptake capacity shared across all declared substrates. substrate_preference controls the relative accessibility of each consumer-resource pair.

source

Processes, factors, and products

Agate.Processes.Growth — Type

Plankton growth process with explicit material inputs and optional multiplicative factors.

bindings.maximum_rate names the model parameter that sets the growth-rate scale. reference_resource supplies the Element represented by the plankton reference_state. additional_resources maps additional Elements to external Pools consumed according to FixedStoichiometry. Factors modify growth rate only; independently prognostic elemental states are supplied through NutrientUptake.

source
Agate.Processes.QuotaResponse — Type

Cellular-quota response used by quota-limited growth.

variable_state identifies the internal inventory whose quota varies relative to the Growth plankton's intrinsic reference state.

source
Agate.Processes.NutrientLimitation — Type

Multi-response nutrient factor with formulation-owned response composition.

External NutrientResponse subfactors read environmental resource Pools, while internal QuotaResponse subfactors read prognostic cellular states. Each responses key is the Element identity represented by that response (for example, nitrogen=...). Both modify process rate only; material transfer is owned by the process itself, so external and internal responses may be combined within one NutrientLimitation factor.

source
Agate.Processes.NutrientUptake — Type

Independent external nutrient uptake into one plankton inventory state.

The plankton reference state scales uptake capacity but is not itself transferred. Parameter bindings are explicit because quota bounds are commonly shared with QuotaResponse.

source
Agate.Processes.Consumption — Type

Consumer-resource process with optional factors and unassimilated products.

For PreferentialGrazing, maximum_rate is one consumer-level ingestion capacity shared across all declared prey. For HeterotrophicConsumption, maximum_rate is likewise one consumer-level uptake capacity shared across substitutable substrates. When one living-prey consumption process routes multi-element unassimilated products from multiple resources, those resources currently must expose the same prognostic Element set.

source
Agate.Processes.Mortality — Type

Plankton mortality process with optional products.

When one mortality process routes multi-element products from multiple plankton, those plankton currently must expose the same prognostic Element set.

source
Agate.Processes.Products — Type

Conservative allocation of one process product flux among named destinations.

Each product destination may be either one component Symbol or a named element-to-component mapping. A multi-element mapping without FixedStoichiometry routes prognostic elemental states directly. FixedStoichiometry derives multi-element products from a one-element source; every product then declares the same elements and includes the stoichiometric reference element.

For N products, specify N - 1 named fractions. The omitted product receives the exact conservative remainder 1 - sum(supplied fractions). This removes one redundant routing degree of freedom while preserving exact closure by construction. A single product requires no fractions.

source
Agate.Processes.FixedStoichiometry — Type

Fixed conversion from one reference element to process target elements.

Each bound ratio is the amount of its target element per unit reference element.

source

Parameter definitions

The keyed parameter block separates runtime process parameters from construction-only inputs. Scientific slots and realized process applicability determine Parameter vector or matrix storage automatically, so runtime parameters never restate axes. ConstructionParameter values exist only during construction to feed DerivedDefault calculations; shaped construction parameters use the global axes=:plankton construction domain. Scientific slot-to-parameter relationships are authored beside the process or factor through bindings=.

Agate.Parameters.Parameter — Type

A runtime model parameter whose storage is determined by scientific process slots.

The stable parameter name is the key in the enclosing parameters NamedTuple. Scalar, vector, and matrix storage are inferred from the slots that bind the parameter and their realized process applicability; process slots therefore determine the storage axes.

source
Agate.Parameters.ConstructionParameter — Type

A construction-only parameter used to derive one or more runtime parameters.

ConstructionParameter values are materialized during setup but are not stored in the runtime biogeochemistry. Shaped construction parameters use axes=:plankton; omitting axes defines a scalar construction parameter.

source
Agate.Parameters.AbstractDefaultProvider — Type

Abstract supertype for construction-time default providers.

Default providers are evaluated on the host during model construction. They must produce concrete numeric values (scalars, vectors, matrices) that can later be moved to a GPU architecture via Adapt.

source
Agate.Parameters.DerivedDefault — Type

Derive a parameter default from other resolved parameters during construction.

deriver is a setup-time strategy object. Custom derivers implement derive_default; built-in context-sensitive providers may also use realized parameter metadata. deps names ordinary runtime parameters and/or construction-only ConstructionParameter values available to the derivation. Derived defaults are evaluated once after direct defaults and explicit overrides are materialized.

source
Agate.Parameters.derive_default — Function

Compute a value for a DerivedDefault provider.

Concrete derivers receive the owning model source, construction context, and a NamedTuple containing exactly the dependencies declared by deps. The owner is a registered model family for named models and the authored ModelDefinition for direct construction. Derivation runs on the host during model construction.

source
Agate.Parameters.NoDefault — Type

Indicates that a parameter has no default value.

The parameter must be supplied by an override before construction can complete.

source

Custom process and factor extension

Custom process implementations attach setup-validated semantic facts with Processes.process_facts and lower a CanonicalProcess with Compilation.process_fluxes using the shared CompileContext. Parameterized custom processes obtain process-owned operands through Compilation.process_parameter_operands. Custom factors declare ordered inputs with Processes.factor_inputs, optional child factors and parameter slots, and evaluate that semantic operand order through Processes.factor_value; Processes.factor_applicable may restrict which processes accept the factor. Extension hooks are called through their fully-qualified module names.

Agate.Processes.CanonicalProcess — Type

Validated process instance in canonical model state.

semantic_facts contains setup-only scientific decisions that compilation may trust. binding_refs contains dense references into the canonical model's ordered parameter-binding tuple, arranged alongside the process/factor/product structure so lowering never reconstructs scientific paths.

source
Agate.Processes.ParameterSlot — Type

Formulation-local declaration of one semantic parameter slot.

Dimensionality is structural: zero, one, or two declared axes imply scalar, vector, or matrix values respectively. qualify identifies repeated semantic instances without changing storage dimensionality. domain owns the formulation's numeric validity contract. For a scalar slot, a qualifier that is also a process participant role provides ecological applicability without becoming a storage axis.

source
Agate.Processes.process_facts — Function

Attach setup-validated semantic facts to a process before compilation.

Custom process implementations may extend this hook when lowering needs setup-resolved facts beyond the authored process object.

source
Agate.Processes.FactorPlanktonState — Type

Setup-only read of one prognostic state from the factor's current logical plankton.

reference.plankton must match the logical plankton at the realized :plankton axis position.

source
Agate.Processes.factor_value — Function

Evaluate a factor from its authoritative semantic operand order.

Compiled factor lowering assembles operands to this contract; direct/compiled parity tests cover every built-in factor formulation.

source
Agate.Compilation.process_fluxes — Function

Lower one canonical process to generic fluxes.

Custom process implementations may extend this hook through CanonicalProcess{Process} for a concrete process type.

source

Derive biomass-gain and resource-loss fluxes for factorized growth.

source
Agate.Compilation.process_parameter_operands — Function

Return compiled operands for the unqualified process-owned parameter slots of a custom process.

This is the narrow parameterized-process extension seam: custom lowering receives semantic slot names mapped directly to static operands without depending on canonical binding references.

source

Named families, recipes, and replay

Named model families add stable code identity and durable recipe replay around the same definition-driven process compiler. ModelRecipe is the agate.model_recipe.v1 family/version/realization document: it records the registered family, exact definition_version, canonical plankton/size realization, parameter overrides, sinking choices, and bottom state. Named scientific mappings are serialized as mappings, so key insertion order does not change recipe equality or the scientific content hash. The loaded family supplies the canonical component/process definition on replay. ModelManifest records the resolved execution state.

External family packages subtype AbstractModelFamily, provide default_components, default_processes, definition_version, and parameter_definitions, and register durable recipe identity through family_id and registered_family. Their user-facing constructors translate family-specific keywords into the nested plankton_pfts mapping and parameter overrides, then call Construction.construct(family; ...). normalize_pft_size_structure provides the shared named-family (n=0,) shorthand without weakening core size validation. Recipes are captured with capture_model_recipe, the durable schema identifier is available through recipe_schema, and replay uses construct(recipe) or construct_plus_manifest(recipe).

Agate.Construction.ModelRecipe — Type

Versioned registered-family recipe captured before runtime realization.

ModelRecipe stores only the registered family identity, its exact scientific definition_version, and canonical construction inputs. ==, isequal, hash, and content hashing share that scientific identity; named mapping insertion order is ignored. Components, processes, parameter definitions, runtime precision, host fields, and compiled equations are supplied by the loaded family implementation on replay.

source
Agate.Construction.ModelManifest — Type

Resolved deterministic scientific state produced by model construction.

ModelManifest records the fully materialized parameters, realized PFT entities and tracer ordering, interaction sources, sinking configuration, and scalar type. Equality and hashing use this resolved scientific content; durable replay is defined by the corresponding recipe representation.

source
Agate.ModelFamilies.definition_version — Function

Scientific definition version for a named model family.

Bump this version whenever family science, defaults, derivation algorithms, or canonical definition structure changes in a way that should invalidate durable recipe replay.

source
Agate.ModelFamilies.default_components — Function

Canonical logical components for a named model family.

Returns a named collection whose keys are stable model component identities and whose values describe intrinsic component structure.

source

Canonical logical components for NiPiZD.

source
Agate.ModelFamilies.default_processes — Function

Canonical named scientific processes for a named model family.

The keys are stable process-instance identities. Process declarations describe scientific topology and are canonicalized before runtime realization.

source

Canonical named scientific processes for NiPiZD.

source

Introspection

Agate.Introspection.model_summary — Function
model_summary(bgc) -> NamedTuple

Return a compact summary of a constructed biogeochemistry instance.

The returned NamedTuple contains:

  • tracers::Vector{Symbol}
  • auxiliary_fields::Vector{Symbol}
  • parameters::Vector{Symbol}
  • has_sinking_velocities::Bool
source
Agate.Introspection.describe — Function
describe([io], bgc; verbose=false)

Print a human-readable summary of bgc.

Set verbose=true to print full tracer / parameter lists.

source
Agate.Introspection.tracer_names — Function
tracer_names(bgc) -> Vector{Symbol}

Return the ordered tracer symbols required by bgc.

This helper is intended for interactive inspection, so it materializes the underlying tracer-name tuple as a Vector{Symbol}.

The ordering matches Oceananigans / OceanBioME state-vector conventions.

source
Agate.Introspection.auxiliary_field_names — Function
auxiliary_field_names(bgc) -> Vector{Symbol}

Return the ordered auxiliary field symbols required by bgc.

Auxiliary fields are non-tracer state fields (for example, light or temperature) that appear in tracer tendencies.

source
Agate.Introspection.parameter_names — Function
parameter_names(bgc) -> Vector{Symbol}

Return the parameter keys available on bgc.parameters.

This list describes the resolved parameter fields available on the constructed biogeochemistry instance.

source
Agate.Introspection.pfts — Function
pfts(bgc) -> NamedTuple

Return a NamedTuple mapping plankton PFT symbols to realized SizeClass symbols. Every PFT has at least one SizeClass: without explicit size structure it has one implicit class named by the PFT; explicit structures use <pft>_<index>. Each class appears once independent of prognostic-state multiplicity. PFT order follows the realized model layout.

source
Agate.Introspection.plankton_diameters — Function
plankton_diameters(bgc) -> Vector

Return diameter metadata for realized plankton SizeClasses. The ordering follows the flattened values of pfts(bgc), with one entry per SizeClass even when it carries multiple prognostic state tracers. Explicit SizeClasses return their equivalent spherical diameter; implicit singleton SizeClasses return nothing. Models without plankton return an empty vector.

source
Agate.Introspection.tracer_groups — Function
tracer_groups(bgc) -> NamedTuple

Return a structural grouping summary of the constructed tracer layout. entities_by_pft contains realized SizeClass identities; plankton contains physical plankton tracers.

source
Agate.Introspection.interaction_matrix — Function
interaction_matrix(bgc, parameter::Symbol) -> NamedTuple

Return a consumer-by-resource parameter matrix with realized entity labels.

parameter is the canonical model parameter identity, for example :palatability_matrix or :assimilation_matrix. Each matrix uses the axes and labels of that parameter rather than one model-global interaction topology. The returned NamedTuple contains parameter, matrix, rows, columns, edges, row_axis, and column_axis. edges contains only modeled interactions; the dense matrix may include additional storage cells.

source

Interaction matrix introspection

using Agate
using Agate.Introspection

bgc = Agate.Models.NiPiZD.construct()
pal = interaction_matrix(bgc, :palatability_matrix)

pal.rows
pal.columns
pal.matrix