Flow123d
linear_reaction.hh
Go to the documentation of this file.
1 /** @brief class Linear_reaction is used to enable simulation of simple chemical reactions
2  *
3  * Class in this file makes it possible to realize simulation of reaction of the first order by simple matrix multiplication.
4  * One step of the linear reaction is represented as a product of a matrix containing concentrations of observed speciesin elements in rows multiplied by so called
5  * reaction_matrix. Through this way radioactive decay can bee also realized and that was exactly what we did at the begining of journey. :-)
6  * Matrix containing concentrations has a dimension Nxn, where N is a number of elements in mesh and n denotes a number of transported chemical species.
7  * The reaction_matrix is a square matrix and it has a dimension nxn.
8  *
9  */
10 #ifndef LINREACT
11 #define LINREACT
12 
13 #include <vector>
14 #include <input/input_type.hh>
15 
16 class Mesh;
17 class Distribution;
18 class ReactionTerm;
19 
21 {
22  public:
23  /*
24  * Static variable for new input data types input
25  */
27  /*
28  * Static variable gets information about particular decay step
29  */
31  /**
32  * Constructor with parameter for initialization of a new declared class member
33  * TODO: parameter description
34  */
35  //Linear_reaction(TimeMarks &marks, Mesh &init_mesh, MaterialDatabase &material_database, Input::Record in_rec, vector<string> &names);
36  Linear_reaction(Mesh &init_mesh, Input::Record in_rec);
37  /**
38  * Destructor.
39  */
40  ~Linear_reaction(void);
41 
42  void zero_time_step() override;
43 
44  /**
45  * For simulation of chemical reaction in just one element either inside of MOBILE or IMMOBILE pores.
46  */
47  virtual double **compute_reaction(double **concentrations, int loc_el) override;
48  /**
49  * Prepared to compute simple chemical reactions inside all of considered elements. It calls compute_reaction(...) for all the elements controled by concrete processor, when the computation is paralelized.
50  */
51  void update_solution(void) override;
52  /**
53  * This method modificates reaction matrix as described in ini-file a single section [Decay_i] or [FoReact_i]. It is used when bifurcation is switched off.
54  */
55  virtual double **modify_reaction_matrix(void);
56 
57  protected:
58 
59  double **allocate_reaction_matrix(void);
60 
61  /**
62  * This method disables to use constructor without parameters.
63  */
65 
66  virtual void init_from_input(Input::Record in_rec) override;
67  /**
68  * For control printing of a matrix describing simple chemical raections.
69  */
70  void print_reaction_matrix(void);
71  /**
72  * For printing nr_of_isotopes identifies of isotopes in a current decay chain.
73  */
74  void print_indices(int dec_nr, int n_subst);
75  /**
76  * Following method releases reaction matrix to make it possible to set a new time step for chemistry.
77  */
79  /**
80  * For printing (nr_of_isotopes - 1) doubles containing half-lives belonging to particular isotopes on screen.
81  */
82  void print_half_lives(int n_subst);
83 
84  /**
85  * Finds a position of a string in specified array.
86  */
87  unsigned int find_subst_name(const std::string &name);
88  /**
89  * Small (nr_of_species x nr_of_species) square matrix for realization of radioactive decay and first order reactions simulation.
90  */
91  double **reaction_matrix;
92  /**
93  * Pointer to reference previous concentration array used in compute_reaction().
94  */
95  double *prev_conc;
96  /**
97  * Sequence of (nr_of_isotopes - 1) doubles containing half-lives belonging to particular isotopes.
98  */
100  /**
101  * Sequence of integers describing an order of isotopes in decay chain or first order reaction.
102  */
104  /**
105  * Two dimensional array contains mass percentage of every single decay bifurcation on every single row.
106  */
108 };
109 
110 #endif