|
8 | 8 | * License: BSD-3-Clause-LBNL |
9 | 9 | */ |
10 | 10 | #include "PlasmaInjector.H" |
11 | | - |
| 11 | +#include "SpeciesPhysicalProperties.H" |
12 | 12 | #include "Utils/WarpXConst.H" |
13 | 13 | #include "Utils/WarpXUtil.H" |
14 | 14 | #include "WarpX.H" |
@@ -95,22 +95,50 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name) |
95 | 95 | pp.query("density_min", density_min); |
96 | 96 | pp.query("density_max", density_max); |
97 | 97 |
|
| 98 | + std::string physical_species_s; |
| 99 | + bool species_is_specified = pp.query("species_type", physical_species_s); |
| 100 | + if (species_is_specified){ |
| 101 | + physical_species = species::from_string( physical_species_s ); |
| 102 | + // charge = SpeciesCharge[physical_species]; |
| 103 | + charge = species::get_charge( physical_species ); |
| 104 | + // mass = SpeciesMass[physical_species]; |
| 105 | + mass = species::get_mass( physical_species ); |
| 106 | + } |
| 107 | + |
98 | 108 | // parse charge and mass |
99 | 109 | std::string charge_s; |
100 | | - pp.get("charge", charge_s); |
101 | | - std::transform(charge_s.begin(), |
102 | | - charge_s.end(), |
103 | | - charge_s.begin(), |
104 | | - ::tolower); |
105 | | - charge = parseChargeString(pp, charge_s); |
| 110 | + bool charge_is_specified = pp.query("charge", charge_s); |
| 111 | + if (charge_is_specified){ |
| 112 | + std::transform(charge_s.begin(), |
| 113 | + charge_s.end(), |
| 114 | + charge_s.begin(), |
| 115 | + ::tolower); |
| 116 | + charge = parseChargeString(pp, charge_s); |
| 117 | + } |
| 118 | + if ( charge_is_specified && species_is_specified ){ |
| 119 | + Print()<<"WARNING: Both <species>.charge and <species>species_type specified\n"; |
| 120 | + Print()<<" The charge in <species>.mass overwrite the one from <species>.species_type\n"; |
| 121 | + } |
| 122 | + if (!charge_is_specified && !species_is_specified){ |
| 123 | + amrex::Abort("Need to specify at least one of species_type or charge"); |
| 124 | + } |
106 | 125 |
|
107 | 126 | std::string mass_s; |
108 | | - pp.get("mass", mass_s); |
109 | | - std::transform(mass_s.begin(), |
110 | | - mass_s.end(), |
111 | | - mass_s.begin(), |
112 | | - ::tolower); |
113 | | - mass = parseMassString(pp, mass_s); |
| 127 | + bool mass_is_specified = pp.query("mass", mass_s); |
| 128 | + if (mass_is_specified){ |
| 129 | + std::transform(mass_s.begin(), |
| 130 | + mass_s.end(), |
| 131 | + mass_s.begin(), |
| 132 | + ::tolower); |
| 133 | + mass = parseMassString(pp, mass_s); |
| 134 | + } |
| 135 | + if ( mass_is_specified && species_is_specified ){ |
| 136 | + Print()<<"WARNING: Both <species>.mass and <species>species_type specified\n"; |
| 137 | + Print()<<" The mass in <species>.mass overwrite the one from <species>.species_type\n"; |
| 138 | + } |
| 139 | + if (!mass_is_specified && !species_is_specified){ |
| 140 | + amrex::Abort("Need to specify at least one of species_type or mass"); |
| 141 | + } |
114 | 142 |
|
115 | 143 | // parse injection style |
116 | 144 | std::string part_pos_s; |
@@ -362,4 +390,3 @@ PlasmaInjector::getInjectorMomentum () |
362 | 390 | { |
363 | 391 | return inj_mom.get(); |
364 | 392 | } |
365 | | - |
|
0 commit comments