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=(;), setting_overrides=(;),
          sinking_tracers=nothing, open_bottom=true, grid=nothing,
          arch=nothing, scalar_type=nothing) -> bgc

Construct a 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, process parameter overrides, and family-level setting 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 model 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 recipe using the explicitly selected model provider and family.

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.

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. composition binds implicitly represented Elements to nonnegative model parameters, measured per unit of the elemental reference state. These parameters are indexed by plankton entity (and therefore by size class when applicable).

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

Implicit composition is declared once on Plankton, e.g. composition=(nitrogen=:nitrogen_to_carbon,); the parameter is plankton/size-class indexed. Living-prey consumers with implicit composition assimilate conservatively when their realized ratios match every prey, including across size classes and active-parameter updates. Material-pool consumers currently use explicit elemental inventories. For inference, matching ratios must be derived from a shared fitted variable: identical parameter names still have separate entity-indexed entries. Direct ODE parameter updates must preserve this equality too.

Processes and factors

Formulations are authored as concrete scientific objects, for example Light(Smith(); driver=:PAR) and Consumption(HeterotrophicConsumption(); ...). Numerical scientific parameters are defined in the model parameter system; 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. Formulations and factors are extended through Julia methods. 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.

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.Q10 — Type

Q10 temperature-response formulation.

Q10() has one scalar q10 coefficient, which may be shared across different processes. Q10(:plankton) or Q10(:consumer) instead indexes q10 by the corresponding process participant. reference_temperature is scalar in both cases.

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.LinearGrazing — Type

Linear grazing with prey consumption proportional to prey and consumer biomass.

The rate parameter is consumer-indexed and has inverse-concentration inverse-time units. palatability scales individual consumer-resource links.

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. half_saturation and substrate_preference are consumer-resource properties, allowing consumers to differ in affinity and relative accessibility for the same substrate.

source

Processes, factors, and products

Agate.Processes.Growth — Type

Plankton growth with elemental resources and optional multiplicative factors.

additional_resources supplies implicitly represented Elements declared by participating Plankton.composition mappings. Each plankton consumes only its own implicit Elements; the reference Element is supplied by reference_resource. Explicit prognostic elemental states are updated by independent processes such as NutrientUptake. Products route gross uptake before biomass retention.

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.Temperature — Type

Temperature-dependent multiplicative process-rate factor.

By default temperature is read from an external driver named :temperature. Pass component instead to read a scalar model component such as an Oceananigans temperature tracer.

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. LinearGrazing instead applies an independent linear grazing rate to each consumer-resource link. 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, its destinations cover the union of their represented Elements.

source
Agate.Processes.Mortality — Type

Plankton mortality process with optional products.

When one mortality process routes multi-element products from multiple plankton, its destinations cover the union of their represented Elements.

source
Agate.Processes.Products — Type

Conservative allocation of one process flux among named destinations.

An element-to-pool mapping routes each represented Element from a plankton component. For N products, declare N - 1 fractions; the last receives the balance.

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. Family-level scientific properties that affect the realized model but are not inputs to an individual process equation use ModelSetting instead. 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
Agate.Parameters.BroadcastConsumerAcrossResources — Type

Broadcast one consumer-indexed value across every resource for that consumer.

The single declared dependency must be a vector over realized plankton SizeClasses. The result is a consumer-by-resource matrix whose rows repeat the corresponding consumer value.

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 support recipe replay around the same definition-driven process compiler. ModelRecipe is the agate.model_recipe.v0.3 family/realization document: it records the family label, canonical plankton/size realization, process parameter overrides, model-setting overrides, sinking choices, and bottom state. Named scientific mappings are canonicalized for recipe equality and content hashing. The selected model provider supplies the canonical component/process definition and setting defaults on replay; the Julia environment identifies the exact implementation. ModelManifest records the resolved execution state, including fully resolved model settings.

External family packages subtype AbstractModelFamily, provide default_components, default_processes, and parameter_definitions, and identify their recipes with family_id. Family-level scientific properties that are not inputs to an individual process equation are declared separately with setting_definitions and ModelSetting; examples include elemental or diagnostic ratios used by an integration layer. User-facing constructors translate family-specific keywords into plankton_pfts, process parameter_overrides, and optional setting_overrides, then call Construction.construct(family; ...). normalize_pft_size_structure resolves the named-family (n=0,) shorthand before size validation. Recipes are captured with capture_model_recipe, the durable schema identifier is available through recipe_schema, and replay explicitly selects the provider through construct(family, recipe) or construct_plus_manifest(family, recipe). import_recipe(path) reads a recipe configuration for replay with the selected family.

Agate.ModelFamilies.ModelSetting — Type

A configurable scientific property of a model family.

ModelSetting stores a default value and validation domain for model-level properties that affect the realized model but are not parameters of an individual biological process, such as carbon-to-nitrogen or chlorophyll-to-nitrogen ratios.

source
Agate.Construction.ModelRecipe — Type

Canonical construction inputs for an explicitly selected model family.

ModelRecipe records the family label and canonical construction configuration. The selected provider and Julia environment determine the implementation on replay. Named mapping order is canonicalized for recipe equality and content hashing.

source
Agate.Construction.ModelManifest — Type

Resolved deterministic scientific state produced by model construction.

ModelManifest records the fully materialized process parameters and model settings, 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.Introspection.model_settings — Function
model_settings(bgc) -> NamedTuple

Return resolved model-level settings. For an NPDPlankton adapter, return the settings used by the adapter, including explicitly supplied standalone-runtime ratios.

source
Agate.Construction.encode_recipe — Function

Encode model configuration with a deterministic content hash.

The hash identifies the recorded family label and construction inputs. Reproducible execution uses the selected model provider and its resolved Julia environment.

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

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

source

OceanBioME NPD integration

Agate.Integrations.NPDPlankton adapts a compiled Agate plankton runtime to OceanBioME's NutrientsPlanktonDetritus interface. It maps Agate's living-tracer tendencies, nutrient uptake and detritus/waste exchanges onto OceanBioME's existing hooks. Its owned_components specify the living tracers contributed by Agate; nutrient_tracers and consumed_detritus identify native NPD components, and exchange_tracers names the three channels :solid, :dissolved, and :inorganic (use nothing for an unused channel). The constructor checks that all nonzero compiled tendencies have exactly one destination and that supplied settings agree with the runtime's resolved family settings. Agate nutrient tracers may be a subset of OceanBioME's native nutrients; unconfigured NO₃/NH₄ uptake is zero. Native nutrient and detritus compatibility is checked when the composed NPD model's tracer set is requested. The FrankenLOBSTER model supplies a ready-to-use example.

Agate.Integrations.NPDPlankton — Type

OceanBioME NPD plankton component backed by one compiled Agate runtime.

NPDPlankton is an integration boundary, not a biological model. The compiled Agate runtime owns the ecological equations; this wrapper maps their signed tracer tendencies onto OceanBioME's existing NPD plankton hooks. Its settings field holds the resolved Agate model settings used by the coupling.

source
Agate.Integrations.npd_configuration — Function

Return family-specific NPDPlankton keyword overrides for a realized runtime.

Ownership, phytoplankton identity, external dependencies, standard exchange channels, and resolved model settings are inferred from Agate metadata. External families only need to declare choices that cannot be inferred safely, such as nutrient uptake tracers, consumed detritus, or physical-driver dependencies. Configured dependencies are appended to the inferred tracer dependencies.

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 Onyx
using Agate.Introspection

bgc = Onyx.construct()
pal = interaction_matrix(bgc, :palatability_matrix)

pal.rows
pal.columns
pal.matrix