API Reference
This page provides a comprehensive reference for all exported types and functions in PDEBase.jl.
PDEBase.AbstractEquationSystemDiscretization — Type
AbstractEquationSystemDiscretization <: AbstractDiscretizationSupertype for discretizations that lower a PDESystem into an equation-based SciML system, typically an ODESystem or DAESystem.
Discretizer packages subtype this type and implement the developer extension hooks documented in the Developer Extension API.
PDEBase.AbstractOptimizationSystemDiscretization — Type
AbstractOptimizationSystemDiscretization <: AbstractDiscretizationSupertype for discretizations that lower a PDESystem into an optimization system.
Use this type when the generated system is consumed by an optimization problem rather than by an ODE or DAE solver.
PDEBase.AbstractDiscreteSpace — Type
AbstractDiscreteSpaceSupertype for discretized spatial domain representations produced from a PDESystem and a discretization.
Concrete spaces are returned by construct_discrete_space and are passed to the remaining discretization hooks.
PDEBase.AbstractCartesianDiscreteSpace — Type
AbstractCartesianDiscreteSpace <: AbstractDiscreteSpaceSupertype for discrete space representations whose coordinates form a Cartesian product grid.
Subtype this type when x2i and Cartesian indexing describe the spatial coordinates without a general mesh connectivity object.
PDEBase.AbstractVarEqMapping — Type
AbstractVarEqMappingSupertype for mappings that assign dependent variables and boundary conditions to the equations used to discretize them.
Concrete mappings are returned by construct_var_equation_mapping; their get_eqvar method must identify the discrete variable for every PDE.
PDEBase.AbstractDifferentialDiscretizer — Type
AbstractDifferentialDiscretizerSupertype for objects that hold the data needed to discretize differential operators on a discrete space.
Concrete derivative data is returned by construct_differential_discretizer and consumed by discretize_equation!.
PDEBase.AbstractDiscretizationState — Type
AbstractDiscretizationStateSupertype for mutable state accumulated while PDE equations and boundary conditions are discretized.
Concrete state is returned by construct_disc_state and is updated in place by discretize_equation! before generate_system consumes it.
PDEBase.AbstractBoundary — Type
AbstractBoundaryAbstract base type for all boundary condition representations.
PDEBase.AbstractTruncatingBoundary — Type
AbstractTruncatingBoundary <: AbstractBoundaryAbstract type for boundary conditions at domain boundaries that truncate the domain.
PDEBase.AbstractInterfaceBoundary — Type
AbstractInterfaceBoundary <: AbstractTruncatingBoundaryAbstract type for boundary conditions at interfaces between different regions or subdomains.
PDEBase.LowerBoundary — Type
LowerBoundary <: AbstractTruncatingBoundaryRepresents a boundary condition at the lower boundary of a domain.
The public fields describe the boundary after PDEBase has matched the input condition to a dependent variable and spatial coordinate. Construct instances through LowerBoundary(u, t, x, order, eq, v) while parsing a PDESystem.
Fields
u: The dependent variablex: The independent variable at this boundarydepvars: All dependent variables involved in the boundary conditionindvars: All independent variables involved in the boundary conditioneq: The boundary condition equationorder: The order of the derivative in the boundary condition
Arguments
u: The dependent-variable expression at the boundary.t: The time variable, ornothingfor a steady-state system.x: The independent variable whose lower endpoint is represented.order: The derivative order associated with the boundary condition.eq: The symbolic boundary equation.v::VariableMap: The variable map used to reconstruct dependent variables.
Returns
LowerBoundary: A normalized boundary representation.
Examples
boundary = LowerBoundary(u(t, 0), t, x, 0, u(t, 0) ~ 0, v)
boundary.x == xPDEBase.UpperBoundary — Type
UpperBoundary <: AbstractTruncatingBoundaryRepresents a boundary condition at the upper boundary of a domain.
Construct instances through UpperBoundary(u, t, x, order, eq, v) while parsing a PDESystem.
Fields
u: The dependent variablex: The independent variable at this boundarydepvars: All dependent variables involved in the boundary conditionindvars: All independent variables involved in the boundary conditioneq: The boundary condition equationorder: The order of the derivative in the boundary condition
Arguments
u: The dependent-variable expression at the boundary.t: The time variable, ornothingfor a steady-state system.x: The independent variable whose upper endpoint is represented.order: The derivative order associated with the boundary condition.eq: The symbolic boundary equation.v::VariableMap: The variable map used to reconstruct dependent variables.
Returns
UpperBoundary: A normalized boundary representation.
Examples
boundary = UpperBoundary(u(t, 1), t, x, 0, u(t, 1) ~ 0, v)
boundary.x == xPDEBase.InterfaceBoundary — Type
InterfaceBoundary{IsUpper_u, IsUpper_u2} <: AbstractInterfaceBoundaryRepresents a boundary condition at an interface between two regions or subdomains.
Use the ordinary five-field constructor after the two sides have been classified. The type parameters record whether each side is at its upper endpoint; they are Val types so dispatch can use the orientation.
Type Parameters
IsUpper_u:Val{true}if the first variable is at the upper boundary,Val{false}otherwiseIsUpper_u2:Val{true}if the second variable is at the upper boundary,Val{false}otherwise
Fields
u: The first dependent variable at the interfaceu2: The second dependent variable at the interfacex: The independent variable for the first variablex2: The independent variable for the second variableeq: The interface boundary condition equation
Note
It is assumed that the variables in an interface boundary condition have the same argument signature, differing in only one variable which defines the interface. This assumption is not validated but will cause errors if violated.
Arguments
u,u2: Dependent-variable expressions on the two sides.x,x2: The interface coordinates on the two sides.eq: The symbolic interface equation.
Returns
InterfaceBoundary: An orientation-aware interface condition.
Examples
boundary = InterfaceBoundary{Val(true), Val(false)}(u, u2, x, x2, u ~ u2)
isinterface(boundary) == Val(true)PDEBase.HigherOrderInterfaceBoundary — Type
HigherOrderInterfaceBoundary <: AbstractInterfaceBoundaryRepresents a higher-order boundary condition at an interface between regions.
Higher-order interface boundary conditions involve derivatives and are handled differently from simple interface conditions. These are typically flux conditions or derivative matching conditions at interfaces.
Construct instances through HigherOrderInterfaceBoundary(u, u2, x, x2, t, order, eq, v) so the dependent and independent variable fields are normalized from eq.
Fields
u: The first dependent variable at the interfaceu2: The second dependent variable at the interfacex: The independent variable for the first variablex2: The independent variable for the second variabledepvars: All dependent variables involved in the boundary conditionindvars: All independent variables involved in the boundary conditioneq: The interface boundary condition equationorder: The maximum order of derivatives in the boundary condition
Arguments
u,u2: Dependent-variable expressions on the two sides.x,x2: The interface coordinates on the two sides.t: The time variable, ornothingfor a steady-state system.order: The maximum derivative order represented byeq.eq: The symbolic interface equation.v::VariableMap: The variable map used to reconstruct dependent variables.
Returns
HigherOrderInterfaceBoundary: A normalized higher-order interface.
PDEBase.VariableMap — Type
VariableMapA container that maps dependent and independent variables from a PDESystem along with their properties.
VariableMap is created during SciMLBase.symbolic_discretize and is passed to discretizer hooks. VariableMap(pdesys) is useful when a package needs to inspect the symbolic variables without selecting a discretization.
Fields
ū: Collection of all dependent variables (filtered to exclude boundary values)x̄: Collection of spatial independent variables (excludes time)ps: Parameters of the systemtime: The time variable (if the system is time-dependent)intervals: Dictionary mapping each independent variable to its domain bounds (min, max)args: Dictionary mapping each dependent variable operation to its argumentsdepvar_ops: Operations (function symbols) of the dependent variablesx2i: Dictionary mapping independent variables to their dimension indicesi2x: Dictionary mapping dimension indices to independent variablesreplaced_vars: Dictionary of variable substitutions/replacements
Constructors
VariableMap(pdesys): Build a map without a discretization.VariableMap(pdesys, disc; replaced_vars = Dict()): Build a map fordisc.
Returns
VariableMap: The normalized variable and domain information used by PDEBase.
Examples
v = VariableMap(pdesys)
depvars(v)
indvars(v)PDEBase.PeriodicMap — Type
PeriodicMap{hasperiodic}A structure that tracks periodic boundary conditions for variables in a PDE system.
Type Parameters
hasperiodic: AValtype parameter indicating whether any periodic conditions exist
Fields
map: A nested dictionary structure mapping dependent variable operations to their independent variables and whether each boundary is periodic
Arguments
hasperiodic: AValtype parameter indicating whether the map contains a periodic pair.map: A nested dictionary from dependent-variable operations to independent variables andValperiodicity markers.
Constructor
PeriodicMap(bmap, v::VariableMap): Build the map from a parsed boundary map and variable map.
Constructs a PeriodicMap from a boundary map and variable map, automatically detecting which boundaries have periodic conditions.
Returns
PeriodicMap{Val{true}}orPeriodicMap{Val{false}}, depending on the map.
Examples
periodic = PeriodicMap(boundarymap, v)
periodic.mapPDEBase.count_differentials — Function
count_differentials(term, x)Counts the number of Differential operators with respect to variable x in a term. This is used to determine the order of a PDE.
Arguments
term: A symbolic expression to analyzex: The symbolic variable to count differentials for
Returns
The total count of differential operators with respect to x in the term.
PDEBase.differential_order — Function
differential_order(eq, x)Returns a set of all differential orders present in the equation with respect to variable x.
Arguments
eq: A symbolic equation or expression to analyzex: The symbolic variable to compute differential orders for
Returns
A set of integers representing all differential orders found in the equation (excluding zero).
Examples
differential_order(Dx(Dx(u)) ~ 0, x) == Set([2])PDEBase.has_derivatives — Function
has_derivatives(term)Determines whether a term contains any Differential operators.
Arguments
term: A symbolic expression to check
Returns
true if the term contains any derivatives, false otherwise.
PDEBase.find_derivative — Function
find_derivative(term, depvar_op)Finds the first Differential operator or dependent variable matching depvar_op within a term.
Arguments
term: A symbolic expression to searchdepvar_op: The operation (function symbol) of the dependent variable to find
Returns
The first matching derivative or dependent variable found, or nothing if none exists.
Examples
find_derivative(Dx(u) + 1, operation(u)) == Dx(u)PDEBase.d_orders — Function
d_orders(x, pdeeqs)Return derivative orders with respect to independent variable x that appear in the PDE equations or boundary conditions pdeeqs.
Arguments
x: The independent variable to inspect.pdeeqs: An iterable ofEquationorPairvalues.
Returns
- A descending vector of unique derivative orders.
Examples
d_orders(x, [Dx(Dx(u)) ~ 0]) == [2]PDEBase.subs_alleqs! — Function
subs_alleqs!(eqs, bcs, rules)Applies substitution rules to all equations and boundary conditions in place.
Arguments
eqs: Vector of equations to modifybcs: Vector of boundary conditions to modifyrules: Substitution rules to apply
Returns
eqs: The mutated equation vector.
Examples
eqs = [u ~ x]
subs_alleqs!(eqs, [x => 1])PDEBase.get_depvars — Function
get_depvars(eq, depvar_ops)Finds all dependent variables matching the given operations in an expression.
Arguments
eq: A symbolic expression to searchdepvar_ops: Collection of dependent variable operations to match
Returns
A set of all dependent variables found in the expression that match the given operations.
Examples
get_depvars(Dx(u) ~ u, [operation(u)])PDEBase.getvars — Function
getvars(b::AbstractBoundary)Return the dependent variable and independent boundary variable represented by boundary object b.
Arguments
b::AbstractBoundary: A lower, upper, or interface boundary.
Returns
Tuple:(b.u, b.x).
Examples
u_at_boundary, x = getvars(boundary)PDEBase.pde_substitute — Function
pde_substitute(expr, dict)Custom substitute function for PDE discretization that properly handles Differential operators. In Symbolics v7, Differential(constant) throws an error, and the standard SymbolicUtils Substituter doesn't respect filter functions when processing Differential operators.
This implementation manually traverses the expression tree and:
- Substitutes variables according to the dict
- Does NOT substitute inside
Differential(x)operators (the differential variable stays symbolic) - DOES substitute inside the arguments of derivative calls like
Dx(u(t,x))
This allows expressions like Dx(u(t, boundary_value)) to work correctly.
Arguments
expr: The symbolic expression to transform.dict: An iterable of substitution pairs.
Returns
- A symbolic expression with the requested substitutions applied.
Examples
pde_substitute(u(t, x), Dict(x => 0))PDEBase.get_all_depvars — Function
get_all_depvars(pdeeqs, depvar_ops)
get_all_depvars(pdesys::PDESystem, depvar_ops)Return all dependent variables with operations in depvar_ops that appear in the equations or boundary conditions.
Arguments
pdeeqsorpdesys::PDESystem: Equations, or a PDE system containing them.depvar_ops: Operations identifying dependent variables.
Returns
- A vector of matching dependent-variable expressions.
PDEBase.split_terms — Function
split_terms(eq)
split_terms(eq, x̄)Split an equation or boundary condition into symbolic terms used by PDE discretization rules.
Arguments
eq: AnEquationor initial-conditionPair.x̄: Optional spatial-variable collection used by the derivative-aware method.
Returns
- A vector of symbolic terms extracted from both sides of
eq.
Examples
split_terms(u + Dx(u) ~ 0)PDEBase.split_additive_terms — Function
split_additive_terms(eq)Return the left- and right-hand additive terms of equation eq.
Arguments
eq: A symbolic equation withlhsandrhsfields.
Returns
- A vector containing additive terms from the left-hand side followed by additive terms from the right-hand side.
Examples
split_additive_terms(u + x ~ 2u) == [u, x, 2u]PDEBase.subsmatch — Function
subsmatch(expr, rule)Return true when rule.first appears anywhere in expression expr.
Arguments
expr: An equation or symbolic expression to search.rule: A pair whose first element is the expression to match.
Returns
Bool: Whether the expression occurs inexpr.
PDEBase.ex2term — Function
ex2term(x::Term) -> Symbolic
ex2term(x) -> xConvert a Term to a variable Term. Note that it only takes a Term not a Num.
Arguments
term: The symbolic term to replace.v::VariableMap: The variable map used to identify dependent variables.
Returns
- A new symbolic variable with the same argument signature as the selected dependent variable, or
termif it is not a call expression.
Examples
ex2term(Dx(u), v)PDEBase.safe_unwrap — Function
safe_unwrap(x)Return the wrapped symbolic value for Num inputs and leave all other values unchanged.
PDEBase.recursive_unwrap — Function
recursive_unwrap(ex)Recursively unwrap Num values inside a symbolic expression.
Arguments
ex: A symbolic expression, possibly containing nestedNumwrappers.
Returns
- The expression with wrappers removed recursively.
Examples
recursive_unwrap(u(x))PDEBase.flatten_vardict — Function
flatten_vardict(bmps)Flatten a nested boundary map into a vector of boundary objects.
Arguments
bmps: A nested boundary map indexed by dependent variable and independent variable.
Returns
Vector: All boundary objects in the map, preserving map traversal order.
Examples
boundaries = flatten_vardict(boundarymap)PDEBase.filter_interfaces — Function
filter_interfaces(bs)Return the interface boundaries contained in the collection bs.
Arguments
bs: An iterable of boundary representations.
Returns
- A vector containing only
InterfaceBoundaryvalues.
PDEBase.isperiodic — Function
isperiodic(b1::InterfaceBoundary, b2::InterfaceBoundary)Return true when interface boundaries b1 and b2 form matching periodic boundary conditions.
Arguments
b1,b2: Interface boundaries to compare.
Returns
Bool: Whether the variable operations and interface coordinates are paired.
PDEBase.isinterface — Function
isinterface(b)Return Val(true) when b is an InterfaceBoundary, otherwise Val(false).
Arguments
b: A boundary representation.
Returns
Val{true}forInterfaceBoundaryandVal{false}otherwise.
PDEBase.haslowerupper — Function
haslowerupper(bs, x)Return booleans indicating whether interface boundaries in bs include lower and upper boundaries for independent variable x.
Arguments
bs: An iterable of boundary representations.x: The independent variable to inspect.
Returns
Tuple{Bool, Bool}:(has_lower, has_upper).
PDEBase.has_interfaces — Function
has_interfaces(bmps)Return true when a nested boundary map contains at least one InterfaceBoundary.
Arguments
bmps: A nested boundary map indexed by dependent variable and independent variable.
Returns
Bool: Whether at least one interface boundary is present.
PDEBase.isupper — Function
isupper(b)Return true when boundary object b corresponds to the upper side of a domain or interface.
Arguments
b: A boundary representation.
Returns
Bool: Whetherbis oriented to the upper side.
PDEBase.ivs — Function
ivs(u, v::VariableMap)Return the independent variables of dependent variable u, excluding the time variable stored in v.
PDEBase.all_ivs — Function
all_ivs(v::VariableMap)
all_ivs(u, v::VariableMap)Return all independent variables tracked by v, including time when present. With a dependent variable u, return the full argument list for u.
PDEBase.depvar — Function
depvar(u, v::VariableMap)Reconstruct dependent variable u with the argument ordering stored in v.
PDEBase.depvars — Function
depvars(v::VariableMap)Return the dependent variables tracked by v.
PDEBase.indvars — Function
indvars(v::VariableMap)Return the spatial independent variables tracked by v, excluding time.
PDEBase.replaced_vars — Function
replaced_vars(v::VariableMap)Return the variable replacements made while normalizing array-valued dependent variables. The dictionary maps each flattened scalar variable to its original indexed variable, allowing discretizers to translate solution queries between the normalized and user-facing forms. The map is empty when no array-valued dependent variables are present.
PDEBase.x2i — Function
x2i(v::VariableMap, u, x)Return the spatial dimension index of independent variable x in the arguments of dependent variable u.
Abstract Types
Discretization Types
AbstractEquationSystemDiscretization <: AbstractDiscretization
Base type for discretizations that produce systems of ODEs or DAEs.
AbstractOptimizationSystemDiscretization <: AbstractDiscretization
Base type for discretizations targeting optimization problems.
Space Types
AbstractDiscreteSpace
Base type for discrete spatial representations.
AbstractCartesianDiscreteSpace <: AbstractDiscreteSpace
Specialized type for Cartesian grid discretizations.
Auxiliary Types
AbstractVarEqMapping
Abstract type for mappings from variables to the equations they are solved from.
AbstractDifferentialDiscretizer
Abstract type for objects that discretize differential operators.
AbstractDiscretizationState
Abstract type for mutable state containers used during discretization.
Boundary Condition Types
AbstractBoundary
Root abstract type for all boundary conditions.
AbstractTruncatingBoundary <: AbstractBoundary
Abstract type for boundaries at domain edges.
AbstractInterfaceBoundary <: AbstractTruncatingBoundary
Abstract type for interface boundaries between regions.
LowerBoundary <: AbstractTruncatingBoundary
Boundary condition at the lower edge of a spatial domain. Fields:
u- Dependent variablex- Independent variable (spatial dimension)depvars- All dependent variables in the BCindvars- Independent variables in the BCeq- The boundary condition equationorder- Derivative order
UpperBoundary <: AbstractTruncatingBoundary
Boundary condition at the upper edge of a spatial domain. Same fields as LowerBoundary.
InterfaceBoundary{IsUpper_u, IsUpper_u2} <: AbstractInterfaceBoundary
Interface condition connecting two regions at zero-th order. Fields:
u,u2- The two variablesx,x2- Interface coordinateseq- Interface equation
HigherOrderInterfaceBoundary <: AbstractInterfaceBoundary
Interface condition with derivatives (e.g., flux continuity). Additional fields include depvars, indvars, and order.
Concrete Types
VariableMap
Central data structure storing information about PDESystem variables. See VariableMap for details.
Fields:
ū- Dependent variablesx̄- Independent spatial variablesps- Parameterstime- Time variableintervals- Domain intervalsargs- Argument signaturesdepvar_ops- Dependent variable operationsx2i,i2x- Index mappingsreplaced_vars- Variables replaced during preprocessing
PeriodicMap
Tracks which variables have periodic boundary conditions.
Interface Functions
For detailed documentation of interface functions, see Developer Extension API.
Summary
| Function | Purpose |
|---|---|
interface_errors | Check PDESystem compatibility |
check_boundarymap | Validate boundary conditions |
should_transform | Determine if system needs transformation |
transform_pde_system! | Transform PDESystem |
construct_disc_state | Create discretization state container |
construct_discrete_space | Build discrete grid and variables |
construct_var_equation_mapping | Map variables to equations |
construct_differential_discretizer | Prepare derivative approximations |
discretize_equation! | Convert PDE to discrete equations |
generate_ic_defaults | Create initial conditions |
generate_metadata | Build discretization metadata |
generate_system | Create final symbolic system |
get_time | Get time variable |
get_discvars | Get discrete variables |
get_system_unknowns | Get the unknowns of the generated system |
get_eqvar | Get equation variable |
add_metadata! | Add to metadata |
VariableMap Accessor Functions
| Function | Purpose |
|---|---|
depvars(v) | Get all dependent variables |
indvars(v) | Get spatial independent variables |
all_ivs(v) | Get all independent variables |
ivs(u, v) | Get independent variables for a dependent variable |
depvar(u, v) | Get full dependent variable expression |
x2i(v, u, x) | Get index of spatial variable |
Boundary Utility Functions
| Function | Purpose |
|---|---|
isupper(b) | Check if upper boundary |
isinterface(b) | Check if interface boundary |
isperiodic(b1, b2) | Check if periodic pair |
filter_interfaces(bs) | Get interface boundaries |
haslowerupper(bs, x) | Check for lower/upper boundaries |
has_interfaces(bmps) | Check for interfaces in boundary map |
getvars(b) | Get boundary variables |
flatten_vardict(bmps) | Flatten boundary map |
Symbolic Utility Functions
Differential Analysis
| Function | Purpose |
|---|---|
count_differentials(term, x) | Count derivatives w.r.t. variable |
differential_order(eq, x) | Get derivative orders in equation |
has_derivatives(term) | Check for derivatives |
find_derivative(term, op) | Find derivative in expression |
d_orders(x, eqs) | Get derivative orders across equations |
Expression Manipulation
| Function | Purpose |
|---|---|
get_depvars(eq, ops) | Find dependent variables |
get_all_depvars(eqs, ops) | Find all dependent variables |
split_terms(eq) | Split equation into terms |
split_additive_terms(eq) | Split by addition |
subs_alleqs!(eqs, rules) | Substitute in all equations |
subsmatch(expr, rule) | Check if rule matches |
ex2term(term, v) | Convert to term variable |
safe_unwrap(x) | Unwrap Num types |
recursive_unwrap(ex) | Recursively unwrap |