13 using namespace Input::Type;
16 =
Record(
"Substep",
"Equation for reading information about radioactive decays.")
18 "Identifier of an isotope.")
20 "Half life of the parent substance.")
22 "Kinetic constants describing first order reactions.")
24 "Identifies isotopes which decays parental atom to.")
26 "Decay chain branching percentage.");
30 =
Record(
"LinearReactions",
"Information for a decision about the way to simulate radioactive decay.")
33 "Description of particular decay chain substeps.");
50 ASSERT(
time_ !=
nullptr,
"Time governor has not been set yet.\n");
59 for(
unsigned int i_subst = 0; i_subst <
n_substances_; i_subst++)
67 ASSERT(
time_ !=
nullptr,
"Time governor has not been set yet.\n");
76 unsigned int rows, cols;
90 unsigned int parent_idx, product_idx,
92 double relative_timestep,
96 for (i_decay = 0; i_decay <
half_lives_.size(); i_decay++) {
100 temp_power = pow(0.5, relative_timestep);
104 for (i_product = 1; i_product <
substance_ids_[i_decay].size(); ++i_product) {
114 unsigned int cols, rows;
118 prev_conc_[rows] = concentrations[rows][loc_el];
119 concentrations[rows][loc_el] = 0.0;
130 return concentrations;
152 it_hl = dec_it->find<
double>(
"kinetic");
156 xprintf(
UsrErr,
"Missing half-life or kinetic in the %d-th reaction.\n", i_decay);
161 string parent_name = dec_it->val<
string>(
"parent");
166 if (product_array.size() > 0)
substance_ids_[i_decay].resize( product_array.size()+1 );
167 else xprintf(
UsrErr,
"Empty array of products in the %d-th reaction.\n", i_decay);
173 else xprintf(
UsrErr,
"Wrong name of parent substance in the %d-th reaction.\n", i_decay);
176 unsigned int i_product = 1;
177 for(
Input::Iterator<string> product_it = product_array.begin<
string>(); product_it != product_array.end(); ++product_it, i_product++)
181 else xprintf(
Warn,
"Wrong name of %d-th product in the %d-th reaction.\n", i_product-1 , i_decay);
185 if (ratio_array.size() == product_array.size() ) ratio_array.copy_to(
bifurcation_[i_decay] );
186 else xprintf(
UsrErr,
"Number of branches %d has to match number of products %d in the %d-th reaction.\n",
187 ratio_array.size(), product_array.size(), i_decay);
211 unsigned int cols,rows;
223 xprintf(
Msg,
"\nReaction matrix needs to be allocated.\n");
231 xprintf(
Msg,
"\nHalf-lives are defined as:\n");
241 for(; k <
names_.size(); k++)
242 if (name ==
names_[k])
return k;
void reset_reaction_matrix()
Resets reaction matrix as eye matrix.
void update_solution(void) override
Updates the solution.
void initialize() override
Prepares the object to usage.
double ** concentration_matrix_
vector< string > names_
Names belonging to substances.
~LinearReaction(void)
Destructor.
std::vector< std::vector< double > > reaction_matrix_
unsigned int find_subst_name(const std::string &name)
virtual void modify_reaction_matrix(void)
void initialize_from_input()
Initializes private members of sorption from the input record.
std::vector< double > half_lives_
static Input::Type::AbstractRecord input_type
Global macros to enhance readability and debugging, general constants.
static Input::Type::Record input_type
Distribution * distribution_
Pointer to reference to distribution of elements between processors.
unsigned int n_substances_
void print_reaction_matrix(void)
#define ASSERT_LESS(a, b)
bool is_changed_dt() const
#define START_TIMER(tag)
Starts a timer with specified tag.
virtual double ** compute_reaction(double **concentrations, int loc_el) override
Support classes for parallel programing.
LinearReaction(Mesh &init_mesh, Input::Record in_rec)
Constructor.
std::vector< std::vector< unsigned int > > substance_ids_
Input::Record input_record_
std::vector< std::vector< double > > bifurcation_
static Input::Type::Record input_type_one_decay_substep
void zero_time_step() override
#define END_TIMER(tag)
Ends a timer with specified tag.
std::vector< double > prev_conc_
unsigned int lsize(int proc) const
get local size