Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
d01325c
Merge pull request #3 from ECP-WarpX/development
lgiacome Jul 20, 2021
e92ce6f
Merge remote-tracking branch 'upstream/development' into development
lgiacome Jul 30, 2021
5381ea5
adding the FieldProbe
lgiacome Aug 2, 2021
8938adc
adding missing file
lgiacome Aug 2, 2021
30c195d
updating makefile
lgiacome Aug 2, 2021
801e6fc
fixing host-device problem
lgiacome Aug 2, 2021
2c640ed
Revert "fixing host-device problem"
lgiacome Aug 2, 2021
cfa4af2
fixing host-device problem
lgiacome Aug 2, 2021
aa911a3
making some variables const
lgiacome Aug 2, 2021
9236ddf
adding a few comments
lgiacome Aug 2, 2021
507a59c
Adding the FieldProbe to the documentation
lgiacome Aug 2, 2021
7380e0e
making the probe mpi-safe
lgiacome Aug 3, 2021
65a77b9
added field probe to reduced diag test
lgiacome Aug 3, 2021
0742072
added field probe to reduced diag analysis
lgiacome Aug 3, 2021
674031d
using cell-centered fields in probe diag
lgiacome Aug 3, 2021
56c7a72
removed a few typos
lgiacome Aug 3, 2021
215a035
Interpolating to the point instead oof cell center
lgiacome Aug 4, 2021
dc2f249
bug fix
lgiacome Aug 4, 2021
3942501
improved a comment
lgiacome Aug 4, 2021
1a29f6c
updated documentation
lgiacome Aug 4, 2021
823d20f
Undone an outdated change
lgiacome Aug 5, 2021
3fc9b33
Merge remote-tracking branch 'upstream/development' into probe_diag
lgiacome Aug 5, 2021
b529d47
improving some variable names
lgiacome Aug 12, 2021
f785621
improving the box extraction
lgiacome Aug 12, 2021
43f7312
making the interpolation order an input parameter
lgiacome Aug 12, 2021
4655cf5
fix a typo
lgiacome Aug 12, 2021
1843a83
setting the field values to zero if the point is not in the domain
lgiacome Aug 12, 2021
21b0b69
skipping the communication if probe proc is IO prcessor
lgiacome Aug 12, 2021
be077a1
Fixed typo in documentation
lgiacome Aug 25, 2021
4706b42
Updating an header
lgiacome Aug 25, 2021
1a5abd7
Added a comment on the probe position
lgiacome Aug 25, 2021
03c38bc
tidying up the analysis script
lgiacome Aug 25, 2021
7696029
fixed a comment
lgiacome Aug 25, 2021
1b17a68
removing an unused include
lgiacome Aug 25, 2021
80959f1
improving the parsing of parameters
lgiacome Aug 25, 2021
ef577e4
fixing some comments
lgiacome Aug 25, 2021
83d71c6
making some variables const
lgiacome Aug 25, 2021
e76a574
changed some ParticleReal into Real
lgiacome Aug 25, 2021
25c0a17
using better tags in MPI communication
lgiacome Aug 25, 2021
0dc1a4c
Making field probe work in 2D
lgiacome Aug 25, 2021
fbd9091
making a variable const
lgiacome Aug 25, 2021
cca32be
initializing y_probe only in 3D
lgiacome Aug 25, 2021
45f95b1
tidying up a line which is common to 2D and 3D
lgiacome Aug 25, 2021
629a5d0
making a variable constexpr
lgiacome Aug 25, 2021
a7d4cee
adding a _rt
lgiacome Aug 25, 2021
bd47ae6
checking that the probe location is in one of the processors
lgiacome Aug 25, 2021
2682a74
removing a useless if condition
lgiacome Aug 25, 2021
175c4c5
Fixing the initialization in 2D
lgiacome Oct 11, 2021
7c3e2a9
Avoiding scrape particles in 2D (it segfaults)
lgiacome Oct 11, 2021
5277c6f
Adding a test for 2D EB
lgiacome Oct 11, 2021
3825457
Fixed the areas initialization
lgiacome Oct 11, 2021
3fbd6fc
Merge branch 'probe_diag' into eb_2d
lgiacome Oct 12, 2021
b06a626
Merge remote-tracking branch 'upstream/development' into eb_2d
lgiacome Oct 13, 2021
3f172b1
Initializing to zero some multifabs
lgiacome Oct 13, 2021
98896de
Modified the ECT solver to make it work in 2D
lgiacome Oct 13, 2021
9758cce
Modified the cell extensions to make them work in 2D
lgiacome Oct 13, 2021
6cc6d67
Improved 2D cube test
lgiacome Oct 13, 2021
b94c6ed
Added 2D rotated cube test
lgiacome Oct 13, 2021
00630d8
Merge remote-tracking branch 'upstream/development' into eb_2d
lgiacome Oct 18, 2021
8bce737
Adding the 2d analysis script and CI
lgiacome Oct 18, 2021
16edb3d
Removed an unused import from the analysis script
lgiacome Oct 18, 2021
f4b5584
Ignoring some unused variables
lgiacome Oct 18, 2021
704495a
Fixing the number of dimensions in the 2d test
lgiacome Oct 18, 2021
a5bf374
Added missing analysis for ECT
lgiacome Oct 18, 2021
adb2b02
Enabled again 2d particles scraping
lgiacome Oct 19, 2021
358bf3d
Merge remote-tracking branch 'upstream/development' into eb_2d
lgiacome Nov 11, 2021
8d3b246
Fixing the test_name with the general logic
lgiacome Nov 11, 2021
915bdbc
Fixing the test_name with the general logic
lgiacome Nov 11, 2021
fe59be0
Removed some commented code
lgiacome Nov 11, 2021
d3d0cb9
Modified several preprocessor directives to check consistency EB-dime…
lgiacome Nov 11, 2021
5f038e8
Added missing semicolons
lgiacome Nov 11, 2021
cad584f
Fixed a preprocessor directivew
lgiacome Nov 11, 2021
c6cdbbb
Fix typo: WARPX_DIM_XZ
ax3l Nov 12, 2021
d5914d4
Improving some comments
lgiacome Nov 12, 2021
39a03d1
Adding some more consistency checks
lgiacome Nov 12, 2021
606b0b9
Adding some more consistency checks
lgiacome Nov 12, 2021
7fae59c
Fixed a typo
lgiacome Nov 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions Examples/Modules/embedded_boundary_cube/analysis_fields_2d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#! /usr/bin/env python

