Skip to content

Commit 95bb259

Browse files
atmyersRemiLehe
andauthored
Implement Checkpoint / Restart for Laser Particles (#2360)
* Initialize lasers when restarting + recalculate z position at each iteration * Fix restart for rigid-injected particles * Fix laser injection box at restart * Use correct positions for the moving window of the BTD * implement restart for laser particles * add CI test for laser acceleration restarting * writespace * Revert "Fix restart for rigid-injected particles" This reverts commit 33bf3a6. * don't add lasers to all full diags, only checkpoints * fix unused parameter warning * move the call to reset the m_laser_injection_box into PostRestart * bugfix for non-boosted frame simulations * Read the mean velocity of the injected species * Remove unused line * Revert "Initialize lasers when restarting + recalculate z position at each iteration" This reverts commit 322634c. * Add new ReadHeader / WriteHeader functions * Add WriteHeader/ReadHeader for laser particles * Revert "add CI test for laser acceleration restarting" This reverts commit 6ba0fb3. * Fix merge commit * Correct reading of updated position * Add laser in restart test * Remove unused parameters * Update regression tests * Add benchmark files * Update boundary conditions for restart_psatd Co-authored-by: Remi Lehe <[email protected]>
1 parent 876c994 commit 95bb259

File tree

12 files changed

+174
-112
lines changed

12 files changed

+174
-112
lines changed

Examples/Tests/restart/inputs

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ warpx.cfl = .99
2828
warpx.do_moving_window = 1
2929
warpx.moving_window_dir = z
3030
warpx.moving_window_v = 1. # in units of the speed of light
31-
my_constants.lramp = 8.e-3
3231
my_constants.dens = 1e+23
3332

3433
# Order of particle shape factors
@@ -93,12 +92,14 @@ plasma_e.mass = m_e
9392
plasma_e.injection_style = "NUniformPerCell"
9493
plasma_e.zmin = -100.e-6
9594
plasma_e.zmax = 0.2
96-
plasma_e.xmin = -70.e-6
97-
plasma_e.xmax = 70.e-6
98-
plasma_e.ymin = -70.e-6
99-
plasma_e.ymax = 70.e-6
100-
plasma_e.profile = parse_density_function
101-
plasma_e.density_function(x,y,z) = "(z<lramp)*0.5*(1-cos(pi*z/lramp))*dens+(z>lramp)*dens"
95+
plasma_e.xmin = -100.e-6
96+
plasma_e.xmax = 100.e-6
97+
plasma_e.ymin = -100.e-6
98+
plasma_e.ymax = 100.e-6
99+
plasma_e.profile = "predefined"
100+
plasma_e.predefined_profile_name = "parabolic_channel"
101+
# predefined_profile_params = z_start ramp_up plateau ramp_down rc n0
102+
plasma_e.predefined_profile_params = 0. 0. 3. 0. 40.e-6 dens
102103
plasma_e.num_particles_per_cell_each_dim = 1 1 1
103104
plasma_e.momentum_distribution_type = "constant"
104105
plasma_e.ux = 0.0
@@ -111,12 +112,14 @@ plasma_p.mass = m_p
111112
plasma_p.injection_style = "NUniformPerCell"
112113
plasma_p.zmin = -100.e-6
113114
plasma_p.zmax = 0.2
114-
plasma_p.profile = parse_density_function
115-
plasma_p.density_function(x,y,z) = "(z<lramp)*0.5*(1-cos(pi*z/lramp))*dens+(z>lramp)*dens"
116-
plasma_p.xmin = -70.e-6
117-
plasma_p.xmax = 70.e-6
118-
plasma_p.ymin = -70.e-6
119-
plasma_p.ymax = 70.e-6
115+
plasma_p.profile = "predefined"
116+
plasma_p.predefined_profile_name = "parabolic_channel"
117+
# predefined_profile_params = z_start ramp_up plateau ramp_down rc n0
118+
plasma_p.predefined_profile_params = 0. 0. 3. 0. 40.e-6 dens
119+
plasma_p.xmin = -100.e-6
120+
plasma_p.xmax = 100.e-6
121+
plasma_p.ymin = -100.e-6
122+
plasma_p.ymax = 100.e-6
120123
plasma_p.num_particles_per_cell_each_dim = 1 1 1
121124
plasma_p.momentum_distribution_type = "constant"
122125
plasma_p.ux = 0.0
@@ -145,9 +148,21 @@ beam.uz_th = 200.
145148
beam.zinject_plane = .8e-3
146149
beam.rigid_advance = true
147150

151+
lasers.names = laser1
152+
laser1.profile = Gaussian
153+
laser1.position = 0. 0. 0.e-6 # This point is on the laser plane
154+
laser1.direction = 0. 0. 1. # The plane normal direction
155+
laser1.polarization = 1. 0. 0. # The main polarization vector
156+
laser1.e_max = 16.e12 # Maximum amplitude of the laser field (in V/m)
157+
laser1.profile_waist = 40.e-6 # The waist of the laser (in meters)
158+
laser1.profile_duration = 30.e-15 # The duration of the laser (in seconds)
159+
laser1.profile_t_peak = 60.e-15 # The time at which the laser reaches its peak (in seconds)
160+
laser1.profile_focal_distance = 0.e-6 # Focal distance from the antenna (in meters)
161+
laser1.wavelength = 5.e-6 # The wavelength of the laser (in meters)
162+
148163
# Diagnostics
149164
diagnostics.diags_names = diag1 chk
150-
diag1.intervals = 1
165+
diag1.intervals = 5
151166
diag1.diag_type = Full
152167
chk.intervals = 5
153168
chk.diag_type = Full

Regression/Checksum/benchmarks_json/restart.json

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,36 @@
3333
"particle_weight": 6241509074.460762
3434
},
3535
"lev=0": {
36-
"Bx": 98192.19947145433,
37-
"By": 98202.24044988544,
38-
"Bz": 32.176883437432316,
39-
"Ex": 14065714408245.07,
40-
"Ey": 14064073072398.174,
41-
"Ez": 33307954593489.707,
42-
"jx": 304667056543.9146,
43-
"jy": 180701392073.9691,
44-
"jz": 904275753595636.4
36+
"Bx": 115327.15140818382,
37+
"By": 242416.19187313571,
38+
"Bz": 62096.66973827369,
39+
"Ex": 120130722555567.77,
40+
"Ey": 20867597109617.934,
41+
"Ez": 53551348241648.52,
42+
"jx": 2.1551699509760676e+16,
43+
"jy": 332122730528260.0,
44+
"jz": 4524888666510641.0
4545
},
4646
"plasma_e": {
47-
"particle_cpu": 4116.0,
48-
"particle_id": 22919946.0,
49-
"particle_momentum_x": 5.40817681171179e-22,
50-
"particle_momentum_y": 5.385133314763837e-22,
51-
"particle_momentum_z": 1.1184395632063724e-17,
52-
"particle_position_x": 0.1350593467304257,
53-
"particle_position_y": 0.1350593241232737,
54-
"particle_position_z": 0.20362721013846566,
55-
"particle_weight": 126912632943.3621
47+
"particle_cpu": 9680.0,
48+
"particle_id": 117349672.0,
49+
"particle_momentum_x": 2.6417827387235982e-19,
50+
"particle_momentum_y": 1.3246227891556811e-20,
51+
"particle_momentum_z": 2.632691328351647e-17,
52+
"particle_position_x": 0.49916178543521594,
53+
"particle_position_y": 0.4991848022446371,
54+
"particle_position_z": 0.45626376648502054,
55+
"particle_weight": 33067341227104.594
5656
},
5757
"plasma_p": {
58-
"particle_cpu": 4116.0,
59-
"particle_id": 25328394.0,
60-
"particle_momentum_x": 5.408310433658191e-22,
61-
"particle_momentum_y": 5.385274435809097e-22,
62-
"particle_momentum_z": 2.0535791481240203e-14,
63-
"particle_position_x": 0.13505624831336835,
64-
"particle_position_y": 0.13505624832567958,
65-
"particle_position_z": 0.2036271949467523,
66-
"particle_weight": 126912632943.3621
58+
"particle_cpu": 9680.0,
59+
"particle_id": 128125448.0,
60+
"particle_momentum_x": 2.6389034754489564e-19,
61+
"particle_momentum_y": 5.3122104782787265e-21,
62+
"particle_momentum_z": 4.8296005971893094e-14,
63+
"particle_position_x": 0.4991250026192299,
64+
"particle_position_y": 0.4991249980376633,
65+
"particle_position_z": 0.4563845472659988,
66+
"particle_weight": 33067341227104.594
6767
}
6868
}

Regression/Checksum/benchmarks_json/restart_psatd.json

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,36 @@
3333
"particle_weight": 6241509074.460762
3434
},
3535
"lev=0": {
36-
"Bx": 97806.19840108546,
37-
"By": 97815.85756771098,
38-
"Bz": 31.732427701722912,
39-
"Ex": 12877754924119.082,
40-
"Ey": 12876901684280.229,
41-
"Ez": 32448463177834.543,
42-
"jx": 307666015585.9687,
43-
"jy": 182363554739.9786,
44-
"jz": 904274413323325.2
36+
"Bx": 114349.71019313535,
37+
"By": 237246.30659111793,
38+
"Bz": 61241.57839321267,
39+
"Ex": 113310667309569.25,
40+
"Ey": 18419343979199.57,
41+
"Ez": 50966992135551.99,
42+
"jx": 2.343755417758882e+16,
43+
"jy": 264692970881696.72,
44+
"jz": 4106459950194407.0
4545
},
4646
"plasma_e": {
47-
"particle_cpu": 4116.0,
48-
"particle_id": 22919946.0,
49-
"particle_momentum_x": 5.685881126709523e-22,
50-
"particle_momentum_y": 5.6629711844429285e-22,
51-
"particle_momentum_z": 1.1184398018026139e-17,
52-
"particle_position_x": 0.1350592433885383,
53-
"particle_position_y": 0.1350592219411637,
54-
"particle_position_z": 0.20362720921987482,
55-
"particle_weight": 126912632943.36244
47+
"particle_cpu": 9680.0,
48+
"particle_id": 117349672.0,
49+
"particle_momentum_x": 1.473920377077317e-19,
50+
"particle_momentum_y": 1.0295357463154818e-20,
51+
"particle_momentum_z": 2.631936992393973e-17,
52+
"particle_position_x": 0.4991563943788139,
53+
"particle_position_y": 0.49917524942325764,
54+
"particle_position_z": 0.4562708055573991,
55+
"particle_weight": 33067341227104.625
5656
},
5757
"plasma_p": {
58-
"particle_cpu": 4116.0,
59-
"particle_id": 25328394.0,
60-
"particle_momentum_x": 5.686071969908394e-22,
61-
"particle_momentum_y": 5.663169754132697e-22,
62-
"particle_momentum_z": 2.0535791478848e-14,
63-
"particle_position_x": 0.13505624836966013,
64-
"particle_position_y": 0.13505624838133984,
65-
"particle_position_z": 0.20362719494726383,
66-
"particle_weight": 126912632943.36244
58+
"particle_cpu": 9680.0,
59+
"particle_id": 128125448.0,
60+
"particle_momentum_x": 1.4773149979258644e-19,
61+
"particle_momentum_y": 3.3342009095840554e-21,
62+
"particle_momentum_z": 4.8296010015063954e-14,
63+
"particle_position_x": 0.4991250009706611,
64+
"particle_position_y": 0.49912499871191435,
65+
"particle_position_z": 0.4563845474003356,
66+
"particle_weight": 33067341227104.625
6767
}
6868
}

