Flow123d  jenkins-Flow123d-linux-release-multijob-282
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
LinearODEAnalytic Class Reference

This class implements the analytic solution of a system of linear ODEs with constant matrix. More...

#include <linear_ode_analytic.hh>

Inheritance diagram for LinearODEAnalytic:
Inheritance graph
[legend]
Collaboration diagram for LinearODEAnalytic:
Collaboration graph
[legend]

Public Member Functions

 LinearODEAnalytic ()
 Default constructor is possible because the input record is not needed. More...
 
 LinearODEAnalytic (Input::Record in_rec)
 Constructor from the input data. More...
 
 ~LinearODEAnalytic (void)
 Destructor. More...
 
void update_solution (arma::vec &init_vector, arma::vec &output_vec) override
 Updates solution of the ODEs system. More...
 
- Public Member Functions inherited from LinearODESolver< LinearODEAnalytic >
 LinearODESolver ()
 
virtual ~LinearODESolver ()
 
virtual void update_solution (arma::mat &init_vecs, arma::mat &output_vecs, const std::vector< unsigned int > &mask=std::vector< unsigned int >(0)) override
 Updates solution of the system with different initial vectors. More...
 
- Public Member Functions inherited from LinearODESolverBase
 LinearODESolverBase ()
 
virtual ~LinearODESolverBase ()
 
void set_system_matrix (const arma::mat &matrix)
 Sets the matrix of ODE system. More...
 
void set_step (double step)
 Sets the step of the numerical method. More...
 

Static Public Attributes

static Input::Type::Record input_type
 
- Static Public Attributes inherited from LinearODESolverBase
static Input::Type::AbstractRecord input_type = AbstractRecord("LinearODESolver", "Solver of a linear system of ODEs.")
 

Protected Member Functions

void compute_matrix ()
 

Protected Attributes

arma::mat solution_matrix_
 The solution is computed only by a matrix multiplication (standard fundamental matrix). More...
 
- Protected Attributes inherited from LinearODESolverBase
arma::mat system_matrix_
 the square matrix of ODE system More...
 
arma::vec rhs_
 the column vector of RHS values (not used currently) More...
 
double step_
 the step of the numerical method More...
 
bool step_changed_
 flag is true if the step has been changed More...
 

Detailed Description

This class implements the analytic solution of a system of linear ODEs with constant matrix.

The analytic solution can be obtained in the special case due to a physical nature of the problem. The problem is then solved only by a matrix multiplication.

The assumption is made that the equations are independent. Each quantity is decreased (supposing negative diagonal) to $ e^{a_{ii} t} $. The decrement $ \left( 1-e^{a_{ii} t} \right) $ is then distributed among other quantities according to the given fraction.

In case of the decays and first order reactions the elements of the solution matrix are:

\begin{eqnarray*} a_{ii} &=& e^{-\lambda_i t} \\ a_{ji} &=& \left( 1-e^{-\lambda_i t} \right) b_{ji} \frac{M_j}{M_i} \end{eqnarray*}

where $ b_{ji} $ is the branching ratio of $ i $-th reactant and $ \frac{M_j}{M_i} $ is the fraction of molar masses.

The fractions $ b_{ji} \frac{M_j}{M_i} $ are then obtained from the system matrix by dividing $ -\frac{a_{ji}}{a_{ii}} $.

Drawback: These assumptions (equation independence) are adequate when very small time step is applied. This will lead to huge amount of evaluations of the exponential functions which can be expensive, so other numerical methods might be more appropriate. When the time step is large then the assumption is quite inadequate.

Definition at line 32 of file linear_ode_analytic.hh.

Constructor & Destructor Documentation

LinearODEAnalytic::LinearODEAnalytic ( )
inline

Default constructor is possible because the input record is not needed.

Definition at line 41 of file linear_ode_analytic.hh.

LinearODEAnalytic::LinearODEAnalytic ( Input::Record  in_rec)

Constructor from the input data.

Definition at line 12 of file linear_ode_analytic.cc.

LinearODEAnalytic::~LinearODEAnalytic ( void  )

Destructor.

Definition at line 16 of file linear_ode_analytic.cc.

Member Function Documentation

void LinearODEAnalytic::compute_matrix ( )
protected

Computes the standard fundamental matrix.

Definition at line 31 of file linear_ode_analytic.cc.

void LinearODEAnalytic::update_solution ( arma::vec &  init_vec,
arma::vec &  output_vec 
)
overridevirtual

Updates solution of the ODEs system.

Parameters
init_vecis the column initial vector
output_vecis the column output vector containing the result

Implements LinearODESolverBase.

Definition at line 20 of file linear_ode_analytic.cc.

Member Data Documentation

Record LinearODEAnalytic::input_type
static
Initial value:
= Record("LinearODEAnalytic", "Evaluate analytic solution of the system of ODEs.")

Input record for class LinearODE_analytic.

Definition at line 38 of file linear_ode_analytic.hh.

arma::mat LinearODEAnalytic::solution_matrix_
protected

The solution is computed only by a matrix multiplication (standard fundamental matrix).

Definition at line 58 of file linear_ode_analytic.hh.


The documentation for this class was generated from the following files: