Skip to content

Conversation

@prkkumar
Copy link
Member

@prkkumar prkkumar commented Sep 17, 2021

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:

  • build system
  • documentation
  • algorithms, algorithms:
    - 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)
  • data structures & accessors (e.g., particle positions)
  • tests
  • CI
  • I/O
  • GNUMake build system

Following algorithms have not been adapted for 1D as part of this PR:

  • PSATD, PML, QED, Ionization, Collisions, OPENPMD.

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

langmuir_multi_1d_analysis

Test 2 (Ex)

plt_Ex

@ax3l ax3l requested review from RemiLehe and ax3l September 17, 2021 00:22
@ax3l ax3l added the enhancement New feature or request label Sep 17, 2021
@ax3l ax3l mentioned this pull request Sep 17, 2021
7 tasks
@ax3l ax3l marked this pull request as ready for review October 22, 2021 18:32
endif

ifeq ($(DIM),1)
DEFINES += -DWARPX_DIM_1D_Z
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed it.

Copy link
Member

@RemiLehe RemiLehe left a 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?


else // PSATD (finite-order interpolation)
{
#if (AMREX_SPACEDIM > 1) // 1D not implemented for PSATD
Copy link
Member

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.

Copy link
Member Author

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;
Copy link
Member

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;

Copy link
Member Author

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 *
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

// 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;
Copy link
Member

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?

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;
Copy link
Member

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

Suggested change
Real z = j*dx[0] + real_box.lo(0) + fac_z;
Real z = i*dx[0] + real_box.lo(0) + fac_z;

?

Copy link
Member Author

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!!

@prkkumar
Copy link
Member Author

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?

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]
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks!

@ax3l
Copy link
Member

ax3l commented Nov 19, 2021

Awesome, I think this is nearly ready. I added my suggestions inline as well :)

@prkkumar
Copy link
Member Author

Awesome, I think this is nearly ready. I added my suggestions inline as well :)

Thank you for reviewing and for the suggestions! I have addressed them.

Copy link
Member

@ax3l ax3l left a 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 🚀 ✨

@ax3l ax3l merged commit 45ef533 into BLAST-WarpX:development Nov 19, 2021
dpgrote pushed a commit to dpgrote/WarpX that referenced this pull request Nov 29, 2021
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants