Dynamics (a.k.a. Active Tension)
Initialize nonlinear solve

Located in pcty/server/problem/Biomechanics/SolversBm.py (initializeSolve and setupSolve)

Calculate initial conditions and rpars at each gauss point with calculateValue() (nonlin_solve > get_strain_energy_init_dynamic)

Do a “preliminary mechanics solve” and derive initial conditions for “update variables” which show up in rpar[updateVar_{cur}]

copy rpar[updateVar_{cur}] into rpar[updateVar_{prev}] and y[updateVar] (probably don’t need to copy to y_mechanics[updateVar])

 Copy y state variables to y_mechanics

Do second half time step (SolversBm.py > solveActiveODEs)
 Do a “full update” solve
 Update all state variables using Backwards Euler (previously radau)
 Do a “full update” solve
Inside mechanics gauss point loop (mechanics or partial update)
 Takes place in SolversBM.assemble_element_resid_vector
 Inside the call to p_strain_energy
 Calculate a new value for each update var (according to current nodal solution) (previously strain2sarclen)

Copy this value into rpar[updateVar_{cur}] and y_mechanics[updateVar] (prior to partial update solve)

 User defined equations (perhaps to calculate passive stress)
 Upon first declaration of a “time dependent variable”…

Calculate y_mechancs_{t+1} for all “time dependent variables” using Backwards Euler (previously RK4)

 More user defined equations (perhaps to calculate tension and formerly tension2stress calculations)
 Calculate second PiolaKirchhoff stress (as defined by user – probably from passive and active)
 Calculate a new value for each update var (according to current nodal solution) (previously strain2sarclen)
At the end of each time step (after “load loop” finishes)
 Do first half time step
 Do a “full update” solve
 Update all state variables using Backwards Euler (previously radau)
 Do a “full update” solve
 Copy y state variables to y_mechanics
 Reconcile updateVars in y for accuracy

copy rpar[updateVar_{prev}] to y[updateVar] Shouldn’t rpar[updateVar_{cur}] be copied instead???

 Do second half time step
 Do a “full update” solve
 Update all state variables using Backwards Euler (previously radau)
 Do a “full update” solve

Update the “update variables” (such as SL) by copying rpar[updateVar_{cur}] into rpar[updateVar_{prev}]
Overview of code gen process

User selects a dynamics model (no need to compile anything at this point)

User selects a constitutive model which requires a dynamics model
 User clicks “Compile…”.
 If there are no “dynamics” variables or “update” variables, then this isn’t a constitutive model that relies on a “dynamics” model. Skip the rest of the steps.
 Otherwise…

From IonicBuildSympy.py:rawCompileDynamics(), do the following:
 If it exists, delete “dynamicData.pickle” in the ode_cuda directory, to make sure we get a fresh copy (or no copy if subsequent steps fail)

We check the constitutive model for dynamics variables. We then again call gen_sympy_model.py, but this time we include ‘–target’ flags for each dynamics variable. For example, if we identified T_active as a dynamics variable, it would look like this:

python gen_sympy_model.py target T_active dynamics justmodel.py
 This creates a pickle file with important data to be used during a subsequent step (“dynamicData.pickle”). It contains the list of the state variables which are actually needed during the partial update. It also contains some lines of code for the “dynamics variables” which will get embedded in the constitutive law.

 We calculated the partial update model like this:

python gen_sympy_model.py dynamics justmodel.py


Based on dynamics selection, we call gen_sympy_model.py to generate and compile a full update version of ODE model (to be used at the end of each time step)

python gen_sympy_model.py justmodel.py

 Generate the constitutive model (which calls the generated partial update function)
See Also
Electromechanics
 Dynamic model is replaced by electrophysiology cell model
 Rather than using rpar to transfer data, “exchange” variables are used
 – Both models have a copy of this data structure and place and retrieve data from the structure