import yt
import os
import sys
from scipy.constants import mu_0, pi, c
import numpy as np

sys.path.insert(1, '../../../../warpx/Regression/Checksum/')
import checksumAPI

# This is a script that analyses the simulation results from
# the script `inputs_3d`. This simulates a TMmnp mode in a PEC cubic resonator.
# The magnetic field in the simulation is given (in theory) by:
# $$ B_y = \mu \cos(k_x x)\cos(k_z z)\cos( \omega_p t)$$
# with
# $$ k_x = \frac{m\pi}{L}$$
# $$ k_y = \frac{n\pi}{L}$$
# $$ k_z = \frac{p\pi}{L}$$

hi = [0.8, 0.8]
lo = [-0.8, -0.8]
ncells = [32, 32, 1]
dx = (hi[0] - lo[0]) / ncells[0]
dz = (hi[1] - lo[1]) / ncells[1]
m = 0
n = 1
Lx = 1
Lz = 1

# Open the right plot file
filename = sys.argv[1]
ds = yt.load(filename)
data = ds.covering_grid(level=0, left_edge=ds.domain_left_edge, dims=ds.domain_dimensions)

t = ds.current_time.to_value()

# Compute the analytic solution
By_th = np.zeros(ncells)
for i in range(ncells[0]):
for j in range(ncells[1]):
x = (i+0.5) * dx + lo[0]
z = (j+0.5) * dz + lo[1]

By_th[i, j, 0] = mu_0 * (np.cos(m * pi / Lx * (x - Lx / 2)) *
np.cos(n * pi / Lz * (z - Lz / 2)) *
(-Lx / 2 <= x < Lx / 2) *
(-Lz / 2 <= z < Lz / 2) *
np.cos(np.pi / Lx * c * t))

rel_tol_err = 1e-3

