svMultiPhysics
Loading...
Searching...
No Matches
ActiveStressODE.h
1// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the
2// University of California, and others. SPDX-License-Identifier: BSD-3-Clause
3
4#ifndef ACTIVE_STRESS_ODE_H
5#define ACTIVE_STRESS_ODE_H
6
7#include "ActiveStress.h"
8
9/**
10 * @brief Abstract ODE-based active stress model.
11 *
12 * This class provides an interface for defining active stress models for which
13 * the evolution of the state vector @f$\astressstate@f$ is governed by a system
14 * of ordinary differential equations (ODEs):
15 * @f[ \begin{aligned}
16 * \dv{\astressstate}{t} &=
17 * \mathbf{F}_\text{AS}(t, \astressstate, \calcium, \fiberstretch,
18 * \fiberstretchrate)\;, \\
19 * \Tact &= \Tact(\astressstate, \fiberstretch)\;.
20 * \end{aligned} @f]
21 *
22 * ### Numerical methods
23 *
24 * The ODE system is advanced with one of the methods described in
25 * @ref ODESolver. After that, the active tension is computed for every node
26 * @f$i@f$ as:
27 * @f[
28 * {\Tact}_{i}^{n+1} = \Tact(\astressstate_i^{n+1}, \fiberstretch_i^{n+1})\;.
29 * @f]
30 *
31 * ### Implementing derived models
32 *
33 * To implement a new ODE-based active stress model, the following steps need to
34 * be taken:
35 *
36 * 1. Create a new class derived from @ref ActiveStressODE.
37 * 2. Override the method init_local (from the base class @ref ActiveStress) to
38 * define the initial condition for the state vector at a single node.
39 * 3. Override the method @ref getf to define the right-hand side function
40 * @f$\mathbf{F}_\text{AS}@f$ of the ODE system.
41 * 4. Create a new class derived from @ref ActiveStressODE::Parameters to store
42 * the parameters specific to the new active stress model.
43 * 5. Override the methods @ref get_parameters, @ref read_parameters and
44 * @ref distribute_parameters to manage the parameters of the new active
45 * stress model. Both read_parameters and distribute_parameters need to call
46 * the corresponding method of ActiveStressODE.
47 * 6. Register the new class into the active stress model factory by using the
48 * macro @ref REGISTER_ACTIVE_STRESS_MODEL. The macro should be called in a
49 * `.cpp` file, not in a header file.
50 */
52public:
53 /**
54 * @brief Enumeration of supported ODE solvers.
55 *
56 * In the documentation of the individual methods below, the subscript @f$i@f$
57 * is used to denote the value of variables at the @f$i@f$-th node, and the
58 * superscript @f$n@f$ is used to denote the time step.
59 */
60 enum class ODESolver {
61 /**
62 * @brief Forward Euler.
63 *
64 * The state vector is updated as follows:
65 * @f[
66 * \astressstate_i^{n+1} = \astressstate_i^n
67 * + \Delta t \mathbf{F}_\text{AS}(t^n, \astressstate_i^n, \calcium_i^n,
68 * \fiberstretch_i^n,
69 * \fiberstretchrate_i^n)\;.
70 * @f]
71 */
73
74 /**
75 * @brief 4th order explicit Runge-Kutta.
76 *
77 * The state vector is updated as follows:
78 * @f[ \begin{aligned}
79 * \mathbf{k}_1 &= \mathbf{F}_\text{AS}(t^n, \astressstate_i^n,
80 * \calcium_i^n, \fiberstretch_i^n, \fiberstretchrate_i^n)\;, \\
81 * \mathbf{k}_2 &= \mathbf{F}_\text{AS}(t^n + \Delta t / 2,
82 * \astressstate_i^n + \Delta t \mathbf{k}_1 / 2, \calcium_i^n,
83 * \fiberstretch_i^n, \fiberstretchrate_i^n)\;, \\
84 * \mathbf{k}_3 &= \mathbf{F}_\text{AS}(t^n + \Delta t / 2,
85 * \astressstate_i^n + \Delta t \mathbf{k}_2 / 2, \calcium_i^n,
86 * \fiberstretch_i^n, \fiberstretchrate_i^n)\;, \\
87 * \mathbf{k}_4 &= \mathbf{F}_\text{AS}(t^{n+1},
88 * \astressstate_i^n + \Delta t \mathbf{k}_3, \calcium_i^n,
89 * \fiberstretch_i^n, \fiberstretchrate_i^n)\;, \\
90 * \astressstate_i^{n+1} &= \astressstate_i^n + \frac{\Delta t}{6}
91 * \left( \mathbf{k}_1 + 2 \mathbf{k}_2 + 2 \mathbf{k}_3
92 * + \mathbf{k}_4 \right)\;.
93 * \end{aligned} @f]
94 *
95 * Note that the driving quantities @f$\calcium@f$, @f$\fiberstretch@f$ and
96 * @f$\fiberstretchrate@f$ are held fixed at their values at @f$t^{n+1}@f$
97 * across all four stages.
98 */
100 };
101
102 /**
103 * @brief Model parameters class.
104 *
105 * Declares parameters that are common to all ODE-based active stress models.
106 * Classes derived from ActiveStressODE one should declare their own
107 * Parameters class, deriving from ActiveStressODE::parameters.
108 */
109 class Parameters : public ActiveStressModelParameters {
110 public:
111 Parameters(const std::string &label) : ActiveStressModelParameters(label) {
112 constexpr bool required = true;
113
114 add_parameter("ODE_solver", std::string("FE"), required);
115 }
116 };
117
118 /**
119 * @brief Constructor.
120 *
121 * @param n_states Number of state variables for this model.
122 * @param needs_fiber_stretch See @ref ActiveStress::ActiveStress.
123 * @param needs_fiber_stretch_rate See @ref ActiveStress::ActiveStress.
124 */
128
129protected:
130 /**
131 * @brief Read model parameters from a parameter object.
132 */
134 const ActiveStressModelParameters &params) override;
135
136 /**
137 * @brief Distribute model parameters to all parallel processes.
138 */
139 virtual void distribute_model_specific_parameters(const CmMod &cm_mod,
140 const cmType &cm) override;
141
142 /**
143 * @brief Advance in time for a single node.
144 *
145 * Solves one forward Euler time step for the ODE system.
146 *
147 * @param[in] t Current time (i.e. the time instant being advanced to).
148 * @param[in] dt Time step size.
149 * @param[in] calcium Calcium concentration at the current node.
150 * @param[in] fiber_stretch Fiber stretch at the current node.
151 * @param[in] fiber_stretch_rate Fiber stretch rate at the current node.
152 * @param[in,out] state State vector for a single node, to be updated by
153 * this function.
154 *
155 * @todo[michelebucelli] It might be necessary or useful to implement
156 * implicit time stepping too, e.g. by adding a method to evaluate the
157 * Jacobian matrix of the system, as in @ref IonicModel.
158 */
159 virtual void advance_time_step_local(const double t, const double dt,
160 const double calcium,
161 const double fiber_stretch,
162 const double fiber_stretch_rate,
163 Vector<double> &state) const override;
164
165 /**
166 * @brief Compute the rate of change in the state variables.
167 *
168 * @param[in] t Current time (i.e. the time instant being advanced to).
169 * @param[in] dt Time step size.
170 * @param[in] calcium Calcium concentration at the current node.
171 * @param[in] fiber_stretch Fiber stretch at the current node.
172 * @param[in] fiber_stretch_rate Fiber stretch rate at the current node.
173 *
174 * @return A vector containing the rate of change for each state variable.
175 */
176 virtual Vector<double> getf(const double t, const Vector<double> &state,
177 const double calcium, const double fiber_stretch,
178 const double fiber_stretch_rate) const = 0;
179
180 /// ODE solver.
182};
183
184#endif
const unsigned int n_states
Number of state variables for this model.
Definition ActiveStress.h:388
bool needs_fiber_stretch_rate() const
Whether this model uses the fiber stretch rate passed to update. This flag can be used to determine w...
Definition ActiveStress.h:378
bool needs_fiber_stretch() const
Whether this model uses the fiber stretch passed to update. This flag can be used to determine whethe...
Definition ActiveStress.h:371
ActiveStress(const unsigned int n_states_, const bool needs_fiber_stretch, const bool needs_fiber_stretch_rate)
Constructor.
Definition ActiveStress.h:270
Parameters for a generic active stress model.
Definition Parameters.h:1450
ActiveStressModelParameters(const std::string &xml_element_name_)
Constructor.
Definition Parameters.cpp:1860
void add_parameter(const std::string &label, double default_value, bool required)
Add a new parameter to this object.
Definition Parameters.h:1496
virtual Vector< double > getf(const double t, const Vector< double > &state, const double calcium, const double fiber_stretch, const double fiber_stretch_rate) const =0
Compute the rate of change in the state variables.
ODESolver
Enumeration of supported ODE solvers.
Definition ActiveStressODE.h:60
@ RungeKutta4
4th order explicit Runge-Kutta.
Definition ActiveStressODE.h:99
@ ForwardEuler
Forward Euler.
Definition ActiveStressODE.h:72
virtual void distribute_model_specific_parameters(const CmMod &cm_mod, const cmType &cm) override
Distribute model parameters to all parallel processes.
Definition ActiveStressODE.cpp:20
virtual void advance_time_step_local(const double t, const double dt, const double calcium, const double fiber_stretch, const double fiber_stretch_rate, Vector< double > &state) const override
Advance in time for a single node.
Definition ActiveStressODE.cpp:25
virtual void read_model_specific_parameters(const ActiveStressModelParameters &params) override
Read model parameters from a parameter object.
Definition ActiveStressODE.cpp:6
ActiveStressODE(const unsigned int n_states, const bool needs_fiber_stretch, const bool needs_fiber_stretch_rate)
Constructor.
Definition ActiveStressODE.h:125
ODESolver ode_solver
ODE solver.
Definition ActiveStressODE.h:181
The CmMod class duplicates the data structures in the Fortran CMMOD module defined in COMU....
Definition CmMod.h:37
The Vector template class is used for storing int and double data.
Definition Vector.h:26
The cmType class stores data and defines methods used for mpi communication.
Definition CmMod.h:57