API Reference
Apoblast.Param.LibraryApoblast.Param.ModelApoblast.Param.TransformationApoblast.Core.apply_transApoblast.Core.coeff_matrixApoblast.Core.collect_followerApoblast.Core.infinitesimal_trans_matrixApoblast.Core.trans_matrixApoblast.Utils.find_invalid_fieldlike_functionApoblast.Utils.listorderApoblast.Utils.safe_printApoblast.Utils.validate_terms
Public API
Apoblast.Param.Model — Type
Model struct represents a mathematical model with specified coordinates and fields. The constructor takes tuples of strings for coordinates and fields, converts them to symbolic variables and functions, and initializes the Model struct.
Parameters
coords: A tuple of symbolic variables representing the coordinates (e.g., spatial dimensions).fields: A tuple of symbolic functions representing the fields defined over the coordinates (e.g., physical quantities like velocity, pressure, etc.).
Apoblast.Param.Library — Type
Library struct represents a collection of terms (symbolic expressions) that are validated against a given Model. The constructor takes a Model instance and a tuple of symbolic expressions, validates the expressions using the Utils.validate_terms function, and initializes the Library struct.
Parameters
model: An instance of the Model struct containing defined coordinates and fields.term: A tuple of symbolic expressions that are validated to ensure they only contain symbols from the model's coordinates and fields.
Apoblast.Param.Transformation — Type
Transformation struct represents a transformation of coordinates and fields in a given Model. The constructor takes a Model instance, tuples of new coordinates and fields, optional parameters, and an optional Jacobian inverse. It creates replacement dictionaries for the coordinates and fields, computes the Jacobian inverse if not provided, and initializes the Transformation struct.
Parameters
model: An instance of the Model struct containing defined coordinates and fields.coords_replace: A tuple of symbolic variables representing the new coordinates after transformation.fields_replace: A tuple of symbolic functions representing the new fields after transformation.parameter: An optional tuple of symbolic variables representing parameters that may be involved in the transformation (default is an empty tuple).jacobian_inverse: An optional symbolic expression representing the inverse of the Jacobian matrix of the transformation. If not provided, it will be computed based on the new coordinates and the original coordinates.
Apoblast.Core.collect_follower — Function
collect_follower(model::Model, library::Library, Li::Vector{<:Sym}, f̃::Vector{<:Sym}, trans::Transformation...)Given a model, a library of terms, a set of linearly independent terms Li, a set of transformed terms f̃, and a variable number of transformations, this function collects the follower terms by applying the transformations to the basis of coefficients obtained from the coeff_basis function. The resulting follower terms are returned as a vector.
Parameters
model: An instance of the Model struct containing defined coordinates and fields.library: An instance of the Library struct containing the terms to be used in the transformations.Li: A vector of symbolic expressions representing the linearly independent terms before transformation.f̃: A vector of symbolic expressions representing the transformed terms after applying the transformations.trans: A variable number of Transformation instances representing the transformations to be applied.print_progress: A boolean indicating whether to print progress information.
Core transformations
Apoblast.Core.apply_trans — Function
apply_trans(model::Model, trans::Transformation, term::Sym)Applies the given transformation to the specified term (symbolic expression) based on the rules defined in the Transformation struct. The function handles different cases for plain function applications, coordinate replacements, field replacements, and derivatives, recursively applying the transformation as needed.
Parameters
model: An instance of the Model struct containing defined coordinates and fields.trans: An instance of the Transformation struct containing the transformation rules.term: A symbolic expression (Sym) to which the transformation will be applied.
Apoblast.Core.coeff_matrix — Function
coeff_matrix(terms_after::Vector{<:Sym}, terms_before::Vector{<:Sym})Given two lists of symbolic expressions, terms_after and terms_before, this function computes the transformation matrix T that relates the two sets of terms, as well as a coefficient matrix D for any "leak" terms that appear in terms_after but not in terms_before. The function returns the transformation matrix T, the coefficient matrix D, and a list of leak terms g.
Parameters
terms_after: A vector of symbolic expressions representing the terms after transformation.terms_before: A vector of symbolic expressions representing the terms before transformation.
Apoblast.Core.trans_matrix — Function
trans_matrix(model::Model, trans::Transformation, terms_before::Vector{<:Sym})Applies the given transformation to a list of symbolic expressions (terms) and computes the transformation matrix T, the coefficient matrix D for any leak terms, and the list of leak terms g. The function first applies the transformation to each term in terms_before to get terms_after, and then uses the coeff_matrix function to compute the matrices and leak terms.
Parameters
model: An instance of the Model struct containing defined coordinates and fields.trans: An instance of the Transformation struct containing the transformation rules.terms_before: A vector of symbolic expressions representing the terms before transformation.
Apoblast.Core.infinitesimal_trans_matrix — Function
infinitesimal_trans_matrix(model::Model, trans::Transformation, parameter::Sym, terms_before::Vector{<:Sym})Applies an infinitesimal transformation to a list of symbolic expressions (terms) and computes the transformation matrix T, the coefficient matrix D for any leak terms, and the list of leak terms g. The function first applies the transformation to each term in terms_before, differentiates the transformed terms with respect to the specified parameter, simplifies the result, and then uses the coeff_matrix function to compute the matrices and leak terms.
Parameters
model: An instance of the Model struct containing defined coordinates and fields.trans: An instance of the Transformation struct containing the transformation rules.parameter: A symbolic variable representing the parameter with respect to which the differentiation will be performed.terms_before: A vector of symbolic expressions representing the terms before transformation.
Utilities
Apoblast.Utils.validate_terms — Function
validate_terms(model, terms)Validates that the given terms only contain symbols from the model's coordinates and fields.
Arguments
model: An instance of theModelstruct containing defined coordinates and fields.terms: A tuple of symbolic expressions to validate.
Apoblast.Utils.safe_print — Function
safe_print(print_progress, str)Prints the given string if print_progress is true.
Apoblast.Utils.find_invalid_fieldlike_function — Function
find_invalid_fieldlike_function(expr, coords, allowed_fields)Recursively checks if the expression contains any function that looks like a field (i.e., a function of the coordinates) but is not in the allowed fields.
Arguments
expr: The symbolic expression to check.coords: The coordinates of the model, used to identify field-like functions.allowed_fields: The set of allowed field symbols defined in the model.
Apoblast.Utils.listorder — Function
listorder(monoterms, order)Generates a list of all combinations of the given monoterms up to the specified order. For example, if monoterms is [x, y] and order is 2, it will generate [1, x, y, x^2, x*y, y^2].
Arguments
monoterms: A vector of symbolic variables representing the monoterms to combine.order: An integer specifying the maximum order of combinations to generate.
listorder(monoterm, coords, order)Generates a list of all combinations of derivatives of the given monoterm with respect to the specified coordinates up to the specified order. For example, if monoterm is u, coords is [x, y], and order is 2, it will generate a list of derivatives like `[u, diff(u, x), diff(u, y), diff(u, x, x), diff(u, x, y), diff(u, y, y)].
Arguments
monoterm: A symbolic expression representing the monoterm to differentiate.coords: A vector of symbolic variables representing the coordinates with respect to which the derivatives will be taken.order: An integer specifying the maximum order of derivatives to generate.