-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdata.cpp
More file actions
2633 lines (2203 loc) · 87.1 KB
/
data.cpp
File metadata and controls
2633 lines (2203 loc) · 87.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Implements basic nuclear data functions.
#ifndef PYNE_IS_AMALGAMATED
#include "data.h"
#include "atomic_data.h"
#endif
//
// Math Helpers
//
const double pyne::pi = 3.14159265359;
const double pyne::N_A = 6.0221415e+23;
const double pyne::barns_per_cm2 = 1e24;
const double pyne::cm2_per_barn = 1e-24;
const double pyne::sec_per_day = 24.0 * 3600.0;
const double pyne::MeV_per_K = 8.617343e-11;
const double pyne::MeV_per_MJ = 6.2415096471204E+18;
const double pyne::Bq_per_Ci = 3.7e10;
const double pyne::Ci_per_Bq = 2.7027027e-11;
/********************************/
/*** data_checksums Functions ***/
/********************************/
std::map<std::string, std::string> pyne::get_data_checksums() {
std::map<std::string, std::string> temp_map;
// Initialization of dataset hashes
temp_map["/atomic_mass"]="10edfdc662e35bdfab91beb89285efff";
temp_map["/material_library"]="8b10864378fbd88538434679acf908cc";
temp_map["/neutron/eaf_xs"]="29622c636c4a3a46802207b934f9516c";
temp_map["/neutron/scattering_lengths"]="a24d391cc9dc0fc146392740bb97ead4";
temp_map["/neutron/simple_xs"]="3d6e086977783dcdf07e5c6b0c2416be";
temp_map["/decay"]="4f41f3e46f4306cc44449f08a20922e0";
temp_map["/dose_factors"]="dafa32c24b2303850a0bebdf3e6b122e";
return temp_map;
}
std::map<std::string, std::string> pyne::data_checksums =
pyne::get_data_checksums();
/*****************************/
/*** atomic_mass Functions ***/
/*****************************/
std::map<int, double> pyne::atomic_mass_map = std::map<int, double>();
void pyne::_load_atomic_mass_map() {
// Loads the important parts of atomic_wight table into atomic_mass_map
//Check to see if the file is in HDF5 format.
if (!pyne::file_exists(pyne::NUC_DATA_PATH)) {
pyne::_load_atomic_mass_map_memory();
return;
}
bool ish5 = H5Fis_hdf5(pyne::NUC_DATA_PATH.c_str());
if (!ish5)
throw h5wrap::FileNotHDF5(pyne::NUC_DATA_PATH);
// Get the HDF5 compound type (table) description
hid_t desc = H5Tcreate(H5T_COMPOUND, sizeof(atomic_mass_data));
H5Tinsert(desc, "nuc", HOFFSET(atomic_mass_data, nuc), H5T_NATIVE_INT);
H5Tinsert(desc, "mass", HOFFSET(atomic_mass_data, mass), H5T_NATIVE_DOUBLE);
H5Tinsert(desc, "error", HOFFSET(atomic_mass_data, error), H5T_NATIVE_DOUBLE);
H5Tinsert(desc, "abund", HOFFSET(atomic_mass_data, abund), H5T_NATIVE_DOUBLE);
// Open the HDF5 file
hid_t nuc_data_h5 = H5Fopen(pyne::NUC_DATA_PATH.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
// Open the data set
hid_t atomic_mass_set = H5Dopen2(nuc_data_h5, "/atomic_mass", H5P_DEFAULT);
hid_t atomic_mass_space = H5Dget_space(atomic_mass_set);
int atomic_mass_length = H5Sget_simple_extent_npoints(atomic_mass_space);
// Read in the data
atomic_mass_data * atomic_mass_array = new atomic_mass_data[atomic_mass_length];
H5Dread(atomic_mass_set, desc, H5S_ALL, H5S_ALL, H5P_DEFAULT, atomic_mass_array);
// close the nuc_data library, before doing anything stupid
H5Dclose(atomic_mass_set);
H5Fclose(nuc_data_h5);
// Ok now that we have the array of structs, put it in the map
for(int n = 0; n < atomic_mass_length; n++) {
atomic_mass_map.insert(std::pair<int, double>(atomic_mass_array[n].nuc, \
atomic_mass_array[n].mass));
natural_abund_map.insert(std::pair<int, double>(atomic_mass_array[n].nuc, \
atomic_mass_array[n].abund));
}
delete[] atomic_mass_array;
}
double pyne::atomic_mass(int nuc) {
// Find the nuclide's mass in AMU
std::map<int, double>::iterator nuc_iter, nuc_end;
nuc_iter = atomic_mass_map.find(nuc);
nuc_end = atomic_mass_map.end();
// First check if we already have the nuc mass in the map
if (nuc_iter != nuc_end) {
return (*nuc_iter).second;
}
// Next, fill up the map with values from the
// nuc_data.h5, if the map is empty.
if (atomic_mass_map.empty()) {
// Don't fail if we can't load the library
_load_atomic_mass_map();
return atomic_mass(nuc);
}
double aw;
int nucid = nucname::id(nuc);
// If in an excited state, return the ground
// state mass...not strictly true, but good guess.
if (0 < nucid%10000) {
aw = atomic_mass((nucid/10000)*10000);
if (atomic_mass_map.count(nuc) != 1) {
atomic_mass_map.insert(std::pair<int, double>(nuc, aw));
}
return aw;
};
// Finally, if none of these work,
// take a best guess based on the
// aaa number.
aw = (double) ((nucid/10000)%1000);
if (atomic_mass_map.count(nuc) != 1) {
atomic_mass_map.insert(std::pair<int, double>(nuc, aw));
}
return aw;
}
double pyne::atomic_mass(char * nuc) {
int nuc_zz = nucname::id(nuc);
return atomic_mass(nuc_zz);
}
double pyne::atomic_mass(std::string nuc) {
int nuc_zz = nucname::id(nuc);
return atomic_mass(nuc_zz);
}
/*******************************/
/*** natural_abund functions ***/
/*******************************/
std::map<int, double> pyne::natural_abund_map = std::map<int, double>();
double pyne::natural_abund(int nuc) {
// Find the nuclide's natural abundance
std::map<int, double>::iterator nuc_iter, nuc_end;
nuc_iter = natural_abund_map.find(nuc);
nuc_end = natural_abund_map.end();
// First check if we already have the nuc mass in the map
if (nuc_iter != nuc_end)
return (*nuc_iter).second;
// Next, fill up the map with values from the
// nuc_data.h5, if the map is empty.
if (natural_abund_map.empty()) {
// Don't fail if we can't load the library
_load_atomic_mass_map();
return natural_abund(nuc);
}
double na;
int nucid = nucname::id(nuc);
// If in an excited state, return the ground
// state abundance...not strictly true, but good guess.
if (0 < nucid%10000) {
na = natural_abund((nucid/10000)*10000);
natural_abund_map[nuc] = na;
return na;
}
// Finally, if none of these work,
// take a best guess based on the
// aaa number.
na = 0.0;
natural_abund_map[nuc] = na;
return na;
}
double pyne::natural_abund(char * nuc) {
int nuc_zz = nucname::id(nuc);
return natural_abund(nuc_zz);
}
double pyne::natural_abund(std::string nuc) {
int nuc_zz = nucname::id(nuc);
return natural_abund(nuc_zz);
}
/*************************/
/*** Q_value Functions ***/
/*************************/
void pyne::_load_q_val_map() {
// Loads the important parts of q_value table into q_value_map
//Check to see if the file is in HDF5 format.
if (!pyne::file_exists(pyne::NUC_DATA_PATH))
throw pyne::FileNotFound(pyne::NUC_DATA_PATH);
bool ish5 = H5Fis_hdf5(pyne::NUC_DATA_PATH.c_str());
if (!ish5)
throw h5wrap::FileNotHDF5(pyne::NUC_DATA_PATH);
// Get the HDF5 compound type (table) description
hid_t desc = H5Tcreate(H5T_COMPOUND, sizeof(q_val_data));
H5Tinsert(desc, "nuc", HOFFSET(q_val_data, nuc), H5T_NATIVE_INT);
H5Tinsert(desc, "q_val", HOFFSET(q_val_data, q_val), H5T_NATIVE_DOUBLE);
H5Tinsert(desc, "gamma_frac", HOFFSET(q_val_data, gamma_frac), H5T_NATIVE_DOUBLE);
// Open the HDF5 file
hid_t nuc_data_h5 = H5Fopen(pyne::NUC_DATA_PATH.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
// Open the data set
hid_t q_val_set = H5Dopen2(nuc_data_h5, "/decay/q_values", H5P_DEFAULT);
hid_t q_val_space = H5Dget_space(q_val_set);
int q_val_length = H5Sget_simple_extent_npoints(q_val_space);
// Read in the data
q_val_data * q_val_array = new q_val_data[q_val_length];
H5Dread(q_val_set, desc, H5S_ALL, H5S_ALL, H5P_DEFAULT, q_val_array);
// close the nuc_data library, before doing anything stupid
H5Dclose(q_val_set);
H5Fclose(nuc_data_h5);
// Ok now that we have the array of structs, put it in the map
for(int n = 0; n < q_val_length; n++) {
q_val_map[q_val_array[n].nuc] = q_val_array[n].q_val;
gamma_frac_map[q_val_array[n].nuc] = q_val_array[n].gamma_frac;
}
delete[] q_val_array;
}
std::map<int, double> pyne::q_val_map = std::map<int, double>();
double pyne::q_val(int nuc) {
// Find the nuclide's q_val in MeV/fission
std::map<int, double>::iterator nuc_iter, nuc_end;
nuc_iter = q_val_map.find(nuc);
nuc_end = q_val_map.end();
// First check if we already have the nuc q_val in the map
if (nuc_iter != nuc_end)
return (*nuc_iter).second;
// Next, fill up the map with values from the nuc_data.h5 if the map is empty.
if (q_val_map.empty()) {
_load_q_val_map();
return q_val(nuc);
};
double qv;
int nucid = nucname::id(nuc);
if (nucid != nuc)
return q_val(nucid);
// If nuclide is not found, return 0
qv = 0.0;
q_val_map[nuc] = qv;
return qv;
}
double pyne::q_val(const char * nuc) {
int nuc_zz = nucname::id(nuc);
return q_val(nuc_zz);
}
double pyne::q_val(std::string nuc) {
int nuc_zz = nucname::id(nuc);
return q_val(nuc_zz);
}
/****************************/
/*** gamma_frac functions ***/
/****************************/
std::map<int, double> pyne::gamma_frac_map = std::map<int, double>();
double pyne::gamma_frac(int nuc) {
// Find the nuclide's fraction of Q that comes from gammas
std::map<int, double>::iterator nuc_iter, nuc_end;
nuc_iter = gamma_frac_map.find(nuc);
nuc_end = gamma_frac_map.end();
// First check if we already have the gamma_frac in the map
if (nuc_iter != nuc_end)
return (*nuc_iter).second;
// Next, fill up the map with values from nuc_data.h5 if the map is empty.
if (gamma_frac_map.empty()) {
_load_q_val_map();
return gamma_frac(nuc);
}
double gf;
int nucid = nucname::id(nuc);
if (nucid != nuc)
return gamma_frac(nucid);
// If nuclide is not found, return 0
gf = 0.0;
gamma_frac_map[nucid] = gf;
return gf;
}
double pyne::gamma_frac(const char * nuc) {
int nuc_zz = nucname::id(nuc);
return gamma_frac(nuc_zz);
}
double pyne::gamma_frac(std::string nuc) {
int nuc_zz = nucname::id(nuc);
return gamma_frac(nuc_zz);
}
/*****************************/
/*** Dose Factor Functions ***/
/*****************************/
/***************************************************************************
This data is from: [Exposure Scenarios and Unit Dose Factors for the Hanford
Immobilized Low-Activity Tank Waste Performance Assessment, ref.
HNF-SD-WM-TI-707 Rev. 1 December 1999] Appendix O of HNF-5636 [DATA PACKAGES
FOR THE HANFORD IMMOBILIZED LOW-ACTIVITY TANK WASTE PERFORMANCE ASSESSMENT:
2001 VERSION]
Liability Disclaimer: The PyNE Development Team shall not be liable for any
loss or injury resulting from decisions made with this data.
**************************************************************************/
void pyne::_load_dose_map(std::map<int, dose>& dm, std::string source_path) {
herr_t status;
//Check to see if the file is in HDF5 format.
if (!pyne::file_exists(pyne::NUC_DATA_PATH))
throw pyne::FileNotFound(pyne::NUC_DATA_PATH);
bool ish5 = H5Fis_hdf5(pyne::NUC_DATA_PATH.c_str());
if (!ish5)
throw h5wrap::FileNotHDF5(pyne::NUC_DATA_PATH);
// Defining string type for lung model data
hid_t string_type_;
string_type_ = H5Tcopy(H5T_C_S1);
H5Tset_size(string_type_, 1);
H5Tset_strpad(string_type_, H5T_STR_NULLPAD);
// Get the HDF5 compound type (table) description
hid_t desc = H5Tcreate(H5T_COMPOUND, sizeof(dose));
status = H5Tinsert(desc, "nuc", HOFFSET(dose, nuc), H5T_NATIVE_INT);
status = H5Tinsert(desc, "ext_air_dose", HOFFSET(dose, ext_air_dose), H5T_NATIVE_DOUBLE);
status = H5Tinsert(desc, "ratio", HOFFSET(dose, ratio), H5T_NATIVE_DOUBLE);
status = H5Tinsert(desc, "ext_soil_dose", HOFFSET(dose, ext_soil_dose), H5T_NATIVE_DOUBLE);
status = H5Tinsert(desc, "ingest_dose", HOFFSET(dose, ingest_dose), H5T_NATIVE_DOUBLE);
status = H5Tinsert(desc, "fluid_frac", HOFFSET(dose, fluid_frac), H5T_NATIVE_DOUBLE);
status = H5Tinsert(desc, "inhale_dose", HOFFSET(dose, inhale_dose), H5T_NATIVE_DOUBLE);
status = H5Tinsert(desc, "lung_mod", HOFFSET(dose, lung_mod), string_type_);
// Open the HDF5 file
hid_t nuc_data_h5 = H5Fopen(pyne::NUC_DATA_PATH.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
// Convert source_path to proper format for HD5open
const char * c = source_path.c_str();
// Open the data set
hid_t dose_set = H5Dopen2(nuc_data_h5, c, H5P_DEFAULT);
hid_t dose_space = H5Dget_space(dose_set);
int dose_length = H5Sget_simple_extent_npoints(dose_space);
// Read in the data
dose * dose_array = new dose[dose_length];
H5Dread(dose_set, desc, H5S_ALL, H5S_ALL, H5P_DEFAULT, dose_array);
// Put array of structs in the map
for (int n = 0; n < dose_length; n++) {
dm[dose_array[n].nuc] = dose_array[n];
}
// Close the nuc_data library
H5Dclose(dose_set);
H5Tclose(string_type_);
H5Fclose(nuc_data_h5);
delete[] dose_array;
}
///
/// Functions for Source Location in nuc_data.h5
/// and related Map Pointers
///
std::string source_string(int source) {
std::string source_location;
if (source == 1) {
source_location = "/dose_factors/DOE";
} else if (source == 2) {
source_location = "/dose_factors/GENII";
} else {
source_location = "/dose_factors/EPA";
}
return source_location;
}
std::map<int, pyne::dose>& dose_source_map(int source) {
std::map<int, pyne::dose>* dm;
if (source == 1) {
dm = &pyne::doe_dose_map;
} else if (source == 2) {
dm = &pyne::genii_dose_map;
} else {
dm = &pyne::epa_dose_map;
}
if (dm->empty()) {
std::string source_path = source_string(source);
_load_dose_map(*dm, source_path);
}
return *dm;
}
std::map<int, pyne::dose> pyne::epa_dose_map;
std::map<int, pyne::dose> pyne::doe_dose_map;
std::map<int, pyne::dose> pyne::genii_dose_map;
///
/// Functions for External Air and
/// Ratio of External Air to Inhalation Dose Factors
///
/// External Air
double pyne::ext_air_dose(int nuc, int source) {
std::map<int, pyne::dose>& dm = dose_source_map(source);
int nucid = nucname::id(nuc);
if (dm.count(nucid)==1) {
return dm[nucid].ext_air_dose;
} else {
return -1;
}
}
double pyne::ext_air_dose(const char * nuc, int source) {
int nuc_zz = nucname::id(nuc);
return ext_air_dose(nuc_zz, source);
}
double pyne::ext_air_dose(std::string nuc, int source) {
int nuc_zz = nucname::id(nuc);
return ext_air_dose(nuc_zz, source);
}
/// Dose Ratio
double pyne::dose_ratio(int nuc, int source) {
std::map<int, pyne::dose>& dm = dose_source_map(source);
int nucid = nucname::id(nuc);
if (dm.count(nucid)==1) {
return dm[nucid].ratio;
} else {
return -1;
}
}
double pyne::dose_ratio(const char * nuc, int source) {
int nuc_zz = nucname::id(nuc);
return dose_ratio(nuc_zz, source);
}
double pyne::dose_ratio(std::string nuc, int source) {
int nuc_zz = nucname::id(nuc);
return dose_ratio(nuc_zz, source);
}
///
/// Function for External Soil Dose Factors
///
double pyne::ext_soil_dose(int nuc, int source) {
std::map<int, pyne::dose>& dm = dose_source_map(source);
int nucid = nucname::id(nuc);
if (dm.count(nucid)==1) {
return dm[nucid].ext_soil_dose;
} else {
return -1;
}
}
double pyne::ext_soil_dose(const char * nuc, int source) {
int nuc_zz = nucname::id(nuc);
return ext_soil_dose(nuc_zz, source);
}
double pyne::ext_soil_dose(std::string nuc, int source) {
int nuc_zz = nucname::id(nuc);
return ext_soil_dose(nuc_zz, source);
}
///
/// Functions for Ingestion Dose Factors and
/// Fraction of activity that is absorbed by body fluids
///
/// Ingestion
double pyne::ingest_dose(int nuc, int source) {
std::map<int, pyne::dose>& dm = dose_source_map(source);
int nucid = nucname::id(nuc);
if (dm.count(nucid)==1) {
return dm[nucid].ingest_dose;
} else {
return -1;
}
}
double pyne::ingest_dose(const char * nuc, int source) {
int nuc_zz = nucname::id(nuc);
return ingest_dose(nuc_zz, source);
}
double pyne::ingest_dose(std::string nuc, int source) {
int nuc_zz = nucname::id(nuc);
return ingest_dose(nuc_zz, source);
}
/// Fluid Fraction
double pyne::dose_fluid_frac(int nuc, int source) {
std::map<int, pyne::dose>& dm = dose_source_map(source);
int nucid = nucname::id(nuc);
if (dm.count(nucid)==1) {
return dm[nucid].fluid_frac;
} else {
return -1;
}
}
double pyne::dose_fluid_frac(const char * nuc, int source) {
int nuc_zz = nucname::id(nuc);
return dose_fluid_frac(nuc_zz, source);
}
double pyne::dose_fluid_frac(std::string nuc, int source) {
int nuc_zz = nucname::id(nuc);
return dose_fluid_frac(nuc_zz, source);
}
///
/// Functions for Inhalation Dose Factors and
/// Lung Model used to obtain dose factors
///
/// Inhalation
double pyne::inhale_dose(int nuc, int source) {
std::map<int, pyne::dose>& dm = dose_source_map(source);
int nucid = nucname::id(nuc);
if (dm.count(nucid)==1) {
return dm[nucid].inhale_dose;
} else {
return -1;
}
}
double pyne::inhale_dose(const char * nuc, int source) {
int nuc_zz = nucname::id(nuc);
return inhale_dose(nuc_zz, source);
}
double pyne::inhale_dose(std::string nuc, int source) {
int nuc_zz = nucname::id(nuc);
return inhale_dose(nuc_zz, source);
}
/// Lung Model
std::string pyne::dose_lung_model(int nuc, int source) {
std::map<int, pyne::dose>& dm = dose_source_map(source);
int nucid = nucname::id(nuc);
if (dm.count(nucid)==1) {
return std::string(1, dm[nucid].lung_mod);
} else {
return "Nada";
}
}
std::string pyne::dose_lung_model(const char * nuc, int source) {
int nuc_zz = nucname::id(nuc);
return dose_lung_model(nuc_zz, source);
}
std::string pyne::dose_lung_model(std::string nuc, int source) {
int nuc_zz = nucname::id(nuc);
return dose_lung_model(nuc_zz, source);
}
/***********************************/
/*** scattering length functions ***/
/***********************************/
std::map<int, xd_complex_t> pyne::b_coherent_map = std::map<int, xd_complex_t>();
std::map<int, xd_complex_t> pyne::b_incoherent_map = std::map<int, xd_complex_t>();
std::map<int, double> pyne::b_map = std::map<int, double>();
void pyne::_load_scattering_lengths() {
// Loads the important parts of atomic_wight table into atomic_mass_map
herr_t status;
//Check to see if the file is in HDF5 format.
if (!pyne::file_exists(pyne::NUC_DATA_PATH))
throw pyne::FileNotFound(pyne::NUC_DATA_PATH);
bool ish5 = H5Fis_hdf5(pyne::NUC_DATA_PATH.c_str());
if (!ish5)
throw h5wrap::FileNotHDF5(pyne::NUC_DATA_PATH);
// Get the HDF5 compound type (table) description
hid_t desc = H5Tcreate(H5T_COMPOUND, sizeof(scattering_lengths));
status = H5Tinsert(desc, "nuc", HOFFSET(scattering_lengths, nuc), H5T_NATIVE_INT);
status = H5Tinsert(desc, "b_coherent", HOFFSET(scattering_lengths, b_coherent),
h5wrap::PYTABLES_COMPLEX128);
status = H5Tinsert(desc, "b_incoherent", HOFFSET(scattering_lengths, b_incoherent),
h5wrap::PYTABLES_COMPLEX128);
status = H5Tinsert(desc, "xs_coherent", HOFFSET(scattering_lengths, xs_coherent),
H5T_NATIVE_DOUBLE);
status = H5Tinsert(desc, "xs_incoherent", HOFFSET(scattering_lengths, xs_incoherent),
H5T_NATIVE_DOUBLE);
status = H5Tinsert(desc, "xs", HOFFSET(scattering_lengths, xs), H5T_NATIVE_DOUBLE);
// Open the HDF5 file
hid_t nuc_data_h5 = H5Fopen(pyne::NUC_DATA_PATH.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
// Open the data set
hid_t scat_len_set = H5Dopen2(nuc_data_h5, "/neutron/scattering_lengths", H5P_DEFAULT);
hid_t scat_len_space = H5Dget_space(scat_len_set);
int scat_len_length = H5Sget_simple_extent_npoints(scat_len_space);
// Read in the data
scattering_lengths * scat_len_array = new scattering_lengths[scat_len_length];
status = H5Dread(scat_len_set, desc, H5S_ALL, H5S_ALL, H5P_DEFAULT, scat_len_array);
// close the nuc_data library, before doing anything stupid
status = H5Dclose(scat_len_set);
status = H5Fclose(nuc_data_h5);
// Ok now that we have the array of stucts, put it in the maps
for(int n = 0; n < scat_len_length; n++) {
b_coherent_map[scat_len_array[n].nuc] = scat_len_array[n].b_coherent;
b_incoherent_map[scat_len_array[n].nuc] = scat_len_array[n].b_incoherent;
}
delete[] scat_len_array;
}
//
// Coherent functions
//
xd_complex_t pyne::b_coherent(int nuc) {
// Find the nuclide's bound scattering length in cm
std::map<int, xd_complex_t>::iterator nuc_iter, nuc_end;
nuc_iter = b_coherent_map.find(nuc);
nuc_end = b_coherent_map.end();
// First check if we already have the nuc in the map
if (nuc_iter != nuc_end)
return (*nuc_iter).second;
// Next, fill up the map with values from the
// nuc_data.h5, if the map is empty.
if (b_coherent_map.empty()) {
_load_scattering_lengths();
return b_coherent(nuc);
}
xd_complex_t bc;
int nucid = nucname::id(nuc);
int znum = nucname::znum(nucid);
int anum = nucname::anum(nucid);
// Try to find a nuclide with matching A-number
nuc_iter = b_coherent_map.begin();
while (nuc_iter != nuc_end) {
if (anum == nucname::anum((*nuc_iter).first)) {
bc = (*nuc_iter).second;
b_coherent_map[nuc] = bc;
return bc;
}
nuc_iter++;
}
// Try to find a nuclide with matching Z-number
nuc_iter = b_coherent_map.begin();
while (nuc_iter != nuc_end) {
if (znum == nucname::znum((*nuc_iter).first)) {
bc = (*nuc_iter).second;
b_coherent_map[nuc] = bc;
return bc;
}
nuc_iter++;
}
// Finally, if none of these work,
// just return zero...
bc.re = 0.0;
bc.im = 0.0;
b_coherent_map[nuc] = bc;
return bc;
}
xd_complex_t pyne::b_coherent(char * nuc) {
int nuc_zz = nucname::id(nuc);
return b_coherent(nuc_zz);
}
xd_complex_t pyne::b_coherent(std::string nuc) {
int nuc_zz = nucname::id(nuc);
return b_coherent(nuc_zz);
}
//
// Incoherent functions
//
xd_complex_t pyne::b_incoherent(int nuc) {
// Find the nuclide's bound inchoherent scattering length in cm
std::map<int, xd_complex_t>::iterator nuc_iter, nuc_end;
nuc_iter = b_incoherent_map.find(nuc);
nuc_end = b_incoherent_map.end();
// First check if we already have the nuc in the map
if (nuc_iter != nuc_end)
return (*nuc_iter).second;
// Next, fill up the map with values from the
// nuc_data.h5, if the map is empty.
if (b_incoherent_map.empty()) {
_load_scattering_lengths();
return b_incoherent(nuc);
}
xd_complex_t bi;
int nucid = nucname::id(nuc);
int znum = nucname::znum(nucid);
int anum = nucname::anum(nucid);
// Try to find a nuclide with matching A-number
nuc_iter = b_incoherent_map.begin();
while (nuc_iter != nuc_end) {
if (anum == nucname::anum((*nuc_iter).first)) {
bi = (*nuc_iter).second;
b_incoherent_map[nuc] = bi;
return bi;
}
nuc_iter++;
}
// Try to find a nuclide with matching Z-number
nuc_iter = b_incoherent_map.begin();
while (nuc_iter != nuc_end) {
if (znum == nucname::znum((*nuc_iter).first)) {
bi = (*nuc_iter).second;
b_incoherent_map[nuc] = bi;
return bi;
}
nuc_iter++;
}
// Finally, if none of these work,
// just return zero...
bi.re = 0.0;
bi.im = 0.0;
b_incoherent_map[nuc] = bi;
return bi;
}
xd_complex_t pyne::b_incoherent(char * nuc) {
return b_incoherent(nucname::id(nuc));
}
xd_complex_t pyne::b_incoherent(std::string nuc) {
return b_incoherent(nucname::id(nuc));
}
//
// b functions
//
double pyne::b(int nuc) {
// Find the nuclide's bound scattering length in cm
std::map<int, double>::iterator nuc_iter, nuc_end;
nuc_iter = b_map.find(nuc);
nuc_end = b_map.end();
// First check if we already have the nuc in the map
if (nuc_iter != nuc_end)
return (*nuc_iter).second;
// Next, calculate the value from coherent and incoherent lengths
xd_complex_t bc = b_coherent(nuc);
xd_complex_t bi = b_incoherent(nuc);
double b_val = sqrt(bc.re*bc.re + bc.im*bc.im + bi.re*bi.re + bi.im*bi.im);
return b_val;
}
double pyne::b(char * nuc) {
int nucid = nucname::id(nuc);
return b(nucid);
}
double pyne::b(std::string nuc) {
int nucid = nucname::id(nuc);
return b(nucid);
}
//
// Fission Product Yield Data
//
std::map<std::pair<int, int>, double> pyne::wimsdfpy_data = \
std::map<std::pair<int, int>, double>();
void pyne::_load_wimsdfpy() {
herr_t status;
//Check to see if the file is in HDF5 format.
if (!pyne::file_exists(pyne::NUC_DATA_PATH))
throw pyne::FileNotFound(pyne::NUC_DATA_PATH);
bool ish5 = H5Fis_hdf5(pyne::NUC_DATA_PATH.c_str());
if (!ish5)
throw h5wrap::FileNotHDF5(pyne::NUC_DATA_PATH);
// Get the HDF5 compound type (table) description
hid_t desc = H5Tcreate(H5T_COMPOUND, sizeof(wimsdfpy));
status = H5Tinsert(desc, "from_nuc", HOFFSET(wimsdfpy, from_nuc),
H5T_NATIVE_INT);
status = H5Tinsert(desc, "to_nuc", HOFFSET(wimsdfpy, to_nuc),
H5T_NATIVE_INT);
status = H5Tinsert(desc, "yields", HOFFSET(wimsdfpy, yields),
H5T_NATIVE_DOUBLE);
// Open the HDF5 file
hid_t nuc_data_h5 = H5Fopen(pyne::NUC_DATA_PATH.c_str(), H5F_ACC_RDONLY,
H5P_DEFAULT);
// Open the data set
hid_t wimsdfpy_set = H5Dopen2(nuc_data_h5, "/neutron/wimsd_fission_products",
H5P_DEFAULT);
hid_t wimsdfpy_space = H5Dget_space(wimsdfpy_set);
int wimsdfpy_length = H5Sget_simple_extent_npoints(wimsdfpy_space);
// Read in the data
wimsdfpy * wimsdfpy_array = new wimsdfpy[wimsdfpy_length];
status = H5Dread(wimsdfpy_set, desc, H5S_ALL, H5S_ALL, H5P_DEFAULT, wimsdfpy_array);
// close the nuc_data library, before doing anything stupid
status = H5Dclose(wimsdfpy_set);
status = H5Fclose(nuc_data_h5);
// Ok now that we have the array of stucts, put it in the maps
for(int n=0; n < wimsdfpy_length; n++) {
wimsdfpy_data[std::make_pair(wimsdfpy_array[n].from_nuc,
wimsdfpy_array[n].to_nuc)] = wimsdfpy_array[n].yields;
}
delete[] wimsdfpy_array;
}
std::map<std::pair<int, int>, pyne::ndsfpysub> pyne::ndsfpy_data = \
std::map<std::pair<int, int>, pyne::ndsfpysub>();
void pyne::_load_ndsfpy() {
herr_t status;
//Check to see if the file is in HDF5 format.
if (!pyne::file_exists(pyne::NUC_DATA_PATH))
throw pyne::FileNotFound(pyne::NUC_DATA_PATH);
bool ish5 = H5Fis_hdf5(pyne::NUC_DATA_PATH.c_str());
if (!ish5)
throw h5wrap::FileNotHDF5(pyne::NUC_DATA_PATH);
// Get the HDF5 compound type (table) description
hid_t desc = H5Tcreate(H5T_COMPOUND, sizeof(ndsfpy));
status = H5Tinsert(desc, "from_nuc", HOFFSET(ndsfpy, from_nuc),
H5T_NATIVE_INT);
status = H5Tinsert(desc, "to_nuc", HOFFSET(ndsfpy, to_nuc),
H5T_NATIVE_INT);
status = H5Tinsert(desc, "yield_thermal", HOFFSET(ndsfpy, yield_thermal),
H5T_NATIVE_DOUBLE);
status = H5Tinsert(desc, "yield_thermal_err", HOFFSET(ndsfpy, yield_thermal_err),
H5T_NATIVE_DOUBLE);
status = H5Tinsert(desc, "yield_fast", HOFFSET(ndsfpy, yield_fast),
H5T_NATIVE_DOUBLE);
status = H5Tinsert(desc, "yield_fast_err", HOFFSET(ndsfpy, yield_fast_err),
H5T_NATIVE_DOUBLE);
status = H5Tinsert(desc, "yield_14MeV", HOFFSET(ndsfpy, yield_14MeV),
H5T_NATIVE_DOUBLE);
status = H5Tinsert(desc, "yield_14MeV_err", HOFFSET(ndsfpy, yield_14MeV_err),
H5T_NATIVE_DOUBLE);
// Open the HDF5 file
hid_t nuc_data_h5 = H5Fopen(pyne::NUC_DATA_PATH.c_str(), H5F_ACC_RDONLY,
H5P_DEFAULT);
// Open the data set
hid_t ndsfpy_set = H5Dopen2(nuc_data_h5, "/neutron/nds_fission_products",
H5P_DEFAULT);
hid_t ndsfpy_space = H5Dget_space(ndsfpy_set);
int ndsfpy_length = H5Sget_simple_extent_npoints(ndsfpy_space);
// Read in the data
ndsfpy * ndsfpy_array = new ndsfpy[ndsfpy_length];
status = H5Dread(ndsfpy_set, desc, H5S_ALL, H5S_ALL, H5P_DEFAULT, ndsfpy_array);
// close the nuc_data library, before doing anything stupid
status = H5Dclose(ndsfpy_set);
status = H5Fclose(nuc_data_h5);
ndsfpysub ndsfpysub_temp;
// Ok now that we have the array of structs, put it in the maps
for(int n=0; n < ndsfpy_length; n++) {
ndsfpysub_temp.yield_thermal = ndsfpy_array[n].yield_thermal;
ndsfpysub_temp.yield_thermal_err = ndsfpy_array[n].yield_thermal_err;
ndsfpysub_temp.yield_fast = ndsfpy_array[n].yield_fast;
ndsfpysub_temp.yield_fast_err = ndsfpy_array[n].yield_fast_err;
ndsfpysub_temp.yield_14MeV = ndsfpy_array[n].yield_14MeV;
ndsfpysub_temp.yield_14MeV_err = ndsfpy_array[n].yield_14MeV_err;
ndsfpy_data[std::make_pair(ndsfpy_array[n].from_nuc,
ndsfpy_array[n].to_nuc)] = ndsfpysub_temp;
}
delete[] ndsfpy_array;
}
double pyne::fpyield(std::pair<int, int> from_to, int source, bool get_error) {
// Note that this may be expanded eventually to include other
// sources of fission product data.
// Find the parent/child pair branch ratio as a fraction
if (source == 0) {
std::map<std::pair<int, int>, double>::iterator fpy_iter, fpy_end;
fpy_iter = wimsdfpy_data.find(from_to);