Regression/Checksum/benchmarks_json/restart_psatd_time_avg.json

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,36 @@
3333
"particle_weight": 6241509074.460762
3434
},
3535
"lev=0": {
36-
"Bx": 97799.68920761721,
37-
"By": 97809.22760976445,
38-
"Bz": 31.138421896287632,
39-
"Ex": 12848024095028.355,
40-
"Ey": 12847124613971.557,
41-
"Ez": 32437971780449.27,
42-
"jx": 308194378521.1045,
43-
"jy": 182890492089.67697,
44-
"jz": 904274843199463.8
36+
"Bx": 113572.32066454006,
37+
"By": 233769.68176084137,
38+
"Bz": 58935.90471405687,
39+
"Ex": 111077830627827.34,
40+
"Ey": 18104292500486.71,
41+
"Ez": 49957933531975.0,
42+
"jx": 2.3032421193292172e+16,
43+
"jy": 252044670800869.56,
44+
"jz": 4052661521670030.0
4545
},
4646
"plasma_e": {
47-
"particle_cpu": 4116.0,
48-
"particle_id": 22919946.0,
49-
"particle_momentum_x": 5.744112487812186e-22,
50-
"particle_momentum_y": 5.721125891605127e-22,
51-
"particle_momentum_z": 1.1184397774190402e-17,
52-
"particle_position_x": 0.13505927138536114,
53-
"particle_position_y": 0.13505924998293056,
54-
"particle_position_z": 0.20362720922167785,
55-
"particle_weight": 126912632943.36244
47+
"particle_cpu": 9680.0,
48+
"particle_id": 117349672.0,
49+
"particle_momentum_x": 1.3889342284437047e-19,
50+
"particle_momentum_y": 9.709966613374186e-21,
51+
"particle_momentum_z": 2.6318578216093305e-17,
52+
"particle_position_x": 0.4991547138014627,
53+
"particle_position_y": 0.49917221491130515,
54+
"particle_position_z": 0.4562788688974234,
55+
"particle_weight": 33067341227104.625
5656
},
5757
"plasma_p": {
58-
"particle_cpu": 4116.0,
59-
"particle_id": 25328394.0,
60-
"particle_momentum_x": 5.744307393038055e-22,
61-
"particle_momentum_y": 5.721328534468911e-22,
62-
"particle_momentum_z": 2.0535791479091845e-14,
63-
"particle_position_x": 0.13505624835441166,
64-
"particle_position_y": 0.13505624836606694,
65-
"particle_position_z": 0.20362719494726217,
66-
"particle_weight": 126912632943.36244
58+
"particle_cpu": 9680.0,
59+
"particle_id": 128125448.0,
60+
"particle_momentum_x": 1.3957368399934083e-19,
61+
"particle_momentum_y": 3.3829656839017584e-21,
62+
"particle_momentum_z": 4.829601122286012e-14,
63+
"particle_position_x": 0.4991250008410111,
64+
"particle_position_y": 0.4991249984371928,
65+
"particle_position_z": 0.4563845474251499,
66+
"particle_weight": 33067341227104.625
6767
}
6868
}

