diff --git a/Examples/Tests/restart/inputs b/Examples/Tests/restart/inputs index c34146518a6..35a87e13ab1 100644 --- a/Examples/Tests/restart/inputs +++ b/Examples/Tests/restart/inputs @@ -28,7 +28,6 @@ warpx.cfl = .99 warpx.do_moving_window = 1 warpx.moving_window_dir = z warpx.moving_window_v = 1. # in units of the speed of light -my_constants.lramp = 8.e-3 my_constants.dens = 1e+23 # Order of particle shape factors @@ -93,12 +92,14 @@ plasma_e.mass = m_e plasma_e.injection_style = "NUniformPerCell" plasma_e.zmin = -100.e-6 plasma_e.zmax = 0.2 -plasma_e.xmin = -70.e-6 -plasma_e.xmax = 70.e-6 -plasma_e.ymin = -70.e-6 -plasma_e.ymax = 70.e-6 -plasma_e.profile = parse_density_function -plasma_e.density_function(x,y,z) = "(zlramp)*dens" +plasma_e.xmin = -100.e-6 +plasma_e.xmax = 100.e-6 +plasma_e.ymin = -100.e-6 +plasma_e.ymax = 100.e-6 +plasma_e.profile = "predefined" +plasma_e.predefined_profile_name = "parabolic_channel" +# predefined_profile_params = z_start ramp_up plateau ramp_down rc n0 +plasma_e.predefined_profile_params = 0. 0. 3. 0. 40.e-6 dens plasma_e.num_particles_per_cell_each_dim = 1 1 1 plasma_e.momentum_distribution_type = "constant" plasma_e.ux = 0.0 @@ -111,12 +112,14 @@ plasma_p.mass = m_p plasma_p.injection_style = "NUniformPerCell" plasma_p.zmin = -100.e-6 plasma_p.zmax = 0.2 -plasma_p.profile = parse_density_function -plasma_p.density_function(x,y,z) = "(zlramp)*dens" -plasma_p.xmin = -70.e-6 -plasma_p.xmax = 70.e-6 -plasma_p.ymin = -70.e-6 -plasma_p.ymax = 70.e-6 +plasma_p.profile = "predefined" +plasma_p.predefined_profile_name = "parabolic_channel" +# predefined_profile_params = z_start ramp_up plateau ramp_down rc n0 +plasma_p.predefined_profile_params = 0. 0. 3. 0. 40.e-6 dens +plasma_p.xmin = -100.e-6 +plasma_p.xmax = 100.e-6 +plasma_p.ymin = -100.e-6 +plasma_p.ymax = 100.e-6 plasma_p.num_particles_per_cell_each_dim = 1 1 1 plasma_p.momentum_distribution_type = "constant" plasma_p.ux = 0.0 @@ -145,9 +148,21 @@ beam.uz_th = 200. beam.zinject_plane = .8e-3 beam.rigid_advance = true +lasers.names = laser1 +laser1.profile = Gaussian +laser1.position = 0. 0. 0.e-6 # This point is on the laser plane +laser1.direction = 0. 0. 1. # The plane normal direction +laser1.polarization = 1. 0. 0. # The main polarization vector +laser1.e_max = 16.e12 # Maximum amplitude of the laser field (in V/m) +laser1.profile_waist = 40.e-6 # The waist of the laser (in meters) +laser1.profile_duration = 30.e-15 # The duration of the laser (in seconds) +laser1.profile_t_peak = 60.e-15 # The time at which the laser reaches its peak (in seconds) +laser1.profile_focal_distance = 0.e-6 # Focal distance from the antenna (in meters) +laser1.wavelength = 5.e-6 # The wavelength of the laser (in meters) + # Diagnostics diagnostics.diags_names = diag1 chk -diag1.intervals = 1 +diag1.intervals = 5 diag1.diag_type = Full chk.intervals = 5 chk.diag_type = Full diff --git a/Regression/Checksum/benchmarks_json/restart.json b/Regression/Checksum/benchmarks_json/restart.json index ebb35357ccd..7cf4ce0c0b8 100644 --- a/Regression/Checksum/benchmarks_json/restart.json +++ b/Regression/Checksum/benchmarks_json/restart.json @@ -33,36 +33,36 @@ "particle_weight": 6241509074.460762 }, "lev=0": { - "Bx": 98192.19947145433, - "By": 98202.24044988544, - "Bz": 32.176883437432316, - "Ex": 14065714408245.07, - "Ey": 14064073072398.174, - "Ez": 33307954593489.707, - "jx": 304667056543.9146, - "jy": 180701392073.9691, - "jz": 904275753595636.4 + "Bx": 115327.15140818382, + "By": 242416.19187313571, + "Bz": 62096.66973827369, + "Ex": 120130722555567.77, + "Ey": 20867597109617.934, + "Ez": 53551348241648.52, + "jx": 2.1551699509760676e+16, + "jy": 332122730528260.0, + "jz": 4524888666510641.0 }, "plasma_e": { - "particle_cpu": 4116.0, - "particle_id": 22919946.0, - "particle_momentum_x": 5.40817681171179e-22, - "particle_momentum_y": 5.385133314763837e-22, - "particle_momentum_z": 1.1184395632063724e-17, - "particle_position_x": 0.1350593467304257, - "particle_position_y": 0.1350593241232737, - "particle_position_z": 0.20362721013846566, - "particle_weight": 126912632943.3621 + "particle_cpu": 9680.0, + "particle_id": 117349672.0, + "particle_momentum_x": 2.6417827387235982e-19, + "particle_momentum_y": 1.3246227891556811e-20, + "particle_momentum_z": 2.632691328351647e-17, + "particle_position_x": 0.49916178543521594, + "particle_position_y": 0.4991848022446371, + "particle_position_z": 0.45626376648502054, + "particle_weight": 33067341227104.594 }, "plasma_p": { - "particle_cpu": 4116.0, - "particle_id": 25328394.0, - "particle_momentum_x": 5.408310433658191e-22, - "particle_momentum_y": 5.385274435809097e-22, - "particle_momentum_z": 2.0535791481240203e-14, - "particle_position_x": 0.13505624831336835, - "particle_position_y": 0.13505624832567958, - "particle_position_z": 0.2036271949467523, - "particle_weight": 126912632943.3621 + "particle_cpu": 9680.0, + "particle_id": 128125448.0, + "particle_momentum_x": 2.6389034754489564e-19, + "particle_momentum_y": 5.3122104782787265e-21, + "particle_momentum_z": 4.8296005971893094e-14, + "particle_position_x": 0.4991250026192299, + "particle_position_y": 0.4991249980376633, + "particle_position_z": 0.4563845472659988, + "particle_weight": 33067341227104.594 } } \ No newline at end of file diff --git a/Regression/Checksum/benchmarks_json/restart_psatd.json b/Regression/Checksum/benchmarks_json/restart_psatd.json index 3fbcd97728f..b08c3879533 100644 --- a/Regression/Checksum/benchmarks_json/restart_psatd.json +++ b/Regression/Checksum/benchmarks_json/restart_psatd.json @@ -33,36 +33,36 @@ "particle_weight": 6241509074.460762 }, "lev=0": { - "Bx": 97806.19840108546, - "By": 97815.85756771098, - "Bz": 31.732427701722912, - "Ex": 12877754924119.082, - "Ey": 12876901684280.229, - "Ez": 32448463177834.543, - "jx": 307666015585.9687, - "jy": 182363554739.9786, - "jz": 904274413323325.2 + "Bx": 114349.71019313535, + "By": 237246.30659111793, + "Bz": 61241.57839321267, + "Ex": 113310667309569.25, + "Ey": 18419343979199.57, + "Ez": 50966992135551.99, + "jx": 2.343755417758882e+16, + "jy": 264692970881696.72, + "jz": 4106459950194407.0 }, "plasma_e": { - "particle_cpu": 4116.0, - "particle_id": 22919946.0, - "particle_momentum_x": 5.685881126709523e-22, - "particle_momentum_y": 5.6629711844429285e-22, - "particle_momentum_z": 1.1184398018026139e-17, - "particle_position_x": 0.1350592433885383, - "particle_position_y": 0.1350592219411637, - "particle_position_z": 0.20362720921987482, - "particle_weight": 126912632943.36244 + "particle_cpu": 9680.0, + "particle_id": 117349672.0, + "particle_momentum_x": 1.473920377077317e-19, + "particle_momentum_y": 1.0295357463154818e-20, + "particle_momentum_z": 2.631936992393973e-17, + "particle_position_x": 0.4991563943788139, + "particle_position_y": 0.49917524942325764, + "particle_position_z": 0.4562708055573991, + "particle_weight": 33067341227104.625 }, "plasma_p": { - "particle_cpu": 4116.0, - "particle_id": 25328394.0, - "particle_momentum_x": 5.686071969908394e-22, - "particle_momentum_y": 5.663169754132697e-22, - "particle_momentum_z": 2.0535791478848e-14, - "particle_position_x": 0.13505624836966013, - "particle_position_y": 0.13505624838133984, - "particle_position_z": 0.20362719494726383, - "particle_weight": 126912632943.36244 + "particle_cpu": 9680.0, + "particle_id": 128125448.0, + "particle_momentum_x": 1.4773149979258644e-19, + "particle_momentum_y": 3.3342009095840554e-21, + "particle_momentum_z": 4.8296010015063954e-14, + "particle_position_x": 0.4991250009706611, + "particle_position_y": 0.49912499871191435, + "particle_position_z": 0.4563845474003356, + "particle_weight": 33067341227104.625 } } \ No newline at end of file diff --git a/Regression/Checksum/benchmarks_json/restart_psatd_time_avg.json b/Regression/Checksum/benchmarks_json/restart_psatd_time_avg.json index bc8d71bbce8..cd6280d83fe 100644 --- a/Regression/Checksum/benchmarks_json/restart_psatd_time_avg.json +++ b/Regression/Checksum/benchmarks_json/restart_psatd_time_avg.json @@ -33,36 +33,36 @@ "particle_weight": 6241509074.460762 }, "lev=0": { - "Bx": 97799.68920761721, - "By": 97809.22760976445, - "Bz": 31.138421896287632, - "Ex": 12848024095028.355, - "Ey": 12847124613971.557, - "Ez": 32437971780449.27, - "jx": 308194378521.1045, - "jy": 182890492089.67697, - "jz": 904274843199463.8 + "Bx": 113572.32066454006, + "By": 233769.68176084137, + "Bz": 58935.90471405687, + "Ex": 111077830627827.34, + "Ey": 18104292500486.71, + "Ez": 49957933531975.0, + "jx": 2.3032421193292172e+16, + "jy": 252044670800869.56, + "jz": 4052661521670030.0 }, "plasma_e": { - "particle_cpu": 4116.0, - "particle_id": 22919946.0, - "particle_momentum_x": 5.744112487812186e-22, - "particle_momentum_y": 5.721125891605127e-22, - "particle_momentum_z": 1.1184397774190402e-17, - "particle_position_x": 0.13505927138536114, - "particle_position_y": 0.13505924998293056, - "particle_position_z": 0.20362720922167785, - "particle_weight": 126912632943.36244 + "particle_cpu": 9680.0, + "particle_id": 117349672.0, + "particle_momentum_x": 1.3889342284437047e-19, + "particle_momentum_y": 9.709966613374186e-21, + "particle_momentum_z": 2.6318578216093305e-17, + "particle_position_x": 0.4991547138014627, + "particle_position_y": 0.49917221491130515, + "particle_position_z": 0.4562788688974234, + "particle_weight": 33067341227104.625 }, "plasma_p": { - "particle_cpu": 4116.0, - "particle_id": 25328394.0, - "particle_momentum_x": 5.744307393038055e-22, - "particle_momentum_y": 5.721328534468911e-22, - "particle_momentum_z": 2.0535791479091845e-14, - "particle_position_x": 0.13505624835441166, - "particle_position_y": 0.13505624836606694, - "particle_position_z": 0.20362719494726217, - "particle_weight": 126912632943.36244 + "particle_cpu": 9680.0, + "particle_id": 128125448.0, + "particle_momentum_x": 1.3957368399934083e-19, + "particle_momentum_y": 3.3829656839017584e-21, + "particle_momentum_z": 4.829601122286012e-14, + "particle_position_x": 0.4991250008410111, + "particle_position_y": 0.4991249984371928, + "particle_position_z": 0.4563845474251499, + "particle_weight": 33067341227104.625 } } \ No newline at end of file diff --git a/Regression/WarpX-tests.ini b/Regression/WarpX-tests.ini index 8749f6f50c7..b7826be05d6 100644 --- a/Regression/WarpX-tests.ini +++ b/Regression/WarpX-tests.ini @@ -912,7 +912,7 @@ tolerance = 1.e-14 [restart_psatd] buildDir = . inputFile = Examples/Tests/restart/inputs -runtime_params = algo.maxwell_solver=psatd psatd.use_default_v_galilean=1 particles.use_fdtd_nci_corr=0 chk.file_prefix=restart_psatd_chk +runtime_params = algo.maxwell_solver=psatd psatd.use_default_v_galilean=1 particles.use_fdtd_nci_corr=0 chk.file_prefix=restart_psatd_chk boundary.field_lo=periodic periodic damped boundary.field_hi=periodic periodic damped dim = 3 addToCompileString = USE_PSATD=TRUE restartTest = 1 diff --git a/Source/Diagnostics/FullDiagnostics.cpp b/Source/Diagnostics/FullDiagnostics.cpp index 6f996682095..05ce1327924 100644 --- a/Source/Diagnostics/FullDiagnostics.cpp +++ b/Source/Diagnostics/FullDiagnostics.cpp @@ -54,7 +54,13 @@ FullDiagnostics::InitializeParticleBuffer () const MultiParticleContainer& mpc = warpx.GetPartContainer(); // If not specified, dump all species - if (m_output_species_names.empty()) m_output_species_names = mpc.GetSpeciesNames(); + if (m_output_species_names.empty()) { + if (m_format == "checkpoint") { + m_output_species_names = mpc.GetSpeciesAndLasersNames(); + } else { + m_output_species_names = mpc.GetSpeciesNames(); + } + } // Initialize one ParticleDiag per species requested for (auto const& species : m_output_species_names){ const int idx = mpc.getSpeciesID(species); diff --git a/Source/Diagnostics/ParticleIO.cpp b/Source/Diagnostics/ParticleIO.cpp index a7b389d785a..1ed5b02781f 100644 --- a/Source/Diagnostics/ParticleIO.cpp +++ b/Source/Diagnostics/ParticleIO.cpp @@ -11,6 +11,7 @@ #include "Particles/MultiParticleContainer.H" #include "Particles/ParticleBuffer.H" #include "Particles/PhysicalParticleContainer.H" +#include "Particles/LaserParticleContainer.H" #include "Particles/RigidInjectedParticleContainer.H" #include "Particles/SpeciesPhysicalProperties.H" #include "Particles/WarpXParticleContainer.H" @@ -38,11 +39,33 @@ using namespace amrex; +void +LaserParticleContainer::ReadHeader (std::istream& is) +{ + if (do_continuous_injection) { + m_updated_position.resize(3); + for (int i = 0; i < 3; ++i) { + is >> m_updated_position[i]; + WarpX::GotoNextLine(is); + } + } +} + +void +LaserParticleContainer::WriteHeader (std::ostream& os) const +{ + if (do_continuous_injection) { + for (int i = 0; i < 3; ++i) { + os << m_updated_position[i] << "\n"; + } + } +} + void RigidInjectedParticleContainer::ReadHeader (std::istream& is) { // Call parent class - WarpXParticleContainer::ReadHeader( is ); + PhysicalParticleContainer::ReadHeader( is ); // Read quantities that are specific to rigid-injected species int nlevs; @@ -66,7 +89,7 @@ void RigidInjectedParticleContainer::WriteHeader (std::ostream& os) const { // Call parent class - WarpXParticleContainer::WriteHeader( os ); + PhysicalParticleContainer::WriteHeader( os ); // Write quantities that are specific to the rigid-injected species int nlevs = zinject_plane_levels.size(); @@ -79,14 +102,14 @@ RigidInjectedParticleContainer::WriteHeader (std::ostream& os) const } void -WarpXParticleContainer::ReadHeader (std::istream& is) +PhysicalParticleContainer::ReadHeader (std::istream& is) { is >> charge >> mass; WarpX::GotoNextLine(is); } void -WarpXParticleContainer::WriteHeader (std::ostream& os) const +PhysicalParticleContainer::WriteHeader (std::ostream& os) const { // no need to write species_id os << charge << " " << mass << "\n"; @@ -97,11 +120,14 @@ MultiParticleContainer::Restart (const std::string& dir) { // note: all containers is sorted like this // - species_names - // - laser_names + // - lasers_names // we don't need to read back the laser particle charge/mass for (unsigned i = 0, n = species_names.size(); i < n; ++i) { allcontainers.at(i)->Restart(dir, species_names.at(i)); } + for (unsigned i = species_names.size(); i < species_names.size()+lasers_names.size(); ++i) { + allcontainers.at(i)->Restart(dir, lasers_names.at(i-species_names.size())); + } } void @@ -109,9 +135,8 @@ MultiParticleContainer::ReadHeader (std::istream& is) { // note: all containers is sorted like this // - species_names - // - laser_names - // we don't need to read back the laser particle charge/mass - for (unsigned i = 0, n = species_names.size(); i < n; ++i) { + // - lasers_names + for (unsigned i = 0, n = species_names.size()+lasers_names.size(); i < n; ++i) { allcontainers.at(i)->ReadHeader(is); } } @@ -121,9 +146,8 @@ MultiParticleContainer::WriteHeader (std::ostream& os) const { // note: all containers is sorted like this // - species_names - // - laser_names - // we don't need to read back the laser particle charge/mass - for (unsigned i = 0, n = species_names.size(); i < n; ++i) { + // - lasers_names + for (unsigned i = 0, n = species_names.size()+lasers_names.size(); i < n; ++i) { allcontainers.at(i)->WriteHeader(os); } } diff --git a/Source/Particles/LaserParticleContainer.H b/Source/Particles/LaserParticleContainer.H index a592e790177..1e7d8c41694 100644 --- a/Source/Particles/LaserParticleContainer.H +++ b/Source/Particles/LaserParticleContainer.H @@ -45,6 +45,10 @@ public: virtual void InitData () final; + virtual void ReadHeader (std::istream& is) final; + + virtual void WriteHeader (std::ostream& os) const final; + virtual void Evolve (int lev, const amrex::MultiFab&, const amrex::MultiFab&, const amrex::MultiFab&, const amrex::MultiFab&, const amrex::MultiFab&, const amrex::MultiFab&, diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index 4c13ea87b34..f0ff379d303 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -278,6 +278,14 @@ public: std::vector GetSpeciesNames() const { return species_names; } + std::vector GetLasersNames() const { return lasers_names; } + + std::vector GetSpeciesAndLasersNames() const { + std::vector tmp = species_names; + tmp.insert(tmp.end(), lasers_names.begin(), lasers_names.end()); + return tmp; + } + PhysicalParticleContainer& GetPCtmp () { return *pc_tmp; } void ScrapeParticles (const amrex::Vector& distance_to_eb); diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 3868442c544..3f916c92a4f 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -834,13 +834,14 @@ MultiParticleContainer::mapSpeciesProduct () int MultiParticleContainer::getSpeciesID (std::string product_str) const { + auto species_and_lasers_names = GetSpeciesAndLasersNames(); int i_product = 0; bool found = 0; // Loop over species - for (int i=0; i < static_cast(species_names.size()); i++){ + for (int i=0; i < static_cast(species_and_lasers_names.size()); i++){ // If species name matches, store its ID // into i_product - if (species_names[i] == product_str){ + if (species_and_lasers_names[i] == product_str){ found = 1; i_product = i; } diff --git a/Source/Particles/PhysicalParticleContainer.H b/Source/Particles/PhysicalParticleContainer.H index 2c9e0ed1f9d..83f008d3a6d 100644 --- a/Source/Particles/PhysicalParticleContainer.H +++ b/Source/Particles/PhysicalParticleContainer.H @@ -67,6 +67,10 @@ public: virtual void InitData () override; + virtual void ReadHeader (std::istream& is) override; + + virtual void WriteHeader (std::ostream& os) const override; + void InitIonizationModule (); /** diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H index 45610211988..fa482287030 100644 --- a/Source/Particles/WarpXParticleContainer.H +++ b/Source/Particles/WarpXParticleContainer.H @@ -262,9 +262,9 @@ public: const amrex::ParticleReal* vx, const amrex::ParticleReal* vy, const amrex::ParticleReal* vz, int nattr, const amrex::ParticleReal* attr, int uniqueparticles, amrex::Long id=-1); - virtual void ReadHeader (std::istream& is); + virtual void ReadHeader (std::istream& is) = 0; - virtual void WriteHeader (std::ostream& os) const; + virtual void WriteHeader (std::ostream& os) const = 0; virtual void ConvertUnits (ConvertDirection /*convert_dir*/){}