Skip to content

Commit

Permalink
Add semi-implicit CI test (ECP-WarpX#4565)
Browse files Browse the repository at this point in the history
* Add semi-implicit CI test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update CI benchmark values

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
dpgrote and pre-commit-ci[bot] authored Jan 2, 2024
1 parent 5cff5e0 commit 2444f15
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Examples/Tests/Implicit/analysis_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# This is a script that analyses the simulation results from
# the script `inputs_1d`. This simulates a 1D periodic plasma using the implicit solver.
import os
import re
import sys

import numpy as np
Expand All @@ -28,7 +29,11 @@
delta_E = (total_energy - total_energy[0])/total_energy[0]
max_delta_E = np.abs(delta_E).max()

tolerance_rel = 1.e-14
if re.match('SemiImplicitPicard_1d', fn):
tolerance_rel = 2.5e-5
elif re.match('ImplicitPicard_1d', fn):
# This case should have near machine precision conservation of energy
tolerance_rel = 1.e-14

print(f"max change in energy: {max_delta_E}")
print(f"tolerance: {tolerance_rel}")
Expand Down
81 changes: 81 additions & 0 deletions Examples/Tests/Implicit/inputs_1d_semiimplicit
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#################################
############ CONSTANTS #############
#################################

my_constants.n0 = 1.e30 # plasma densirty, m^-3
my_constants.nz = 40 # number of grid cells
my_constants.Ti = 100. # ion temperature, eV
my_constants.Te = 100. # electron temperature, eV
my_constants.wpe = q_e*sqrt(n0/(m_e*epsilon0)) # electron plasma frequency, radians/s
my_constants.de0 = clight/wpe # skin depth, m
my_constants.nppcz = 100 # number of particles/cell in z
my_constants.dt = 0.1/wpe # time step size, s

#################################
####### GENERAL PARAMETERS ######
#################################

max_step = 100
amr.n_cell = nz
amr.max_level = 0

geometry.dims = 1
geometry.prob_lo = 0.0
geometry.prob_hi = 10.*de0
boundary.field_lo = periodic
boundary.field_hi = periodic
boundary.particle_lo = periodic
boundary.particle_hi = periodic

#################################
############ NUMERICS ###########
#################################

warpx.const_dt = dt
algo.evolve_scheme = semi_implicit_picard
algo.max_picard_iterations = 5
algo.picard_iteration_tolerance = 0.
algo.current_deposition = esirkepov
algo.field_gathering = energy-conserving
algo.particle_shape = 2
warpx.use_filter = 0

#################################
############ PLASMA #############
#################################

particles.species_names = electrons protons

electrons.species_type = electron
electrons.injection_style = "NUniformPerCell"
electrons.num_particles_per_cell_each_dim = nppcz
electrons.profile = constant
electrons.density = n0
electrons.momentum_distribution_type = gaussian
electrons.ux_th = sqrt(Te*q_e/m_e)/clight
electrons.uy_th = sqrt(Te*q_e/m_e)/clight
electrons.uz_th = sqrt(Te*q_e/m_e)/clight

protons.species_type = proton
protons.injection_style = "NUniformPerCell"
protons.num_particles_per_cell_each_dim = nppcz
protons.profile = constant
protons.density = n0
protons.momentum_distribution_type = gaussian
protons.ux_th = sqrt(Ti*q_e/m_p)/clight
protons.uy_th = sqrt(Ti*q_e/m_p)/clight
protons.uz_th = sqrt(Ti*q_e/m_p)/clight

# Diagnostics
diagnostics.diags_names = diag1
diag1.intervals = 100
diag1.diag_type = Full
diag1.fields_to_plot = Ex Ey Ez Bx By Bz jx jy jz rho divE
diag1.electrons.variables = w ux uy uz
diag1.protons.variables = w ux uy uz

warpx.reduced_diags_names = particle_energy field_energy
particle_energy.type = ParticleEnergy
particle_energy.intervals = 1
field_energy.type = FieldEnergy
field_energy.intervals = 1
29 changes: 29 additions & 0 deletions Regression/Checksum/benchmarks_json/SemiImplicitPicard_1d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"lev=0": {
"Bx": 3559.0541122456157,
"By": 1685.942868827529,
"Bz": 0.0,
"Ex": 796541204346.5195,
"Ey": 961740397927.6577,
"Ez": 3528140764527.8877,
"divE": 2.0829159085076083e+21,
"jx": 7.683674095607745e+17,
"jy": 1.4132459141738875e+18,
"jz": 1.350650739310074e+18,
"rho": 18442528652.19583
},
"protons": {
"particle_momentum_x": 5.231109104020749e-19,
"particle_momentum_y": 5.367985047933474e-19,
"particle_momentum_z": 5.253213505843665e-19,
"particle_position_x": 0.00010628272743703473,
"particle_weight": 5.314093261582036e+22
},
"electrons": {
"particle_momentum_x": 1.196357181461066e-20,
"particle_momentum_y": 1.2271903040162696e-20,
"particle_momentum_z": 1.2277743615209627e-20,
"particle_position_x": 0.0001064956905491333,
"particle_weight": 5.314093261582036e+22
}
}
17 changes: 17 additions & 0 deletions Regression/WarpX-tests.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4479,3 +4479,20 @@ compileTest = 0
doVis = 0
compareParticles = 1
analysisRoutine = Examples/Tests/Implicit/analysis_1d.py

[SemiImplicitPicard_1d]
buildDir = .
inputFile = Examples/Tests/Implicit/inputs_1d_semiimplicit
runtime_params = warpx.abort_on_warning_threshold=high
dim = 1
addToCompileString =
cmakeSetupOpts = -DWarpX_DIMS=1
restartTest = 0
useMPI = 1
numprocs = 2
useOMP = 0
numthreads = 1
compileTest = 0
doVis = 0
compareParticles = 1
analysisRoutine = Examples/Tests/Implicit/analysis_1d.py

0 comments on commit 2444f15

Please sign in to comment.