-
Notifications
You must be signed in to change notification settings - Fork 196
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
Add 3D tests for proton boron fusion #2450
Conversation
This pull request introduces 1 alert when merging f1027f9 into fcf8872 - view on LGTM.com new alerts:
|
f1027f9
to
dd64205
Compare
This pull request introduces 1 alert when merging dd64205 into 02096d0 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 1f00d4c into 02096d0 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging edf52f4 into 02096d0 - view on LGTM.com new alerts:
|
def add_species_to_dict(yt_ad, data_dict, species_name, prefix, suffix): | ||
try: | ||
## If species exist, we add its data to the dictionary | ||
add_existing_species_to_dict(yt_ad, data_dict, species_name, prefix, suffix) | ||
except: | ||
## If species does not exist, we avoid python crash and add empty arrays to the | ||
## dictionnary. Currently, this happens for the boron species in test number 4, which | ||
## entirely fuses into alphas. | ||
add_empty_species_to_dict(data_dict, species_name, prefix, suffix) |
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.
I see that the lgtm-bot raised an alert because I've added a try
-except
block. Is this not a good idea in an automated test? If so, I'll have to find a way to check if a species still exists in yt
before reading the data.
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 alert may be because it is a bare except:
. It would be better to specify the error you are checking against. Perhaps except KeyError:
?
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.
I think you are right, I've added the type of the exception and there was no alert raised.
Thanks for the hint!
87192c2
to
a9d98bc
Compare
@NeilZaim ready for rebase :) |
a9d98bc
to
eeb765e
Compare
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.
This looks pretty solid to me and is well documented. Thank you! ✨
## calculation is done by noting that the maximum (minimum) energy corresponds to an alpha | ||
## emitted exactly in the (opposite) direction of the proton in the lab frame. This | ||
## calculation involves solving a polynomial equation of order 2 in p_alpha1. | ||
max_p_alpha1 = (m_a/m_be*np.sqrt(p_proton_sq) + \ |
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 line continuation \
is not needed if the RHS expression is currently in an open bracket (
, as in the cases 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.
(optional change, just a note)
|
||
def main(): | ||
filename_end = sys.argv[1] | ||
filename_start = filename_end[:-4] + '0000' |
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.
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.
actually still works, as it only replaces the last 4 digits here to get the first step
Examples/Modules/nuclear_fusion/analysis_proton_boron_fusion.py
Outdated
Show resolved
Hide resolved
Current analysis python output in CI:
|
Co-authored-by: Axel Huebl <[email protected]>
for more information, see https://pre-commit.ci
This looks good. |
Co-authored-by: Remi Lehe <[email protected]>
Co-authored-by: Remi Lehe <[email protected]>
## Returns cross section in b using the fits described in W.M. Nevins and R. Swain, | ||
## Nuclear Fusion, 40, 865 (2000) | ||
E_MeV = E/1.e3 | ||
return astrophysical_factor(E)/E_MeV * np.exp(-np.sqrt(E_Gamow_MeV / E_MeV)) |
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.
I see this in CI now:
./analysis_proton_boron_fusion.py:306: RuntimeWarning: divide by zero encountered in true_divide
return astrophysical_factor(E)/E_MeV * np.exp(-np.sqrt(E_Gamow_MeV / E_MeV))
./analysis_proton_boron_fusion.py:306: RuntimeWarning: invalid value encountered in multiply
return astrophysical_factor(E)/E_MeV * np.exp(-np.sqrt(E_Gamow_MeV / E_MeV))
# 5 sigma test that has an intrinsic probability to fail of 1 over ~2 millions | ||
assert(np.all(is_close(alpha_weight_theory, alpha_weight_simulation, | ||
rtol = 5.*relative_std_alpha_weight))) |
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.
This one currently fails:
Traceback (most recent call last):
File "./analysis_proton_boron_fusion.py", line 703, in <module>
main()
File "./analysis_proton_boron_fusion.py", line 693, in main
eval("specific_check"+str(i)+"(data)")
File "<string>", line 1, in <module>
File "./analysis_proton_boron_fusion.py", line 632, in specific_check1
check_alpha_yield(data, expected_fusion_number, E_com, proton_density = 1.,
File "./analysis_proton_boron_fusion.py", line 403, in check_alpha_yield
assert(np.all(is_close(alpha_weight_theory, alpha_weight_simulation,
ping @NeilZaim as bespoken: did you fix a couple of div by zeros here already or can you push such a change please? :) |
Hi @ax3l and @RemiLehe. Thanks for the reviews and sorry for the long delay in responding. Point by point response:
The function
Yes that's a very good point, a lot of the tolerances have been set empirically so we may definitely expect sporadic failures (even if we fix the seed a change in another part of the code that uses random number generation may still break the test). I've run a series of tests (~25) locally with various seeds and updated the tolerances accordingly. Hopefully that should make this CI test more robust in the future. |
* Apply shift in BTD for zmax different than 0 (ECP-WarpX#3091) * Include shift in t_lab when `zmax` is different than 0 * Revert "Include shift in t_lab when `zmax` is different than 0" This reverts commit 5f786f2. * Apply shift in BTD for zmax > 0 * AMReX: Weekly Update (ECP-WarpX#3095) * Fix miscellaneous issues found with clang tidy (ECP-WarpX#3083) * fix miscellaneous issues found with clang tidy * fix miscellaneous issues found with clang tidy * moved default constructors and destructors to header * fix issue * Use default again * Add a python script to generate timestep duration plots (ECP-WarpX#3036) * add script to generate timestep duration plots * disable transparent background * fix bugs * fix bug in doc * Update plot_timestep_duration.rst * add permissions * using argparse * using if __name__ == __main__: * add page in workflows * Update Docs/source/usage/workflows.rst * added missing file * Formatting * Apply shift for zmax>0 in old BTD (ECP-WarpX#3094) * Apply shift for zmax>0 in old BTD * BTD: also shift t_slice_lab * Use uniform error message formatting for all the amrex::Abort() calls in WarpX.cpp (ECP-WarpX#2952) * use WARPX_ALWAYS_ASSERT_WITH_MESSAGE instead of Abort() * fix bug * Update Source/WarpX.cpp * fixed bug * fixed bug * Update Source/WarpX.cpp * Update Source/WarpX.cpp Co-authored-by: Axel Huebl <[email protected]> * Use queryWithParser to Parse v_particle_pml (ECP-WarpX#3096) Use queryWithParser, instead of query, to parse v_particle_pml, in order to support functions like sin, cos, sqrt, etc. * Fix Wrong Abort Message for PSATD w/ Time Averaging (ECP-WarpX#3098) * Doc: Improve Doxygen Links (ECP-WarpX#3099) * Doc: Improve Doxygen Links - download also openPMD-api tag files & link them - improve developer page: clearer links * Update: .gitignore * Fix Mirrors for RZ (NullifyMF) (ECP-WarpX#3101) * Fix Breaking Pip 22.1 Logic (ECP-WarpX#3106) * CI: Fix Windows Pip's `--no-build-isolation` says we have to have build-deps pre-installed. But Pip does offer no option to install those from `pyproject.toml`. * Pip 22.1: in-tree-build default And dropped the old option with a fatal error... classic. * Pip no-build isolation: pre-install build tools not installed in non-isolated builds - we want isolated builds, because they have a derministic path that we can cache with ccache * fix bug (ECP-WarpX#3110) * Fix Laser Injection in RZ (ECP-WarpX#3104) * Add STL files support in pywarpx (ECP-WarpX#3089) * Added STL files support in pywarpx * Add new EB bucket * Added name to file headers * Fixing year in file headers * Checking that stl file and imp function are not both specified * Renamed EB bucket to EB2 * Adding STL documentation * Implement suggestions from code review Co-authored-by: lgiacome <[email protected]> * Stricter Tolerance for 3D Langmuir Tests (ECP-WarpX#3097) * CI: HIP with https (ECP-WarpX#3111) Small update in HIP docs: now supports HTTPS: https://rocmdocs.amd.com/en/latest/Installation_Guide/Installation-Guide.html#ubuntu * Add Headers to Input File Written by PICMI (ECP-WarpX#3093) * Add Headers to Input File Written by PICMI * Commit Suggestion by @dpgrote * Add Comment * Add Empty Line * Slightly Better Readable with a newline * AMReX/PICSAR: Weekly Update (ECP-WarpX#3112) * AMReX: Weekly Update * PICSAR: Weekly Update * [pre-commit.ci] pre-commit autoupdate (ECP-WarpX#3113) updates: - [github.com/Lucas-C/pre-commit-hooks: v1.1.13 → v1.1.14](Lucas-C/pre-commit-hooks@v1.1.13...v1.1.14) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Use uniform error message formatting in more source files (ECP-WarpX#2964) * use WARPX_ALWAYS_ASSERT_WITH_MESSAGE instead of Abort() * fix bug * Update Source/WarpX.cpp Co-authored-by: Axel Huebl <[email protected]> * use more uniform text formatting * fixed bug * fixed bug * using Utils::TextMsg in more files * fixed bug * use Utils::TextMsg in more files * fixed bug * use Utils::TextMsg in more files * fixed last merge conflict * fixed bug * fix indentation Co-authored-by: Axel Huebl <[email protected]> * Avoid resizing ParticleBoundaryBuffer allocation to total particle count (ECP-WarpX#3068) * Avoid resizing ParticleBoundaryBuffer allocation to total particle count * Switch atomic increments over to reductions * Lassen (LLNL): ADIOS2, BLAS++ & LAPACK++ (ECP-WarpX#3071) * Lassen (LLNL): ADIOS2, BLAS++ & LAPACK++ Document how to install ADIOS2 (for openPMD `.bp`) and BLAS++/LAPACK++ (for PSATD in RZ) on Lassen at LLNL. * Update: ADIOS2~SST, BLAS++/LAPACK++ w/ ESSL * Add workaround for Libfabric bug on Crusher to job script. (ECP-WarpX#3114) * Add workaround for Libfabric bug on Crusher to job script. * add known issues section for Crusher * ABLASTR: localIDtoGlobal (ECP-WarpX#3115) * ABLASTR: localIDtoGlobal Move the control of `localIDtoGlobal` to ABLASTR for particle IDs. * WarpX: Use ABLASTR now * Clarify error messages when parsing diagnostics input (ECP-WarpX#3122) * Add `do_average` option to the particle fields diagnostic (ECP-WarpX#3067) * Added do_average option to the particle fields diagnostic * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Updated CI benchmark files * Updated CI benchmark files * Fix ParticleReductionFunctor comment * Changed maps to vector for code simplification * Change do_average to bool Co-authored-by: Hannah Klion <[email protected]> Co-authored-by: Edoardo Zoni <[email protected]> * Fix from the merge Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Hannah Klion <[email protected]> Co-authored-by: Edoardo Zoni <[email protected]> * fix unnecessary double promotions (ECP-WarpX#3120) * use fwd declaration for WarpXFaceInfoBox (ECP-WarpX#3125) * remove unused enum (ECP-WarpX#3124) * AMReX/PICSAR: Weekly Update (ECP-WarpX#3126) * AMReX: Weekly Update * PICSAR: Weekly Update * [pre-commit.ci] pre-commit autoupdate (ECP-WarpX#3128) updates: - [github.com/Lucas-C/pre-commit-hooks: v1.1.14 → v1.2.0](Lucas-C/pre-commit-hooks@v1.1.14...v1.2.0) - [github.com/hadialqattan/pycln: v1.3.2 → v1.3.3](hadialqattan/pycln@v1.3.2...v1.3.3) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Add new class `NamedComponentParticleContainer` (ECP-WarpX#3100) * Add new class `NamedComponentParticleContainer` * Update docstrings * Fix compilation * Address review comments * Update Doxygen Co-authored-by: Axel Huebl <[email protected]> * Fold Python tests into their corresponding base configurations, to better exploit ccache (ECP-WarpX#3107) * Fold Python tests into their corresponding base configurations, to better exploit ccache * Align 1D Python tests with rest of 1D tests * Remove archaic test exclusions * Reintroduce exclusion of Python_Langmuir test, since it currently fails * Docs: New Perlmutter Default Env, Microarch (ECP-WarpX#3127) * Docs: New Perlmutter Default Env The default environment on Perlmutter is now the one we already used, `PrgEnv-gnu`. Thus, we don't need to switch anymore. * Perlmutter: Build Microarch Tuned for Zen3, which is used on Login and Compute nodes alike: https://docs.nersc.gov/systems/perlmutter/system_details/ * Keep PrgEnv-gnu ... in case it changes again * Comment microarch flags * CMake Pip: Unique Custom Targets (ECP-WarpX#3116) Add a prefix to custom targets so we do not collide if used as a CMake subproject, e.g., in ARTEMIS. * Simplify the function computePhi (ECP-WarpX#3026) * Simplify the function computePhi * Allow to compile RZ without EB * Allow to compile RZ without EB * Deactivate semi-coarsening when both EB and RZ are used * Update Source/FieldSolver/ElectrostaticSolver.cpp Co-authored-by: Edoardo Zoni <[email protected]> Co-authored-by: Axel Huebl <[email protected]> * Specify particle precision (ECP-WarpX#3065) * Add precision to printed PIC parameters * Added WarpX_PARTICLE_PRECISION as a build option * Update types to ParticleReal * Updated libwarpx to inject particles with correct ParticleReal type * Fix syntax error * Add logic to avoid duplicate definitions * Use correct ParticleReal type in add_particles * Cleaned up code, addressed comments * Update Python/pywarpx/_libwarpx.py Co-authored-by: Peter Scherpelz <[email protected]> * Removed redundant functions, fixed some typing * Modified template functions * Cast d_w to Real * Fixed failing tests * Cast types to be consistent * removed in-tree-build from pip command * Added GPU device macros to PDim3 methods * rerun tests * Removed unecessary casting, update calls to use PDim3 instead of XDim3 * Refactored comments * Added mcc fields double precision, particles single precision test * Updated casting and formatting * Removed cast, updated declaration Co-authored-by: Peter Scherpelz <[email protected]> Co-authored-by: Peter Scherpelz <[email protected]> * Test Filter: Include Python Langmuir (ECP-WarpX#3129) * Test Filter: Include Python Langmuir * Reset Benchmarks (Python Langmuir) Co-authored-by: Tools <[email protected]> * Reactivate Multi-J RZ PSATD Checksums (ECP-WarpX#2459) * Try to reactivate Multi-J RZ PSATD checksums * Reduce size of test and add debug prints * No MPI in test * Revert "Reduce size of test and add debug prints" This reverts commit c865671. * Revert "No MPI in test" This reverts commit 1a0a682. * Remove close to zero values from field outputs * Update benchmarks * PML.cpp: missing util include (ECP-WarpX#3138) fix a missing include for `PML.cpp` * Fix: Field Probe no-MPI Gather (ECP-WarpX#3134) In AMReX, Gather without MPI was implemented as a no-OP. This applies a work-around so we can patch already released WarpX versions. * SpectralFieldDataRZ: Missing Utils Include (ECP-WarpX#3140) * Fix: Install ABLASTR (ECP-WarpX#3141) Since ABLASTR is a proper library now, we need to install it as well. * Write Inputs to `warpx_used_inputs` (ECP-WarpX#3132) Write a general file `warpx_used_inputs` that contains all inputs of a simulation. This is needed, since we add & overwrite the inputs parameters in the inputs file with command-line options regularly. Writing the actually used inputs increases reproducibility of such workflows, especially in unsupervised scripted runs/optimizations. * Docs: Improve `collision_name>.species` (ECP-WarpX#3143) ... for `background_stopping` we also just use one species. * Remove Extraneous `WARPX_DIM_RZ` in Gaussian Laser Init (ECP-WarpX#3144) * move serialization to ablastr (ECP-WarpX#3145) * Use Utils::TextMsg::Err and WARPX_ALWAYS_ASSERT_WITH_MESSAGE in more files (ECP-WarpX#3117) * use formatted error messages * fixed bug * fixed bug * fixed bugs * fixed bug * Move MsgLogger to ablastr (ECP-WarpX#3148) * move Msg Logger to ablastr * fixed bug * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixed bug Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * AMReX: Weekly Update (ECP-WarpX#3147) * Docs: Science Highlights (ECP-WarpX#3139) * Docs: Science Highlights Document science papers of ours and users that use WarpX. * Add: More LWFA Preprints 🚀 * Use Ordered (Numbered) Lists * Add 3D tests for proton boron fusion (ECP-WarpX#2450) * Add 3D tests for proton boron fusion * Add execute permission to analysis script * Fix Checksum path * Increase tolerance for energy check * Update benchmarks * Specify type of exception in try expect block * Apply suggestions from code review Co-authored-by: Axel Huebl <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add review suggestions Co-authored-by: Remi Lehe <[email protected]> * Safe Runtime: <species>.do_not_deposit = 1 Co-authored-by: Remi Lehe <[email protected]> * Remove division by zero warning in python analysis script * Update cross-section in the E > 3.5 MeV range * Increase some tolerances * Update benchmark Co-authored-by: Remi Lehe <[email protected]> Co-authored-by: Axel Huebl <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Revert ""Gradient descent" convergence to steady-state (#176)" This reverts commit e31338f. * update changelog and version * Gradient Descent (#181) * Added ArbitraryDistributionVolumeEmitter * Updated particle weight calculation * renamed thermionic_emission test directory to emission * arbitrary seed from uniform distribution * Bug fixes and changes to test * add test for arbitrary seeding * Changed position sampling, added test * Removed unused imports and code * revert traceback printout * Added comments for binning particle positions * increased rtol for test * Allow input of any 2d array, add interpolation of 2d array onto current simulation grid * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Updated changelog * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Updated changelog * update version * created steady_state_descent.py file * Added coarsening algorithm * Added ability to read numpy data and coarsen grid * Added regression function calculation * Solve system of equations rather than curve fit * Use skimage block_reduce * Hard coded inverse exponential solve * take mean if exponential equation can't be solved * Added special cases to use linear regression * Update docstring * Added command line arguments * Modified linear regression logic and added main function * Added entry point * Change output file name * Change output file name * Fixed interpolate grid * updated arbitrary distribution emitter test * Fix interpolation logic * Changed to take in exact prediction timestep rather than a multiple * Added ability to specify save directory * Updated docstrings, removed unneeded files * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added gradient descent test, refactored code * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Changed test parameters * Increase rtol of arbitrary seed test by 0.01 * Update mewarpx/mewarpx/utils_store/plasma_density_oracle.py Co-authored-by: Roelof Groenewald <[email protected]> * Update changelog * Update version * Add controller for plasma density oracle * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * WIP oracle control * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Allow oracle control bins to be overridden * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added command line arguments * Fixed bugs, added info logging * added ability to modify run_script * removed unnecessary code * Cleaned up code * Refactored code to be clearer * Update docstrings * Added test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added documentation about oracle_control * Updated changelog * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fixed TOTAL_TIME calculation * update wheel in docker build * change numpy to oldest-supported-numpy for docker * Updated formatting and documentation Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Remi Lehe <[email protected]> Co-authored-by: Axel Huebl <[email protected]> Co-authored-by: Luca Fedeli <[email protected]> Co-authored-by: amadou38 <[email protected]> Co-authored-by: Edoardo Zoni <[email protected]> Co-authored-by: David Grote <[email protected]> Co-authored-by: Lorenzo Giacomel <[email protected]> Co-authored-by: lgiacome <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Phil Miller <[email protected]> Co-authored-by: Andrew Myers <[email protected]> Co-authored-by: Hannah Klion <[email protected]> Co-authored-by: Phil Miller <[email protected]> Co-authored-by: Peter Scherpelz <[email protected]> Co-authored-by: Peter Scherpelz <[email protected]> Co-authored-by: Tools <[email protected]> Co-authored-by: Neïl Zaim <[email protected]> Co-authored-by: Ryan Sandberg <[email protected]>
This PR is based on #2330, which is based on #2315, so it should probably be reviewed once these PRs have been merged.
This adds a 3D automated test for proton boron fusion (2D incoming in a follow-up PR). I tried to do all the checks I could think of, but that ended up being quite long, I'm sorry about that (at least, I'm now quite confident that the module works as expected 😄). If that is too hard to review, I can make the effort to split it into somewhat smaller PRs.
Since this PR is very long, this is the order that I'd recommend reading it:
main
function and reading the python functions as they are used.For now I'm putting the [WIP] tag because I haven't tested this on GPU yet.Edit: I've tested on GPU and it looks like the tests are working, so I'm removing the [WIP]