Project

EarthSciASTDiff

Analytical sparse Jacobians for EarthSciAST (.esm) models by symbolic differentiation of the expression AST.

Contents

This is the documentation for the older version v0.7.0. For the latest release, see v0.8.0.

hvp_document

Stable function · Evaluate the Jacobian

Tier: stable · Kind: function · Topic: Evaluate the Jacobian

JuliaPythonRust
hvp_documenthvp_documenthvp_document

Julia

hvp_document(input; stages, wrt, form, model_name, forcing, cse, cse_min_nodes, data_sources)
hvp_document(input; stages, wrt = (:states, :states), form = :contract,
             model_name = nothing, forcing = nothing, cse = true) -> (doc, io)

The second-order product document of esm-jacobian-spec.md §9.4 for the axis pair wrt and stages stage pairs: its right-hand side leaves g = ∇_{a2} Σᵢ μᵢᵀ J(u) wᵢ (∇_{a2} (Σᵢ wᵢ μᵢ)ᵀ f_t on a time pair) in the derivative slots of its outputs. io.mu[i] / io.w[i] map each state (each first-axis column variable; "t" on a time pair) to stage i’s inputs and io.hvp each second-axis column variable to its output. form = :symmetric (a (:states, :states) pair only) scatters by the first column instead (model "HvpEvalSymmetric"); both forms give the same g.

Source

Python

hvp_document(obj, stages: int, model_name: str | None = None, wrt=('states', 'states'), form: str = 'contract', forcing=None, cse: bool = True, cse_min_nodes: int = 12, data_sources=None)

The second-order product document of spec §9.4 for the axis pair wrt and stages stage pairs: its right-hand side leaves g = ∇_{a2} Σᵢ μᵢᵀ J(u) wᵢ (∇_{a2} (Σᵢ wᵢ μᵢ)ᵀ f_t on a time pair) in the derivative slots of its outputs.

Returns (doc, io): io["mu"][i] / io["w"][i] map each state (each first-axis column variable; "t" on a time pair) to stage i’s inputs and io["hvp"] each second-axis column variable to its output. form="symmetric" (a ("states", "states") pair only) scatters by the first column instead (model "HvpEvalSymmetric"); both forms give the same g.

Source

Rust

pub fn hvp_document(sv: &SysView<'_>, entries: &[JacEntry2], wrt: (Wrt, Wrt), stages: usize, form: HvpForm, opts: &ProductOptions<'_>) -> Result<(Value, HvpIo), BandError>

The second-order product document of spec §9.4 for the axis pair wrt, the second-order entries (as crate::jacobian_bands2 gives them) and stages stage pairs: its right-hand side leaves g = ∇_{a2} Σᵢ μᵢᵀ J(u) wᵢ (∇_{a2} (Σᵢ wᵢ μᵢ)ᵀ f_t on a time pair) in the derivative slots of its outputs. HvpForm::Symmetric (a (states, states) pair only) scatters by the first column instead (model "HvpEvalSymmetric"). entries and opts.forcing must agree, as for jvp_document .

Source · Rust docs