-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge
ECP-WarpX:development
into EZoni:remove_tmp_particle_data
- Loading branch information
Showing
63 changed files
with
1,116 additions
and
143 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
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
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
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
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
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
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
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
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
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
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
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,57 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# | ||
# | ||
# This file is part of WarpX. | ||
# | ||
# License: BSD-3-Clause-LBNL | ||
# | ||
# This is a script that analyses the simulation results from | ||
# the scripts `inputs_test_2d_pec_field_insulator_implicit` and | ||
# `inputs_test_2d_pec_field_insulator_implicit_restart`. | ||
# The scripts model an insulator boundary condition on part of the | ||
# upper x boundary that pushes B field into the domain. The implicit | ||
# solver is used, converging to machine tolerance. The energy accounting | ||
# should be exact to machine precision, so that the energy is the system | ||
# should be the same as the amount of energy pushed in from the boundary. | ||
# This is checked using the FieldEnergy and FieldPoyntingFlux reduced | ||
# diagnostics. | ||
import sys | ||
|
||
import matplotlib | ||
|
||
matplotlib.use("Agg") | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
# this will be the name of the plot file | ||
fn = sys.argv[1] | ||
|
||
EE = np.loadtxt(f"{fn}/../reducedfiles/fieldenergy.txt", skiprows=1) | ||
SS = np.loadtxt(f"{fn}/../reducedfiles/poyntingflux.txt", skiprows=1) | ||
SSsum = SS[:, 2:6].sum(1) | ||
EEloss = SS[:, 7:].sum(1) | ||
|
||
dt = EE[1, 1] | ||
|
||
fig, ax = plt.subplots() | ||
ax.plot(EE[:, 0], EE[:, 2], label="field energy") | ||
ax.plot(SS[:, 0], -EEloss, label="-flux*dt") | ||
ax.legend() | ||
ax.set_xlabel("time (s)") | ||
ax.set_ylabel("energy (J)") | ||
fig.savefig("energy_history.png") | ||
|
||
fig, ax = plt.subplots() | ||
ax.plot(EE[:, 0], (EE[:, 2] + EEloss) / EE[:, 2].max()) | ||
ax.set_xlabel("time (s)") | ||
ax.set_ylabel("energy difference/max energy (1)") | ||
fig.savefig("energy_difference.png") | ||
|
||
tolerance_rel = 1.0e-13 | ||
|
||
energy_difference_fraction = np.abs((EE[:, 2] + EEloss) / EE[:, 2].max()).max() | ||
print(f"energy accounting error = {energy_difference_fraction}") | ||
print(f"tolerance_rel = {tolerance_rel}") | ||
|
||
assert energy_difference_fraction < tolerance_rel |
73 changes: 73 additions & 0 deletions
73
Examples/Tests/pec/inputs_test_2d_pec_field_insulator_implicit
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,73 @@ | ||
# Maximum number of time steps | ||
max_step = 20 | ||
|
||
# number of grid points | ||
amr.n_cell = 32 32 | ||
amr.blocking_factor = 16 | ||
|
||
# Maximum level in hierarchy (for now must be 0, i.e., one level in total) | ||
amr.max_level = 0 | ||
|
||
# Geometry | ||
geometry.dims = 2 | ||
geometry.prob_lo = 0. 2.e-2 # physical domain | ||
geometry.prob_hi = 1.e-2 3.e-2 | ||
|
||
# Boundary condition | ||
boundary.field_lo = neumann periodic | ||
boundary.field_hi = pec_insulator periodic | ||
|
||
insulator.area_x_hi(y,z) = (2.25e-2 <= z and z <= 2.75e-2) | ||
insulator.By_x_hi(y,z,t) = min(t/1.0e-12,1)*1.e1*3.3e-4 | ||
|
||
warpx.serialize_initial_conditions = 1 | ||
|
||
# Implicit setup | ||
# Note that this is the CFL step size for the explicit simulation, over 2. | ||
# This value allows quick convergence of the Picard solver. | ||
warpx.const_dt = 7.37079480234276e-13/2. | ||
|
||
algo.maxwell_solver = Yee | ||
algo.evolve_scheme = "theta_implicit_em" | ||
#algo.evolve_scheme = "semi_implicit_em" | ||
|
||
implicit_evolve.theta = 0.5 | ||
#implicit_evolve.max_particle_iterations = 21 | ||
#implicit_evolve.particle_tolerance = 1.0e-12 | ||
|
||
implicit_evolve.nonlinear_solver = "picard" | ||
picard.verbose = true | ||
picard.max_iterations = 25 | ||
picard.relative_tolerance = 0.0 | ||
picard.absolute_tolerance = 0.0 | ||
picard.require_convergence = false | ||
|
||
#implicit_evolve.nonlinear_solver = "newton" | ||
#newton.verbose = true | ||
#newton.max_iterations = 20 | ||
#newton.relative_tolerance = 1.0e-20 | ||
#newton.absolute_tolerance = 0.0 | ||
#newton.require_convergence = false | ||
|
||
#gmres.verbose_int = 2 | ||
#gmres.max_iterations = 1000 | ||
#gmres.relative_tolerance = 1.0e-20 | ||
#gmres.absolute_tolerance = 0.0 | ||
|
||
# Verbosity | ||
warpx.verbose = 1 | ||
|
||
# Diagnostics | ||
diagnostics.diags_names = diag1 chk | ||
diag1.intervals = 20 | ||
diag1.diag_type = Full | ||
|
||
chk.intervals = 10 | ||
chk.diag_type = Full | ||
chk.format = checkpoint | ||
|
||
warpx.reduced_diags_names = fieldenergy poyntingflux | ||
poyntingflux.type = FieldPoyntingFlux | ||
poyntingflux.intervals = 1 | ||
fieldenergy.type = FieldEnergy | ||
fieldenergy.intervals = 1 |
5 changes: 5 additions & 0 deletions
5
Examples/Tests/pec/inputs_test_2d_pec_field_insulator_implicit_restart
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,5 @@ | ||
# base input parameters | ||
FILE = inputs_test_2d_pec_field_insulator_implicit | ||
|
||
# test input parameters | ||
amr.restart = "../test_2d_pec_field_insulator_implicit/diags/chk000010" |
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,54 @@ | ||
# Set-up to test the PMC Boundary condition for the fields | ||
# Constructive interference between the incident and reflected wave result in a | ||
# standing wave. | ||
|
||
# max step | ||
max_step = 134 | ||
|
||
# number of grid points | ||
amr.n_cell = 32 32 256 | ||
|
||
# Maximum allowable size of each subdomain | ||
amr.max_grid_size = 1024 | ||
amr.blocking_factor = 32 | ||
|
||
amr.max_level = 0 | ||
|
||
# Geometry | ||
geometry.dims = 3 | ||
geometry.prob_lo = -8.e-6 -8.e-6 -4.e-6 | ||
geometry.prob_hi = 8.e-6 8.e-6 4.e-6 | ||
|
||
# Boundary condition | ||
boundary.field_lo = periodic periodic pmc | ||
boundary.field_hi = periodic periodic pmc | ||
|
||
warpx.serialize_initial_conditions = 1 | ||
|
||
# Verbosity | ||
warpx.verbose = 1 | ||
|
||
# Algorithms | ||
algo.current_deposition = esirkepov | ||
# CFL | ||
warpx.cfl = 0.9 | ||
|
||
|
||
my_constants.z1 = -2.e-6 | ||
my_constants.z2 = 2.e-6 | ||
my_constants.wavelength = 1.e-6 | ||
warpx.E_ext_grid_init_style = parse_E_ext_grid_function | ||
warpx.Ez_external_grid_function(x,y,z) = "0." | ||
warpx.Ex_external_grid_function(x,y,z) = "0." | ||
warpx.Ey_external_grid_function(x,y,z) = "((1.e5*sin(2*pi*(z)/wavelength)) * (z<z2) * (z>z1))" | ||
|
||
warpx.B_ext_grid_init_style = parse_B_ext_grid_function | ||
warpx.Bx_external_grid_function(x,y,z)= "(((-1.e5*sin(2*pi*(z)/wavelength))/clight))*(z<z2) * (z>z1) " | ||
warpx.By_external_grid_function(x,y,z)= "0." | ||
warpx.Bz_external_grid_function(x,y,z) = "0." | ||
|
||
# Diagnostics | ||
diagnostics.diags_names = diag1 | ||
diag1.intervals = 134 | ||
diag1.diag_type = Full | ||
diag1.fields_to_plot = Ey Bx |
Oops, something went wrong.