-
Notifications
You must be signed in to change notification settings - Fork 229
2D EM solver with EB #2401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
2D EM solver with EB #2401
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 e92ce6f
Merge remote-tracking branch 'upstream/development' into development
lgiacome 5381ea5
adding the FieldProbe
lgiacome 8938adc
adding missing file
lgiacome 30c195d
updating makefile
lgiacome 801e6fc
fixing host-device problem
lgiacome 2c640ed
Revert "fixing host-device problem"
lgiacome cfa4af2
fixing host-device problem
lgiacome aa911a3
making some variables const
lgiacome 9236ddf
adding a few comments
lgiacome 507a59c
Adding the FieldProbe to the documentation
lgiacome 7380e0e
making the probe mpi-safe
lgiacome 65a77b9
added field probe to reduced diag test
lgiacome 0742072
added field probe to reduced diag analysis
lgiacome 674031d
using cell-centered fields in probe diag
lgiacome 56c7a72
removed a few typos
lgiacome 215a035
Interpolating to the point instead oof cell center
lgiacome dc2f249
bug fix
lgiacome 3942501
improved a comment
lgiacome 1a29f6c
updated documentation
lgiacome 823d20f
Undone an outdated change
lgiacome 3fc9b33
Merge remote-tracking branch 'upstream/development' into probe_diag
lgiacome b529d47
improving some variable names
lgiacome f785621
improving the box extraction
lgiacome 43f7312
making the interpolation order an input parameter
lgiacome 4655cf5
fix a typo
lgiacome 1843a83
setting the field values to zero if the point is not in the domain
lgiacome 21b0b69
skipping the communication if probe proc is IO prcessor
lgiacome be077a1
Fixed typo in documentation
lgiacome 4706b42
Updating an header
lgiacome 1a5abd7
Added a comment on the probe position
lgiacome 03c38bc
tidying up the analysis script
lgiacome 7696029
fixed a comment
lgiacome 1b17a68
removing an unused include
lgiacome 80959f1
improving the parsing of parameters
lgiacome ef577e4
fixing some comments
lgiacome 83d71c6
making some variables const
lgiacome e76a574
changed some ParticleReal into Real
lgiacome 25c0a17
using better tags in MPI communication
lgiacome 0dc1a4c
Making field probe work in 2D
lgiacome fbd9091
making a variable const
lgiacome cca32be
initializing y_probe only in 3D
lgiacome 45f95b1
tidying up a line which is common to 2D and 3D
lgiacome 629a5d0
making a variable constexpr
lgiacome a7d4cee
adding a _rt
lgiacome bd47ae6
checking that the probe location is in one of the processors
lgiacome 2682a74
removing a useless if condition
lgiacome 175c4c5
Fixing the initialization in 2D
lgiacome 7c3e2a9
Avoiding scrape particles in 2D (it segfaults)
lgiacome 5277c6f
Adding a test for 2D EB
lgiacome 3825457
Fixed the areas initialization
lgiacome 3fbd6fc
Merge branch 'probe_diag' into eb_2d
lgiacome b06a626
Merge remote-tracking branch 'upstream/development' into eb_2d
lgiacome 3f172b1
Initializing to zero some multifabs
lgiacome 98896de
Modified the ECT solver to make it work in 2D
lgiacome 9758cce
Modified the cell extensions to make them work in 2D
lgiacome 6cc6d67
Improved 2D cube test
lgiacome b94c6ed
Added 2D rotated cube test
lgiacome 00630d8
Merge remote-tracking branch 'upstream/development' into eb_2d
lgiacome 8bce737
Adding the 2d analysis script and CI
lgiacome 16edb3d
Removed an unused import from the analysis script
lgiacome f4b5584
Ignoring some unused variables
lgiacome 704495a
Fixing the number of dimensions in the 2d test
lgiacome a5bf374
Added missing analysis for ECT
lgiacome adb2b02
Enabled again 2d particles scraping
lgiacome 358bf3d
Merge remote-tracking branch 'upstream/development' into eb_2d
lgiacome 8d3b246
Fixing the test_name with the general logic
lgiacome 915bdbc
Fixing the test_name with the general logic
lgiacome fe59be0
Removed some commented code
lgiacome d3d0cb9
Modified several preprocessor directives to check consistency EB-dime…
lgiacome 5f038e8
Added missing semicolons
lgiacome cad584f
Fixed a preprocessor directivew
lgiacome c6cdbbb
Fix typo: WARPX_DIM_XZ
ax3l d5914d4
Improving some comments
lgiacome 39a03d1
Adding some more consistency checks
lgiacome 606b0b9
Adding some more consistency checks
lgiacome 7fae59c
Fixed a typo
lgiacome File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
Examples/Modules/embedded_boundary_cube/analysis_fields_2d.py
This file contains hidden or 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,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) |
This file contains hidden or 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,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 |
64 changes: 64 additions & 0 deletions
64
Examples/Modules/embedded_boundary_rotated_cube/analysis_fields_2d.py
This file contains hidden or 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,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) |
This file contains hidden or 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 @@ | ||
| 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
11
Regression/Checksum/benchmarks_json/embedded_boundary_cube_2d.json
This file contains hidden or 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,11 @@ | ||
| { | ||
| "lev=0": { | ||
| "Bx": 0.0, | ||
| "By": 0.00031905198933489135, | ||
| "Bz": 0.0, | ||
| "Ex": 8553.906698053022, | ||
| "Ey": 0.0, | ||
| "Ez": 0.0 | ||
| } | ||
| } | ||
|
|
10 changes: 10 additions & 0 deletions
10
Regression/Checksum/benchmarks_json/embedded_boundary_rotated_cube_2d.json
This file contains hidden or 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,10 @@ | ||
| { | ||
| "lev=0": { | ||
| "Bx": 0.0, | ||
| "By": 0.0002722100736459592, | ||
| "Bz": 0.0, | ||
| "Ex": 78275.78138124556, | ||
| "Ey": 0.0, | ||
| "Ez": 31681.635842293996 | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.