-
Notifications
You must be signed in to change notification settings - Fork 0
/
LSDCRNParameters.cpp
2904 lines (2470 loc) · 96.2 KB
/
LSDCRNParameters.cpp
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
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// LSDCRNParameters.cpp
//
// Land Surface Dynamics Cosmogenic Radionuclide Parameters Object
//
// This keeps track of paramters used to calculate the evolution of
// in situ cosmogenic nuclides.
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// An object within the University
// of Edinburgh Land Surface Dynamics group topographic toolbox
// for calculating concntration of environmental tracers, CRNs, TCN, fallout
// nuclides
//
// Developed by:
// Simon M. Mudd
// Martin D. Hurst
// David T. Milodowski
// Stuart W.D. Grieve
// Declan A. Valters
// Fiona Clubb
//
// Copyright (C) 2013 Simon M. Mudd 2013
//
// Developer can be contacted by simon.m.mudd _at_ ed.ac.uk
//
// Simon Mudd
// University of Edinburgh
// School of GeoSciences
// Drummond Street
// Edinburgh, EH8 9XP
// Scotland
// United Kingdom
//
// This program is free software;
// you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation;
// either version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY;
// without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the
// GNU General Public License along with this program;
// if not, write to:
// Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301
// USA
//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include <fstream>
#include <math.h>
#include <iostream>
#include <vector>
#include <map>
#include "TNT/tnt.h"
#include "LSDStatsTools.hpp"
#include "LSDCRNParameters.hpp"
using namespace std;
using namespace TNT;
#ifndef LSDCRNParameters_CPP
#define LSDCRNParameters_CPP
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// the LSDCRNParameters object
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// function to set CRN parameters
void LSDCRNParameters::create()
{
version = "1.0";
S_t = 1;
neutron_S_t = 1;
// from Vermeesh 2007
lambda_10Be = 456e-9; // in yr-1
lambda_26Al = 980e-9; // in yr-1
lambda_14C = 121e-6; // in yr-1
lambda_36Cl = 230e-8; // in yr-1
// from Vermeesh 2007
P0_10Be = 5.11; // in a/g/yr
P0_26Al = 30.31; // in a/g/yr
P0_14C = 5.86; // in a/g/yr
P0_36Cl = 55.45; // in a/g/yr
P0_21Ne = 20.29; // in a/g/yr
P0_3He = 97.40; // in a/g/yr
// in g/cm^2
Gamma[0] = 160;
Gamma[1] = 738.6;
Gamma[2] = 2688;
Gamma[3] = 4360;
// dimensionless
F_10Be[0] = 0.9724;
F_10Be[1] = 0.0186;
F_10Be[2] = 0.004;
F_10Be[3] = 0.005;
// dimensionless
F_26Al[0] = 0.9655;
F_26Al[1] = 0.0233;
F_26Al[2] = 0.005;
F_26Al[3] = 0.0062;
// dimensionless
F_14C[0] = 0.83;
F_14C[1] = 0.0691;
F_14C[2] = 0.0809;
F_14C[3] = 0.02;
// dimensionless
F_36Cl[0] = 0.903;
F_36Cl[1] = 0.0447;
F_36Cl[2] = 0.05023;
F_36Cl[3] = 0.0;
}
// this function gets the parameters used to convert elevation to
// pressure
void LSDCRNParameters::load_parameters_for_atmospheric_scaling(string path_to_data)
{
cout.precision(8);
// first load the levels
levels.push_back(1000);
levels.push_back(925);
levels.push_back(850);
levels.push_back(700);
levels.push_back(600);
levels.push_back(500);
levels.push_back(400);
levels.push_back(300);
// the dimensions of the data
int n_levels = 8;
int NRows = 73;
int NCols = 145;
Array2D<double> new_slp(NRows,NCols,0.0);
Array2D<double> new_meant(NRows,NCols,0.0);
// now load the mean sea level pressure
string filename = "NCEP2.bin";
filename = path_to_data+filename;
//cout << "Loading mean sea level, file is: " << endl << filename << endl;
ifstream ifs_data(filename.c_str(), ios::in | ios::binary);
if( ifs_data.fail() )
{
cout << "\nFATAL ERROR: the data file \"" << filename
<< "\" doesn't exist" << endl;
exit(EXIT_FAILURE);
}
double temp;
//cout << "The size of a double is: " << sizeof(temp) << endl;
for (int i=0; i<NCols; ++i)
{
for (int j=0; j<NRows; ++j)
{
ifs_data.read(reinterpret_cast<char*>(&temp), sizeof(temp));
new_slp[j][i] = temp;
//cout << "new_slp["<<j+1<<"]["<<i+1<<"]: " << new_slp[j][i] << endl;
}
}
for (int i=0; i<NCols; ++i)
{
for (int j=0; j<NRows; ++j)
{
ifs_data.read(reinterpret_cast<char*>(&temp), sizeof(temp));
new_meant[j][i] = temp;
//cout << "new_meant100["<<j+1<<"]["<<i+1<<"]: " << new_meant[j][i] << endl;
}
}
// now get the indices
vector<double> temp_lat(NRows,0.0);
for (int i=0; i<NRows; ++i)
{
ifs_data.read(reinterpret_cast<char*>(&temp), sizeof(temp));
temp_lat[i] = temp;
//cout << "Lat["<<i+1<<"]: " << temp_lat[i] << endl;
}
vector<double> temp_long(NCols,0.0);
for (int i=0; i<NCols; ++i)
{
ifs_data.read(reinterpret_cast<char*>(&temp), sizeof(temp));
temp_long[i] = temp;
//cout << "Long["<<i+1<<"]: " << temp_long[i] << endl;
}
ifs_data.close();
// now the data with levels
filename = "NCEP_hgt.bin";
filename = path_to_data+filename;
//cout << "Loading hgt, file is: " << endl << filename << endl;
ifstream ifs_data2(filename.c_str(), ios::in | ios::binary);
if( ifs_data2.fail() )
{
cout << "\nFATAL ERROR: the data file \"" << filename
<< "\" doesn't exist" << endl;
exit(EXIT_FAILURE);
}
// get the gm heights
vector< Array2D<double> > vec_hgt_gm_array;
for (int lvl = 0; lvl < n_levels; lvl++)
{
Array2D<double> current_hgt_array(NRows,NCols,0.0);
for (int i=0; i<NCols; ++i)
{
for (int j=0; j<NRows; ++j)
{
ifs_data2.read(reinterpret_cast<char*>(&temp), sizeof(temp));
current_hgt_array[j][i] = temp;
//cout << "new_slp["<<lvl<<"]["<<j+1<<"]["<<i+1<<"]: " << current_hgt_array[j][i] << endl;
}
}
//cout << "new_slp["<<j+1<<"]["<<i+1<<"]: " << new_slp[j][i] << endl;
vec_hgt_gm_array.push_back(current_hgt_array.copy());
}
// now the gp heights
vector< Array2D<double> > vec_hgt_gp_array;
for (int lvl = 0; lvl < n_levels; lvl++)
{
Array2D<double> current_hgt_array(NRows,NCols,0.0);
for (int i=0; i<NCols; ++i)
{
for (int j=0; j<NRows; ++j)
{
ifs_data2.read(reinterpret_cast<char*>(&temp), sizeof(temp));
current_hgt_array[j][i] = temp;
//cout << "new_slp["<<lvl<<"]["<<j+1<<"]["<<i+1<<"]: " << current_hgt_array[j][i] << endl;
}
}
//cout << "new_slp["<<j+1<<"]["<<i+1<<"]: " << new_slp[j][i] << endl;
vec_hgt_gp_array.push_back(current_hgt_array.copy());
}
ifs_data2.close();
// now update the data elements
NCEPlat = temp_lat;
NCEPlon = temp_long;
meanslp = new_slp.copy();
meant1000 = new_meant.copy();
gp_hgt = vec_hgt_gp_array;
gm_hgt = vec_hgt_gp_array;
//cout << "Size lat: " << NCEPlat.size() << " size long: " << NCEPlon.size() << endl;
//cout << "size slp:" << meanslp.dim1() << " " << meanslp.dim2() << endl;
//cout << "size t1000: " << meant1000.dim1() << " " << meant1000.dim2() << endl;
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// This function sets a number of paramters that are used for acalucaltion
// of scaling and error propigation
//
// They are constants used in the CRONUS caluclator, and have been ported
// from make_al_be_consts_v22.m written by Greg Balco
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
void LSDCRNParameters::set_CRONUS_data_maps()
{
//cout << "Line 278, creating the CRONUS data maps" << endl;
map<string,double> temp_map;
// 10Be decay: this is specific to the CRONUS calculator
temp_map["l10"] = -log(0.5)/1.387e6; // Chmeleff/Korschinek value
// Al-26 decay constant -- value compatible with Nishiizumi standards
temp_map["l26"] = 9.83e-7;
//cout << "Creating CRONUS data maps, lambda 10: " << temp_map["l10"]
// << " and lambda 26: " << temp_map["l26"] << endl;
// Note that the uncertainty is not used in exposure-age or erosion-rate
// calculators. Here only for development purposes
double dldt = -log(0.5)*(1/(1.387e6*1.387e6));
temp_map["dell10"] = sqrt((dldt*1/(0.012e6*0.012e6)));
temp_map["dell26"] = 2.5e-8;
//Effective attenuation length for spallation in rock
// Commonly accepted value: 160 g/cm2
// For discussion see Gosse and Phillips (2000)
temp_map["Lsp"] = 160.0;
// Fsp - fraction of total production by spallation rather than muons
// For use with Lal/Stone scaling scheme in exposure age calculation
// For details, see Stone (2000)
// This aspect of Stone(2000) is de-emphasized in version 2. These constants
// are only in use for historical comparisons and quick initial guesses for
// the exposure age and erosion rate solvers.
// Note that they are probably incorrect WRT Be-10 restandardization. Don't
// use these for anything important.
temp_map["Fsp10"] = 0.978;
temp_map["Fsp26"] = 0.974;
// Be-10 standardization info.
// Standards comparison/conversion lookup table
temp_map["Be_std_07KNSTD"] = 1.0000;
temp_map["Be_std_KNSTD"] = 0.9042;
temp_map["Be_std_NIST_Certified"] = 1.0425;
temp_map["Be_std_LLNL31000"] = 0.8761;
temp_map["Be_std_LLNL10000"] = 0.9042;
temp_map["Be_std_LLNL3000"] = 0.8644;
temp_map["Be_std_LLNL1000"] = 0.9313;
temp_map["Be_std_LLNL300"] = 0.8562;
temp_map["Be_std_NIST_30000"] = 0.9313;
temp_map["Be_std_NIST_30200"] = 0.9251;
temp_map["Be_std_NIST_30300"] = 0.9221;
temp_map["Be_std_NIST_30600"] = 0.9130;
temp_map["Be_std_NIST_27900"] = 1;
temp_map["Be_std_S555"] = 0.9124;
temp_map["Be_std_S2007"] = 0.9124;
temp_map["Be_std_BEST433"] = 0.9124;
temp_map["Be_std_BEST433N"] = 1;
temp_map["Be_std_S555N"] = 1;
temp_map["Be_std_S2007N"] = 1;;
// Same for Al-26. A zero placeholder is
// also allowed.
temp_map["Al_std_KNSTD"] = 1.0;
temp_map["Al_std_ZAL94"] = 0.9134;
temp_map["Al_std_SMAL11"] = 1.021;
temp_map["Al_std_0"] = 1.0;
temp_map["Al_std_ZAL94N"] = 1.0;
temp_map["Al_std_ASTER"] = 1.021;
temp_map["Al_std_Z92-0222"] = 1;
// Reference production rates at SLHL for spallation according to various
// scaling schemes. Letter codes De, Du, Li, and St refer to
// scaling schemes of Desilets et al. (2006), Dunai (2001), Lifton (2006),
// and Stone (2000) respectively. The final letter code Lm refers to the
// paleomagnetically corrected version of the Lal 1991/Stone 2000 scaling
// factors.
// These reference production rates are derived using the current version of
// get_al_be_age.m.
// Al-26 and Be-10 production rates are linked by the production ratio,
// not determined independently. This is because there are not very
// many geological-calibration sites for Al-26. See the calibration data
// sets and the accompanying paper for more information.
// This reflects the v 2.1 air pressure upgrade.
// Also the update to 07KNSTD in version 2.2.
// Be-10 production rates. Brent's values. Greg agrees.
temp_map["P10_ref_St"] = 4.49;
temp_map["delP10_ref_St"] = 0.39;
temp_map["P10_ref_Lm"] = 4.39;
temp_map["delP10_ref_Lm"] = 0.37;
temp_map["P10_ref_De"] = 4.41;
temp_map["delP10_ref_De"] = 0.52;
temp_map["P10_ref_Du"] = 4.43;
temp_map["delP10_ref_Du"] = 0.52;
temp_map["P10_ref_Li"] = 4.87;
temp_map["delP10_ref_Li"] = 0.48;
// Al-26 production rates are derived from Be-10 production rates
double R2610 = 6.1*1.106; // Update assumed production ratio
temp_map["P26_ref_St"] = temp_map["P10_ref_St"]*R2610;
temp_map["delP26_ref_St"] = temp_map["delP10_ref_St"]*R2610;
temp_map["P26_ref_Lm"] = temp_map["P10_ref_Lm"]*R2610;
temp_map["delP26_ref_Lm"] = temp_map["delP10_ref_Lm"]*R2610;
temp_map["P26_ref_De"] = temp_map["P10_ref_De"]*R2610;
temp_map["delP26_ref_De"] = temp_map["delP10_ref_De"]*R2610;
temp_map["P26_ref_Du"] = temp_map["P10_ref_Du"]*R2610;
temp_map["delP26_ref_Du"] = temp_map["delP10_ref_Du"]*R2610;
temp_map["P26_ref_Li"] = temp_map["P10_ref_Li"]*R2610;
temp_map["delP26_ref_Li"] = temp_map["delP10_ref_Li"]*R2610;
// Muon interaction cross-sections. All follow Heisinger (2002a,b).
// Note that the energy-dependence-of-muon-interaction-cross-section
// exponent alpha is treated as model-dependent -- it's internal to
// P_mu_total.m and can't be passed.
temp_map["Natoms10"] = 2.006e22;
temp_map["Natoms26"] = 1.003e22;
// Be-10 interaction cross-sections
// Restandardized by ETH-07KNSTD factor for version 2.2.1.
temp_map["k_neg10"] = (0.704 * 0.1828 * 0.0043)/1.096;
temp_map["delk_neg10"] = (0.704 * 0.1828 * 0.0003)/1.096;
temp_map["sigma190_10"] = (0.094e-27)/1.096;
temp_map["delsigma190_10"] = (0.013e-27)/1.096;
temp_map["Be10_Natoms_times_sigma190"] = 1.7205e-6;
temp_map["Be10_Natoms_times_delsigma190"] = 2.37938e-7;
temp_map["Be10_Natoms_sigma_modified_for_fast"] = 3.361886e-8;
//cout << "LINE 405, be10 prod: " << temp_map["Be10_Natoms_sigma_modified_for_fast"] << endl;
// Al-26 interaction cross-sections
temp_map["k_neg26"] = 0.296 * 0.6559 * 0.022;
temp_map["delk_neg26"] = 0.296 * 0.6559 * 0.002;
temp_map["sigma190_26"] = 1.41e-27;
temp_map["delsigma190_26"] = 0.17e-27;
temp_map["Al26_Natoms_times_sigma190"] = 1.41423e-5;
temp_map["Al26_Natoms_times_delsigma190"] = 1.7051e-6;
temp_map["Al26_Natoms_sigma_modified_for_fast"] = 2.76347e-8;
// Paleomagnetic records for use in time-dependent production rate schemes
// Derived from Nat Lifton's compilation of paleomagnetic data from
// various sources. See Lifton et al. (2006) and Pigati and Lifton (2005).
// Load the magnetic field data
// load PMag_Mar07
// Relative dipole moment and time vector
// al_be_consts.M = MM0;
// al_be_consts.t_M = t_M;
// These start at 7500 yr -- time slices are 7500,8500,9500,10500,11500
// in order to use data from Yang et al; subsequent time slices are
// 12000:1000:800000 for SINT800 data; final two time points are 801000
// and Inf.
// Cutoff rigidity blocks for past 6900 yr.
// TTRc and IHRC are lon x lat x time blocks of Rc values for the past
// 6900 years.
// Both are derived by Nat Lifton from the magnetic field reconstructions of
// Korte and Constable.
// TTRC has cutoff rigidity obtained by trajectory tracing -- these are for
// the Lifton and Desilets scaling factors. IHRc has cutoff rigidity
// obtained by finding magnetic inclination and horizontal field strength
// from the field model, then applying Equation 2 of Dunai(2001).
// al_be_consts.TTRc = TTRc; % data block
// al_be_consts.IHRc = IHRc; % data block
// al_be_consts.lat_Rc = lat_Rc; % lat and lon indices for Rc data block
// al_be_consts.lon_Rc = lon_Rc;
// al_be_consts.t_Rc = t_Rc; % time vector for Rc data block
// Effective pole positions and field strengths inferred from K and C field
// reconstructions for last 7000 yr. These are used in the
// paleomagnetically-corrected implementation of the Lal SF. They are for
// the same times as the RC slices in the data block above. Again,
// generated by Nat Lifton -- hence KCL = Korte-Constable-Lifton.
// al_be_consts.MM0_KCL = MM0_KCL;
// al_be_consts.lat_pp_KCL = lat_pp_KCL;
// al_be_consts.lon_pp_KCL = lon_pp_KCL;
// Solar variability from Lifton et al. 2005
// Has been averaged and resampled to the same time slices as everything
// else.
// al_be_consts.S = S;
// al_be_consts.SInf = 0.95; % Long-term mean S value;
// set the data member map
CRONUS_data_map = temp_map;
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// This function retrieves the Stone production reference values for 10Be and
// 26Al
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
vector<double> LSDCRNParameters::get_Stone_Pref()
{
// first check to see if CRONUS data maps are set
if(CRONUS_data_map.find("l10") == CRONUS_data_map.end())
{
cout << "You haven't set the CRONUS data map. I'm doing that for you now!" << endl;
set_CRONUS_data_maps();
}
vector<double> Stone_pref(2,0.0);
Stone_pref[0] = CRONUS_data_map["P10_ref_St"];
Stone_pref[1] = CRONUS_data_map["P26_ref_St"];
return Stone_pref;
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// This function wraps the CRONUS muon production function
// It returns a vector with elements
// Muon_production[0] = 10Be fast
// Muon_production[1] = 26Al fast
// Muon_production[2] = 10Be neg
// Muon_production[3] = 26Al neg
// 14/10/2014
// SMM
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
vector<double> LSDCRNParameters::calculate_muon_production_CRONUS(double z, double h)
{
vector<double> Muon_production(4,0.0);
P_mu_total(z,h);
Muon_production[0] = CRONUS_muon_data["P_fast_10Be"];
Muon_production[1] = CRONUS_muon_data["P_fast_26Al"];
Muon_production[2] = CRONUS_muon_data["P_neg_10Be"];
Muon_production[3] = CRONUS_muon_data["P_neg_26Al"];
return Muon_production;
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//
// This function sets CRONUS muon production paramteters
//
// Calculates the production rate of Al-26 or Be-10 by muons
// as a function of depth below the surface z (g/cm2) and
// site atmospheric pressure h (hPa).
//
// out.phi_vert_slhl muons/cm2/s/sr
// out.R_vert_slhl muons/g/s/sr
// out.R_vert_site muons/g/s/sr
// out.phi_vert_site muons/cm2/s/sr
// out.phi muons/cm2/yr
// out.R muons/g/yr
// out.P_fast atoms/g/yr
// out.P_neg atoms/g/yr
// out.Beta nondimensional
// out.Ebar GeV
// out.H g/cm2
// out.LZ g/cm2
//
// This uses the scheme in Heisinger and others (2002, 2 papers). The
// vertically traveling muon flux is scaled to the site elevation using
// energy-dependent attenuation lengths from Boezio et al. (2000). See the
// hard-copy documentation for detailed citations and a full discussion of
// the calculation.
//
// Note that some constants are internal to the function. The only ones that
// get passed from upstream are the ones that a) are nuclide-specific, or b)
// actually have quoted uncertainties in Heisinger's papers.
// The fraction of muons that are negative is internal; so is the
// energy-dependence exponent alpha.
//
// Original Written by Greg Balco -- UW Cosmogenic Nuclide Lab
// March, 2006
// Part of the CRONUS-Earth online calculators:
// http://hess.ess.washington.edu/math
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
void LSDCRNParameters::P_mu_total(double z,double h)
{
map<string,double> temp_data_map;
//cout << "CHECKING MUON FLUX, Line 504 " << endl;
// first check to see if CRONUS data maps are set
if(CRONUS_data_map.find("l10") == CRONUS_data_map.end())
{
cout << "You haven't set the CRONUS data map. I'm doing that for you now!" << endl;
set_CRONUS_data_maps();
}
// calculator the atmospheric depth in g/cm2
double H = (1013.25 - h)*1.019716;
//cout << "Atmospheric depth is: " << H << " g/cm^2" << endl;
// find the vertical flux at SLHL
double a = 258.5*(pow(100,2.66));
double b = 75*(pow(100,1.66));
// this is equation (1) From Heisinger 2002a and (3) from Heisinger 2002b
double phi_vert_slhl = (a/((z+21000.0)*((pow((z+1000),1.66)) + b)))
*exp(-5.5e-6* z);
// The above expression is only good to 2e5 g/cm2. We don't ever consider production
// below that depth. The full-depth scheme appears in the comments below.
// ------ begin full-depth flux equations -------
//phiz_1 = (a./((z+21000).*(((z+1000).^1.66) + b))).*exp(-5.5e-6 .* z);
//phiz_2 = 1.82e-6.*((121100./z).^2).*exp(-z./121100) + 2.84e-13;
//out(find(z<200000)) = phiz_1(find(z<200000));
//out(find(z>=200000)) = phiz_2(find(z>=200000));
// ------ end full-depth flux equations -------
// find the stopping rate of vertical muons at SLHL
// this is done in a subfunction Rv0, because it gets integrated later.
double R_vert_slhl = Rv0(z);
// find the stopping rate of vertical muons at site
double R_vert_site = R_vert_slhl*exp(H/LZ(z));
//cout << "LZ(" << z << "): " << LZ(z) << endl;
//cout << "R_vert_slhl: " << R_vert_slhl << " R_vert_site: " << R_vert_site << endl;
// find the flux of vertical muons at site
// integrate
// ends at 200,001 g/cm2 to avoid being asked for an zero
// range of integration --
// get integration tolerance -- want relative tolerance around
// 1 part in 10^4.
double tol = phi_vert_slhl*1e-4;
double phi_vert_site = integrate_muon_flux(z, H, tol);
//=====================
// I THINK below here is an error in Balco's code
// The below equation uses a which is calculated above,
// but in balco's code a is then used as an index, so the below
// equation takes the index value rather than the precalculated
// value of a
//=======================
// invariant flux at 2e5 g/cm2 depth - constant of integration
// calculated using commented-out formula above
double phi_200k = (a/((2.0e5+21000.0)*((pow((2.0e5+1000.0),1.66)) + b)))
*exp(-5.5e-6 * 2.0e5);
//double test_balco_error = (1.0/((2.0e5+21000.0)*((pow((2.0e5+1000.0),1.66)) + b)))
// *exp(-5.5e-6 * 2.0e5);
phi_vert_site = phi_vert_site + phi_200k;
// find the total flux of muons at site
// angular distribution exponent
double nofz = 3.21 - 0.297*log((z+H)/100.0 + 42.0) + 1.21e-5*(z+H);
// derivative of same
double dndz = (-0.297/100.0)/((z+H)/100.0 + 42.0) + 1.21e-5;
// caluculate phi in muons/cm2/s
double phi_temp = (phi_vert_site*2* M_PI) / (nofz+1.0);
// convert to muons/cm2/yr
double phi = phi_temp*60.0*60.0*24.0*365.0;
// find the total stopping rate of muons at site in muons/g/s
double R_temp = (2*M_PI/(nofz+1.0))*R_vert_site
- phi_vert_site*(-2*M_PI*(1/((nofz+1.0)*(nofz+1.0))))*dndz;
// convert to negative muons/g/yr
double this_R = R_temp*0.44*60.0*60.0*24.0*365.0;
// Now calculate the production rates.
// Depth-dependent parts of the fast muon reaction cross-section
double Beta = 0.846 - 0.015 * log((z/100.0)+1.0)
+ 0.003139 * (log((z/100.0)+1.0)*log((z/100.0)+1.0));
double Ebar = 7.6 + 321.7*(1 - exp(-8.059e-6*z))
+ 50.7*(1-exp(-5.05e-7*z));
// internally defined constants
double aalpha = 0.75;
double sigma0_Be10 = CRONUS_data_map["sigma190_10"]/(pow(190.0,aalpha));
double sigma0_Al26 = CRONUS_data_map["sigma190_26"]/(pow(190.0,aalpha));
// fast muon production
double P_fast_Be10 = phi*Beta*(pow(Ebar,aalpha))
*sigma0_Be10*CRONUS_data_map["Natoms10"];
double P_fast_Al26 = phi*Beta*(pow(Ebar,aalpha))
*sigma0_Al26*CRONUS_data_map["Natoms26"];
//cout << "Phi: " << phi << " Beta " << Beta << " Ebar: " << Ebar << endl
// << "aalpha: " << aalpha << endl
// << " prod10: " << CRONUS_data_map["Be10_Natoms_sigma_modified_for_fast"] << endl
// << " prod26: " << CRONUS_data_map["Al26_Natoms_sigma_modified_for_fast"] << endl;
//double P2_10Be = phi*Beta*(pow(Ebar,aalpha))*
// CRONUS_data_map["Be10_Natoms_sigma_modified_for_fast"];
//double P2_26Al = phi*Beta*(pow(Ebar,aalpha))*
// CRONUS_data_map["Al26_Natoms_sigma_modified_for_fast"];
//cout << "Pfast10be: " << P_fast_Be10 << " P2: " << P2_10Be << endl;
//cout << "Pfast26Al: " << P_fast_Al26 << " P2: " << P2_26Al << endl;
// negative muon capture
double P_neg_Be10 = this_R*CRONUS_data_map["k_neg10"];
double P_neg_Al26 = this_R*CRONUS_data_map["k_neg26"];
//cout << "Sig0: " << sigma0_Be10 << " Pfast: " << P_fast_Be10 << " P_neg: " << P_neg_Be10 << endl;
temp_data_map["phi_vert_slhl"] = phi_vert_slhl;
temp_data_map["R_vert_slhl"] = R_vert_slhl;
temp_data_map["phi_vert_site"] = phi_vert_site;
temp_data_map["R_vert_site"] = R_vert_site;
temp_data_map["phi"] = phi;
temp_data_map["R"] = this_R;
temp_data_map["Beta"] = Beta;
temp_data_map["Ebar"] = Ebar;
temp_data_map["P_fast_10Be"] = P_fast_Be10;
temp_data_map["P_fast_26Al"] = P_fast_Al26;
temp_data_map["P_neg_10Be"] = P_neg_Be10;
temp_data_map["P_neg_26Al"] = P_neg_Al26;
temp_data_map["H"] = H;
temp_data_map["LZ"] = LZ(z);
CRONUS_muon_data = temp_data_map;
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// This function wraps the P_mu_tot function and replaces the 10Be and
// 26Al production rates
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
void LSDCRNParameters::P_mu_total_return_nuclides(double z,double h,
double& Be10_total_mu, double& Al26_total_mu)
{
// get the muon roduction
P_mu_total(z,h);
double p10 = CRONUS_muon_data["P_fast_10Be"]+CRONUS_muon_data["P_neg_10Be"];
double p26 = CRONUS_muon_data["P_fast_26Al"]+CRONUS_muon_data["P_neg_26Al"];
Be10_total_mu = p10;
Al26_total_mu = p26;
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// this subfunction does the integration of muon sotpping to get the total
// muon flux
//
// NOTE: THIS IS RATE LIMITING
// Will probably need to come back and try to speed up.
// The best way is to retain previously calculated balues, so at new
// node spacings only the intermediate values are recalculated.
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
double LSDCRNParameters::integrate_muon_flux(double z, double H, double tolerance)
{
// we just use a simple simpsons rule but we keep fining the grid until there
// is no difference in the solution
int n_nodes = 101;
double start_z = z;
double end_z = 2.0e5+1.0;
double spacing = (end_z-z)/double(n_nodes-1);
double a,b, intermediate;
double fa,fb,fi,sum, last_sum;
double integral_difference;
// get the inital guess
b = start_z;
fb = Rv0(b)*exp(H/LZ(b));
sum = 0;
for(int i = 1; i< n_nodes; i++)
{
// locations of spacings
a = b;
b = a+spacing;
intermediate = (b+a)/2.0;
//cout << "z["<<i<<"]: " << a << " i+1/2: " << intermediate << " i+1: " << b << endl;
// functions evaluated at spacings
fa = fb;
fi = Rv0(intermediate)*exp(H/LZ(intermediate));
fb = Rv0(b)*exp(H/LZ(b));
sum+= ((b-a)/6.0)*(fa+4.0*fi+fb);
}
last_sum = sum;
//cout << "LINE 660, integrating muon flux, initial guess: " << last_sum << endl;
double log_error_ratio = 0.5;
double node_multiplier;
// now loop until the error tolerance is reached
do
{
// this implements and adaptive spacing between nodes, determined by the
// ratio between the error and the tolerance in an attempt to speed up
// the integration
node_multiplier = 1.0+log_error_ratio;
// increase the density of the nodes
n_nodes = int(double(n_nodes)*node_multiplier);
//cout << "Looping for simpsons, n_nodes: " << n_nodes << endl;
spacing = (end_z-z)/double(n_nodes-1);
//cout << "Nodes: " << n_nodes << " and spacing: " << spacing << endl;
b = start_z;
fb = Rv0(b)*exp(H/LZ(b));
sum = 0;
for(int i = 1; i< n_nodes; i++)
{
// locations of spacings
a = b;
b = a+spacing;
intermediate = (b+a)/2.0;
// functions evaluated at spacings
fa = fb;
fi = Rv0(intermediate)*exp(H/LZ(intermediate));
fb = Rv0(b)*exp(H/LZ(b));
sum+= ((b-a)/6.0)*(fa+4.0*fi+fb);
}
// compare this integral with the last one
integral_difference = fabs(last_sum-sum);
log_error_ratio = log(integral_difference/tolerance);
//cout << "log error_ratio: " << log_error_ratio << endl;
// reset the last sum
last_sum = sum;
//cout << "this sum: " << last_sum << endl;
} while(integral_difference>tolerance);
// now return the integral
return last_sum;
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// this subfunction returns the stopping rate of vertically traveling muons
// as a function of depth z at sea level and high latitude.
// Modified from Greg Balco's CRONUS calculator
// z is the depth below the surface in g/cm^2
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
double LSDCRNParameters::Rv0(double z)
{
double a = exp(-5.5e-6*z);
double b = z + 21000.0;
double c = pow((z + 1000.0),1.66) + 1.567e5;
double dadz = -5.5e-6 * exp(-5.5e-6*z);
double dbdz = 1.0;
double dcdz = 1.66*(pow((z + 1000),0.66));
double out = -5.401e7*(b*c*dadz-a*(c*dbdz+b*dcdz))/(b*b*c*c);
return out;
// full depth calculation appears in comments below
// testing indicates this isn't really necessary
//R_1 = -5.401e7 .* (b.*c.*dadz - a.*(c.*dbdz + b.*dcdz))./(b.^2 .* c.^2);
//f = (121100./z).^2;
//g = exp(-z./121100);
//dfdz = (-2.*(121100.^2))./(z.^3);
//dgdz = -exp(-z./121100)./121100;
//R_2 = -1.82e-6.*(g.*dfdz + f.*dgdz);
//out(find(z<200000)) = R_1(find(z<200000));
//out(find(z>=200000)) = R_2(find(z>=200000));
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//
// this subfunction returns the effective atmospheric attenuation length for
// muons of range Z
// z is the depth in g/cm^2
//
// Original by Greg Balco as part of the CRONUS calculator
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
double LSDCRNParameters::LZ(double z)
{
//define range/momentum relation
// table for muons in standard rock in Groom and others 2001
// units are range in g cm-2 (column 2)
//momentum in MeV/c (column 1)
vector<double> data_for_LZ_range;
vector<double> data_for_LZ_momentum;
data_for_LZ_momentum.push_back(4.704e1);
data_for_LZ_range.push_back(8.516e-1);
data_for_LZ_momentum.push_back(5.616e1);
data_for_LZ_range.push_back(1.542e0);
data_for_LZ_momentum.push_back(6.802e1);
data_for_LZ_range.push_back(2.866e0);
data_for_LZ_momentum.push_back(8.509e1);
data_for_LZ_range.push_back(5.698e0);
data_for_LZ_momentum.push_back(1.003e2);
data_for_LZ_range.push_back(9.145e0);
data_for_LZ_momentum.push_back(1.527e2);
data_for_LZ_range.push_back(2.676e1);
data_for_LZ_momentum.push_back(1.764e2);
data_for_LZ_range.push_back(3.696e1);
data_for_LZ_momentum.push_back(2.218e2);
data_for_LZ_range.push_back(5.879e1);
data_for_LZ_momentum.push_back(2.868e2);
data_for_LZ_range.push_back(9.332e1);
data_for_LZ_momentum.push_back(3.917e2);
data_for_LZ_range.push_back(1.524e2);
data_for_LZ_momentum.push_back(0.945e2);
data_for_LZ_range.push_back(2.115e2);
data_for_LZ_momentum.push_back(8.995e2);
data_for_LZ_range.push_back(4.418e2);
data_for_LZ_momentum.push_back(1.101e3);
data_for_LZ_range.push_back(5.534e2);
data_for_LZ_momentum.push_back(1.502e3);
data_for_LZ_range.push_back(7.712e2);
data_for_LZ_momentum.push_back(2.103e3);
data_for_LZ_range.push_back(1.088e3);
data_for_LZ_momentum.push_back(3.104e3);
data_for_LZ_range.push_back(1.599e3);
data_for_LZ_momentum.push_back(4.104e3);
data_for_LZ_range.push_back(2.095e3);
data_for_LZ_momentum.push_back(8.105e3);
data_for_LZ_range.push_back(3.998e3);
data_for_LZ_momentum.push_back(1.011e4);
data_for_LZ_range.push_back(4.920e3);
data_for_LZ_momentum.push_back(1.411e4);
data_for_LZ_range.push_back(6.724e3);
data_for_LZ_momentum.push_back(2.011e4);
data_for_LZ_range.push_back(9.360e3);
data_for_LZ_momentum.push_back(3.011e4);
data_for_LZ_range.push_back(1.362e4);
data_for_LZ_momentum.push_back(4.011e4);
data_for_LZ_range.push_back(1.776e4);
data_for_LZ_momentum.push_back(8.011e4);
data_for_LZ_range.push_back(3.343e4);
data_for_LZ_momentum.push_back(1.001e5);
data_for_LZ_range.push_back(4.084e4);
data_for_LZ_momentum.push_back(1.401e5);
data_for_LZ_range.push_back(5.495e4);
data_for_LZ_momentum.push_back(2.001e5);
data_for_LZ_range.push_back(7.459e4);
data_for_LZ_momentum.push_back(3.001e5);
data_for_LZ_range.push_back(1.040e5);
data_for_LZ_momentum.push_back(4.001e5);
data_for_LZ_range.push_back(1.302e5);
data_for_LZ_momentum.push_back(8.001e5);
data_for_LZ_range.push_back(2.129e5);
// deal with zero situation
if(z < 1)
{
z = 1.0;
}
double log_z = log(z);
//cout << "z is:" << z << " and log z is: " << log_z << endl;
// obtain momenta
// use log-linear interpolation
int n_momentum_dpoints = int(data_for_LZ_momentum.size());
vector<double> log_momentum;
vector<double> log_range;
for(int i = 0; i<n_momentum_dpoints; i++)
{
log_momentum.push_back(log(data_for_LZ_momentum[i]));
log_range.push_back(log(data_for_LZ_range[i]));
//cout << "Momentum: " << log_momentum[i] << " range: " << log_range[i] << endl;
}
double P_MeVc = exp(interp1D_ordered(log_range,log_momentum,log_z));
//cout << "log_z: " << log_z << " interp: "
// << interp1D_ordered(log_range,log_momentum,log_z) << " P_MeVc: " << P_MeVc << endl;
// obtain attenuation lengths
double out = 263.0 + 150*(P_MeVc/1000.0);
return out;
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// This sets the parameters to those used by Granger and Smith 2000
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
void LSDCRNParameters::set_Granger_parameters()
{
//S_t = 1;
// from Vermeesh 2007
// 10Be from Chmeleff/Korschinek 10Be decay constant;
lambda_10Be = 500e-9; // in yr-1
lambda_26Al = 980e-9; // in yr-1
lambda_14C = 121e-6; // in yr-1
lambda_36Cl = 230e-8; // in yr-1
// from Vermeesh 2007
// These are calibrated to the Stone scaling
// Also linke to the nishizumii standards
// These come with Cosmocalc version 2.0
// http://www.ucl.ac.uk/~ucfbpve/cosmocalc/updates.html
P0_10Be = 4.30; // in a/g/yr
P0_26Al = 31.10; // in a/g/yr
P0_14C = 15.21; // in a/g/yr
P0_36Cl = 58.95; // in a/g/yr
P0_21Ne = 18.23; // in a/g/yr
P0_3He = 121.59; // in a/g/yr
// in g/cm^2
Gamma[0] = 160;
Gamma[1] = 738.6;
Gamma[2] = 2688;
Gamma[3] = 4360;