-
Notifications
You must be signed in to change notification settings - Fork 227
1D3V Cartesian Support #2307
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
1D3V Cartesian Support #2307
Conversation
…o topic-build1d
Source/Make.WarpX
Outdated
| endif | ||
|
|
||
| ifeq ($(DIM),1) | ||
| DEFINES += -DWARPX_DIM_1D_Z |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you correct the indentation here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, fixed it.
RemiLehe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot again for implementing and finalizing this PR!
I finished reviewing the full PR and have a few additional inline comments/suggestions? Would you have time to incorporate them in the PR?
Source/Parallelization/WarpXComm_K.H
Outdated
|
|
||
| else // PSATD (finite-order interpolation) | ||
| { | ||
| #if (AMREX_SPACEDIM > 1) // 1D not implemented for PSATD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case AMREX_SPACEDIM = 1, could you add a runtime error here (e.g. with amrex::Abort)?
I am afraid that otherwise we might forget to implement that part of the code if we later implement PSATD 1D, in which case the code might silently skip the interpolation here - which would probably be difficult to detect and debug then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I added runtime error with amrex::Abort for PSATD 1D.
| std::vector<Real> windir(3, 0.0); | ||
| #if (AMREX_SPACEDIM==2) | ||
| #if (AMREX_SPACEDIM==1) | ||
| windir[2+dir] = 1.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is slightly misleading here.
Could instead you use amrex::ignore_unused for dir and then simply do
windir[2] = 1.0;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Modified it.
| // In 1D, dir=0 corresponds to z | ||
| // This needs to be converted in order to index `boost_direction` | ||
| // which has 3 components, for 1D, 2D, and 3D simulations. | ||
| m_updated_position[2 + dir] -= WarpX::beta_boost * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment on dir ; could you use amrex::ignore_unused here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Source/Utils/WarpXMovingWindow.cpp
Outdated
| // In 1D, dir=0 corresponds to z | ||
| // This needs to be converted in order to index `boost_direction` | ||
| // which has 3 components, for 1D, 2D, and 3D simulations. | ||
| WarpX::boost_direction[2+dir] * PhysConst::c * a_dt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use amrex::ignore_unused for dir here?
Source/Utils/WarpXMovingWindow.cpp
Outdated
| Real x = 0.0; | ||
| Real y = 0.0; | ||
| Real fac_z = (1.0 - mf_type[0]) * dx[0]*0.5; | ||
| Real z = j*dx[0] + real_box.lo(0) + fac_z; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I correct that this should be
| Real z = j*dx[0] + real_box.lo(0) + fac_z; | |
| Real z = i*dx[0] + real_box.lo(0) + fac_z; |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes! That should be i. Thank you!!
Thanks for reviewing the full PR! I have incorporated the suggested changes. |
| print("tolerance = {}".format(tolerance)) | ||
| assert( error_rel < tolerance ) | ||
|
|
||
| test_name = fn[:-9] # Could also be os.path.split(os.getcwd())[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please import os and use the pattern that is written here as a comment.
Reason: #2385
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thanks!
Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H
Outdated
Show resolved
Hide resolved
|
Awesome, I think this is nearly ready. I added my suggestions inline as well :) |
Co-authored-by: Axel Huebl <[email protected]>
Co-authored-by: Axel Huebl <[email protected]>
Co-authored-by: Axel Huebl <[email protected]>
…rithms/CartesianCKCAlgorithm.H Co-authored-by: Axel Huebl <[email protected]>
…rithms/CartesianNodalAlgorithm.H Co-authored-by: Axel Huebl <[email protected]>
Co-authored-by: Axel Huebl <[email protected]>
Co-authored-by: Axel Huebl <[email protected]>
Co-authored-by: Axel Huebl <[email protected]>
Co-authored-by: Axel Huebl <[email protected]>
Co-authored-by: Axel Huebl <[email protected]>
Co-authored-by: Axel Huebl <[email protected]>
Thank you for reviewing and for the suggestions! I have addressed them. |
ax3l
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic, thanks a lot for this PR!
All green, two reviews, in we go 🚀 ✨
* Build System: Add 1D Geometry * test PR * test PR * 1D cartesian yee algorithm * fixed typo * Fixes for PML * 1D support related multiple changes * Fix compilation * change 1D to 1D_Z * 1D Field Gather and typo fix * 1D Charge Deposition * Particle Pusher * multiple changes related to 1D * 1D diagnostics and initialization * PlasmaInjector and PEC fixes for 1D * clean-up delete diags file * mobility 1D laser particle and bilinear filter * deleted diags files * update laser particle weight formula * delete diags files * Azure: Add 1D Cartesian Runner * 1D fixes for FieldProbe * Update Docs/source/developers/dimensionality.rst Co-authored-by: Remi Lehe <[email protected]> * 1d laser injection and langmuir test input files * 1d tests * clean up : delete print statements * analyse simulation result for laser injection and Langmuir tests * EOL * delete input files for which there are no automated tests * delete input files for which there are no automated tests * add ignore_unused to remove warnings * remove space * Fix compilation issues * fix error : macro name must be an identifier * Small bug fix * cleanup Python script for analysis * bug fix * bug fix * Update ParticleProbe: Check 1D in-domain * Update Source/Make.WarpX * Update .azure-pipelines.yml * Add USE_OPENPMD=FALSE to .azure-pipeline.yml * resolve conflict * resolve conflict * fix typo * Correct out-of-bound access * Fix Particle BC in WarpXParticleContainer and correct path to checksumAPI in python analysis scripts * EOL * Fix bug : accessing out of bound index of cell in 1D * remove 1d test for cartesian3d * Fix CI check * Slight style change * Address review comments * Fix GPU compilation Filter.cpp * Fix CI * Fix Indentation * Address review comments * More consistent ifdef for dimension bigger than 1 * Update Examples/Tests/Langmuir/analysis_langmuir_multi_1d.py Co-authored-by: Axel Huebl <[email protected]> * Update GNUmakefile Co-authored-by: Axel Huebl <[email protected]> * Update Regression/prepare_file_ci.py Co-authored-by: Axel Huebl <[email protected]> * Update Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H Co-authored-by: Axel Huebl <[email protected]> * Update Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianNodalAlgorithm.H Co-authored-by: Axel Huebl <[email protected]> * Update Source/Filter/Filter.cpp Co-authored-by: Axel Huebl <[email protected]> * Update Source/Filter/Filter.cpp Co-authored-by: Axel Huebl <[email protected]> * Update Source/Filter/Filter.cpp Co-authored-by: Axel Huebl <[email protected]> * Update Source/Filter/Filter.cpp Co-authored-by: Axel Huebl <[email protected]> * Update Source/Initialization/PlasmaInjector.cpp Co-authored-by: Axel Huebl <[email protected]> * Update Source/Initialization/PlasmaInjector.cpp Co-authored-by: Axel Huebl <[email protected]> * add comment inline to explain twice push_back * Add amrex::Abort for NCIGodfreyFilter Co-authored-by: Axel Huebl <[email protected]> Co-authored-by: Prabhat Kumar <[email protected]> Co-authored-by: Remi Lehe <[email protected]> Co-authored-by: Remi Lehe <[email protected]>
This PR introduces 1D3V Cartesian support to WarpX. We adopted the same strategy as for 2D/RZ/3D, i.e. we introduced new preprocessor macro (WARPX_DIM_1D_Z) and corresponding #ifdef conditions. Main updates are listed below:
- Field solver (Cartesian Yee, CKC, Nodal)
- Boundary Conditions (PEC, Silver Muller, Periodic)
- Field Gather
- Current/charge deposition (Only Esirkepov Current Deposition is implemented at the moment)
- Particle pusher
- Filter (Only BilnearFilter)
- Moving Window
- Laser Profiles (Only Gaussian is supported)
Following algorithms have not been adapted for 1D as part of this PR:
We have also introduced two CI tests, which are 1D adaptations of Langmuir and laser injection tests. Results of the analysis of these two tests are attached below. Input file corresponding to these tests are
Test 1. Examples/Tests/Langmuir/inputs_1d_multi_rt (Langmuir Test)
Test 2. Examples/Modules/laser_injection/inputs_1d_rt (Laser Injection)
Test 1
Test 2 (Ex)