Flow123d  jenkins-Flow123d-linux-release-multijob-282
linear_ode_analytic.hh
Go to the documentation of this file.
1 #ifndef LINEAR_ODE_ANALYTIC_H_
2 #define LINEAR_ODE_ANALYTIC_H_
3 
5 
6 /** @brief This class implements the analytic solution of a system of linear ODEs with constant matrix.
7  *
8  * The analytic solution can be obtained in the special case due to a physical nature of the problem.
9  * The problem is then solved only by a matrix multiplication.
10  *
11  * The assumption is made that the equations are independent. Each quantity is decreased (supposing
12  * negative diagonal) to \f$ e^{a_{ii} t} \f$. The decrement \f$ \left( 1-e^{a_{ii} t} \right) \f$
13  * is then distributed among other quantities according to the given fraction.
14  *
15  * In case of the decays and first order reactions the elements of the solution matrix are:
16  * \f{eqnarray*}{
17  * a_{ii} &=& e^{-\lambda_i t} \\
18  * a_{ji} &=& \left( 1-e^{-\lambda_i t} \right) b_{ji} \frac{M_j}{M_i}
19  * \f}
20  * where \f$ b_{ji} \f$ is the branching ratio of \f$ i \f$-th reactant and \f$ \frac{M_j}{M_i} \f$ is
21  * the fraction of molar masses.
22  *
23  * The fractions \f$ b_{ji} \frac{M_j}{M_i} \f$ are then obtained from the system matrix by dividing
24  * \f$ -\frac{a_{ji}}{a_{ii}} \f$.
25  *
26  * <B>Drawback:</B> These assumptions (equation independence) are adequate when very small time step is
27  * applied. This will lead to huge amount of evaluations of the exponential functions which can be expensive,
28  * so other numerical methods might be more appropriate.
29  * When the time step is large then the assumption is quite inadequate.
30  *
31  */
32 class LinearODEAnalytic : public LinearODESolver<LinearODEAnalytic>
33 {
34 public:
35  /**
36  * Input record for class LinearODE_analytic.
37  */
39 
40  ///Default constructor is possible because the input record is not needed.
42 
43  /// Constructor from the input data.
45 
46  /// Destructor.
47  ~LinearODEAnalytic(void);
48 
49  void update_solution(arma::vec &init_vector, arma::vec &output_vec) override;
50 
51 protected:
52  /**
53  * Computes the standard fundamental matrix.
54  */
55  void compute_matrix();
56 
57  /// The solution is computed only by a matrix multiplication (standard fundamental matrix).
58  arma::mat solution_matrix_;
59 };
60 
61 #endif // LINEAR_ODE_ANALYTIC_H_
arma::mat solution_matrix_
The solution is computed only by a matrix multiplication (standard fundamental matrix).
This class implements the analytic solution of a system of linear ODEs with constant matrix...
Template class of the linear ODE solver.
void update_solution(arma::vec &init_vector, arma::vec &output_vec) override
Updates solution of the ODEs system.
Accessor to the data with type Type::Record.
Definition: accessors.hh:327
~LinearODEAnalytic(void)
Destructor.
LinearODEAnalytic()
Default constructor is possible because the input record is not needed.
static Input::Type::Record input_type
Record type proxy class.
Definition: type_record.hh:169