# Compute relative l^2 error on By
By_sim = data['By'].to_ndarray()
rel_err_y = np.sqrt(np.sum(np.square(By_sim - By_th)) / np.sum(np.square(By_th)))
assert (rel_err_y < rel_tol_err)

test_name = os.path.split(os.getcwd())[1]

checksumAPI.evaluate_checksum(test_name, filename)
36 changes: 36 additions & 0 deletions Examples/Modules/embedded_boundary_cube/inputs_2d
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
stop_time = 1.3342563807926085e-08
amr.n_cell = 32 32
amr.max_grid_size = 128
amr.max_level = 0

geometry.coord_sys = 0
geometry.prob_lo = -0.8 -0.8
geometry.prob_hi = 0.8 0.8
warpx.cfl = 1

boundary.field_lo = pec pec
boundary.field_hi = pec pec

my_constants.xmin = -0.5
my_constants.zmin = -0.5
my_constants.xmax = 0.5
my_constants.zmax = 0.5
# Alternatively one could use parser to build EB
# Note that for amrex EB implicit function, >0 is covered, =0 is boundary and <0 is regular.
warpx.eb_implicit_function = "max(max(x+xmin,-(x+xmax)), max(z+zmin,-(z+zmax)))"

warpx.B_ext_grid_init_style = parse_B_ext_grid_function

my_constants.m = 0
my_constants.p = 1
my_constants.Lx = 1
my_constants.Lz = 1

warpx.Bz_external_grid_function(x,y,z) = 0
warpx.Bx_external_grid_function(x,y,z) = 0
warpx.By_external_grid_function(x,y,z) = cos(m * pi / Lx * (x - Lx / 2)) * cos(p * pi / Lz * (z - Lz / 2))*mu0

diagnostics.diags_names = diag1
diag1.intervals = 1
diag1.diag_type = Full
diag1.fields_to_plot = Ex Ey Ez Bx By Bz
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#! /usr/bin/env python

import yt
import os
import sys
from scipy.constants import mu_0, pi, c
import numpy as np

sys.path.insert(1, '../../../../warpx/Regression/Checksum/')
import checksumAPI

# This is a script that analyses the simulation results from
# the script `inputs_3d`. This simulates a TMmnp mode in a PEC cubic resonator.
# The magnetic field in the simulation is given (in theory) by:
# $$ B_y = \mu \cos(k_x x)\cos(k_z z)\cos( \omega_p t)$$
# with
# $$ k_x = \frac{m\pi}{L}$$
# $$ k_y = \frac{n\pi}{L}$$
# $$ k_z = \frac{p\pi}{L}$$

hi = [0.8, 0.8]
lo = [-0.8, -0.8]
ncells = [32, 32]
dx = (hi[0] - lo[0]) / ncells[0]
dz = (hi[1] - lo[1]) / ncells[1]
m = 0
n = 1
Lx = 1.06
Lz = 1.06

# Open the right plot file
filename = sys.argv[1]
ds = yt.load(filename)
data = ds.covering_grid(level=0, left_edge=ds.domain_left_edge, dims=ds.domain_dimensions)
my_grid = ds.index.grids[0]

By_sim = my_grid['By'].squeeze().v

t = ds.current_time.to_value()

theta = np.pi/8

# Compute the analytic solution
By_th = np.zeros(ncells)
for i in range(ncells[0]):
for j in range(ncells[1]):
x = i * dx + lo[0]
z = j * dz + lo[1]
xr = x*np.cos(-theta) + z*np.sin(-theta)
zr = -x*np.sin(-theta) + z*np.cos(-theta)

By_th[i, j] = mu_0 * (np.cos(m * pi / Lx * (xr - Lx / 2)) *
np.cos(n * pi / Lz * (zr - Lz / 2)) *
np.cos(np.pi / Lx * c * t))*(By_sim[i, j] != 0)

rel_tol_err = 1e-1

# Compute relative l^2 error on By
rel_err_y = np.sqrt(np.sum(np.square(By_sim - By_th)) / np.sum(np.square(By_th)))
assert (rel_err_y < rel_tol_err)

test_name = os.path.split(os.getcwd())[1]

