11 using namespace Input::Type;
14 =
Record(
"Substep",
"Equation for reading information about radioactive decays.")
16 "Identifier of an isotope.")
18 "Half life of the parent substance.")
20 "Kinetic constants describing first order reactions.")
22 "Identifies isotopes which decays parental atom to.")
24 "Decay chain branching percentage.");
28 =
Record(
"PadeApproximant",
"Abstract record with an information about pade approximant parameters.")
31 "Description of particular decay chain substeps.")
33 "Polynomial degree of the nominator of Pade approximant.")
35 "Polynomial degree of the nominator of Pade approximant");
55 xprintf(
UsrErr,
"You did not specify Pade approximant required polynomial degrees.");
68 unsigned int reactant_index, product_index;
70 for (
unsigned int i_decay = 0; i_decay <
half_lives_.size(); i_decay++) {
73 r_reaction_matrix_(reactant_index, reactant_index) = -exponent;
75 for (
unsigned int i_product = 1; i_product <
substance_ids_[i_decay].size(); ++i_product){
77 r_reaction_matrix_(product_index, reactant_index) = exponent *
bifurcation_[i_decay][i_product-1];
86 nominator_matrix.fill(0);
87 denominator_matrix.fill(0);
88 pade_approximant_matrix.fill(0);
99 pade_approximant_matrix = nominator_matrix * inv(denominator_matrix);
103 unsigned int rows, cols;
114 unsigned int denominator_degree,
121 for(
unsigned int i = 1; i < factorials.size(); i++)
122 factorials[i] = factorials[i-1]*i;
126 for(
int j = nominator_degree; j >= 0; j--)
129 (double)(factorials[nominator_degree + denominator_degree - j] * factorials[nominator_degree])
130 / (factorials[nominator_degree + denominator_degree] * factorials[j] * factorials[nominator_degree - j]);
133 for(
int i = denominator_degree; i >= 0; i--)
135 if(i % 2 == 0) sign = 1;
else sign = -1;
136 denominator_coefs[i] = sign *
137 (double)(factorials[nominator_degree + denominator_degree - i] * factorials[denominator_degree])
138 / (factorials[nominator_degree + denominator_degree] * factorials[i] * factorials[denominator_degree - i]);
143 const mat& reaction_matrix,
149 for(
int i = coefs.size()-1; i >= 0; i--)
151 polynomial_matrix = coefs[i] * identity + (polynomial_matrix * reaction_matrix);
PadeApproximant(Mesh &mesh, Input::Record in_rec)
Constructor.
int nominator_degree_
Degree of the polynomial in the nominator.
void initialize() override
Prepares the object to usage.
void compute_exp_coefs(unsigned int nominator_degree, unsigned int denominator_degree, std::vector< double > &nominator_coefs, std::vector< double > &denominator_coefs)
Evaluates nominator and denominator coeficients of PadeApproximant for exponencial function...
static Input::Type::Record input_type
std::vector< std::vector< double > > reaction_matrix_
std::vector< double > half_lives_
static Input::Type::AbstractRecord input_type
int denominator_degree_
Degree of the polynomial in the denominator.
Global macros to enhance readability and debugging, general constants.
unsigned int n_substances_
void initialize() override
Prepares the object to usage.
void modify_reaction_matrix(void) override
std::vector< std::vector< unsigned int > > substance_ids_
~PadeApproximant(void)
Destructor.
Input::Record input_record_
std::vector< std::vector< double > > bifurcation_
void zero_time_step() override
void evaluate_matrix_polynomial(mat &polynomial_matrix, const mat &reaction_matrix, const std::vector< double > &coefs)
Evaluates the matrix polynomial by Horner scheme.
void zero_time_step() override
static Input::Type::Record input_type_one_decay_substep