Regression/WarpX-tests.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ tolerance = 1.e-14
912912
[restart_psatd]
913913
buildDir = .
914914
inputFile = Examples/Tests/restart/inputs
915-
runtime_params = algo.maxwell_solver=psatd psatd.use_default_v_galilean=1 particles.use_fdtd_nci_corr=0 chk.file_prefix=restart_psatd_chk
915+
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
916916
dim = 3
917917
addToCompileString = USE_PSATD=TRUE
918918
restartTest = 1

Source/Diagnostics/FullDiagnostics.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ FullDiagnostics::InitializeParticleBuffer ()
5454

5555
const MultiParticleContainer& mpc = warpx.GetPartContainer();
5656
// If not specified, dump all species
57-
if (m_output_species_names.empty()) m_output_species_names = mpc.GetSpeciesNames();
57+
if (m_output_species_names.empty()) {
58+
if (m_format == "checkpoint") {
59+
m_output_species_names = mpc.GetSpeciesAndLasersNames();
60+
} else {
61+
m_output_species_names = mpc.GetSpeciesNames();
62+
}
63+
}
5864
// Initialize one ParticleDiag per species requested
5965
for (auto const& species : m_output_species_names){
6066
const int idx = mpc.getSpeciesID(species);

0 commit comments

Comments
 (0)