diff --git a/Docs/source/usage/parameters.rst b/Docs/source/usage/parameters.rst index 02eed3fce23..11d703d4b73 100644 --- a/Docs/source/usage/parameters.rst +++ b/Docs/source/usage/parameters.rst @@ -574,8 +574,19 @@ Particle initialization * ``.species_type`` (`string`) optional (default `unspecified`) Type of physical species. - Currently, the accepted species are ``"electron"``, ``"positron"``, ``"photon"``, ``"hydrogen"`` (or equivalently ``"proton"``), ``"helium"`` (or equivalently ``"alpha"``), ``"boron"``, ``"carbon"``, ``"oxygen"``, ``"nitrogen"``, ``"argon"``, ``"copper"`` and ``"xenon"``. - Either this or both ``mass`` and ``charge`` have to be specified. + Currently, the accepted species are + ``"electron"``, ``"positron"``, ``"muon"``, ``"antimuon"``, ``"photon"``, ``"neutron"``, ``"proton"`` , ``"alpha"``, + ``"hydrogen1"`` (a.k.a. ``"protium"``), ``"hydrogen2"`` (a.k.a. ``"deuterium"``), ``"hydrogen3"`` (a.k.a.``"tritium"``), + ``"helium"``, ``"helium3"``, ``"helium4"``, + ``"lithium"``, ``"lithium6"``, ``"lithium7"``, ``"beryllium"``, ``"boron"``, ``"boron10"``, ``"boron11"``, + ``"carbon"``, ``"carbon12"``, ``"carbon13"``, ``"nitrogen"``, ``"nitrogen14"``, ``"nitrogen15"``, + ``"oxygen"``, ``"oxygen16"``, ``"oxygen17"``, ``"oxygen18"``, ``"fluorine"``, ``"neon"``, ``"neon20"``, + ``"neon21"``, ``"neon22"``, ``"aluminium"``, ``"argon"``, ``"copper"``, ``"xenon"`` and ``"gold"``. + The difference between ``"proton"`` and ``"hydrogen1"`` is that the mass of the latter includes also the mass + of the bound electron (same for ``"alpha"`` and ``"helium4"``). When only the name of an element is specified, the mass + is a weighted average of the masses of the stable isotopes. For all the elements with ``Z < 11`` we provide + also the stable isotopes as an option for ``species_type`` (e.g., ``"helium3"`` and ``"helium4"``). + Either ``species_type`` or both ``mass`` and ``charge`` have to be specified. * ``.charge`` (`float`) optional (default `NaN`) The charge of one `physical` particle of this species. diff --git a/Examples/Modules/nuclear_fusion/analysis_proton_boron_fusion.py b/Examples/Modules/nuclear_fusion/analysis_proton_boron_fusion.py index 140c281cc7b..37b680deea1 100755 --- a/Examples/Modules/nuclear_fusion/analysis_proton_boron_fusion.py +++ b/Examples/Modules/nuclear_fusion/analysis_proton_boron_fusion.py @@ -66,9 +66,9 @@ MeV_to_Joule = scc.e*1e6 barn_to_square_meter = 1.e-28 m_p = scc.m_p # Proton mass -m_b = 10.9298*m_p # Boron 11 mass +m_b = 11.00930536*scc.m_u # Boron 11 mass m_reduced = m_p*m_b/(m_p+m_b) -m_a = 3.97369*m_p # Alpha mass +m_a = 4.002602*scc.m_u # Alpha mass m_be = 7.94748*m_p # Beryllium 8 mass Z_boron = 5. Z_proton = 1. @@ -381,7 +381,7 @@ def p_sq_boron_frame_to_E_COM_frame(p_proton_sq): E_com = np.sqrt(E_lab**2 - p_proton_sq*scc.c**2) # Corresponding kinetic energy E_com_kin = E_com - (m_b+scc.m_p)*scc.c**2 - return E_com_kin + return E_com_kin*(p_proton_sq>0.) def p_sq_to_kinetic_energy(p_sq, m): ## Returns the kinetic energy of a particle as a function of its squared momentum. diff --git a/Examples/Modules/nuclear_fusion/inputs_3d b/Examples/Modules/nuclear_fusion/inputs_3d index babd2655da3..73f0d52a523 100644 --- a/Examples/Modules/nuclear_fusion/inputs_3d +++ b/Examples/Modules/nuclear_fusion/inputs_3d @@ -32,7 +32,7 @@ algo.particle_shape = 1 particles.species_names = proton1 boron1 alpha1 proton2 boron2 alpha2 proton3 boron3 alpha3 proton4 boron4 alpha4 proton5 boron5 alpha5 -my_constants.m_b11 = 10.9298*m_p # Boron 11 mass +my_constants.m_b11 = 11.00930536*m_u # Boron 11 mass my_constants.m_reduced = m_p*m_b11/(m_p+m_b11) my_constants.keV_to_J = 1.e3*q_e my_constants.Energy_step = 22. * keV_to_J @@ -63,7 +63,7 @@ boron1.momentum_function_uz(x,y,z) = -sqrt(2*m_reduced*Energy_step*(floor(z)**2) boron1.do_not_push = 1 boron1.do_not_deposit = 1 -alpha1.species_type = alpha +alpha1.species_type = helium alpha1.do_not_push = 1 alpha1.do_not_deposit = 1 @@ -94,7 +94,7 @@ boron2.momentum_distribution_type = "constant" boron2.do_not_push = 1 boron2.do_not_deposit = 1 -alpha2.species_type = alpha +alpha2.species_type = helium alpha2.do_not_push = 1 alpha2.do_not_deposit = 1 @@ -120,7 +120,7 @@ boron3.theta = temperature/(m_b11*clight**2) boron3.do_not_push = 1 boron3.do_not_deposit = 1 -alpha3.species_type = alpha +alpha3.species_type = helium alpha3.do_not_push = 1 alpha3.do_not_deposit = 1 @@ -145,7 +145,7 @@ boron4.momentum_distribution_type = "constant" boron4.do_not_push = 1 boron4.do_not_deposit = 1 -alpha4.species_type = alpha +alpha4.species_type = helium alpha4.do_not_push = 1 alpha4.do_not_deposit = 1 @@ -168,7 +168,7 @@ boron5.momentum_distribution_type = "constant" boron5.do_not_push = 1 boron5.do_not_deposit = 1 -alpha5.species_type = alpha +alpha5.species_type = helium alpha5.do_not_push = 1 alpha5.do_not_deposit = 1 diff --git a/Regression/Checksum/benchmarks_json/LaserIonAcc2d.json b/Regression/Checksum/benchmarks_json/LaserIonAcc2d.json index a092c777f5b..a276d6032a1 100644 --- a/Regression/Checksum/benchmarks_json/LaserIonAcc2d.json +++ b/Regression/Checksum/benchmarks_json/LaserIonAcc2d.json @@ -2,37 +2,37 @@ "electrons": { "particle_cpu": 0.0, "particle_id": 2101654260.0, - "particle_momentum_x": 3.8190076010374515e-19, + "particle_momentum_x": 3.819011093562328e-19, "particle_momentum_y": 0.0, - "particle_momentum_z": 1.6442919198257052e-18, - "particle_position_x": 0.008132686110435036, - "particle_position_y": 0.030529759951728817, + "particle_momentum_z": 1.6442909854275157e-18, + "particle_position_x": 0.008132686101590795, + "particle_position_y": 0.030529760810180325, "particle_weight": 2.641331189632942e+17 }, "hydrogen": { "particle_cpu": 0.0, "particle_id": 8663540542.0, - "particle_momentum_x": 2.2442930534191287e-18, + "particle_momentum_x": 2.2442952799834144e-18, "particle_momentum_y": 0.0, - "particle_momentum_z": 1.084110863159823e-18, + "particle_momentum_z": 1.0841140295639398e-18, "particle_orig_x": 0.008258544921875001, "particle_orig_z": 0.0366896337890625, - "particle_position_x": 0.008258183385255663, - "particle_position_y": 0.03668783554837751, + "particle_position_x": 0.008258183633694481, + "particle_position_y": 0.036687836783915156, "particle_weight": 2.701906737218416e+17 }, "lev=0": { "Bx": 0.0, - "By": 11393535.73084639, + "By": 11393530.864665572, "Bz": 0.0, - "Ex": 2033400430027297.5, + "Ex": 2033401599040428.8, "Ey": 0.0, - "Ez": 316047261967858.8, - "jx": 1.6346708093212e+19, + "Ez": 316047997346965.6, + "jx": 1.634666300264935e+19, "jy": 0.0, - "jz": 8.884557829033169e+18, - "rho": 61729754469.05863, - "rho_electrons": 17451988254912.61, - "rho_hydrogen": 17441820007044.357 + "jz": 8.884561198935773e+18, + "rho": 61730016945.00626, + "rho_electrons": 17451988195798.281, + "rho_hydrogen": 17441819816491.93 } } \ No newline at end of file diff --git a/Regression/Checksum/benchmarks_json/PlasmaAccelerationBoost2d.json b/Regression/Checksum/benchmarks_json/PlasmaAccelerationBoost2d.json index 89d62990447..5b99c69ce5b 100644 --- a/Regression/Checksum/benchmarks_json/PlasmaAccelerationBoost2d.json +++ b/Regression/Checksum/benchmarks_json/PlasmaAccelerationBoost2d.json @@ -20,21 +20,21 @@ "particle_weight": 93622636116911.45 }, "lev=0": { - "Bx": 0.3939499531816347, - "By": 9563.615022656986, - "Bz": 0.3591030695780064, - "Ex": 1057402535431.5992, - "Ey": 144244335.4692135, - "Ez": 3010491709181.335, - "jx": 3227914399.2203197, - "jy": 5068791609.127958, - "jz": 102420312561236.62 + "Bx": 0.3939499531816364, + "By": 9563.615022656964, + "Bz": 0.3591030695780125, + "Ex": 1057402535431.6746, + "Ey": 144244335.46922195, + "Ez": 3010491709181.3467, + "jx": 3227914369.7171793, + "jy": 5068791609.12788, + "jz": 102420312561226.17 }, "plasma_e": { "particle_cpu": 504.0, "particle_id": 236124.0, - "particle_momentum_x": 1.2615128163446419e-23, - "particle_momentum_y": 1.5392234050947253e-27, + "particle_momentum_x": 1.2615128163589931e-23, + "particle_momentum_y": 1.5392234051130659e-27, "particle_momentum_z": 1.3694904132251956e-18, "particle_position_x": 0.01771877489382093, "particle_position_y": 0.020620065534187347, @@ -43,11 +43,11 @@ "plasma_p": { "particle_cpu": 504.0, "particle_id": 272412.0, - "particle_momentum_x": 1.2615099271970135e-23, - "particle_momentum_y": 1.5392492676794249e-27, - "particle_momentum_z": 2.514586739414616e-15, - "particle_position_x": 0.017718749986442184, - "particle_position_y": 0.02062006546318014, + "particle_momentum_x": 1.2615099272124483e-23, + "particle_momentum_y": 1.53924926768808e-27, + "particle_momentum_z": 2.51631809113383e-15, + "particle_position_x": 0.017718749986451513, + "particle_position_y": 0.020620065463180168, "particle_weight": 727797380314273.1 } } \ No newline at end of file diff --git a/Regression/Checksum/benchmarks_json/Proton_Boron_Fusion_3D.json b/Regression/Checksum/benchmarks_json/Proton_Boron_Fusion_3D.json index 32e2da2bc94..e63a64a2703 100644 --- a/Regression/Checksum/benchmarks_json/Proton_Boron_Fusion_3D.json +++ b/Regression/Checksum/benchmarks_json/Proton_Boron_Fusion_3D.json @@ -2,43 +2,43 @@ "alpha1": { "particle_cpu": 60780.0, "particle_id": 1351279015596.0, - "particle_momentum_x": 4.659632892446219e-15, - "particle_momentum_y": 4.617309311289228e-15, - "particle_momentum_z": 4.617390264429112e-15, + "particle_momentum_x": 4.659631949650719e-15, + "particle_momentum_y": 4.617308377231923e-15, + "particle_momentum_z": 4.617389330519975e-15, "particle_position_x": 453219.3436004627, - "particle_position_y": 457393.4211433249, + "particle_position_y": 457393.42114332493, "particle_position_z": 970481.0580153911, - "particle_weight": 1.904380063679924e-27 + "particle_weight": 1.9043802455895325e-27 }, "alpha2": { "particle_cpu": 54528.0, "particle_id": 1211463810981.0, - "particle_momentum_x": 4.071679285778659e-15, - "particle_momentum_y": 4.119641921839256e-15, - "particle_momentum_z": 4.181785619797154e-15, + "particle_momentum_x": 4.071678402460901e-15, + "particle_momentum_y": 4.1196410276880726e-15, + "particle_momentum_z": 4.181784710058622e-15, "particle_position_x": 405848.1200755021, - "particle_position_y": 408011.5319128882, + "particle_position_y": 408011.53191288817, "particle_position_z": 866330.5923068221, - "particle_weight": 1.926173353413784e+19 + "particle_weight": 1.9261737121655108e+19 }, "alpha3": { "particle_cpu": 6252.0, "particle_id": 153642773313.0, - "particle_momentum_x": 4.853583107582054e-16, - "particle_momentum_y": 4.797298533911113e-16, - "particle_momentum_z": 4.759502498651132e-16, + "particle_momentum_x": 4.853582081563116e-16, + "particle_momentum_y": 4.797297548379446e-16, + "particle_momentum_z": 4.759501504671248e-16, "particle_position_x": 51342.57223394147, "particle_position_y": 50913.6612890173, - "particle_position_z": 101306.340590083, - "particle_weight": 1.036014694926736e+28 + "particle_position_z": 101306.34059008301, + "particle_weight": 1.0360147595748265e+28 }, "alpha4": { "particle_cpu": 307200.0, "particle_id": 7431218688000.0, - "particle_momentum_x": 2.337391296198344e-14, - "particle_momentum_y": 2.343942459367338e-14, - "particle_momentum_z": 2.355941676163024e-14, - "particle_position_x": 2457367.458278153, + "particle_momentum_x": 2.3373908106523292e-14, + "particle_momentum_y": 2.3439419725501755e-14, + "particle_momentum_z": 2.3559411845892612e-14, + "particle_position_x": 2457367.4582781526, "particle_position_y": 2457512.044373058, "particle_position_z": 4914475.776513073, "particle_weight": 3072.000000000002 @@ -46,11 +46,11 @@ "alpha5": { "particle_cpu": 307200.0, "particle_id": 7619962368000.0, - "particle_momentum_x": 2.333624736682437e-14, - "particle_momentum_y": 2.345594456920183e-14, - "particle_momentum_z": 2.357453114426799e-14, + "particle_momentum_x": 2.333624251961068e-14, + "particle_momentum_y": 2.3455939695798916e-14, + "particle_momentum_z": 2.3574526216382372e-14, "particle_position_x": 2457556.857163842, - "particle_position_y": 2457059.635379324, + "particle_position_y": 2457059.6353793237, "particle_position_z": 4915847.043341331, "particle_weight": 3.0719999999999984e-18 }, @@ -59,7 +59,7 @@ "particle_id": 78643205120000.0, "particle_momentum_x": 0.0, "particle_momentum_y": 0.0, - "particle_momentum_z": 2.524243076150406e-13, + "particle_momentum_z": 2.524242836246531e-13, "particle_position_x": 40958301.591654316, "particle_position_y": 40961136.14476712, "particle_position_z": 81920546.19181262, @@ -74,18 +74,18 @@ "particle_position_x": 409798.0158217681, "particle_position_y": 409670.9858143465, "particle_position_z": 819255.8152412223, - "particle_weight": 1.0239999999360338e+29 + "particle_weight": 1.0239999999357942e+29 }, "boron3": { "particle_cpu": 512000.0, "particle_id": 11639194112000.0, - "particle_momentum_x": 9.277703190700158e-15, - "particle_momentum_y": 9.268420145552847e-15, - "particle_momentum_z": 9.279457128810487e-15, - "particle_position_x": 4096178.166422465, - "particle_position_y": 4096499.706038672, + "particle_momentum_x": 9.277692671587846e-15, + "particle_momentum_y": 9.268409636965691e-15, + "particle_momentum_z": 9.279446607709548e-15, + "particle_position_x": 4096178.1664224654, + "particle_position_y": 4096499.7060386725, "particle_position_z": 8191465.586938233, - "particle_weight": 5.119654661768357e+31 + "particle_weight": 5.119654661746806e+31 }, "boron5": { "particle_cpu": 51200.0, @@ -93,7 +93,7 @@ "particle_momentum_x": 0.0, "particle_momentum_y": 0.0, "particle_momentum_z": 0.0, - "particle_position_x": 409547.3312927569, + "particle_position_x": 409547.33129275695, "particle_position_y": 409518.5558814353, "particle_position_z": 819306.5006950963, "particle_weight": 1023.9999999999999 @@ -106,7 +106,7 @@ "particle_id": 26214405120000.0, "particle_momentum_x": 0.0, "particle_momentum_y": 0.0, - "particle_momentum_z": 2.524243076150406e-13, + "particle_momentum_z": 2.524242836246531e-13, "particle_position_x": 40960140.72983793, "particle_position_y": 40959772.69310104, "particle_position_z": 81919021.52308556, @@ -121,18 +121,18 @@ "particle_position_x": 4095630.698135355, "particle_position_y": 4096073.5517983637, "particle_position_z": 8191737.5566503005, - "particle_weight": 1.022781024071589e+29 + "particle_weight": 1.0227810240713489e+29 }, "proton3": { "particle_cpu": 307181.0, "particle_id": 6731321892958.0, - "particle_momentum_x": 1.684351051519872e-15, - "particle_momentum_y": 1.682381896868337e-15, - "particle_momentum_z": 1.679996145653965e-15, + "particle_momentum_x": 1.6843510515198723e-15, + "particle_momentum_y": 1.6823818968683368e-15, + "particle_momentum_z": 1.6799961456539653e-15, "particle_position_x": 2457338.899376694, "particle_position_y": 2457069.647393952, "particle_position_z": 4914642.288898885, - "particle_weight": 1.023654661768358e+31 + "particle_weight": 1.0236546617468092e+31 }, "proton4": { "particle_cpu": 51200.0, @@ -151,8 +151,8 @@ "particle_momentum_x": 0.0, "particle_momentum_y": 0.0, "particle_momentum_z": 1.7581275870306353e-15, - "particle_position_x": 409638.287761857, - "particle_position_y": 409501.3225783394, + "particle_position_x": 409638.28776185703, + "particle_position_y": 409501.32257833943, "particle_position_z": 819309.1804186807, "particle_weight": 1.0240000000000003e+38 } diff --git a/Regression/Checksum/benchmarks_json/background_mcc.json b/Regression/Checksum/benchmarks_json/background_mcc.json index af6475b6a44..28480ffe4a2 100644 --- a/Regression/Checksum/benchmarks_json/background_mcc.json +++ b/Regression/Checksum/benchmarks_json/background_mcc.json @@ -2,25 +2,25 @@ "electrons": { "particle_cpu": 187518.0, "particle_id": 58269281905.0, - "particle_momentum_x": 1.011638818579948e-18, - "particle_momentum_y": 2.819742987610991e-19, - "particle_momentum_z": 2.809194032686416e-19, - "particle_position_x": 17136.0186544969, - "particle_position_y": 936.3651769904283, + "particle_momentum_x": 1.0116388186647586e-18, + "particle_momentum_y": 2.8197429874443205e-19, + "particle_momentum_z": 2.809194032519318e-19, + "particle_position_x": 17136.01865460215, + "particle_position_y": 936.3651769897449, "particle_weight": 61113170379.63868 }, "he_ions": { "particle_cpu": 262836.0, "particle_id": 206754755365.0, - "particle_momentum_x": 2.883077691926682e-18, - "particle_momentum_y": 2.195706192591097e-18, - "particle_momentum_z": 2.198217877500162e-18, - "particle_position_x": 17607.42545807472, - "particle_position_y": 1100.024786059285, + "particle_momentum_x": 2.8830766335132965e-18, + "particle_momentum_y": 2.1957048705835945e-18, + "particle_momentum_z": 2.198216553980008e-18, + "particle_position_x": 17607.425457521826, + "particle_position_y": 1100.0247860591508, "particle_weight": 71976747650.1465 }, "lev=0": { - "rho_electrons": 0.03566284217155322, - "rho_he_ions": 0.04192588072776678 + "rho_electrons": 0.035662842171864814, + "rho_he_ions": 0.041925880726395526 } } \ No newline at end of file diff --git a/Regression/Checksum/benchmarks_json/background_mcc_dp_psp.json b/Regression/Checksum/benchmarks_json/background_mcc_dp_psp.json index 4b779e655bc..aec36e4c5be 100644 --- a/Regression/Checksum/benchmarks_json/background_mcc_dp_psp.json +++ b/Regression/Checksum/benchmarks_json/background_mcc_dp_psp.json @@ -2,25 +2,25 @@ "electrons": { "particle_cpu": 187506.0, "particle_id": 58260371529.0, - "particle_momentum_x": 1.011437761051452e-18, - "particle_momentum_y": 2.818489820307945e-19, - "particle_momentum_z": 2.810005779603514e-19, - "particle_position_x": 17134.12316775415, - "particle_position_y": 935.6698541530053, + "particle_momentum_x": 1.0114377612798924e-18, + "particle_momentum_y": 2.8184898200776714e-19, + "particle_momentum_z": 2.810005779758007e-19, + "particle_position_x": 17134.123168296646, + "particle_position_y": 935.6698541620412, "particle_weight": 61112621534.71875 }, "he_ions": { "particle_cpu": 262803.0, "particle_id": 206741084466.0, - "particle_momentum_x": 2.882594194576035e-18, - "particle_momentum_y": 2.19602229398326e-18, - "particle_momentum_z": 2.198235662538558e-18, - "particle_position_x": 17605.83295227928, - "particle_position_y": 1099.980517380142, + "particle_momentum_x": 2.8825928770053435e-18, + "particle_momentum_y": 2.1960207748059422e-18, + "particle_momentum_z": 2.1982341415215343e-18, + "particle_position_x": 17605.83295166959, + "particle_position_y": 1099.9805173814, "particle_weight": 71973184795.40625 }, "lev=0": { - "rho_electrons": 0.03566096918916276, - "rho_he_ions": 0.04192386049475352 + "rho_electrons": 0.03566096918517184, + "rho_he_ions": 0.04192386049381602 } } \ No newline at end of file diff --git a/Regression/Checksum/benchmarks_json/embedded_circle.json b/Regression/Checksum/benchmarks_json/embedded_circle.json index 6bb0faa05ff..d17fb86e6be 100644 --- a/Regression/Checksum/benchmarks_json/embedded_circle.json +++ b/Regression/Checksum/benchmarks_json/embedded_circle.json @@ -1,27 +1,27 @@ { "ar_ions": { "particle_cpu": 31743.0, - "particle_id": 3219974926.0, - "particle_momentum_x": 2.673080656628151e-18, - "particle_momentum_y": 2.6734826129917346e-18, - "particle_momentum_z": 2.6677137825404595e-18, - "particle_position_x": 3.174244144020173, - "particle_position_y": 3.1742742523212426, - "particle_weight": 988078308.1054688 + "particle_id": 3219840760.0, + "particle_momentum_x": 2.656937628868437e-18, + "particle_momentum_y": 2.6462397149880108e-18, + "particle_momentum_z": 2.653197184723758e-18, + "particle_position_x": 3.174140583032092, + "particle_position_y": 3.174226960143397, + "particle_weight": 988047180.1757812 }, "electrons": { - "particle_cpu": 30723.0, - "particle_id": 1040042009.0, - "particle_momentum_x": 2.99271246971674e-20, - "particle_momentum_y": 3.014893117483374e-20, - "particle_momentum_z": 3.016015662279529e-20, - "particle_position_x": 3.072306870914145, - "particle_position_y": 3.072501289015288, - "particle_weight": 956421203.6132812 + "particle_cpu": 30736.0, + "particle_id": 1041926893.0, + "particle_momentum_x": 3.017862149732503e-20, + "particle_momentum_y": 3.016284742627221e-20, + "particle_momentum_z": 3.026716864845998e-20, + "particle_position_x": 3.077259990879374, + "particle_position_y": 3.0760809372537063, + "particle_weight": 957635192.8710938 }, "lev=0": { - "phi": 56898.115832092146, - "rho_ar_ions": 257.8023434408326, - "rho_electrons": 250.15834020610757 + "phi": 56891.444043840616, + "rho_ar_ions": 257.79395973399653, + "rho_electrons": 250.42393788893844 } } \ No newline at end of file diff --git a/Regression/Checksum/benchmarks_json/multi_J_2d_psatd.json b/Regression/Checksum/benchmarks_json/multi_J_2d_psatd.json index 7374c6b3c4c..b205ebce78b 100644 --- a/Regression/Checksum/benchmarks_json/multi_J_2d_psatd.json +++ b/Regression/Checksum/benchmarks_json/multi_J_2d_psatd.json @@ -2,50 +2,50 @@ "driver": { "particle_cpu": 0.0, "particle_id": 5000050000.0, - "particle_momentum_x": 1.4539950862665395e-16, + "particle_momentum_x": 1.4539941020025028e-16, "particle_momentum_y": 0.0, - "particle_momentum_z": 9.822790382172455e-09, - "particle_position_x": 0.40000376722743924, + "particle_momentum_z": 9.822790382172444e-09, + "particle_position_x": 0.4000037672275025, "particle_position_y": 30.100865423602578, "particle_weight": 124830181489215.27 }, "lev=0": { "Bx": 0.0, - "By": 923872.859945843, + "By": 923873.3689884299, "Bz": 0.0, - "Ex": 271445847158043.47, + "Ex": 271445959245867.38, "Ey": 0.0, - "Ez": 93017427963875.12, - "F": 6525.367402828258, + "Ez": 93017410300609.08, + "F": 6525.329585276354, "G": 0.0, - "divE": 2.511375187843704e+19, - "jx": 1.007185165524125e+16, + "divE": 2.511377423363695e+19, + "jx": 1.0071853348781318e+16, "jy": 0.0, - "jz": 6.431576337481891e+16, - "rho": 220511207.32501236, - "rho_driver": 2562225.119933119, + "jz": 6.431583372170538e+16, + "rho": 220511427.01289138, + "rho_driver": 2562225.119933118, "rho_driver_back": 0.0, - "rho_plasma_e": 1359622971.7373238, - "rho_plasma_p": 1361225480.346084 + "rho_plasma_e": 1359622970.398378, + "rho_plasma_p": 1361225477.7925916 }, "plasma_e": { "particle_cpu": 29652.0, "particle_id": 1194907032.0, - "particle_momentum_x": 7.245349306901261e-19, + "particle_momentum_x": 7.24535866217633e-19, "particle_momentum_y": 0.0, - "particle_momentum_z": 2.3479179887756406e-17, - "particle_position_x": 1.392419539654138, - "particle_position_y": 10.079133897885754, + "particle_momentum_z": 2.3479181521728354e-17, + "particle_position_x": 1.3924195384912583, + "particle_position_y": 10.079133954833015, "particle_weight": 6.643024495443786e+16 }, "plasma_p": { "particle_cpu": 29696.0, "particle_id": 1202173888.0, - "particle_momentum_x": 1.451501915278136e-18, + "particle_momentum_x": 1.4515031430944076e-18, "particle_momentum_y": 0.0, - "particle_momentum_z": 4.005705789406174e-14, - "particle_position_x": 1.345648018905137, - "particle_position_y": 10.08215472964829, + "particle_momentum_z": 4.0084640226979506e-14, + "particle_position_x": 1.3456479857933001, + "particle_position_y": 10.082154761668846, "particle_weight": 6.652881944445523e+16 } } \ No newline at end of file diff --git a/Regression/Checksum/benchmarks_json/multi_J_2d_psatd_pml.json b/Regression/Checksum/benchmarks_json/multi_J_2d_psatd_pml.json index 16e8ff1fa3e..02ffb91077e 100644 --- a/Regression/Checksum/benchmarks_json/multi_J_2d_psatd_pml.json +++ b/Regression/Checksum/benchmarks_json/multi_J_2d_psatd_pml.json @@ -2,50 +2,50 @@ "driver": { "particle_cpu": 0.0, "particle_id": 5000050000.0, - "particle_momentum_x": 1.449993483262996e-16, + "particle_momentum_x": 1.4499925060974604e-16, "particle_momentum_y": 0.0, - "particle_momentum_z": 9.822790382300402e-09, - "particle_position_x": 0.400003767572696, + "particle_momentum_z": 9.82279038230039e-09, + "particle_position_x": 0.4000037675727589, "particle_position_y": 30.100865423602578, "particle_weight": 124830181489215.27 }, "lev=0": { "Bx": 0.0, - "By": 921659.2047215957, + "By": 921659.7003424203, "Bz": 0.0, - "Ex": 270877084380906.22, + "Ex": 270877199432990.72, "Ey": 0.0, - "Ez": 92626603051693.27, - "F": 6184.06416309773, + "Ez": 92626589083860.39, + "F": 6184.029984601904, "G": 0.0, - "divE": 2.519002692443211e+19, - "jx": 1.0172599655812156e+16, + "divE": 2.519005022753751e+19, + "jx": 1.0172600337490698e+16, "jy": 0.0, - "jz": 6.385227447336726e+16, - "rho": 220316369.1396134, - "rho_driver": 2562225.119933118, + "jz": 6.3852340601837256e+16, + "rho": 220316594.2695177, + "rho_driver": 2562225.1199331186, "rho_driver_back": 0.0, - "rho_plasma_e": 1359476241.7588131, - "rho_plasma_p": 1361225460.3717313 + "rho_plasma_e": 1359476240.39297, + "rho_plasma_p": 1361225457.832027 }, "plasma_e": { "particle_cpu": 29646.0, "particle_id": 1194846491.0, - "particle_momentum_x": 7.183638384394021e-19, + "particle_momentum_x": 7.183647425698553e-19, "particle_momentum_y": 0.0, - "particle_momentum_z": 2.346425019530925e-17, - "particle_position_x": 1.391891175298253, - "particle_position_y": 10.07633717300163, + "particle_momentum_z": 2.3464251836665685e-17, + "particle_position_x": 1.3918911743233844, + "particle_position_y": 10.076337229777174, "particle_weight": 6.641680297852639e+16 }, "plasma_p": { "particle_cpu": 29696.0, "particle_id": 1202173888.0, - "particle_momentum_x": 1.4494632574716746e-18, + "particle_momentum_x": 1.4494644790319828e-18, "particle_momentum_y": 0.0, - "particle_momentum_z": 4.0057072158337995e-14, - "particle_position_x": 1.3456480684446548, - "particle_position_y": 10.082154799435534, + "particle_momentum_z": 4.008465449121937e-14, + "particle_position_x": 1.3456480352993405, + "particle_position_y": 10.082154831407932, "particle_weight": 6.652881944445523e+16 } } \ No newline at end of file diff --git a/Regression/Checksum/benchmarks_json/multi_J_rz_psatd.json b/Regression/Checksum/benchmarks_json/multi_J_rz_psatd.json index 9f00c914745..536df09393a 100644 --- a/Regression/Checksum/benchmarks_json/multi_J_rz_psatd.json +++ b/Regression/Checksum/benchmarks_json/multi_J_rz_psatd.json @@ -6,40 +6,40 @@ "particle_momentum_y": 8.719285567351437e-16, "particle_momentum_z": 5.461771334692466e-13, "particle_position_x": 6.269566322411488, - "particle_position_y": 17.93420080596407, - "particle_theta": 1570790.043609588, + "particle_position_y": 17.934200805964075, + "particle_theta": 1570790.0436095877, "particle_weight": 6241484108.424456 }, "lev=0": { - "By": 24912.66213622398, - "Ex": 4667305981763.072, - "Ez": 4307437907855.343, - "jx": 362736023475894.4, - "jz": 1937267309900551.0, - "rho": 5308545.334478145, - "rho_driver": 6288266.101815153, - "rho_plasma_e": 49569864.07552357, - "rho_plasma_p": 50769175.53040837 + "By": 24912.66260587033, + "Ex": 4667306677660.305, + "Ez": 4307437890419.4253, + "jx": 362735950033724.2, + "jz": 1937267340131275.2, + "rho": 5308546.075566203, + "rho_driver": 6288266.101815152, + "rho_plasma_e": 49569864.00850832, + "rho_plasma_p": 50769174.61530346 }, "plasma_e": { "particle_cpu": 12650.0, "particle_id": 159086515.0, - "particle_momentum_x": 6.658110480654614e-20, - "particle_momentum_y": 6.738986103368656e-20, - "particle_momentum_z": 2.846571070844049e-20, - "particle_position_x": 1.142336749037713, - "particle_position_y": 0.6139715590982434, + "particle_momentum_x": 6.65811141013141e-20, + "particle_momentum_y": 6.738987045495091e-20, + "particle_momentum_z": 2.846571109435123e-20, + "particle_position_x": 1.1423367495493797, + "particle_position_y": 0.6139715590509269, "particle_theta": 20188.939948727297, "particle_weight": 1002457942911.3788 }, "plasma_p": { "particle_cpu": 12650.0, "particle_id": 163728835.0, - "particle_momentum_x": 6.640191214031372e-20, - "particle_momentum_y": 6.767586994284535e-20, - "particle_momentum_z": 5.584762252475822e-20, - "particle_position_x": 1.13652015776656, - "particle_position_y": 0.6152066993974457, + "particle_momentum_x": 6.640192720118765e-20, + "particle_momentum_y": 6.767588557043428e-20, + "particle_momentum_z": 5.58476124317102e-20, + "particle_position_x": 1.1365201600226575, + "particle_position_y": 0.6152066982817419, "particle_theta": 20286.92798337582, "particle_weight": 1002457942911.3788 } diff --git a/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.cpp b/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.cpp index e62b18a2785..fc3aee298c8 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.cpp +++ b/Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.cpp @@ -5,9 +5,12 @@ * License: BSD-3-Clause-LBNL */ #include "BackTransformParticleFunctor.H" + #include "Particles/Pusher/GetAndSetPosition.H" #include "Particles/WarpXParticleContainer.H" +#include "Utils/WarpXConst.H" #include "WarpX.H" + #include #include #include diff --git a/Source/Initialization/PlasmaInjector.cpp b/Source/Initialization/PlasmaInjector.cpp index 9dc4692f7d1..3eced8f5d96 100644 --- a/Source/Initialization/PlasmaInjector.cpp +++ b/Source/Initialization/PlasmaInjector.cpp @@ -125,7 +125,10 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name) std::string physical_species_s; bool species_is_specified = pp_species_name.query("species_type", physical_species_s); if (species_is_specified){ - physical_species = species::from_string( physical_species_s ); + const auto physical_species_from_string = species::from_string( physical_species_s ); + WARPX_ALWAYS_ASSERT_WITH_MESSAGE(physical_species_from_string, + physical_species_s + " does not exist!"); + physical_species = physical_species_from_string.value(); charge = species::get_charge( physical_species ); mass = species::get_mass( physical_species ); } diff --git a/Source/Particles/CMakeLists.txt b/Source/Particles/CMakeLists.txt index 6dd553f2415..4fd69f8539e 100644 --- a/Source/Particles/CMakeLists.txt +++ b/Source/Particles/CMakeLists.txt @@ -8,6 +8,7 @@ target_sources(WarpX WarpXParticleContainer.cpp LaserParticleContainer.cpp ParticleBoundaryBuffer.cpp + SpeciesPhysicalProperties.cpp ) #add_subdirectory(Algorithms) diff --git a/Source/Particles/Collision/BinaryCollision/BinaryCollisionUtils.cpp b/Source/Particles/Collision/BinaryCollision/BinaryCollisionUtils.cpp index 7e78d95ed80..cc0c70fceb2 100644 --- a/Source/Particles/Collision/BinaryCollision/BinaryCollisionUtils.cpp +++ b/Source/Particles/Collision/BinaryCollision/BinaryCollisionUtils.cpp @@ -26,9 +26,9 @@ namespace BinaryCollisionUtils{ auto& species1 = mypc->GetParticleContainerFromName(species_names[0]); auto& species2 = mypc->GetParticleContainerFromName(species_names[1]); - if ((species1.AmIA() && species2.AmIA()) + if ((species1.AmIA() && species2.AmIA()) || - (species1.AmIA() && species2.AmIA()) + (species1.AmIA() && species2.AmIA()) ) { return NuclearFusionType::ProtonBoron; diff --git a/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H b/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H index b203955150c..be1d9622edc 100644 --- a/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H +++ b/Source/Particles/Collision/BinaryCollision/NuclearFusion/NuclearFusionFunc.H @@ -76,7 +76,7 @@ public: auto& product_species = mypc->GetParticleContainerFromName(product_species_name[0]); WARPX_ALWAYS_ASSERT_WITH_MESSAGE( product_species.AmIA(), - "ERROR: Product species of proton-boron fusion must be of type helium"); + "ERROR: Product species of proton-boron fusion must be of type alpha"); } // default fusion multiplier diff --git a/Source/Particles/Collision/BinaryCollision/NuclearFusion/ProtonBoronFusionInitializeMomentum.H b/Source/Particles/Collision/BinaryCollision/NuclearFusion/ProtonBoronFusionInitializeMomentum.H index 9a63874fddb..085fc597f58 100644 --- a/Source/Particles/Collision/BinaryCollision/NuclearFusion/ProtonBoronFusionInitializeMomentum.H +++ b/Source/Particles/Collision/BinaryCollision/NuclearFusion/ProtonBoronFusionInitializeMomentum.H @@ -81,7 +81,7 @@ namespace { // which can cause compilation to fail or generate a warning, so we're explicitly setting // them as double. Note that nuclear fusion module does not currently work with single // precision anyways. - constexpr double m_alpha = PhysConst::m_p * 3.97369_prt; + constexpr double m_alpha = PhysConst::m_u * 4.002602_prt; constexpr double m_beryllium = PhysConst::m_p * 7.94748_prt; constexpr double mBe_sq = m_beryllium*m_beryllium; constexpr amrex::ParticleReal c_sq = PhysConst::c * PhysConst::c; diff --git a/Source/Particles/Deposition/CurrentDeposition.H b/Source/Particles/Deposition/CurrentDeposition.H index f508871c672..edeaba7cd63 100644 --- a/Source/Particles/Deposition/CurrentDeposition.H +++ b/Source/Particles/Deposition/CurrentDeposition.H @@ -12,6 +12,7 @@ #include "Particles/Pusher/GetAndSetPosition.H" #include "Particles/ShapeFactors.H" #include "Utils/WarpXAlgorithmSelection.H" +#include "Utils/WarpXConst.H" #ifdef WARPX_DIM_RZ # include "Utils/WarpX_Complex.H" #endif diff --git a/Source/Particles/Gather/GetExternalFields.H b/Source/Particles/Gather/GetExternalFields.H index 954b94fc7d6..66b98385373 100644 --- a/Source/Particles/Gather/GetExternalFields.H +++ b/Source/Particles/Gather/GetExternalFields.H @@ -4,6 +4,7 @@ #include "Particles/Pusher/GetAndSetPosition.H" #include "Particles/WarpXParticleContainer_fwd.H" +#include "Utils/WarpXConst.H" #include #include diff --git a/Source/Particles/Make.package b/Source/Particles/Make.package index d0f7fc87040..58cbe11a980 100644 --- a/Source/Particles/Make.package +++ b/Source/Particles/Make.package @@ -6,6 +6,7 @@ CEXE_sources += PhotonParticleContainer.cpp CEXE_sources += LaserParticleContainer.cpp CEXE_sources += ParticleBoundaryBuffer.cpp CEXE_sources += ParticleBoundaries.cpp +CEXE_sources += SpeciesPhysicalProperties.cpp include $(WARPX_HOME)/Source/Particles/Algorithms/Make.package include $(WARPX_HOME)/Source/Particles/Pusher/Make.package diff --git a/Source/Particles/SpeciesPhysicalProperties.H b/Source/Particles/SpeciesPhysicalProperties.H index b70f95c5014..dba12e353f5 100644 --- a/Source/Particles/SpeciesPhysicalProperties.H +++ b/Source/Particles/SpeciesPhysicalProperties.H @@ -8,180 +8,50 @@ #ifndef WARPX_SPECIESPHYSICALPROPERTIES_H_ #define WARPX_SPECIESPHYSICALPROPERTIES_H_ -#include "Utils/WarpXConst.H" - -#include #include -#include -#include +#include #include -enum struct PhysicalSpecies{unspecified=0, electron, positron, photon, hydrogen, helium, boron, - boron10, boron11, carbon, nitrogen, oxygen, argon, copper, xenon}; +enum struct PhysicalSpecies{ + unspecified=0, electron, positron, muon, antimuon, photon, neutron, proton, hydrogen, hydrogen1, hydrogen2, hydrogen3, + helium, helium3, helium4, alpha, lithium, lithium6, lithium7, beryllium, beryllium9, boron, boron10, boron11, carbon, + carbon12, carbon13, carbon14, nitrogen, nitrogen14, nitrogen15, oxygen, oxygen16, oxygen17, oxygen18, fluorine, + fluorine19, neon, neon20, neon21, neon22, aluminium, argon, copper, xenon, gold}; namespace species { - AMREX_FORCE_INLINE - PhysicalSpecies from_string(std::string species) - { - if( species=="unspecified" ) - return PhysicalSpecies::unspecified; - if( species=="electron" ) - return PhysicalSpecies::electron; - if( species=="positron" ) - return PhysicalSpecies::positron; - if( species=="photon" ) - return PhysicalSpecies::photon; - if( species=="hydrogen" ) - return PhysicalSpecies::hydrogen; - if( species=="proton" ) - return PhysicalSpecies::hydrogen; - if( species=="helium" ) - return PhysicalSpecies::helium; - if( species=="alpha" ) - return PhysicalSpecies::helium; - if( species=="boron" ) - return PhysicalSpecies::boron; - if( species=="boron10" ) - return PhysicalSpecies::boron10; - if( species=="boron11" ) - return PhysicalSpecies::boron11; - if( species=="carbon" ) - return PhysicalSpecies::carbon; - if( species=="nitrogen" ) - return PhysicalSpecies::nitrogen; - if( species=="oxygen" ) - return PhysicalSpecies::oxygen; - if( species=="argon" ) - return PhysicalSpecies::argon; - if( species=="copper" ) - return PhysicalSpecies::copper; - if( species=="xenon" ) - return PhysicalSpecies::xenon; - amrex::Abort("unknown PhysicalSpecies"); - return PhysicalSpecies::unspecified; - } - - AMREX_FORCE_INLINE - amrex::Real get_charge (PhysicalSpecies ps) - { - switch(ps) { - case PhysicalSpecies::unspecified: - return std::numeric_limits::quiet_NaN(); - case PhysicalSpecies::electron: - return -PhysConst::q_e; - case PhysicalSpecies::positron: - return PhysConst::q_e; - case PhysicalSpecies::photon: - return 0.; - case PhysicalSpecies::hydrogen: - return PhysConst::q_e; - case PhysicalSpecies::helium: - return PhysConst::q_e * amrex::Real(2.0); - case PhysicalSpecies::boron: - return PhysConst::q_e * amrex::Real(5.0); - case PhysicalSpecies::boron10: - return PhysConst::q_e * amrex::Real(5.0); - case PhysicalSpecies::boron11: - return PhysConst::q_e * amrex::Real(5.0); - case PhysicalSpecies::carbon: - return PhysConst::q_e * amrex::Real(6.0); - case PhysicalSpecies::nitrogen: - return PhysConst::q_e * amrex::Real(7.0); - case PhysicalSpecies::oxygen: - return PhysConst::q_e * amrex::Real(8.0); - case PhysicalSpecies::argon: - return PhysConst::q_e * amrex::Real(18.0); - case PhysicalSpecies::copper: - return PhysConst::q_e * amrex::Real(29.0); - case PhysicalSpecies::xenon: - return PhysConst::q_e * amrex::Real(54.0); - default: - amrex::Abort("unknown PhysicalSpecies"); - return 0.; - } - } - - AMREX_FORCE_INLINE - amrex::Real get_mass (PhysicalSpecies ps) - { - switch(ps) { - case PhysicalSpecies::unspecified: - return std::numeric_limits::quiet_NaN(); - case PhysicalSpecies::electron: - return PhysConst::m_e; - case PhysicalSpecies::positron: - return PhysConst::m_e; - case PhysicalSpecies::photon: - return 0.; - case PhysicalSpecies::hydrogen: - return PhysConst::m_p; - case PhysicalSpecies::helium: - return PhysConst::m_p * amrex::Real(3.97369); - case PhysicalSpecies::boron: - return PhysConst::m_p * amrex::Real(10.7319); - case PhysicalSpecies::boron10: - return PhysConst::m_p * amrex::Real(9.94060); - case PhysicalSpecies::boron11: - return PhysConst::m_p * amrex::Real(10.9298); - case PhysicalSpecies::carbon: - return PhysConst::m_e * amrex::Real(22032.0); - case PhysicalSpecies::nitrogen: - return PhysConst::m_e * amrex::Real(25716.9); - case PhysicalSpecies::oxygen: - return PhysConst::m_p * amrex::Real(15.8834); - case PhysicalSpecies::argon: - return PhysConst::m_p * amrex::Real(39.9480); - case PhysicalSpecies::copper: - return PhysConst::m_p * amrex::Real(63.0864); - case PhysicalSpecies::xenon: - return PhysConst::m_p * amrex::Real(131.293); - default: - amrex::Abort("unknown PhysicalSpecies"); - return 0.; - } - } - - AMREX_FORCE_INLINE - std::string get_name (PhysicalSpecies ps) - { - switch(ps) { - case PhysicalSpecies::unspecified: - return "unspecified"; - case PhysicalSpecies::electron: - return "electron"; - case PhysicalSpecies::positron: - return "positron"; - case PhysicalSpecies::photon: - return "photon"; - case PhysicalSpecies::hydrogen: - return "hydrogen"; - case PhysicalSpecies::helium: - return "helium"; - case PhysicalSpecies::boron: - return "boron"; - case PhysicalSpecies::boron10: - return "boron10"; - case PhysicalSpecies::boron11: - return "boron11"; - case PhysicalSpecies::carbon: - return "carbon"; - case PhysicalSpecies::nitrogen: - return "nitrogen"; - case PhysicalSpecies::oxygen: - return "oxygen"; - case PhysicalSpecies::argon: - return "argon"; - case PhysicalSpecies::copper: - return "copper"; - case PhysicalSpecies::xenon: - return "xenon"; - default: - amrex::Abort("unknown PhysicalSpecies"); - return ""; - } - } + /** + * \brief Returns the PhysicalSpecies associated to a given name + * + * \param[in] species_name the name of a species + * \return the PhysicalSpecies corresponding to species_name (if it exists) + */ + std::optional from_string (const std::string& species_name); + + /** + * \brief Returns the charge associated to a PhysicalSpecies + * + * \param[in] ps the PhysicalSpecies + * \return the charge associated to the PhysicalSpecies + */ + amrex::Real get_charge (const PhysicalSpecies& ps); + + /** + * \brief Returns the mass associated to a PhysicalSpecies + * + * \param[in] ps the PhysicalSpecies + * \return the mass associated to the PhysicalSpecies + */ + amrex::Real get_mass (const PhysicalSpecies& ps); + + /** + * \brief Returns the name associated to a PhysicalSpecies + * + * \param[in] ps the PhysicalSpecies + * \return the name associated to the PhysicalSpecies + */ + std::string get_name (const PhysicalSpecies& ps); } #endif // WARPX_SPECIESPHYSICALPROPERTIES_H_ diff --git a/Source/Particles/SpeciesPhysicalProperties.cpp b/Source/Particles/SpeciesPhysicalProperties.cpp new file mode 100644 index 00000000000..8086b14bd29 --- /dev/null +++ b/Source/Particles/SpeciesPhysicalProperties.cpp @@ -0,0 +1,296 @@ +/* Copyright 2021 Luca Fedeli Maxence Thevenet + * + * This file is part of WarpX. + * + * License: BSD-3-Clause-LBNL + */ +#include "SpeciesPhysicalProperties.H" + +#include "Utils/WarpXConst.H" + +#include + +#include +#include +#include + +using namespace species; + +namespace { + struct Properties + { + amrex::Real mass; + amrex::Real charge; + }; + + const auto string_to_species = std::map{ + {"unspecified", PhysicalSpecies::unspecified}, + {"electron" , PhysicalSpecies::electron}, + {"positron" , PhysicalSpecies::positron}, + {"muon" , PhysicalSpecies::muon}, + {"antimuon" , PhysicalSpecies::antimuon}, + {"photon" , PhysicalSpecies::photon}, + {"neutron" , PhysicalSpecies::neutron}, + {"hydrogen" , PhysicalSpecies::hydrogen}, + {"hydrogen1" , PhysicalSpecies::hydrogen1}, + {"protium" , PhysicalSpecies::hydrogen1}, + {"hydrogen2" , PhysicalSpecies::hydrogen2}, + {"deuterium" , PhysicalSpecies::hydrogen2}, + {"hydrogen3" , PhysicalSpecies::hydrogen3}, + {"tritium" , PhysicalSpecies::hydrogen3}, + {"proton" , PhysicalSpecies::proton}, + {"helium" , PhysicalSpecies::helium}, + {"alpha" , PhysicalSpecies::alpha}, + {"helium3" , PhysicalSpecies::helium3}, + {"helium4" , PhysicalSpecies::helium4}, + {"alpha" , PhysicalSpecies::alpha}, + {"lithium" , PhysicalSpecies::lithium}, + {"lithium6" , PhysicalSpecies::lithium6}, + {"lithium7" , PhysicalSpecies::lithium7}, + {"beryllium" , PhysicalSpecies::beryllium}, + {"beryllium9" , PhysicalSpecies::beryllium9}, + {"boron" , PhysicalSpecies::boron}, + {"boron10" , PhysicalSpecies::boron10}, + {"boron11" , PhysicalSpecies::boron11}, + {"carbon" , PhysicalSpecies::carbon}, + {"carbon12" , PhysicalSpecies::carbon12}, + {"carbon13" , PhysicalSpecies::carbon13}, + {"carbon14" , PhysicalSpecies::carbon14}, + {"nitrogen" , PhysicalSpecies::nitrogen}, + {"nitrogen14" , PhysicalSpecies::nitrogen14}, + {"nitrogen15" , PhysicalSpecies::nitrogen15}, + {"oxygen" , PhysicalSpecies::oxygen}, + {"oxygen16" , PhysicalSpecies::oxygen16}, + {"oxygen17" , PhysicalSpecies::oxygen17}, + {"oxygen18" , PhysicalSpecies::oxygen18}, + {"fluorine" , PhysicalSpecies::fluorine}, + {"fluorine19" , PhysicalSpecies::fluorine19}, + {"neon" , PhysicalSpecies::neon}, + {"neon20" , PhysicalSpecies::neon20}, + {"neon21" , PhysicalSpecies::neon21}, + {"neon22" , PhysicalSpecies::neon22}, + {"aluminium" , PhysicalSpecies::aluminium}, + {"argon" , PhysicalSpecies::argon}, + {"copper" , PhysicalSpecies::copper}, + {"xenon" , PhysicalSpecies::xenon}, + {"gold" , PhysicalSpecies::gold}, + }; + + const auto species_to_string = std::map{ + {PhysicalSpecies::unspecified, "unspecified"}, + {PhysicalSpecies::electron , "electron"}, + {PhysicalSpecies::positron , "positron"}, + {PhysicalSpecies::muon , "muon"}, + {PhysicalSpecies::antimuon , "antimuon"}, + {PhysicalSpecies::photon , "photon"}, + {PhysicalSpecies::neutron , "neutron"}, + {PhysicalSpecies::hydrogen , "hydrogen"}, + {PhysicalSpecies::hydrogen1 , "hydrogen1"}, + {PhysicalSpecies::hydrogen2 , "hydrogen2"}, + {PhysicalSpecies::hydrogen3 , "hydrogen3"}, + {PhysicalSpecies::proton , "proton"}, + {PhysicalSpecies::helium , "helium"}, + {PhysicalSpecies::helium3 , "helium3"}, + {PhysicalSpecies::helium4 , "helium4"}, + {PhysicalSpecies::alpha , "alpha"}, + {PhysicalSpecies::lithium , "lithium"}, + {PhysicalSpecies::lithium6 , "lithium6"}, + {PhysicalSpecies::lithium7 , "lithium7"}, + {PhysicalSpecies::beryllium , "beryllium"}, + {PhysicalSpecies::beryllium9 , "beryllium9"}, + {PhysicalSpecies::boron , "boron"}, + {PhysicalSpecies::boron10 , "boron10"}, + {PhysicalSpecies::boron11 , "boron11"}, + {PhysicalSpecies::carbon , "carbon"}, + {PhysicalSpecies::carbon12 , "carbon12"}, + {PhysicalSpecies::carbon13 , "carbon13"}, + {PhysicalSpecies::carbon14 , "carbon14"}, + {PhysicalSpecies::nitrogen , "nitrogen"}, + {PhysicalSpecies::nitrogen14 , "nitrogen14"}, + {PhysicalSpecies::nitrogen15 , "nitrogen15"}, + {PhysicalSpecies::oxygen , "oxygen"}, + {PhysicalSpecies::oxygen16 , "oxygen16"}, + {PhysicalSpecies::oxygen17 , "oxygen17"}, + {PhysicalSpecies::oxygen18 , "oxygen18"}, + {PhysicalSpecies::fluorine , "fluorine"}, + {PhysicalSpecies::fluorine19 , "fluorine19"}, + {PhysicalSpecies::neon , "neon"}, + {PhysicalSpecies::neon20 , "neon20"}, + {PhysicalSpecies::neon21 , "neon21"}, + {PhysicalSpecies::neon22 , "neon22"}, + {PhysicalSpecies::aluminium , "aluminium"}, + {PhysicalSpecies::argon , "argon"}, + {PhysicalSpecies::copper , "copper"}, + {PhysicalSpecies::xenon , "xenon"}, + {PhysicalSpecies::gold , "gold"} + }; + + constexpr auto quiet_NaN = std::numeric_limits::quiet_NaN(); + + // The atomic mass data below is from this NIST page + // https://physics.nist.gov/cgi-bin/Compositions/stand_alone.pl?ele=&ascii=ascii2&isotype=some + const + std::map species_to_properties + { + {PhysicalSpecies::unspecified, Properties{ + quiet_NaN, + quiet_NaN}}, + {PhysicalSpecies::electron, Properties{ + PhysConst::m_e, + -PhysConst::q_e}}, + {PhysicalSpecies::positron, Properties{ + PhysConst::m_e, + PhysConst::q_e}}, + {PhysicalSpecies::muon, Properties{ + amrex::Real(206.7682830) * PhysConst::m_e, + -PhysConst::q_e}}, + {PhysicalSpecies::antimuon, Properties{ + amrex::Real(206.7682830) * PhysConst::m_e, + PhysConst::q_e}}, + {PhysicalSpecies::photon, Properties{ + amrex::Real(0.0), + amrex::Real(0.0)}}, + {PhysicalSpecies::neutron, Properties{ + amrex::Real(1.0013784193052508) * PhysConst::m_p, + amrex::Real(0.0)}}, + {PhysicalSpecies::proton, Properties{ + PhysConst::m_p, + PhysConst::q_e}}, + {PhysicalSpecies::hydrogen, Properties{ + amrex::Real(1.00797) * PhysConst::m_u, + amrex::Real(1) * PhysConst::q_e}}, + {PhysicalSpecies::hydrogen1, Properties{ + amrex::Real(1.00782503223) * PhysConst::m_u, + amrex::Real(1) * PhysConst::q_e}}, + {PhysicalSpecies::hydrogen2, Properties{ + amrex::Real(2.01410177812) * PhysConst::m_u, + amrex::Real(1) * PhysConst::q_e}}, + {PhysicalSpecies::hydrogen3, Properties{ + amrex::Real(3.0160492779) * PhysConst::m_u, + amrex::Real(1) * PhysConst::q_e}}, + {PhysicalSpecies::helium, Properties{ + amrex::Real(4.002602) * PhysConst::m_u, + amrex::Real(2) * PhysConst::q_e}}, + {PhysicalSpecies::helium3, Properties{ + amrex::Real(3.0160293201) * PhysConst::m_u, + amrex::Real(2) * PhysConst::q_e}}, + {PhysicalSpecies::helium4, Properties{ + amrex::Real(4.00260325413) * PhysConst::m_u, + amrex::Real(2) * PhysConst::q_e}}, + {PhysicalSpecies::alpha, Properties{ + amrex::Real(4.00260325413) * PhysConst::m_u - amrex::Real(2) * PhysConst::m_e, + amrex::Real(2) * PhysConst::q_e}}, + {PhysicalSpecies::lithium, Properties{ + amrex::Real(6.967) * PhysConst::m_u, + amrex::Real(3) * PhysConst::q_e}}, + {PhysicalSpecies::lithium6, Properties{ + amrex::Real(6.0151228874) * PhysConst::m_u, + amrex::Real(3) * PhysConst::q_e}}, + {PhysicalSpecies::lithium7, Properties{ + amrex::Real(7.0160034366) * PhysConst::m_u, + amrex::Real(3) * PhysConst::q_e}}, + {PhysicalSpecies::beryllium, Properties{ + amrex::Real(9.0121831) * PhysConst::m_u, + amrex::Real(4) * PhysConst::q_e}}, + {PhysicalSpecies::beryllium9, Properties{ + amrex::Real(9.012183065) * PhysConst::m_u, + amrex::Real(4) * PhysConst::q_e}}, + {PhysicalSpecies::boron, Properties{ + amrex::Real(10.813) * PhysConst::m_u, + amrex::Real(5) * PhysConst::q_e}}, + {PhysicalSpecies::boron10, Properties{ + amrex::Real(10.01293695) * PhysConst::m_u, + amrex::Real(5) * PhysConst::q_e}}, + {PhysicalSpecies::boron11, Properties{ + amrex::Real(11.00930536) * PhysConst::m_u, + amrex::Real(5) * PhysConst::q_e}}, + {PhysicalSpecies::carbon, Properties{ + amrex::Real(12.0106) * PhysConst::m_u, + amrex::Real(6) * PhysConst::q_e}}, + {PhysicalSpecies::carbon12, Properties{ + amrex::Real(12.0000000) * PhysConst::m_u, + amrex::Real(6) * PhysConst::q_e}}, + {PhysicalSpecies::carbon13, Properties{ + amrex::Real(13.00335483507) * PhysConst::m_u, + amrex::Real(6) * PhysConst::q_e}}, + {PhysicalSpecies::carbon14, Properties{ + amrex::Real(14.0032419884) * PhysConst::m_u, + amrex::Real(6) * PhysConst::q_e}}, + {PhysicalSpecies::nitrogen, Properties{ + amrex::Real(14.00685) * PhysConst::m_u, + amrex::Real(7) * PhysConst::q_e}}, + {PhysicalSpecies::nitrogen14, Properties{ + amrex::Real(14.00307400443) * PhysConst::m_u, + amrex::Real(7) * PhysConst::q_e}}, + {PhysicalSpecies::nitrogen15, Properties{ + amrex::Real(15.00010889888) * PhysConst::m_u, + amrex::Real(7) * PhysConst::q_e}}, + {PhysicalSpecies::oxygen, Properties{ + amrex::Real(15.9994) * PhysConst::m_u, + amrex::Real(8) * PhysConst::q_e}}, + {PhysicalSpecies::oxygen16, Properties{ + amrex::Real(15.99491461957) * PhysConst::m_u, + amrex::Real(8) * PhysConst::q_e}}, + {PhysicalSpecies::oxygen17, Properties{ + amrex::Real(16.99913175650) * PhysConst::m_u, + amrex::Real(8) * PhysConst::q_e}}, + {PhysicalSpecies::oxygen18, Properties{ + amrex::Real(17.99915961286) * PhysConst::m_u, + amrex::Real(8) * PhysConst::q_e}}, + {PhysicalSpecies::fluorine, Properties{ + amrex::Real(18.998403163) * PhysConst::m_u, + amrex::Real(9) * PhysConst::q_e}}, + {PhysicalSpecies::fluorine19, Properties{ + amrex::Real(18.99840316273) * PhysConst::m_u, + amrex::Real(9) * PhysConst::q_e}}, + {PhysicalSpecies::neon, Properties{ + amrex::Real(20.1797) * PhysConst::m_u, + amrex::Real(10) * PhysConst::q_e}}, + {PhysicalSpecies::neon20, Properties{ + amrex::Real(19.9924401762) * PhysConst::m_u, + amrex::Real(10) * PhysConst::q_e}}, + {PhysicalSpecies::neon21, Properties{ + amrex::Real(20.993846685) * PhysConst::m_u, + amrex::Real(10) * PhysConst::q_e}}, + {PhysicalSpecies::neon22, Properties{ + amrex::Real(21.991385114) * PhysConst::m_u, + amrex::Real(10) * PhysConst::q_e}}, + {PhysicalSpecies::argon, Properties{ + amrex::Real(39.948) * PhysConst::m_u, + amrex::Real(18) * PhysConst::q_e}}, + {PhysicalSpecies::copper, Properties{ + amrex::Real(63.546) * PhysConst::m_u, + amrex::Real(29) * PhysConst::q_e}}, + {PhysicalSpecies::xenon, Properties{ + amrex::Real(131.293) * PhysConst::m_u, + amrex::Real(54) * PhysConst::q_e}}, + {PhysicalSpecies::gold, Properties{ + amrex::Real(196.966569) * PhysConst::m_u, + amrex::Real(79) * PhysConst::q_e}}, + }; +} + +namespace species +{ + std::optional from_string(const std::string& species) + { + const auto phys_spec = string_to_species.find(species); + return (phys_spec != string_to_species.end())? + std::make_optional(phys_spec->second) : std::nullopt; + } + + amrex::Real get_charge (const PhysicalSpecies& ps) + { + return species_to_properties.at(ps).charge; + } + + amrex::Real get_mass (const PhysicalSpecies& ps) + { + return species_to_properties.at(ps).mass; + } + + std::string get_name (const PhysicalSpecies& ps) + { + return species_to_string.at(ps); + } +}