342 {
343 mfunnamep(
"double ElElasticScat::fill_hist_low_scat(const String& file_name, "
344 "const String& file_name_dist)");
345 int s_write_dist = 0;
346 if (file_name_dist !=
String(
"") && file_name_dist !=
String(
"none"))
347 s_write_dist = 1;
348 const long qh = 100;
349 long qa = atom.get_qel();
350
351 long ne;
352 long nq;
353 const long qquan = 4;
354 long quan[qquan] = { 5, 10, 20, 40 };
355
356
357
358 long zmax = atom[qa - 1].Z;
359
364
365
368
371
372 long n;
373
374
375
376
377
378
379
380
381
382
383
384 angular_mesh_c[0] = 0.0;
385 double amin = 0.3;
386 double amax = 180.0;
388 double ar = amin;
389 angular_mesh_c[1] = ar;
391 angular_mesh_c[n] = angular_mesh_c[n - 1] * rk;
392 }
394
395#ifdef USE_STLSTRING
396 std::ofstream ofile(file_name.c_str());
397#else
398 std::ofstream ofile(file_name);
399#endif
400 if (!ofile) {
402 mcerr <<
"cannot open file " << file_name << endl;
404 }
405 long za;
406 ofile << "this file is created by function void "
407 "ElElasticScat::fill_hist_low_scat(void)\n";
408 ofile << "This is new format, in which the mean of 1 - cos(theta) is "
409 "inserted\n";
410 ofile << " format:\nnumber of atoms maximal number of interactions,\nthen "
411 "loop by atoms:\nZ of atom\n";
412
413 ofile << "ne energy_mesh[ne] (mean of 1 - cos(theta)) (sqrt(mean of "
414 "(1-coef)^2)\n";
415
416
417 ofile << "dollar sign means starting of this format\n";
418 ofile << "$\n" << zmax << ' ' << quan[qquan - 1] << '\n';
419 for (za = 1; za <= zmax; za++) {
420
421
422
423 mcout <<
"starting calculate za=" << za << endl;
424 ofile << za << '\n';
425
427
429 sigma_coef_hist[za - 1] = histdef(name, qe, 0.0, qe);
430 sigma_coef_hist[za - 1].init();
431
432 for (ne = 0; ne < qe; ne++) {
433 mcout <<
"starting calculate ne=" << ne << endl;
434
435 double energy = energy_mesh[ne] * 0.001;
437 long nan;
439 double angle = angular_mesh_c[nan] / 180.0 * M_PI;
440 double s =
get_CS(za, energy, angle);
441
442
443
444 s = s * 2.0 * M_PI *
sin(angle);
445
446 cs[nan] = s;
447 }
451 for (nq = 0; nq < qquan; nq++) {
453
456 ang_hist.ac(za - 1, ne, nq) = histdef(name, 1000, -1.0, 1.0);
457 ang_hist.ac(za - 1, ne, nq).init();
458
459
460 }
462
464
465
466
467
468 mean_hist.ac(za - 1, ne) =
469 histdef(name, quan[qquan - 1] + 1, -0.5, quan[qquan - 1] + 0.5);
470
471
472 mean_hist.ac(za - 1, ne).init();
474 sigma_hist.ac(za - 1, ne) =
475 histdef(name, quan[qquan - 1] + 1, -0.5, quan[qquan - 1] + 0.5);
476
477
478 sigma_hist.ac(za - 1, ne).init();
479
480 long qev = 100000;
481 long nev;
482 long ncs;
483 for (nev = 0; nev < qev; nev++) {
484 nq = 0;
486 for (ncs = 0; ncs < quan[qquan - 1]; ncs++) {
487
488 basis temp(dir,
"temp");
489
490 double theta_rot = angular_points_ran.ran(
SRANLUX());
491
492
493
494
497 vturn = vturn *
sin(theta_rot / 180.0 * M_PI);
498 vec new_dir(vturn.
x, vturn.
y,
cos(theta_rot / 180.0 * M_PI));
499 new_dir.down(&temp);
500
502 length(new_dir));
504
505 dir = new_dir;
506 double ctheta =
cos(theta);
507 if (ncs == quan[nq] - 1)
508 {
509 ang_hist.ac(za - 1, ne, nq).fill(ctheta, 0.0, 1.0);
510
511 nq++;
512 }
513 mean[ncs] += 1.0 - ctheta;
514 disp[ncs] += (ctheta - 1.0) * (ctheta - 1.0);
515 }
516 }
517 nq = 0;
518 for (ncs = 0; ncs < quan[qquan - 1]; ncs++) {
519 mean[ncs] = mean[ncs] / qev;
520 disp[ncs] =
sqrt(disp[ncs] / (qev - 1));
521
522
523 mean_hist.ac(za - 1, ne).fill(ncs + 1, 0.0, mean[ncs]);
524 sigma_hist.ac(za - 1, ne).fill(ncs + 1, 0.0, disp[ncs]);
525 if (ncs == quan[nq] - 1)
526 {
527 mea_ang_hist.ac(za - 1, ne, nq) = mean[ncs];
528 sig_ang_hist.ac(za - 1, ne, nq) = disp[ncs];
529 nq++;
530 }
531 }
532
533 double mean_coef = 0.0;
534 long ns = 0;
535 for (ncs = 0; ncs < quan[qquan - 1]; ncs++) {
536 if (mean[ncs] < 0.4) {
537 mean_coef += mean[ncs] / (ncs + 1.0);
538 ns++;
539 }
540 }
541 mean_coef = mean_coef / ns;
542 double coef = 0.0;
543 ns = 0;
544 for (ncs = 0; ncs < quan[qquan - 1]; ncs++) {
545 if (disp[ncs] < 0.4) {
546 coef += disp[ncs] / (ncs + 1.0);
547 ns++;
548 }
549 }
550 coef = coef / ns;
551 sigma_coef_hist[za - 1].fill(ne, 0.0, coef);
552 ofile << ne << ' ' << setw(12) << energy_mesh[ne] << ' ' << setw(12)
553 << mean_coef << ' ' << setw(12) << coef << '\n';
554 }
555 }
556 if (s_write_dist == 1) {
557#ifdef USE_STLSTRING
558 std::ofstream ofile(file_name_dist.c_str());
559#else
560 std::ofstream ofile(file_name_dist);
561#endif
562 if (!ofile) {
564 mcerr <<
"cannot open file " << file_name_dist << endl;
566 }
567 ofile << setw(5) << zmax << setw(5) << qe << setw(5) << qquan << '\n';
568 for (za = 1; za <= zmax; za++) {
569 for (ne = 0; ne < qe; ne++) {
570 for (nq = 0; nq < qquan; nq++) {
572 ang_hist.ac(za - 1, ne, nq).unpack(hi);
574 ofile << "\n# " << setw(5) << za << ' ' << setw(5) << ne << ' '
575 << setw(5) << nq << ' ' << setw(5) << q << ' ' << setw(15)
576 << mea_ang_hist.ac(za - 1, ne, nq) << ' ' << setw(15)
577 << sig_ang_hist.ac(za - 1, ne, nq) << '\n';
578 long n;
579 for (n = 0; n < q; n++) {
580
581 ofile << hi[n] << '\n';
582 }
583 }
584 }
585 }
586
587 }
588
589}
DoubleAc cos(const DoubleAc &f)
DoubleAc asin(const DoubleAc &f)
DoubleAc sqrt(const DoubleAc &f)
void random_round_vec(void)
const double low_cut_angle_deg
const long q_angular_mesh