24#ifdef ALWAYS_LINEAR_INTERPOLATION
28 if (cs2 >= cs1 || cs2 <= 0 || e1 < 300.0e-6 || e1 < 1.5 * threshold) {
32 const double pw = log(cs1 / cs2) / log(e1 / e2);
37 }
else if (pw < -5.0) {
50 double xmin,
double ,
double x1,
double x2) {
53 res = t_integ_power_2point<double>(xp1, yp1, xp2, yp2, x1, x2);
55 res = t_integ_straight_2point<double>(xp1, yp1, xp2, yp2, x1, x2, 0, 1);
60double my_val_fun(
double xp1,
double yp1,
double xp2,
double yp2,
double xmin,
66 res = t_value_power_2point<double>(xp1, yp1, xp2, yp2, x);
69 res = t_value_straight_2point<double>(xp1, yp1, xp2, yp2, x, 1);
75 double x1,
double x2,
double threshold) {
77 mfunname(
"double glin_integ_ar(DynLinArr< double > x ...)");
269PhotoAbsCS::PhotoAbsCS(
void) : Z(0), threshold(0.0) { ; }
271PhotoAbsCS::PhotoAbsCS(
const String& fname,
int fZ,
double fthreshold)
272 : name(fname), Z(fZ), threshold(fthreshold) {
276void PhotoAbsCS::print(std::ostream& file,
int l)
const {
278 Ifile <<
"PhotoAbsCS: name=" << name <<
" Z = " << Z
279 <<
" threshold = " << threshold << std::endl;
283OveragePhotoAbsCS::OveragePhotoAbsCS(PhotoAbsCS* apacs,
double fwidth,
288 max_q_step(fmax_q_step),
290 mfunname(
"OveragePhotoAbsCS::OveragePhotoAbsCS(...)");
303 name = real_pacs->get_name();
304 Z = real_pacs->get_Z();
305 threshold = real_pacs->get_threshold();
309 mfunname(
"double OveragePhotoAbsCS::get_CS(double energy) const");
314 return real_pacs->get_CS(energy);
316 double w2 = width * 0.5;
317 double e1 = energy - w2;
318 if (e1 < 0.0) e1 = 0.0;
319 double res = real_pacs->get_integral_CS(e1, energy + w2) / width;
327 double energy2)
const {
328 mfunname(
"double OveragePhotoAbsCS::get_integral_CS(double energy1, double "
331 if (width == 0.0 || energy1 >= energy2) {
333 return real_pacs->get_integral_CS(energy1, energy2);
335 long q = long((energy2 - energy1) / step);
336 if (q > max_q_step) {
337 return real_pacs->get_integral_CS(energy1, energy2);
341 double rstep = (energy2 - energy1) / q;
342 double x0 = energy1 + 0.5 * rstep;
344 for (
long n = 0; n < q; n++) {
345 s +=
get_CS(x0 + rstep * n);
355 mfunname(
"void OveragePhotoAbsCS::scale(double fact)");
356 real_pacs->scale(fact);
360 mfunname(
"void PhotoAbsCS::print(std::ostream& file, int l) const");
361 Ifile <<
"OveragePhotoAbsCS: width = " << width <<
" step=" << step
362 <<
" max_q_step=" << max_q_step <<
'\n';
364 real_pacs->print(file, l);
369 : PhotoAbsCS(
"H", 1, 15.43e-6), prefactor(1.) {}
372 if (energy < threshold) {
375 if (energy != DBL_MAX) {
377 prefactor * 0.0535 * (
pow(100.0e-6 / energy, 3.228));
385 double energy2)
const {
386 if (energy2 < threshold) {
389 if (energy1 < threshold) {
392 if (energy2 == DBL_MAX) {
394 prefactor * 0.0535 *
pow(100.0e-6, 3.228) / 2.228 *
395 (1.0 /
pow(energy1, 2.228));
398 prefactor * 0.0535 *
pow(100.0e-6, 3.228) / 2.228 *
399 (1.0 /
pow(energy1, 2.228) - 1.0 /
pow(energy2, 2.228));
408 Ifile <<
"HydrogenPhotoAbsCS: name=" << name <<
" Z = " << Z
409 <<
" threshold = " << threshold << std::endl;
416 : PhotoAbsCS(fname, fZ, fthreshold), file_name(ffile_name) {
417 mfunnamep(
"SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS(...)");
419 std::ifstream file(file_name.c_str());
421 std::ifstream file(file_name);
425 mcerr <<
"cannot open file " << file_name << std::endl;
438 if (!file.good())
break;
445 if (!file.good())
break;
448 if (q == ener.get_qel()) {
464 : PhotoAbsCS(fname, fZ, fthreshold),
468 mfunname(
"SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS(...)");
473 double fthreshold,
int l,
474 double E0,
double yw,
double ya,
475 double P,
double sigma)
476 : PhotoAbsCS(fname, fZ, fthreshold) {
477 mfunname(
"SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS");
482 for (n = 0; n < q; n++) {
483 double energy = ener[n];
484 if (energy < threshold)
487 double Q = 5.5 + l - 0.5 * P;
488 double y = energy / E0;
489 double Fpasc = ((y - 1) * (y - 1) + yw * yw) *
pow(y, (-Q)) *
490 pow((1.0 +
sqrt(y / ya)), (-P));
491 Fpasc = Fpasc * sigma;
503 mfunname(
"SimpleTablePhotoAbsCS::SimpleTablePhotoAbsCS (const "
504 "SimpleTablePhotoAbsCS& total,...)");
508 long qe_i = total.ener.
get_qel();
517 for (ne = 0; ne < qe_r; ne++)
519 if (ener_r[ne] >= total.get_threshold() && ener_r[ne] <= emax_repl) {
523 new_ener[qe - 1] = ener_r[ne];
524 new_cs[qe - 1] = cs_r[ne];
527 for (ne = 0; ne < qe_i; ne++) {
528 if (ener[ne] >= total.get_threshold() && ener[ne] > emax_repl) {
532 new_ener[qe - 1] = total.ener[ne];
533 new_cs[qe - 1] = total.cs[ne];
538 for (ne = 0; ne < qe; ne++) {
539 ener[ne] = new_ener[ne];
550 for (ne = 0; ne < q; ne++) {
551 if (cs[ne] > 0.0)
break;
557 for (nez = ne; nez < q; nez++) {
558 enern[nez - ne] = ener[nez];
559 csn[nez - ne] = cs[nez];
569 for (ne = 0; ne < q; ne++) {
570 if (cs[ne] > level)
break;
576 for (nez = ne; nez < q; nez++) {
577 enern[nez - ne] = ener[nez];
578 csn[nez - ne] = cs[nez];
586 mfunname(
"double SimpleTablePhotoAbsCS::get_CS(double energy) const");
590 if (q == 0)
return 0.0;
593 if (energy < threshold)
596 if (energy <= ener[q - 1]) {
603 pcmd, cs, &
my_val_fun, energy, 1, threshold, 0, DBL_MAX);
606 if (energy == DBL_MAX)
609 return cs[q - 1] *
pow(energy, -2.75) /
pow(ener[q - 1], -2.75);
673 double energy2)
const {
674 mfunname(
"double SimpleTablePhotoAbsCS::get_integral_CS(...)");
677 if (q == 0)
return 0.0;
680 if (energy2 < threshold)
return 0.0;
681 if (energy1 < threshold) energy1 = threshold;
683 double energy21 = ener[q - 1];
684 if (energy1 < energy21) {
685 if (energy21 > energy2) energy21 = energy2;
696 if (energy2 > ener[q - 1]) {
698 if (energy2 == DBL_MAX) {
699 if (energy1 < ener[q - 1]) energy1 = ener[q - 1];
701 cs[q - 1] / (1.75 *
pow(ener[q - 1], -2.75)) *
pow(energy1, -1.75);
705 if (energy1 < ener[q - 1]) energy1 = ener[q - 1];
706 double c = cs[q - 1] / (1.75 *
pow(ener[q - 1], -2.75)) *
707 (
pow(energy1, -1.75) -
pow(energy2, -1.75));
716 mfunnamep(
"void SimpleTablePhotoAbsCS::scale(double fact)");
718 for (
long n = 0; n < q; ++n) {
725 Ifile <<
"SimpleTablePhotoAbsCS: name=" << name <<
" Z = " << Z
727 Ifile <<
" threshold = " << threshold <<
" file_name=" << file_name
731 for (
long n = 0; n < ener.
get_qel(); ++n) {
732 Ifile <<
"n=" << n <<
" ener=" << ener[n] <<
" cs=" << cs[n]
744 : PhotoAbsCS(fname, fZ, fthreshold), power(fpower) {
745 mfunname(
"PhenoPhotoAbsCS::PhenoPhotoAbsCS");
747 " cannot be so, otherwise the integral is infinite",
mcerr);
753 if (energy < threshold || energy == DBL_MAX)
return 0.0;
754 return factor * (
pow(energy, -power));
759 if (energy2 < threshold)
return 0.0;
760 if (energy1 < threshold) energy1 = threshold;
762 if (energy2 == DBL_MAX) {
763 s = factor / (power - 1.) * (1. /
pow(energy1, power - 1.));
765 s = factor / (power - 1.) *
766 (1. /
pow(energy1, power - 1.) - 1. /
pow(energy2, power - 1.));
772 mfunnamep(
"void PhenoPhotoAbsCS::scale(double fact)");
778 Ifile <<
"PhenoPhotoAbsCS: name=" << name <<
" Z = " << Z << std::endl;
779 Ifile <<
" threshold = " << threshold <<
" power=" << power
780 <<
" factor=" << factor << std::endl;
878 mfunnamep(
"void AtomicSecondaryProducts::add_channel(...)");
881 long q_new = q_old + 1;
887 if (s_all_rest == 1) {
889 for (
long n = 0; n < q_old; ++n) {
893 fchannel_prob_dens = 1.0 - s;
899 for (
long n = 0; n < q_new; ++n) {
904 mcerr <<
"s > 1.0, s=" << s <<
'\n';
906 for (
long n = 0; n < q_new; ++n) {
917 mfunname(
"int AtomicSecondaryProducts::get_channel(...)");
918#ifdef DEBUG_PRINT_get_escape_particles
919 mcout <<
"AtomicSecondaryProducts::get_channel is started\n";
925#ifdef DEBUG_PRINT_get_escape_particles
937 for (
long n = 0; n < q; ++n) {
943#ifdef DEBUG_PRINT_get_escape_particles
951#ifdef DEBUG_PRINT_get_escape_particles
952 mcout <<
"AtomicSecondaryProducts::get_channel is finishing\n";
960 Ifile <<
"AtomicSecondaryProducts(l=" << l <<
"):\n";
962 Ifile <<
"number of channels=" << q <<
'\n';
964 for (
long n = 0; n < q; ++n) {
969 Ifile <<
"number of electrons=" << qel <<
'\n';
971 for (
long nel = 0; nel < qel; ++nel) {
977 Ifile <<
"number of photons=" << qph <<
'\n';
979 for (
long nph = 0; nph < qph; ++nph) {
993 double factual_minimal_threshold)
const {
994 mfunname(
"double AtomPhotoAbsCS::get_TICS(double energy, double "
995 "factual_minimal_threshold) const");
997 if (factual_minimal_threshold <= energy) {
1005 double energy1,
double energy2,
double factual_minimal_threshold)
const {
1006 mfunname(
"double AtomPhotoAbsCS::get_integral_TICS(double energy1, double "
1007 "energy2, double factual_minimal_threshold) const");
1009 if (factual_minimal_threshold <= energy2) {
1011 if (energy1 < factual_minimal_threshold) {
1012 energy1 = factual_minimal_threshold;
1020 double factual_minimal_threshold)
const {
1021 mfunname(
"double AtomPhotoAbsCS::get_TICS(int nshell, double energy, double "
1022 "factual_minimal_threshold) const");
1025 if (factual_minimal_threshold <= energy) {
1034 int nshell,
double energy1,
double energy2,
1035 double factual_minimal_threshold)
const {
1036 mfunname(
"double AtomPhotoAbsCS::get_integral_TICS(int nshell, double "
1037 "energy1, double energy2, double factual_minimal_threshold) const");
1040 if (factual_minimal_threshold <= energy1) {
1044 if (factual_minimal_threshold >= energy2)
return 0.0;
1051 mfunname(
"void AtomPhotoAbsCS::remove_shell(int nshell)");
1057 mfunname(
"void AtomPhotoAbsCS::restore_shell(int nshell)");
1063 mfunnamep(
"void AtomPhotoAbsCS::print(std::ostream& file, int l) const");
1065 Ifile <<
"AtomPhotoAbsCS(l=" << l <<
"): name=" <<
name <<
" Z = " <<
Z
1066 <<
" qshell = " <<
qshell << std::endl;
1068 long q =
asp.get_qel();
1072 for (
long n = 0; n < q; ++n) {
1080 for (
long n = 0; n < q; ++n) {
1096 mfunname(
"double AtomPhotoAbsCS::get_I_min(void) const");
1097 double st = DBL_MAX;
1098 for (
int n = 0; n <
qshell; ++n) {
1109 mfunname(
"void AtomPhotoAbsCS::get_escape_particles(...)");
1110#ifdef DEBUG_PRINT_get_escape_particles
1111 mcout <<
"AtomPhotoAbsCS::get_escape_particles is started\n";
1129 double st = DBL_MAX;
1130 for (
int n = 0; n <
qshell; ++n) {
1138#ifdef DEBUG_PRINT_get_escape_particles
1141 if (nshell == n_min) {
1169#ifdef DEBUG_PRINT_get_escape_particles
1172#ifndef DEBUG_ignore_non_standard_channels
1175 is =
asp[nshell].get_channel(felectron_energy, fphoton_energy);
1182#ifdef DEBUG_PRINT_get_escape_particles
1195 int main_n_largest = 0;
1196 for (
int n = 0; n <
qshell; ++n) {
1198 if (t > main_n_largest) main_n_largest = t;
1200#ifdef DEBUG_PRINT_get_escape_particles
1203 if (main_n_largest - main_n >= 2) {
1208 double thr = DBL_MAX;
1210 for (
int n = 0; n <
qshell; ++n) {
1214 if (main_n_t > 0 && main_n_t == main_n + 1) {
1221#ifdef DEBUG_PRINT_get_escape_particles
1225 double e_temp = 0.0;
1232 el_energy[1] = e_temp;
1240 el_energy[2] = e_temp;
1243 el_energy[3] = el_energy[2];
1252 el_energy[1] = e_temp;
1260 el_energy[2] = e_temp;
1305 long q = felectron_energy.
get_qel();
1306 for (
long n = 0; n < q; ++n) {
1309 el_energy[1 + n] = felectron_energy[n] - hdist;
1310 if (el_energy[1 + n] < 0) {
1311 hdist = -el_energy[1 + n];
1312 el_energy[1 + n] = 0.0;
1319 for (
long n = 0; n < q; ++n) {
1322 ph_energy[n] = fphoton_energy[n] - hdist;
1323 if (ph_energy[n] < 0) {
1324 hdist = -ph_energy[n];
1332#ifdef DEBUG_PRINT_get_escape_particles
1335 mcout <<
"AtomPhotoAbsCS::get_escape_particles: exitting\n";
1340 mfunnamep(
"AtomicSecondaryProducts* AtomPhotoAbsCS::get_asp(int nshell)");
1342 return &(
asp[nshell]);
1348 : file_name(ffile_name) {
1349 mfunnamep(
"SimpleAtomPhotoAbsCS::SimpleAtomPhotoAbsCS(int fZ, const String& "
1373 for (
int nshell = 0; nshell <
qshell; ++nshell) {
1393 double st = DBL_MAX;
1394 for (
int nshell = 0; nshell <
qshell; ++nshell) {
1399 for (
int nshell = 0; nshell <
qshell; ++nshell) {
1400 if (fl[nshell] > 0) {
1405 asp[nshell].add_channel(fl[nshell], felectron_energy, fphoton_energy);
1412 mcerr <<
"there is no element Z=" << fZ <<
" in file " <<
file_name
1418 mfunname(
"SimpleAtomPhotoAbsCS::SimpleAtomPhotoAbsCS(int fZ, const "
1419 "PhotoAbsCS& facs)");
1425 name = facs.get_name();
1431 mfunname(
"double SimpleAtomPhotoAbsCS::get_threshold(int nshell) const");
1433 return acs[nshell]->get_threshold();
1437 mfunname(
"double SimpleAtomPhotoAbsCS::get_ACS(double energy) const");
1439 for (
int n = 0; n <
qshell; ++n) {
1441 s +=
acs[n]->get_CS(energy);
1447 double energy2)
const {
1449 "double SimpleAtomPhotoAbsCS::get_integral_ACS(double energy)const");
1451 for (
int n = 0; n <
qshell; ++n) {
1454 s += (t =
acs[n]->get_integral_CS(energy1, energy2));
1469 mfunname(
"double SimpleAtomPhotoAbsCS::get_ACS(int nshell, double energy)");
1472 return acs[nshell]->get_CS(energy);
1478 double energy2)
const {
1479 mfunname(
"double SimpleAtomPhotoAbsCS::get_integral_ACS(int nshell, double "
1480 "energy1, double energy2)");
1483 return acs[nshell]->get_integral_CS(energy1, energy2);
1489 mfunname(
"double SimpleAtomPhotoAbsCS::get_ICS(double energy) const");
1491 for (
int n = 0; n <
qshell; ++n) {
1493 s +=
acs[n]->get_CS(energy);
1500 double energy2)
const {
1501 mfunname(
"double SimpleAtomPhotoAbsCS::get_integral_ICS(double energy1, "
1502 "double energy2) const");
1504 for (
int n = 0; n <
qshell; ++n) {
1506 s +=
acs[n]->get_integral_CS(energy1, energy2);
1513 mfunname(
"double SimpleAtomPhotoAbsCS::get_ICS(int nshell, double energy)");
1516 return acs[nshell]->get_CS(energy);
1522 double energy2)
const {
1523 mfunname(
"double SimpleAtomPhotoAbsCS::get_integral_ICS(int nshell, double "
1524 "energy1, double energy2)");
1527 return acs[nshell]->get_integral_CS(energy1, energy2);
1534 Ifile <<
"SimpleAtomPhotoAbsCS(l=" << l <<
"): name=" <<
name
1535 <<
" Z = " <<
Z <<
" qshell = " <<
qshell
1536 <<
" file_name=" <<
file_name << std::endl;
1540 for (
int n = 0; n <
qshell; ++n) {
1541 Ifile <<
"nshell=" << n << std::endl;
1542 acs[n].print(file, l);
1551 mfunname(
"int SimpleAtomPhotoAbsCS::get_main_shell_number(int nshell) const");
1552 String shell_name =
acs[nshell]->get_name();
1553#ifdef STRSTREAM_AVAILABLE
1555 istrstream sfile(shell_name.c_str());
1557 istrstream sfile(shell_name);
1560 std::istringstream sfile(shell_name.c_str());
1567 if (i < 1 || i > 50) {
1576 const String& fsimple_table_file_name,
1578 double fminimal_threshold)
1579 : threshold_file_name(fthreshold_file_name),
1580 simple_table_file_name(fsimple_table_file_name),
1581 BT_file_name(
"none"),
1582 minimal_threshold(fminimal_threshold) {
1583 mfunnamep(
"SimpleAtomPhotoAbsCS::SimpleAtomPhotoAbsCS(int fZ, const String& "
1584 "fname, , const String& fthreshold_file_name, const String& "
1585 "fsimple_table_file_name, double fminimal_threshold)");
1593 if (!threshold_file) {
1602 while (
findmark(threshold_file,
"#") == 1) {
1603 threshold_file >>
Z;
1605 threshold_file >>
qshell;
1616 threshold_file >> temp_name;
1617 if (fname ==
"none")
1623 for (nshell = 0; nshell <
qshell; nshell++) {
1624 threshold_file >> thr[nshell];
1626 thr[nshell] *= 1.0e-6;
1627 threshold_file >> Zshell[nshell];
1629 sZshell += Zshell[nshell];
1630 threshold_file >> fl[nshell];
1632 threshold_file >> shell_name[nshell];
1638 double st = DBL_MAX;
1639 for (nshell = 0; nshell <
qshell;
1643 if (thr[nshell] < st) {
1648 for (nshell = 0; nshell <
qshell; nshell++) {
1649 if (fl[nshell] > 0) {
1653 fphoton_energy[0] = thr[nshell] - thr[n_min];
1654 asp[nshell].add_channel(fl[nshell], felectron_energy, fphoton_energy);
1673 for (n = 0; n <
qshell; n++)
1689 if (ener[0] < thr[
qshell - 1]) {
1691 for (ne = 0; ne < ener.
get_qel() && (ener[ne] < thr[
qshell - 1] ||
1692 (ener[ne] >= thr[
qshell - 1] &&
1693 ne > 1 && CS[ne - 1] <= CS[ne - 2]));
1695 if (ne > 0) left_CS[ne - 1] = 0.0;
1712 for (nt = nct; nt >= 0; nt--) {
1714 if (thr[nt] > ener[nce]) {
1719 if (thr[nt] > ener[nce + 1]) {
1728 int nce_next = ener.
get_qel();
1735 for (ne = nce; ne < ener.
get_qel();
1737 if (thr[nt] <= ener[ne]) {
1750 if (ne > 1 && ne < ener.
get_qel() - 1 && ne > nce + 2 &&
1751 thr[nt] <= ener[ne + 1] &&
1752 (thr[nt] - ener[ne]) / (ener[ne + 1] - ener[ne]) < 0.1 &&
1753 CS[ne] > CS[ne - 1]) {
1766 int qt = nt1 - nt2 + 1;
1770 for (nt = 0; nt < qt; nt++) {
1771 int nshell = nct - nt;
1772 s += Zshell[nshell];
1774 for (nt = 0; nt < qt; nt++) {
1775 int nshell = nct - nt;
1776 w[nt] = double(Zshell[nshell]) / s;
1778 double save_left_CS = left_CS[nce_next - 1];
1780 for (ne = 0; ne < nce_next; ne++) {
1781 for (nt = 0; nt < qt; nt++) {
1782 int nshell = nct - nt;
1783 SCS[nshell][ne] = left_CS[ne] * w[nt];
1787 for (ne = nce_next; ne < ener.
get_qel(); ne++) {
1789 save_left_CS *
pow(ener[nce_next - 1], 2.75) /
pow(ener[ne], 2.75);
1790 if (extrap_CS > left_CS[ne]) extrap_CS = left_CS[ne];
1791 for (nt = 0; nt < qt; nt++) {
1792 int nshell = nct - nt;
1793 SCS[nshell][ne] = extrap_CS * w[nt];
1795 left_CS[ne] -= extrap_CS;
1799 }
while (s_more != 0);
1805 for (ns = 0; ns < nt2; ns++) {
1809 for (ns = nt2; ns <
qshell; ns++) {
1814 shell_name[ns], Zshell[ns], thr[ns], ener, SCS[ns]);
1825 if (pred_integ > integ) {
1847 }
else if (pred_integ < integ) {
1849 const double fact = pred_integ / integ;
1850 for (
int nshell = 0; nshell <
qshell; ++nshell) {
1851 acs[nshell]->scale(fact);
1861 const String& fBT_file_name,
int id,
1862 double fminimal_threshold)
1863 : threshold_file_name(
"none"),
1864 simple_table_file_name(
"none"),
1865 BT_file_name(fBT_file_name),
1866 minimal_threshold(fminimal_threshold) {
1867 mfunnamep(
"ExAtomPhotoAbsCS::ExAtomPhotoAbsCS(int fZ, const String& fname, "
1868 "const String& fBT_file_name, int id, double fminimal_threshold)");
1886 int i =
findmark(BT_file,
"NUCLEAR CHARGE =");
1889 BT_file >> Z_from_file;
1892 while ((i =
findmark(BT_file,
"Z =")) == 1) {
1896 BT_file >> shellname;
1918 for (nen = 0; nen < qen; nen++) {
1919 BT_file >> fener[nen] >> fcs[nen];
1922 fener[nen] *= 1.0e-3;
1933 double st = DBL_MAX;
1934 for (
int nshell = 0; nshell <
qshell; ++nshell) {
1937 if (thresh[nshell] < st) {
1939 st = thresh[nshell];
1943 for (
int nshell = 0; nshell <
qshell; ++nshell) {
1944 if (fl[nshell] > 0) {
1948 fphoton_energy[0] = thresh[nshell] - thresh[n_min];
1949 asp[nshell].add_channel(fl[nshell], felectron_energy, fphoton_energy);
1963 if (pred_integ > integ) {
1980 const double fact = pred_integ / integ;
1981 for (
int nshell = 0; nshell <
qshell; ++nshell) {
1982 acs[nshell]->scale(fact);
1990#define READ_FILE_WITH_PRINCIPAL_NUMBERS
1993 const String& fFitBT_file_name,
1996 int s_no_scale,
double fminimal_threshold)
1997 : threshold_file_name(
"none"),
1998 simple_table_file_name(
"none"),
1999 BT_file_name(fFitBT_file_name),
2000 minimal_threshold(fminimal_threshold) {
2002 "ExAtomPhotoAbsCS::ExAtomPhotoAbsCS(int fZ, const String& fname, const "
2003 "String& fFitBT_file_name, int id, int id1, double fminimal_threshold)");
2009 std::ifstream BT_file(fFitBT_file_name.c_str());
2011 std::ifstream BT_file(fFitBT_file_name);
2022 while ((i =
findmark(BT_file,
"$")) == 1) {
2036 for (
int nshell = 0; nshell <
qshell; ++nshell) {
2037#ifdef READ_FILE_WITH_PRINCIPAL_NUMBERS
2047 if (BT_file.eof()) {
2051 if (!BT_file.good()) {
2055#ifdef READ_FILE_WITH_PRINCIPAL_NUMBERS
2057 if (!BT_file.good()) {
2063 BT_file >> l >> threshold >> E0 >> sigma >> ya >> P >> yw;
2066 threshold *= 1.0e-6;
2070 "n_princ=" << n_princ <<
" l=" << l <<
'\n',
mcerr);
2074 if (BT_file.eof()) {
2078 if (!BT_file.good()) {
2085 thresh[nshell] = threshold;
2088#ifdef READ_FILE_WITH_PRINCIPAL_NUMBERS
2097 threshold, l, E0, yw, ya, P, sigma));
2107 mcerr <<
"there is no element Z=" << fZ <<
" in file " << fFitBT_file_name
2114 double st = DBL_MAX;
2115 for (
int nshell = 0; nshell <
qshell; ++nshell) {
2118 if (thresh[nshell] < st) {
2120 st = thresh[nshell];
2124 for (
int nshell = 0; nshell <
qshell; ++nshell) {
2125 if (fl[nshell] > 0) {
2129 fphoton_energy[0] = thresh[nshell] - thresh[n_min];
2130 asp[nshell].add_channel(fl[nshell], felectron_energy, fphoton_energy);
2144 if (pred_integ > integ) {
2161 const double fact = pred_integ / integ;
2162 for (
int nshell = 0; nshell <
qshell; ++nshell) {
2163 acs[nshell]->scale(fact);
2172 int fZ,
const String& fname,
2173 const String& fFitBT_file_name,
2176 const String& fsimple_table_file_name,
2177 double emax_repl,
int id,
2178 double fminimal_threshold) {
2179 mfunname(
"ExAtomPhotoAbsCS::ExAtomPhotoAbsCS(...)");
2185 fFitBT_file_name,
id, s_no_scale, fminimal_threshold);
2190 double thrmin = DBL_MAX;
2193 for (
long ns = 0; ns <
qshell; ++ns) {
2197 thrmin =
acs[ns]->get_threshold();
2203 ActivePtr<PhotoAbsCS> facs =
acs[nsmin];
2204 PhotoAbsCS* apacs = facs.get();
2298 if (pred_integ > integ) {
2315 const double fact = pred_integ / integ;
2316 for (
int nshell = 0; nshell <
qshell; ++nshell) {
2317 acs[nshell]->scale(fact);
2326 mfunname(
"double ExAtomPhotoAbsCS::get_threshold(int nshell) const");
2328 double r =
acs[nshell]->get_threshold();
2336 mfunname(
"double ExAtomPhotoAbsCS::get_ACS(double energy) const");
2338 for (
int n = 0; n <
qshell; ++n) {
2341 const double t =
acs[n]->get_threshold();
2346 s +=
acs[n]->get_CS(energy - shift);
2354 double energy2)
const {
2355 mfunname(
"double ExAtomPhotoAbsCS::get_integral_ICS(double energy)const");
2357 for (
int n = 0; n <
qshell; ++n) {
2360 const double t =
acs[n]->get_threshold();
2364 s +=
acs[n]->get_integral_CS(energy1 - shift, energy2 - shift);
2371 mfunname(
"double ExAtomPhotoAbsCS::get_ICS(int nshell, double energy)");
2375 const double t =
acs[nshell]->get_threshold();
2379 return acs[nshell]->get_CS(energy - shift);
2385 double energy2)
const {
2386 mfunname(
"double ExAtomPhotoAbsCS::get_integral_ICS(int nshell, double "
2387 "energy1, double energy2)");
2391 const double t =
acs[nshell]->get_threshold();
2395 return acs[nshell]->get_integral_CS(energy1 - shift, energy2 - shift);
2401 mfunname(
"double ExAtomPhotoAbsCS::get_ACS(double energy) const");
2403 for (
int n = 0; n <
qshell; ++n) {
2406 const double t =
acs[n]->get_threshold();
2410 s +=
acs[n]->get_CS(energy - shift);
2420 double energy2)
const {
2421 mfunname(
"double ExAtomPhotoAbsCS::get_integral_ACS(double energy1, double "
2424 for (
int n = 0; n <
qshell; ++n) {
2427 const double t =
acs[n]->get_threshold();
2431 s +=
acs[n]->get_integral_CS(energy1 - shift, energy2 - shift);
2449 mfunname(
"double ExAtomPhotoAbsCS::get_ACS(int nshell, double energy)");
2453 const double t =
acs[nshell]->get_threshold();
2457 double s =
acs[nshell]->get_CS(energy - shift);
2467 double energy2)
const {
2468 mfunname(
"double ExAtomPhotoAbsCS::get_integral_ACS(int nshell, double "
2469 "energy1, double energy2)");
2473 const double t =
acs[nshell]->get_threshold();
2477 double s =
acs[nshell]->get_integral_CS(energy1 - shift, energy2 - shift);
2479 if (nshell ==
qshell - 1) {
2494 Ifile <<
"ExAtomPhotoAbsCS(l=" << l <<
"): name=" <<
name <<
" Z = " <<
Z
2495 <<
" qshell = " <<
qshell << std::endl;
2507 <<
" exener=" <<
exener[0] <<
' ' <<
exener[1] <<
'\n';
2509 Ifile <<
"integrals by shells:\n";
2510 Ifile <<
"nshell, int(acs), int(ics)\n";
2511 for (
long n = 0; n <
qshell; n++) {
2514 Ifile << n <<
" " << ainteg <<
" " << iinteg <<
'\n';
2520 for (
long n = 0; n <
qshell; ++n) {
2521 Ifile <<
"nshell=" << n << std::endl;
2522 acs[n].print(file, l);
2532 mfunname(
"int ExAtomPhotoAbsCS::get_main_shell_number(int nshell) const");
2533 String shell_name =
acs[nshell]->get_name();
2534#ifdef STRSTREAM_AVAILABLE
2536 istrstream sfile(shell_name.c_str());
2538 istrstream sfile(shell_name);
2541 std::istringstream sfile(shell_name.c_str());
2548 if (i < 1 || i > 50) {
2557 mfunname(
"void ExAtomPhotoAbsCS::replace_shells_by_overage(...)");
2558 for (
long n = 0; n <
qshell; n++) {
2573 double fW,
double fF)
2585 double fW,
double fF)
2587 qatom = fqatom_ps1 + fqatom_ps2;
2590 qatom_ps[0] = fqatom_ps1;
2591 qatom_ps[1] = fqatom_ps2;
2595#ifdef CALC_W_USING_CHARGES
2596 W =
coef_I_to_W * (qatom_ps[0] * atom[0]->get_Z() * atom[0]->get_I_min() +
2597 qatom_ps[1] * atom[1]->get_Z() * atom[1]->get_I_min()) /
2598 (qatom_ps[0] * atom[0]->get_Z() + qatom_ps[1] * atom[1]->get_Z());
2600 W =
coef_I_to_W * (qatom_ps[0] * atom[0]->get_I_min() +
2601 qatom_ps[1] * atom[1]->get_I_min()) / qatom;
2609 double fW,
double fF)
2611 qatom = fqatom_ps1 + fqatom_ps2 + fqatom_ps3;
2614 qatom_ps[0] = fqatom_ps1;
2615 qatom_ps[1] = fqatom_ps2;
2616 qatom_ps[2] = fqatom_ps3;
2621#ifdef CALC_W_USING_CHARGES
2622 W =
coef_I_to_W * (qatom_ps[0] * atom[0]->get_Z() * atom[0]->get_I_min() +
2623 qatom_ps[1] * atom[1]->get_Z() * atom[1]->get_I_min() +
2624 qatom_ps[2] * atom[2]->get_Z() * atom[2]->get_I_min()) /
2625 (qatom_ps[0] * atom[0]->get_Z() + qatom_ps[1] * atom[1]->get_Z() +
2626 qatom_ps[2] * atom[2]->get_Z());
2628 W =
coef_I_to_W * (qatom_ps[0] * atom[0]->get_I_min() +
2629 qatom_ps[1] * atom[1]->get_I_min() +
2630 qatom_ps[2] * atom[2]->get_I_min()) / qatom;
2636 mfunname(
"double MolecPhotoAbsCS::get_ACS(double energy) const");
2637 const long q = qatom_ps.
get_qel();
2639 for (
long n = 0; n < q; n++) {
2640 s += qatom_ps[n] * atom[n]->get_ACS(energy);
2646 mfunname(
"double MolecPhotoAbsCS::get_integral_ACS(double energy1, double "
2648 const long q = qatom_ps.
get_qel();
2650 for (
long n = 0; n < q; n++) {
2651 s += qatom_ps[n] * atom[n]->get_integral_ACS(energy1, energy2);
2657 mfunname(
"double MolecPhotoAbsCS::get_ICS(double energy) const");
2658 const long q = qatom_ps.
get_qel();
2660 for (
long n = 0; n < q; n++) {
2661 s += qatom_ps[n] * atom[n]->get_ICS(energy);
2667 mfunname(
"double MolecPhotoAbsCS::get_integral_ICS(double energy1, double "
2669 const long q = qatom_ps.
get_qel();
2671 for (
long n = 0; n < q; n++) {
2672 s += qatom_ps[n] * atom[n]->get_integral_ICS(energy1, energy2);
2678 mfunname(
"int MolecPhotoAbsCS::get_total_Z() const");
2680 const long q = qatom_ps.
get_qel();
2681 for (
long n = 0; n < q; n++) {
2682 s += atom[n]->get_Z();
2688 Ifile <<
"MolecPhotoAbsCS (l=" << l <<
"):\n";
2692 const long q = qatom_ps.
get_qel();
2693 Ifile <<
"number of sorts of atoms is " << q <<
'\n';
2695 for (
long n = 0; n < q; n++) {
2696 Ifile <<
"n=" << n <<
" qatom_ps[n]=" << qatom_ps[n] <<
" atom:\n";
2697 atom[n]->print(file, l);
DoubleAc pow(const DoubleAc &f, double p)
DoubleAc sqrt(const DoubleAc &f)
DoubleAc find_min(const DoubleAc &a, const DoubleAc &b)
DoubleAc find_max(const DoubleAc &a, const DoubleAc &b)
#define check_econd21(a, sign1_b1_sign0, sign2_b2, stream)
#define check_econd11(a, signb, stream)
#define check_econd11a(a, signb, add, stream)
#define mfunnamep(string)
#define check_econd12(a, sign, b, stream)
String long_to_String(long n)
void increment(const T *val=NULL)
void pass(long fqel, T *fel)
virtual void remove_shell(int nshell)
virtual double get_ACS(double energy) const =0
virtual int get_main_shell_number(int nshell) const =0
virtual void print(std::ostream &file, int l) const
virtual double get_TICS(double energy, double factual_minimal_threshold) const
virtual double get_threshold(int nshell) const =0
DynLinArr< int > s_ignore_shell
virtual double get_integral_TICS(double energy1, double energy2, double factual_minimal_threshold) const
virtual void get_escape_particles(int nshell, double energy, DynLinArr< double > &el_energy, DynLinArr< double > &ph_energy) const
DynLinArr< AtomicSecondaryProducts > asp
virtual void restore_shell(int nshell)
virtual double get_I_min(void) const
AtomicSecondaryProducts * get_asp(int nshell)
virtual double get_integral_ACS(double energy1, double energy2) const =0
int get_channel(DynLinArr< double > &felectron_energy, DynLinArr< double > &fphoton_energy) const
DynLinArr< DynLinArr< double > > photon_energy
DynLinArr< double > channel_prob_dens
virtual void print(std::ostream &file, int l) const
DynLinArr< DynLinArr< double > > electron_energy
void add_channel(double fchannel_prob_dens, const DynLinArr< double > &felectron_energy, const DynLinArr< double > &fphoton_energy, int s_all_rest=0)
double integ_abs_before_corr
String simple_table_file_name
double height_of_excitation
virtual double get_threshold(int nshell) const
double integ_ioniz_after_corr
void replace_shells_by_overage(double fwidth, double fstep, long fmax_q_step)
virtual double get_integral_ACS(double energy1, double energy2) const
virtual double get_ACS(double energy) const
virtual int get_main_shell_number(int nshell) const
DynLinArr< ActivePtr< PhotoAbsCS > > acs
String threshold_file_name
virtual void print(std::ostream &file, int l) const
virtual double get_ICS(double energy) const
virtual double get_integral_ICS(double energy1, double energy2) const
double integ_abs_after_corr
virtual void print(std::ostream &file, int l) const
virtual double get_CS(double energy) const
virtual double get_integral_CS(double energy1, double energy2) const
virtual void scale(double fact)
virtual double get_ACS(double energy) const
virtual double get_ICS(double energy) const
virtual double get_integral_ICS(double energy1, double energy2) const
virtual double get_integral_ACS(double energy1, double energy2) const
virtual void print(std::ostream &file, int l) const
virtual void print(std::ostream &file, int l) const
virtual double get_integral_CS(double energy1, double energy2) const
virtual void scale(double fact)
virtual double get_CS(double energy) const
virtual double get_integral_CS(double energy1, double energy2) const
virtual double get_CS(double energy) const
virtual void print(std::ostream &file, int l) const
virtual void scale(double fact)
SimpleAtomPhotoAbsCS(void)
virtual double get_ACS(double energy) const
virtual void print(std::ostream &file, int l) const
virtual int get_main_shell_number(int nshell) const
virtual double get_integral_ACS(double energy1, double energy2) const
virtual double get_integral_ICS(double energy1, double energy2) const
DynLinArr< ActivePtr< PhotoAbsCS > > acs
virtual double get_threshold(int nshell) const
virtual double get_ICS(double energy) const
virtual double get_integral_CS(double energy1, double energy2) const
void remove_leading_tiny(double level)
virtual double get_CS(double energy) const
virtual void print(std::ostream &file, int l) const
const DynLinArr< double > & get_arr_CS() const
const DynLinArr< double > & get_arr_ener() const
virtual void scale(double fact)
void remove_leading_zeros(void)
int findmark(std::istream &file, const char *s)
DynLinArr< double > make_log_mesh_ec(double emin, double emax, long q)
double my_integr_fun(double xp1, double yp1, double xp2, double yp2, double xmin, double, double x1, double x2)
const int s_scale_to_normalize_if_more
const double low_boundary_of_excitations
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
const double Thomas_sum_rule_const_Mb
double glin_integ_ar(DynLinArr< double > x, DynLinArr< double > y, long q, double x1, double x2, double threshold)
const int s_add_excitations_to_normalize
int sign_nonlinear_interpolation(double e1, double cs1, double e2, double cs2, double threshold)
double my_val_fun(double xp1, double yp1, double xp2, double yp2, double xmin, double, double x)
#define Iprint(file, name)
#define Iprintn(file, name)
#define Iprint2n(file, name1, name2)
T t_integ_generic_point_ar(const M &mesh, const D &y, T(*fun)(T xp1, T yp1, T xp2, T yp2, T xmin, T xmax, T x1, T x2), T x1, T x2, int s_extrap_left, T left_bond, int s_extrap_right, T right_bond)
T t_value_generic_point_ar(const M &mesh, const D &y, T(*funval)(T xp1, T yp1, T xp2, T yp2, T xmin, T xmax, T x), T x, int s_extrap_left, T left_bond, int s_extrap_right, T right_bond)