19 using namespace Input::Type;
22 =
Record(
"Substep",
"Equation for reading information about radioactive decays.")
24 "Identifier of an isotope.")
26 "Half life of the parent substance.")
28 "Kinetic constants describing first order reactions.")
30 "Identifies isotopes which decays parental atom to.")
32 "Decay chain branching percentage.");
36 =
Record(
"LinearReactions",
"Information for a decision about the way to simulate radioactive decay.")
39 "Description of particular decay chain substeps.");
46 reaction_matrix(nullptr)
61 ASSERT(
time_ !=
nullptr,
"Time governor has not been set yet.\n");
73 unsigned int rows, cols;
75 DBGMSG(
"We are going to allocate reaction matrix\n");
77 for(rows = 0; rows <
names_.size(); rows++){
80 for(rows = 0; rows <
names_.size();rows++){
81 for(cols = 0; cols <
names_.size(); cols++){
140 unsigned int index_par;
144 xprintf(
Warn,
"\nReaction matrix pointer is NULL.\n");
148 for (
unsigned int i_decay = 0; i_decay <
half_lives.size(); i_decay++) {
153 for (
unsigned int i_product = 1; i_product <
substance_ids[i_decay].size(); ++i_product)
155 = (1 - pow(0.5, rel_step))*
bifurcation[i_decay][i_product-1];
163 unsigned int cols, rows;
167 for(cols = 0; cols <
names_.size(); cols++){
168 prev_conc[cols] = concentrations[cols][loc_el];
169 concentrations[cols][loc_el] = 0.0;
172 for(rows = 0; rows <
names_.size(); rows++){
173 for(cols = 0; cols <
names_.size(); cols++){
178 return concentrations;
186 for (i = 0; i < (nr_of_substances - 1); i++) {
187 if (i < (nr_of_substances - 2))
189 if (i == (nr_of_substances - 2))
214 it_hl = dec_it->find<
double>(
"kinetic");
218 xprintf(
UsrErr,
"Missing half-life or kinetic in the %d-th reaction.\n", i_decay);
223 string parent_name = dec_it->val<
string>(
"parent");
228 if (product_array.size() > 0)
substance_ids[i_decay].resize( product_array.size()+1 );
229 else xprintf(
UsrErr,
"Empty array of products in the %d-th reaction.\n", i_decay);
235 else xprintf(
UsrErr,
"Wrong name of parent substance in the %d-th reaction.\n", i_decay);
238 unsigned int i_product = 1;
239 for(
Input::Iterator<string> product_it = product_array.begin<
string>(); product_it != product_array.end(); ++product_it, i_product++)
243 else xprintf(
Msg,
"Wrong name of %d-th product in the %d-th reaction.\n", i_product-1 , i_decay);
247 if (ratio_array.size() == product_array.size() ) ratio_array.copy_to(
bifurcation[i_decay] );
248 else xprintf(
UsrErr,
"Number of branches %d has to match number of products %d in the %d-th reaction.\n",
249 ratio_array.size(), product_array.size(), i_decay);
256 DBGMSG(
"LinearReactions - update solution\n");
285 for(
unsigned int i = 0; i <
names_.size(); i++)
300 unsigned int cols,rows;
306 for(rows = 0; rows <
names_.size(); rows++){
307 for(cols = 0; cols <
names_.size(); cols++){
313 xprintf(
Msg,
"\nReaction matrix needs to be allocated.\n");
322 for(; k <
names_.size(); k++)
323 if (name ==
names_[k])
return k;