Authoring

The authoring surface is the @reaction_network DSL and the macros that populate a network with transitions, species, attributes, and the initial-state / parameter / solver metadata a run needs. A network authored here is a pure typed data artifact — no host code is captured — that is later handed to ReactionNetworkProblem for simulation.

ReactiveDynamics.ReactionNetworkType
ReactionNetwork

The static network container (ADR 0015: renamed from the ACSets-lineage ReactionNetworkSchema — it is a populated network INSTANCE, not the schema; the type-level object model is const SCHEMA). It is the inert, typed struct-of-columns store an authored model compiles to before it is handed to ReactionNetworkProblem for simulation. counts counts rows per object; columns is the NamedTuple of typed columns in ALLATTRS order; reactants is the promoted ReactantSpec incidence table (ADR 0003 Phase 2), populated lazily/on-merge (empty for a freshly-constructed or not-yet-promoted model — the runtime never reads it).

source
ReactiveDynamics.@reaction_networkMacro

Macro that takes an expression corresponding to a reaction network and outputs a ReactionNetwork (the static struct-of-columns model), ready to pass to ReactionNetworkProblem for simulation.

Most arrows accepted (both right, left, and bi-drectional arrows). Use 0 or ∅ for annihilation/creation to/from nothing.

Custom functions and sampleable objects can be used as numeric parameters. Note that these have to be accessible from ReactiveDynamics's source code.

Examples

net = @reaction_network begin
    1.0, X ⟶ Y
    1.0, X ⟶ Y, priority => 6.0, prob => 0.7, capacity => 3.0
    1.0, ∅ --> (Poisson(0.3γ)X, Poisson(0.5)Y)
    (XY > 100) && (XY -= 1)
end
@push net 1.0 X ⟶ Y
@prob_init net X = 1 Y = 2 XY = α
@prob_params net γ = 1 α = 4
source
ReactiveDynamics.@pushMacro

Add reactions to a network.

Examples

@push sir β * S * I * tdecay(@time()) S + I --> 2I name => SI2I
@push sir begin
    ν * I, I --> R, name => I2R
    γ, R --> S, name => R2S
end
source
ReactiveDynamics.@modeMacro

Set species modality.

Supported modalities

  • nonblock
  • conserved
  • rate

Examples

@mode net (r"proj\w+", r"experimental\w+") conserved
@mode net (S, I) conserved
@mode net S conserved
source
ReactiveDynamics.@akaMacro

Alias an object name in a network.

Default names

nameshort name
speciesS
transitionT
actionA
eventE
paramP
metaM

Examples

@aka net species = resource transition = reaction
source
ReactiveDynamics.@name_transitionMacro

Set name of a transition in the model.

Examples

@name_transition net 1 = "name"
@name_transition net name = "transition_name"
@name_transition net "name" = "transition_name"
source
ReactiveDynamics.@append_transitionsMacro
@append_transitions net transitions

Append a runtime-built collection of reaction lines to an existing net. transitions evaluates to a collection of strings, each one reaction line in the @reaction_network surface syntax; they are joined into a single begin…end block, parsed, and handed to @push. Use this when the set of transitions is assembled programmatically (a vector built in a loop, read from a table) rather than written literally — the literal-authoring path is @push.

Examples

lines = ["ν * I, I --> R, name => I2R", "γ, R --> S, name => R2S"]
@append_transitions net lines
source
ReactiveDynamics.@prob_metaMacro

Set model metadata (e.g. solver arguments)

Examples

@prob_meta net tspan = (0, 100.0) schedule = schedule_weighted!
@prob_meta sir tspan = 250 dt = 1   # `tstep` is a deprecated alias for `dt`
source
ReactiveDynamics.@jumpMacro

Add a jump process (with specified Poisson intensity per unit time step) to a model.

Examples

@jump net λ Z += rand(state.rng, Poisson(1.0))
source
ReactiveDynamics.@registerMacro

Register a host function/definition into ReactiveDynamics scope so model expressions may call it by name (e.g. a custom rate/guard helper). Evaluates ex at macro-expansion time — an AUTHORING-time escape hatch, distinct from the eval-free runtime; do not use it to inject per-run data.

Examples

@register bool_cond(t) = (100 < t < 200) || (400 < t < 500)
@register tdecay(t) = exp(-t / 10^3)
source

Attributes & shorthands

Common transition attributes. When set inside @reaction_network (or the update macros) they may be referred to by any of their shorthand names.

attributeshorthandinterpretation
transPriorityprioritypriority of a transition (influences resource allocation)
transProbOfSuccessprobability prob posprobability that a transition terminates successfully
transCapacitycap capacitymaximum number of concurrent instances of the transition
transCycleTimect cycletimeduration of a transition's instance (adjusted by resource allocation)
transMaxLifeTimelifetime maxlifetime maxtime timetolivemaximal duration of a transition's instance
transPostActionpostAction postaction to be executed once a transition's instance terminates
transNamename interpretationname of a transition, either a string or unquoted text

Common species attributes.

attributeshorthandinterpretation
specInitUncertaintyuncertainty stoch stochasticityuncertainty about a variable's initial state (modelled as a Gaussian standard deviation)
specInitValinitial value of a variable

Rate semantics

The "rate" term of a transition governs how many instances spawn per step. By default a bare numeric rate is a stochastic (Poisson) intensity: at each step n ~ Poisson(rate * dt) instances are spawned. To specify the rate as a cycle time instead, use @ct(cycle_time) — e.g. @ct(ex), A --> B, ..., a shorthand for 1/ex, A --> B, .... For a deterministic "rate", use @deterministic(ex), where ex evaluates to a deterministic count (floored to whole instances) spawned per integrator step. Note that a deterministic count does not scale with the step length.