svZeroDSolver
|
This tool generates C++ code for block implementations in the svZeroDSolver framework using symbolic mathematics.
The script script/jacobian.py
reads block definitions from YAML files and generates C++ code for implementing the mathematical models in the solver. It uses symbolic differentiation (via SymPy) to automatically derive the necessary Jacobian matrices and system contributions.
The YAML files define the mathematical model of a block with the following structure:
variables
: List of variable names in the modelderivatives
: List of derivative names (must match variables with _dt
suffix)constants
: List of parameter namesresiduals
: List of residual equations that define the systemtime_dependent
: List of parameters that depend on time (e.g., activation functions)helper_functions
: Python code defining helper functions used in the residualsThe script generates three C++ function implementations:
update_constant
- Sets up constant matrix coefficients for the systemupdate_time
- Updates time-dependent parametersupdate_solution
- Computes solution-dependent terms and Jacobiansjacobian.py
on this file to generate C++ codeSee the provided YAML examples:
ChamberSphere.yaml
- Spherical heart chamber modelBloodVessel.yaml
- Blood vessel model with optional stenosisClosedLoopCoronaryBC.yaml
- Coronary boundary condition model