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.

site

Stable type · Differentiate a model

Tier: stable · Kind: type · Topic: Differentiate a model

JuliaPythonRust
SiteSiteSite

Julia

struct Site
Site(expr::EarthSciAST.ASTExpr, key::String, name::String, rank::Int64)
Site(expr, key, name, rank)
Site(e::EarthSciAST.ASTExpr)
Site(expr)

The thing a scalar derivative is taken with respect to: a bare VarExpr (scalar variable) or an index(v, i…) node (one symbolic cell of an array variable). Two nodes denote the same site iff their canonical JSON agrees — d/d(u[i+1,j]) treats index(u, +(i,1), j) and index(u, +(1,i), j) as the same site because canonicalization sorts commutative arguments.

name/rank are a PREFILTER cached off expr, not extra identity: the site reads variable name at rank subscripts (rank == -1 for a bare VarExpr, -2 for a shape this fast path does not describe, which then falls back to the plain key compare). See is_site for why.

Source

Python

class Site
Site(expr: Expr, key: str)
@staticmethod Site.of(e: Expr) -> Site

A bare variable reference or one symbolic index(v, i…) cell.

Source

Rust

pub struct Site {
    pub expr: Expr,
    pub key: String,
}

impl Site { pub fn of(e: &Expr) -> Site }

A bare variable reference or one symbolic index(v, i…) cell.

Source · Rust docs