checksumAPI.evaluate_checksum(test_name, filename)
44 changes: 44 additions & 0 deletions Examples/Modules/embedded_boundary_rotated_cube/inputs_2d
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
stop_time = 8.019424744948937e-09
amr.n_cell = 32 32
amr.max_grid_size = 128
amr.max_level = 0

geometry.coord_sys = 0
geometry.prob_lo = -0.8 -0.8
geometry.prob_hi = 0.8 0.8
warpx.cfl = 1

boundary.field_lo = pec pec
boundary.field_hi = pec pec

algo.maxwell_solver = ect

my_constants.xmin = -0.53
my_constants.zmin = -0.53
my_constants.xmax = 0.53
my_constants.zmax = 0.53
my_constants.pi = 3.141592653589793
my_constants.theta = pi/8

warpx.eb_implicit_function = "xr=x*cos(-theta)+z*sin(-theta); zr=-x*sin(-theta)+z*cos(-theta); max(max(xr+xmin,-(xr+xmax)), max(zr+zmin,-(zr+zmax)))"

my_constants.m = 0
my_constants.p = 1
my_constants.Lx = 1.06
my_constants.Lz = 1.06
my_constants.x_cent = 0.
my_constants.z_cent = 0.
my_constants.mu_0 = 1.25663706212e-06

warpx.B_ext_grid_init_style = parse_B_ext_grid_function

warpx.Bx_external_grid_function(x,y,z) = 0
warpx.By_external_grid_function(x,y,z) = mu_0 *
cos(m * pi / Lx * (x*cos(-theta)+z*sin(-theta) - Lx / 2 - x_cent)) *
cos(p * pi / Lz * (-x*sin(-theta)+z*cos(-theta) - Lz / 2 - z_cent))
warpx.Bz_external_grid_function(x,y,z) = 0

diagnostics.diags_names = diag1
diag1.intervals = 1000
diag1.diag_type = Full
diag1.fields_to_plot = Ex Ey Ez Bx By Bz
11 changes: 11 additions & 0 deletions Regression/Checksum/benchmarks_json/embedded_boundary_cube_2d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"lev=0": {
"Bx": 0.0,
"By": 0.00031905198933489135,
"Bz": 0.0,
"Ex": 8553.906698053022,
"Ey": 0.0,
"Ez": 0.0
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"lev=0": {
"Bx": 0.0,
"By": 0.0002722100736459592,
"Bz": 0.0,
"Ex": 78275.78138124556,
"Ey": 0.0,
"Ez": 31681.635842293996
}
}
32 changes: 32 additions & 0 deletions Regression/WarpX-tests.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2310,6 +2310,22 @@ doVis = 0
compareParticles = 0
analysisRoutine = Examples/Modules/embedded_boundary_cube/analysis_fields.py

[embedded_boundary_cube_2d]
buildDir = .
inputFile = Examples/Modules/embedded_boundary_cube/inputs_2d
runtime_params =
dim = 2
addToCompileString = USE_EB=TRUE
restartTest = 0
useMPI = 1
numprocs = 1
useOMP = 1
numthreads = 1
compileTest = 0
doVis = 0
compareParticles = 0
analysisRoutine = Examples/Modules/embedded_boundary_cube/analysis_fields_2d.py

[embedded_boundary_rotated_cube]
buildDir = .
inputFile = Examples/Modules/embedded_boundary_rotated_cube/inputs_3d
Expand All @@ -2326,6 +2342,22 @@ doVis = 0
compareParticles = 0
analysisRoutine = Examples/Modules/embedded_boundary_rotated_cube/analysis_fields.py

[embedded_boundary_rotated_cube_2d]
buildDir = .
inputFile = Examples/Modules/embedded_boundary_rotated_cube/inputs_2d
runtime_params =
dim = 2
addToCompileString = USE_EB=TRUE
restartTest = 0
useMPI = 1
numprocs = 1
useOMP = 1
numthreads = 1
compileTest = 0
doVis = 0
compareParticles = 0
analysisRoutine = Examples/Modules/embedded_boundary_rotated_cube/analysis_fields_2d.py

[dirichletbc]
buildDir = .
inputFile = Examples/Tests/ElectrostaticDirichletBC/inputs_2d
Expand Down
Loading