17 using namespace Input::Type;
20 =
Record(
"Substep",
"Equation for reading information about radioactive decays.")
22 "Identifier of an isotope.")
24 "Half life of the parent substance.")
26 "Kinetic constants describing first order reactions.")
28 "Identifies isotopes which decays parental atom to.")
30 "Decay chain branching percentage.");
34 =
Record(
"PadeApproximant",
"Abstract record with an information about pade approximant parameters.")
37 "Description of particular decay chain substeps.")
39 "Polynomial degree of the nominator of Pade approximant.")
41 "Polynomial degree of the nominator of Pade approximant");
68 DBGMSG(
"Pade approximant destructor is running.\n");
80 xprintf(
UsrErr,
"You did not specify Pade approximant required polynomial degrees.");
87 unsigned int rows, cols;
89 cout <<
"We are going to allocate reaction matrix" << endl;
91 for(rows = 0; rows <
names_.size(); rows++){
94 for(rows = 0; rows <
names_.size();rows++){
95 for(cols = 0; cols <
names_.size(); cols++){
117 PetscScalar Hlp_mat[1];
118 PetscScalar *Array_hlp;
121 int rows, cols, i, j;
133 PetscScalar rel_step;
135 for (
unsigned int i_decay = 0; i_decay <
half_lives.size(); i_decay++) {
138 extent = -log(2)*rel_step;
139 cout<<
"parental index" << index_par <<
", extent "<< extent << endl;
140 MatSetValue(
Reaction_matrix, index_par, index_par, extent,INSERT_VALUES);
141 for (
unsigned int i_product = 1; i_product <
substance_ids[i_decay].size(); ++i_product){
143 extent = log(2)*rel_step*
bifurcation[i_decay][i_product-1];
145 MatSetValue(
Reaction_matrix, index_par, index_child,extent,INSERT_VALUES);
160 MatZeroEntries(Nominator);
171 MatZeroEntries(Denominator);
183 PCCreate(PETSC_COMM_WORLD, &Precond);
184 PCSetType(Precond, PCLU);
185 PCSetOperators(Precond, Denominator, Denominator, DIFFERENT_NONZERO_PATTERN);
187 PCFactorSetMatOrderingType(Precond, MATORDERINGRCM);
190 VecCreate(PETSC_COMM_WORLD, &tmp1);
191 VecSetSizes(tmp1, PETSC_DECIDE,
names_.size());
192 VecSetFromOptions(tmp1);
193 VecDuplicate(tmp1, &tmp2);
197 MatCreate(PETSC_COMM_SELF, &Pade_approximant);
198 MatSetSizes(Pade_approximant, PETSC_DECIDE, PETSC_DECIDE,
names_.size(),
names_.size());
199 MatSetType(Pade_approximant, MATAIJ);
200 MatSetUp(Pade_approximant);
202 for(rows = 0; rows < (int)(
names_.size() ); rows++){
203 MatGetColumnVector(Nominator, tmp1, rows);
205 PCApply(Precond, tmp1, tmp2);
206 PCView(Precond, PETSC_VIEWER_STDOUT_WORLD);
208 VecGetArray(tmp2, &Array_hlp);
209 for(cols = 0; cols < (int)(
names_.size() ); cols++)
211 MatSetValue(Pade_approximant, rows, cols, Array_hlp[cols], ADD_VALUES);
214 MatAssemblyBegin(Pade_approximant, MAT_FINAL_ASSEMBLY);
215 MatAssemblyEnd(Pade_approximant, MAT_FINAL_ASSEMBLY);
218 for(rows = 0; rows < (int)(
names_.size() ); rows++)
220 for(cols = 0; cols < (int)(
names_.size() ); cols++)
225 for(rows = 0; rows < (int)(
names_.size() ); rows++)
227 for(cols = 0; cols < (int)(
names_.size() ); cols++)
229 MatGetValues(Pade_approximant, 1, &rows, 1, &cols, Hlp_mat);
239 MatDestroy(&Denominator);
240 MatDestroy(&Nominator);
242 MatDestroy(&Pade_approximant);
252 MatCreate(PETSC_COMM_SELF, &Identity);
253 MatSetSizes(Identity, PETSC_DECIDE, PETSC_DECIDE,
names_.size(),
names_.size());
254 MatSetType(Identity, MATAIJ);
257 MatAssemblyBegin(Identity, MAT_FINAL_ASSEMBLY);
258 MatAssemblyEnd(Identity, MAT_FINAL_ASSEMBLY);
259 MatShift(Identity, 1.0);
263 MatMatMult(*Polynomial, *Reaction_matrix, MAT_INITIAL_MATRIX, PETSC_DEFAULT, Polynomial);
264 MatAXPY(*Polynomial, coef[i], Identity, DIFFERENT_NONZERO_PATTERN);
267 MatDestroy(&Identity);
275 unsigned int cols, rows;
279 for(cols = 0; cols <
names_.size(); cols++){
280 prev_conc[cols] = concentrations[cols][loc_el];
281 concentrations[cols][loc_el] = 0.0;
284 for(cols = 0; cols <
names_.size(); cols++){
285 for(rows = 0; rows <
names_.size(); rows++){
290 return concentrations;