Skip to content
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

BTD-RZ Add multiple modes #3482

Merged
merged 33 commits into from
Nov 17, 2022

Conversation

RevathiJambunathan
Copy link
Member

@RevathiJambunathan RevathiJambunathan commented Oct 25, 2022

  • add a test

To be merged after #3350

input file used for testing on summit :
inputs.txt

@RevathiJambunathan RevathiJambunathan added geometry: RZ axisymmetric 2D and quasi-3D component: diagnostics all types of outputs enhancement New feature or request labels Oct 25, 2022
@RevathiJambunathan RevathiJambunathan marked this pull request as ready for review October 28, 2022 22:11
@ax3l
Copy link
Member

ax3l commented Oct 31, 2022

@RevathiJambunathan ready for rebase :)

Copy link
Member

@EZoni EZoni left a comment

Choose a reason for hiding this comment

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

Thank you for this PR, @RevathiJambunathan! Sorry, I decided to jump in as a reviewer to maybe help merge this faster. So far I left only a few minor comments on using WarpX::ncomps directly where possible, following the spirit of #2951. Unless we think it's unsafe for some reason.

Source/Diagnostics/BTDiagnostics.cpp Outdated Show resolved Hide resolved
@lgtm-com
Copy link
Contributor

lgtm-com bot commented Nov 7, 2022

This pull request introduces 1 alert when merging 0aded06 into 8f9da8c - view on LGTM.com

new alerts:

  • 1 for Unused import

@RevathiJambunathan
Copy link
Member Author

RevathiJambunathan commented Nov 12, 2022

The CI test is failing because amrex.fpe_trap_invalid=1 is catching an error which I am able to reproduce locally as well upon adding the same flags.

After running this with DEBUG, Here is the Backtrace.0.0.txt

I am wondering if something about RZ is not quite okay with amrex::get_slice_data?
or it could be that the values in the cell-centered data are junk?
I will print min max values for the multifab and see what I get

In the meanwhile, I also tried running this test with one RZ mode, and I get the following warning

!!! WARNING : [high][Laser] The antenna is completely out of the simulation box
             for laser laser1
!
0::Assertion `msg_priority < abort_priority' failed, file "/home/revanathan/Codes/Warpx_Upstream/Source/ablastr/warn_manager/WarnManager.cpp", line 89, Msg: 
### ERROR   : A warning with priority 'high' has been raised.
 !!!
SIGABRT

@RevathiJambunathan
Copy link
Member Author

Update : I printed the min/max values of the cell-centered multifab being sliced and it all looks okay. nothing suspicious there, definitely no nans or really small/large numbers

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 for this PR!
I added a few suggestions. I will simultaneously also have a look at the failing test to try to understand better what is happening there.

Examples/Tests/BTD_rz/analysis_BTD_laser_antenna.py Outdated Show resolved Hide resolved
Examples/Tests/BTD_rz/analysis_BTD_laser_antenna.py Outdated Show resolved Hide resolved
Examples/Tests/BTD_rz/inputs_rz_z_boosted_BTD Outdated Show resolved Hide resolved
Comment on lines 240 to 249
for (int imode = 0; imode < n_rz; ++imode) {
int offset = 1;
// number of components for a given mode
int ncomp = 2;
if (imode == 0) {
offset = 0;
// Mode 0 has only real part, thus ncomp = 1
ncomp = 1;
}
for (int icomp = 0; icomp < ncomp; ++icomp) {
Copy link
Member

Choose a reason for hiding this comment

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

Could we replace the whole code above by a loop over components?

Suggested change
for (int imode = 0; imode < n_rz; ++imode) {
int offset = 1;
// number of components for a given mode
int ncomp = 2;
if (imode == 0) {
offset = 0;
// Mode 0 has only real part, thus ncomp = 1
ncomp = 1;
}
for (int icomp = 0; icomp < ncomp; ++icomp) {
for (int mode_comp_offset = 0; mode_comp_offset < nr_comp; ++mode_comp_offset) {

Comment on lines 254 to 255
// Offset for a given mode, imode, and component, icomp (0-real, 1-imag)
const int mode_comp_offset = 2*imode + offset*(icomp-1);
Copy link
Member

Choose a reason for hiding this comment

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

If simplify the above loop as suggested, then we can remove these lines.

Suggested change
// Offset for a given mode, imode, and component, icomp (0-real, 1-imag)
const int mode_comp_offset = 2*imode + offset*(icomp-1);
// Offset for a given mode, imode, and component, icomp (0-real, 1-imag)
const int mode_comp_offset = 2*imode + offset*(icomp-1);

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to keep it this way since it accesses the other fields easily
Or rather it has the same "structure" as for cartesian

                e_lab = gamma_boost * ( arr(i, j, k, 0)
                                        + beta_boost * clight * arr(i, j, k, 4) );
                b_lab = gamma_boost * ( arr(i, j, k, 4)
                                        + beta_boost * inv_clight * arr(i, j, k, 0) );

and for RZ we have

                        e_lab = gamma_boost * ( arr(i, j, k, n_rcomps*0 + mode_comp_offset)
                                                + beta_boost * clight * arr(i, j, k, n_rcomps*4+ mode_comp_offset) );
                        b_lab = gamma_boost * ( arr(i, j, k, n_rcomps*4 + mode_comp_offset)
                                                + beta_boost * inv_clight * arr(i, j, k, n_rcomps*0 + mode_comp_offset) );

Copy link
Member Author

@RevathiJambunathan RevathiJambunathan Nov 16, 2022

Choose a reason for hiding this comment

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

But I am open to changing this as well.
Need to think about this one -- I think I can find a way to add in the suggested change in the loop while keeping a similar logic, as long as it does not get too complicated

Copy link
Member Author

Choose a reason for hiding this comment

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

okay this is done :)
Thank you so much @RemiLehe
Your suggestion is more clean and readable! Thanks!

@RemiLehe RemiLehe merged commit f9ff146 into ECP-WarpX:development Nov 17, 2022
dpgrote pushed a commit to dpgrote/WarpX that referenced this pull request Nov 22, 2022
* cell center BTD functors for RZ with openpmd

* add RZ modes to output varnames too

* update varnames once and set map for RZ fields in BTfunctor

* clean commented line

* Apply suggestions from code review

From Axels' review

Co-authored-by: Axel Huebl <[email protected]>

* adding comments, doxygen, and clean-up

* adding mulitple modes to RZ BTD

* fix comment

* fix bug using 2*nrz-1 , instead of nrz

* add comments and clean up

* fix typo

* 1D

* WARPX_DIM_XZ instead of 2D

* Apply suggestions from code review

suggestion from Edoardo

Co-authored-by: Edoardo Zoni <[email protected]>

* remove BTD RZ field warning that does not apply anymore

* BTD rz test for field using laser antenna

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* file starts with analysis

* change analysis

* fix typo

* fix rz input so all snapshots are filled

* remove plt from analysis script

* initialize cell-centered data to 0 so that guard cells are initialized

* Remi's suggestions

Co-authored-by: Remi Lehe <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* AllocInitMultifab to add mf to maps of mfs

* fix path to analysis script

* analysis script executable

* a better and succint for loop

* unused var

* Update Source/Diagnostics/ComputeDiagFunctors/BackTransformFunctor.cpp

Co-authored-by: Remi Lehe <[email protected]>

* fix unused var

* add python path

Co-authored-by: Axel Huebl <[email protected]>
Co-authored-by: Edoardo Zoni <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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
component: diagnostics all types of outputs enhancement New feature or request geometry: RZ axisymmetric 2D and quasi-3D
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants