forked from ECP-WarpX/WarpX
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright 2024 Justin Angus, David Grote | ||
# | ||
# | ||
# This file is part of WarpX. | ||
# | ||
# License: BSD-3-Clause-LBNL | ||
# | ||
# This is a script that analyses the simulation results from the script `inputs_vandb_2d`. | ||
# This simulates a 2D periodic plasma using the implicit solver | ||
# with the Villasenor deposition using shape factor 2. | ||
import os | ||
import sys | ||
|
||
import numpy as np | ||
import yt | ||
from scipy.constants import e, epsilon_0 | ||
|
||
sys.path.insert(1, '../../../../warpx/Regression/Checksum/') | ||
import checksumAPI | ||
|
||
# this will be the name of the plot file | ||
fn = sys.argv[1] | ||
|
||
field_energy = np.loadtxt('diags/reducedfiles/field_energy.txt', skiprows=1) | ||
particle_energy = np.loadtxt('diags/reducedfiles/particle_energy.txt', skiprows=1) | ||
|
||
total_energy = field_energy[:,2] + particle_energy[:,2] | ||
|
||
delta_E = (total_energy - total_energy[0])/total_energy[0] | ||
max_delta_E = np.abs(delta_E).max() | ||
|
||
# This case should have near machine precision conservation of energy | ||
tolerance_rel_energy = 2.e-14 | ||
tolerance_rel_charge = 2.e-15 | ||
|
||
print(f"max change in energy: {max_delta_E}") | ||
print(f"tolerance: {tolerance_rel_energy}") | ||
|
||
assert( max_delta_E < tolerance_rel_energy ) | ||
|
||
test_name = os.path.split(os.getcwd())[1] | ||
checksumAPI.evaluate_checksum(test_name, fn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
################################# | ||
########## CONSTANTS ############ | ||
################################# | ||
|
||
my_constants.n0 = 1.e30 # m^-3 | ||
my_constants.nz = 40 | ||
my_constants.Ti = 100. # eV | ||
my_constants.Te = 100. # eV | ||
my_constants.wpe = q_e*sqrt(n0/(m_e*epsilon0)) | ||
my_constants.de0 = clight/wpe | ||
my_constants.nppcz = 10 # number of particles/cell in z | ||
my_constants.dt = 0.1/wpe # s | ||
|
||
################################# | ||
####### GENERAL PARAMETERS ###### | ||
################################# | ||
max_step = 20 | ||
amr.n_cell = nz nz | ||
amr.max_grid_size = nz | ||
amr.max_level = 0 | ||
geometry.dims = 2 | ||
geometry.prob_lo = 0.0 0.0 # physical domain | ||
geometry.prob_hi = 10.0*de0 10.0*de0 | ||
|
||
################################# | ||
####### Boundary condition ###### | ||
################################# | ||
boundary.field_lo = periodic periodic | ||
boundary.field_hi = periodic periodic | ||
|
||
################################# | ||
############ NUMERICS ########### | ||
################################# | ||
warpx.serialize_initial_conditions = 1 | ||
warpx.verbose = 1 | ||
warpx.const_dt = dt | ||
#warpx.cfl = 0.5656 | ||
warpx.use_filter = 0 | ||
|
||
algo.maxwell_solver = psatd | ||
algo.evolve_scheme = strang_implicit_spectral_em | ||
implicit_evolve.nonlinear_solver = "picard" | ||
|
||
picard.verbose = true | ||
picard.max_iterations = 9 | ||
picard.relative_tolerance = 0.0 | ||
picard.absolute_tolerance = 0.0 | ||
picard.require_convergence = false | ||
|
||
algo.particle_pusher = "boris" | ||
|
||
algo.particle_shape = 2 | ||
algo.current_deposition = direct | ||
algo.charge_deposition = standard | ||
algo.field_gathering = energy-conserving | ||
interpolation.galerkin_scheme = 0 | ||
|
||
psatd.periodic_single_box_fft = 1 | ||
psatd.update_with_rho = 0 | ||
|
||
################################# | ||
############ PLASMA ############# | ||
################################# | ||
particles.species_names = electrons protons | ||
|
||
electrons.species_type = electron | ||
electrons.injection_style = "NUniformPerCell" | ||
electrons.num_particles_per_cell_each_dim = nppcz 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 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 = 20 | ||
diag1.diag_type = Full | ||
diag1.fields_to_plot = Ex Ey Ez Bx By Bz jx jy jz rho divE | ||
diag1.electrons.variables = x z w ux uy uz | ||
diag1.protons.variables = x z 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 |
31 changes: 31 additions & 0 deletions
31
Regression/Checksum/benchmarks_json/StrangImplicitPicard_2d.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"lev=0": { | ||
"Bx": 58018.206830778014, | ||
"By": 88412.25641248813, | ||
"Bz": 63028.38785568341, | ||
"Ex": 87294986087984.7, | ||
"Ey": 14567455995937.832, | ||
"Ez": 84319563939131.92, | ||
"divE": 9.3547754444717e+22, | ||
"jx": 2.549397791350535e+19, | ||
"jy": 2.9362818951630856e+19, | ||
"jz": 2.6731439000207606e+19, | ||
"rho": 846359286867.8794 | ||
}, | ||
"protons": { | ||
"particle_momentum_x": 2.088019539997887e-17, | ||
"particle_momentum_y": 2.086947126875785e-17, | ||
"particle_momentum_z": 2.0940357594177255e-17, | ||
"particle_position_x": 0.004251274413463975, | ||
"particle_position_y": 0.004251274300177974, | ||
"particle_weight": 2823958719279159.5 | ||
}, | ||
"electrons": { | ||
"particle_momentum_x": 4.858827793011859e-19, | ||
"particle_momentum_y": 4.862445227619648e-19, | ||
"particle_momentum_z": 4.880462723064323e-19, | ||
"particle_position_x": 0.004251055434189128, | ||
"particle_position_y": 0.004251294960418283, | ||
"particle_weight": 2823958719279159.5 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters