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.constructFunction
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 size structures are realized from the definition, 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.PlanktonType

Plankton state described by intrinsic component properties.

Ecological function is supplied by process participation. states names every prognostic state carried by the plankton, while reference_state identifies the state used as its biological reference basis. Elemental bookkeeping is inferred centrally by state_element; non-elemental states such as :chlorophyll return nothing.

source
Agate.Components.state_elementFunction

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. Canonical elemental state names map to themselves; other states remain non-elemental until an explicit mapping API is introduced.

source
Agate.Components.component_diametersFunction

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

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

Living-prey grazing formulation with pairwise consumer-resource capacity.

maximum_rate is a per-consumer rate applied independently to each declared prey edge, so each edge receives the full per-consumer rate.

source
Agate.Processes.HeterotrophicConsumptionType

Heterotrophic resource-consumption formulation with pairwise consumer-resource capacity.

maximum_rate is a per-consumer rate applied independently to each declared resource edge, so each edge receives the full per-consumer rate.

source

Processes, factors, and products

Agate.Processes.GrowthType

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

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

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

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

Consumer-resource process with optional factors and unassimilated products.

The formulation maximum_rate is pairwise capacity: one consumer's rate is applied independently to each declared consumer-resource edge. 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.MortalityType

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

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 either N - 1 named fractions or all N fractions. When one fraction is omitted, that product receives the exact conservative remainder 1 - sum(supplied fractions). When all fractions are supplied, every authored value is used directly and setup requires their sum to equal one within floating-point tolerance. A single product requires no fractions.

source
Agate.Processes.FixedStoichiometryType

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

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

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

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

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_defaultFunction

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

Indicates that a parameter has no default value.

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

source

Custom process 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 can obtain their process-owned compiled parameter operands through Compilation.process_parameter_operands, keeping dense binding references and canonicalization representation details internal to setup.

Agate.Processes.CanonicalProcessType

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

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

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.Compilation.process_fluxesFunction

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_operandsFunction

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

Versioned registered-family recipe captured before runtime realization.

ModelRecipe stores only the registered family identity, its exact scientific definition_version, and canonical construction inputs. Named mapping insertion order is not part of recipe identity. Components, processes, parameter definitions, runtime precision, host fields, and compiled equations are supplied by the loaded family implementation on replay.

source
Agate.Construction.ModelManifestType

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. It is an in-memory record of the constructed model state; durable replay is defined by the corresponding recipe representation.

source
Agate.ModelFamilies.definition_versionFunction

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_componentsFunction

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_processesFunction

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_summaryFunction
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.describeFunction
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_namesFunction
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_namesFunction
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_namesFunction
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.pftsFunction
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_diametersFunction
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.interaction_matrixFunction
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, row_axis, and column_axis.

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