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 /**
76 * @brief Model parameters class.
77 *
78 * Declares parameters that are common to all ODE-based active stress models.
79 * Classes derived from ActiveStressODE one should declare their own
80 * Parameters class, deriving from ActiveStressODE::parameters.
81 */
83 public:
84 Parameters(const std::string &label) : ActiveStressModelParameters(label) {
85 constexpr bool required = true;
86
87 add_parameter("ODE_solver", std::string("FE"), required);
88 }
89 };
90
91 /**
92 * @brief Constructor.
93 *
94 * @param n_states Number of state variables for this model.
95 * @param needs_fiber_stretch See @ref ActiveStress::ActiveStress.
96 * @param needs_fiber_stretch_rate See @ref ActiveStress::ActiveStress.
97 */
101
102protected:
103 /**
104 * @brief Read model parameters from a parameter object.
105 */
107 const ActiveStressModelParameters &params) override;
108
109 /**
110 * @brief Distribute model parameters to all parallel processes.
111 */
112 virtual void distribute_model_specific_parameters(const CmMod &cm_mod,
113 const cmType &cm) override;
114
115 /**
116 * @brief Advance in time for a single node.
117 *
118 * Solves one forward Euler time step for the ODE system.
119 *
120 * @param[in] t Current time (i.e. the time instant being advanced to).
121 * @param[in] dt Time step size.
122 * @param[in] calcium Calcium concentration at the current node.
123 * @param[in] fiber_stretch Fiber stretch at the current node.
124 * @param[in] fiber_stretch_rate Fiber stretch rate at the current node.
125 * @param[in,out] state State vector for a single node, to be updated by
126 * this function.
127 *
128 * @todo[michelebucelli] It might be necessary or useful to implement other
129 * timestepping schemes, e.g. Runge-Kutta. In that case, we might want to
130 * expand the interface to support implicit time stepping too, e.g. by
131 * adding a method to evaluate the Jacobian matrix of the system, as in
132 * @ref IonicModel.
133 */
134 virtual void advance_time_step_local(const double t, const double dt,
135 const double calcium,
136 const double fiber_stretch,
137 const double fiber_stretch_rate,
138 Vector<double> &state) const override;
139
140 /**
141 * @brief Compute the rate of change in the state variables.
142 *
143 * @param[in] t Current time (i.e. the time instant being advanced to).
144 * @param[in] dt Time step size.
145 * @param[in] calcium Calcium concentration at the current node.
146 * @param[in] fiber_stretch Fiber stretch at the current node.
147 * @param[in] fiber_stretch_rate Fiber stretch rate at the current node.
148 *
149 * @return A vector containing the rate of change for each state variable.
150 */
151 virtual Vector<double> getf(const double t, const Vector<double> &state,
152 const double calcium, const double fiber_stretch,
153 const double fiber_stretch_rate) const = 0;
154
155 /// ODE solver.
157};
158
159#endif
Abstract active stress class.
Definition ActiveStress.h:100
const unsigned int n_states
Number of state variables for this model.
Definition ActiveStress.h:188
bool needs_fiber_stretch_rate() const
Whether this model uses the fiber stretch rate passed to advance_time_step. This flag can be used to ...
Definition ActiveStress.h:202
bool needs_fiber_stretch() const
Whether this model uses the fiber stretch passed to advance_time_step. This flag can be used to deter...
Definition ActiveStress.h:195
Parameters for a generic active stress model.
Definition Parameters.h:1444
void add_parameter(const std::string &label, double default_value, bool required)
Add a new parameter to this object.
Definition Parameters.h:1490
Model parameters class.
Definition ActiveStressODE.h:82
Abstract ODE-based active stress model.
Definition ActiveStressODE.h:51
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
@ ForwardEuler
Forward Euler.
virtual void distribute_model_specific_parameters(const CmMod &cm_mod, const cmType &cm) override
Distribute model parameters to all parallel processes.
Definition ActiveStressODE.cpp:18
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:23
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:98
ODESolver ode_solver
ODE solver.
Definition ActiveStressODE.h:156
The CmMod class duplicates the data structures in the Fortran CMMOD module defined in COMU....
Definition CmMod.h:36
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:56