Skip to content

Commit c85a4a0

Browse files
Check laser input file contains a normalized vector potential (#1319)
1 parent 5476011 commit c85a4a0

2 files changed

Lines changed: 38 additions & 6 deletions

File tree

docs/source/run/parameters.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,9 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start
924924
The names of the laser pulses, separated by a space.
925925
To run without a laser, choose the name ``no_laser``.
926926

927+
* ``lasers.lambda0`` (`float`)
928+
Wavelength of the laser pulses. Currently, all pulses must have the same wavelength.
929+
927930
* ``lasers.polarization`` (`linear` or `circular`) optional (default `linear`)
928931
Polarization of the laser pulse.
929932
For the same peak amplitude, the ponderomotive force is 2x larger in circular polarization than in linear polarization.
@@ -962,9 +965,6 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start
962965
* ``<laser name>.a0`` (`float`) optional (default `0`)
963966
Peak normalized vector potential of the laser pulse.
964967

965-
* ``lasers.lambda0`` (`float`)
966-
Wavelength of the laser pulses. Currently, all pulses must have the same wavelength.
967-
968968
* ``<laser name>.position_mean`` (3 `float`) optional (default `0 0 0`)
969969
The mean position of the laser in `x, y, z`.
970970

@@ -1031,9 +1031,6 @@ Parameters starting with ``lasers.`` apply to all laser pulses, parameters start
10311031
* ``<laser name>.laser_imag(x,y,z)`` optional (`string`) (default `""`)
10321032
Expression for the imaginary part of the laser envelope `x, y, z`.
10331033

1034-
* ``lasers.lambda0`` (`float`)
1035-
Wavelength of the laser pulses. Currently, all pulses must have the same wavelength.
1036-
10371034
Diagnostic parameters
10381035
---------------------
10391036

src/laser/Laser.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,41 @@ Laser::GetEnvelopeFromFileHelper (amrex::Geometry laser_geom_3D) {
9898

9999
auto mesh = iteration.meshes[m_file_envelope_name];
100100

101+
// Check that we are reading a normalized vector potential and not an electric field
102+
const std::array<double, 7> units_file = mesh.unitDimension();
103+
const std::array<double, 7> units_norm_potential{0., 0., 0., 0., 0., 0., 0.};
104+
const std::array<double, 7> units_electric_field{1., 1., -3., -1., 0., 0., 0.};
105+
const std::string help_msg = "Make sure to store the normalized vector potential, "
106+
"set the Attribute 'envelopeField' to 'normalized_vector_potential' and "
107+
"unitDimension to '" + amrex::ToString(units_norm_potential) + "'. "
108+
"If you are using LASY to generate the laser, pass 'save_as_vector_potential=True' "
109+
"to laser.write_to_file() or write_to_openpmd_file()";
110+
111+
if (mesh.containsAttribute("envelopeField")) {
112+
const std::string field_type = mesh.getAttribute("envelopeField").get<std::string>();
113+
if (field_type == "electric_field") {
114+
amrex::Abort("Attribute 'envelopeField' in file '" + m_input_file_path +
115+
"' is set to 'electric_field' which is not compatible with HiAPCE++. " +
116+
help_msg
117+
);
118+
} else if (field_type != "normalized_vector_potential") {
119+
amrex::AllPrint() << "WARNING: Attribute 'envelopeField' in file '"
120+
<< m_input_file_path << "' is set to '" << field_type << "' which is not "
121+
" recognized. " << help_msg << '\n';
122+
}
123+
}
124+
125+
if (units_file == units_electric_field) {
126+
amrex::Abort("unitDimension '" + amrex::ToString(units_file) + "' in file '"
127+
+ m_input_file_path + "' is that of an electric field which is not compatible "
128+
"with HiAPCE++. " + help_msg
129+
);
130+
} else if (units_file != units_norm_potential) {
131+
amrex::AllPrint() << "WARNING: unitDimension '" << amrex::ToString(units_file)
132+
<< "' in file '" << m_input_file_path << "' is not recognized. "
133+
<< help_msg << '\n';
134+
}
135+
101136
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(
102137
mesh.containsAttribute("angularFrequency"),
103138
"Could not find Attribute 'angularFrequency' of iteration "

0 commit comments

Comments
 (0)