Dynamics Model

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[updateVarcur]

    • copy rpar[updateVarcur] into rpar[updateVarprev] 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)

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[updateVarcurand 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_mechancst+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 Piola-Kirchhoff stress (as defined by user – probably from passive and active)

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)
  • Copy y state variables to y_mechanics
  • Reconcile updateVars in y for accuracy
    • copy rpar[updateVarprev] to y[updateVar] Shouldn’t rpar[updateVarcur] be copied instead???

  • Do second half time step
    • Do a “full update” solve
      • Update all state variables using Backwards Euler (previously radau)
  • Update the “update variables” (such as SL) by copying rpar[updateVarcur] into rpar[updateVarprev]

Overview of code gen process

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

  2. User selects a constitutive model which requires a dynamics model

  3. 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…
  4. From IonicBuildSympy.py:rawCompileDynamics(), do the following:

    1. 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)
    2. 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.
    3. We calculated the partial update model like this:
      • python gen_sympy_model.py --dynamics justmodel.py

    4. 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

  5. Generate the constitutive model (which calls the generated partial update function)

See Also


  • 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