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

Add QED lookup tables generator/reader in /Tools #3137

Merged
merged 64 commits into from
Mar 20, 2024

Conversation

lucafedeli88
Copy link
Member

@lucafedeli88 lucafedeli88 commented May 25, 2022

This PR adds new tools to generate and/or read into human-readable format the QED lookup tables (they can be compiled with cmake by enabling the flag DWarpX_QED_TOOLS. The PR also adds a documentation page to succinctly describe how to use these tools. Finally, it adds a new CI test to check that these tools generate lookup tables identical to those generated by WarpX. Specifically, the CI test does the following:

        export OMP_NUM_THREADS=2
        ./build_qed/bin/qed_tools/qed_table_generator \
          --table BW --mode DP --dndt_chi_min 0.01 \
          --dndt_chi_max 100 --dndt_how_many 64 \
          --pair_chi_min 0.01 --pair_chi_max 100 \
          --pair_chi_how_many 64 --pair_frac_how_many 64 \
          -o bw_table_tool
        ./build_qed/bin/qed_tools/qed_table_generator \
          --table QS --mode DP --dndt_chi_min 0.001 \
          --dndt_chi_max 100 --dndt_how_many 64 \
          --em_chi_min 0.001 --em_chi_max 100 \
          --em_chi_how_many 64 --em_frac_how_many 64 \
          --em_frac_min 1e-12 -o qs_table_tool
        ./build_qed/bin/warpx \
          ./Examples/Modules/qed/quantum_synchrotron/inputs_3d \
          qed_bw.lookup_table_mode = "generate" \
          qed_bw.tab_dndt_chi_min = 0.01 \
          qed_bw.tab_dndt_chi_max = 100.0 \
          qed_bw.tab_dndt_how_many = 64 \
          qed_bw.tab_pair_chi_min = 0.01 \
          qed_bw.tab_pair_chi_max = 100.0 \
          qed_bw.tab_pair_chi_how_many = 64 \
          qed_bw.tab_pair_frac_how_many = 64 \
          qed_bw.save_table_in = "bw_table" \
          qed_qs.lookup_table_mode = "generate" \
          qed_qs.tab_dndt_chi_min = 0.001 \
          qed_qs.tab_dndt_chi_max = 100.0 \
          qed_qs.tab_dndt_how_many = 64 \
          qed_qs.tab_em_chi_min = 0.001 \
          qed_qs.tab_em_frac_min = 1.0e-12 \
          qed_qs.tab_em_chi_max = 100.0 \
          qed_qs.tab_em_chi_how_many = 64 \
          qed_qs.tab_em_frac_how_many = 64 \
          qed_qs.save_table_in = "qs_table"
        ./build_qed/bin/qed_tools/qed_table_reader -i qs_table --table QS --mode DP -o qs_table
        ./build_qed/bin/qed_tools/qed_table_reader -i qs_table_tool --table QS --mode DP -o qs_table_tool
        ./build_qed/bin/qed_tools/qed_table_reader -i bw_table --table BW --mode DP -o bw_table
        ./build_qed/bin/qed_tools/qed_table_reader -i bw_table_tool --table BW --mode DP -o bw_table_tool
        diff bw_table_dndt bw_table_tool_dndt
        diff bw_table_pair bw_table_tool_pair
        diff qs_table_phot_em qs_table_tool_phot_em
        diff qs_table_dndt qs_table_tool_dndt
        ./build_qed/bin/warpx \
          ./Examples/Modules/qed/quantum_synchrotron/inputs_3d \
          qed_bw.lookup_table_mode = "load" \
          qed_bw.load_table_from = "bw_table_tool" \
          qed_qs.lookup_table_mode = "load" \
          qed_qs.load_table_from = "qs_table_tool"

Note that the lookup tables cannot be compared in binary format because the serialization routines also serialize the padding bytes, whose value is in general unspecified. These results in minor (insignificant) differences between the binary table generated by the tool and the binary table generated by WarpX

@lucafedeli88 lucafedeli88 added enhancement New feature or request component: QED QED module component: post-processing post-processing tools labels May 25, 2022
@ax3l ax3l self-assigned this May 25, 2022
@lucafedeli88 lucafedeli88 changed the title [WIP] Add QED lookup tables generator/reader in /Tools Add QED lookup tables generator/reader in /Tools Jun 14, 2022
.github/workflows/ubuntu.yml Outdated Show resolved Hide resolved
.github/workflows/ubuntu.yml Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
@lucafedeli88 lucafedeli88 requested a review from ax3l June 20, 2022 10:46
Copy link
Member

@NeilZaim NeilZaim left a comment

Choose a reason for hiding this comment

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

I've only reviewed to C++ and sh parts and they look good to me (I'll let @ax3l review in more details the github workflows and cmake parts).

Only significant comment is that it would be good to provide somewhere recommended table parameters for users (this can be done in a follow-up PR though).

.github/workflows/scripts/checkQEDTableGenerator.sh Outdated Show resolved Hide resolved
Comment on lines +28 to +39
--dndt_chi_min [DOUBLE] minimum chi parameter for the dNdt table
--dndt_chi_max [DOUBLE] maximum chi parameter for the dNdt table
--dndt_how_many [INTEGR] number of points in the dNdt table
--pair_chi_min [DOUBLE] minimum chi for the pair production table (BW only)
--pair_chi_max [DOUBLE] maximum chi for the pair production table (BW only)
--pair_chi_how_many [INTEGR] number of chi points in the pair production table (BW only)
--pair_frac_how_many [INTEGR] number of frac points in the pair production table (BW only)
--em_chi_min [DOUBLE] minimum chi for the photon emission table (QS only)
--em_chi_max [DOUBLE] maximum chi for the photon emission production table (QS only)
--em_frac_min [DOUBLE] minimum frac for the photon emission production table (QS only)
--em_chi_how_many [INTEGR] number of chi points in the photon emission table (QS only)
--em_frac_how_many [INTEGR] number of frac points in the photon emission table (QS only)
Copy link
Member

Choose a reason for hiding this comment

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

It could be useful for users to give recommended table parameters in this file (there are a lot of parameters and it's not trivial to choose them).

Copy link
Member Author

Choose a reason for hiding this comment

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

you are right... we need to properly document everything related to the QED module... I promise that I will work on that starting from January 2023!

Tools/QedTablesUtils/Source/ArgParser/QedTablesArgParser.H Outdated Show resolved Hide resolved
@lucafedeli88
Copy link
Member Author

@ax3l , what do you think about the cmake and the github workflow parts of this PR?

@@ -2724,6 +2724,8 @@ Lookup tables store pre-computed values for functions used by the QED modules.

* ``qed_bw.save_table_in`` (`string`): where to save the lookup table

Alternatively, the lookup table can be generated using a standalone tool (see workflows section).
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a link to the specific workflow sub-section?

Copy link
Member Author

Choose a reason for hiding this comment

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

should be ok now

@aeriforme
Copy link
Member

This is very convenient, thank you for implementing this tool, @lucafedeli88!
I tried it and it works fine. It's quite fast too.
Just to be sure, I compared the tables obtained with this new tool
with those obtained with the tool integrated in WarpX
(by converting them to human readable format)
and they are the same (at least in the case I chose).

As @NeilZaim mentioned, it would be useful to provide a guide for the choice of the parameters.
It would also be useful to specify the parameters used in the builtin tables.

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

CodeQL found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

Comment on lines 4 to 7
set(arg_parser_cpp "Source/ArgParser/QedTablesArgParser.cpp")
set(arg_parser_h "Source/ArgParser/QedTablesArgParser.H")

add_library( QedToolsArgParser ${arg_parser_cpp} ${arg_parser_h} )
Copy link
Member

@ax3l ax3l Oct 16, 2023

Choose a reason for hiding this comment

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

Is this library used anywhere else?

If you like, generalize it and make it part of the ABLASTR utils? (as a follow-up PR?)

cmake/dependencies/PICSAR.cmake Outdated Show resolved Hide resolved
@ax3l ax3l enabled auto-merge (squash) October 16, 2023 22:38
@lucafedeli88
Copy link
Member Author

@ax3l , it seems to me that when WarpX is compiled as a library the QED tools are not built.
A Tools/ folder is generated in the build directory, but no executables are generated in bin. If I run make inside this Tools folder the qed tools executables are correctly generated in the bin folder. Unfortunately I don't know how to modify the cmake file to fix this...

@ax3l ax3l merged commit 29a0a56 into ECP-WarpX:development Mar 20, 2024
45 checks passed
@@ -12,6 +12,7 @@ This section collects typical user workflows and best practices for WarpX.
workflows/domain_decomposition
workflows/plot_distribution_mapping
workflows/debugging
workflows/generate_lookup_tables_with_tools.rst
Copy link
Member

@ax3l ax3l Mar 26, 2024

Choose a reason for hiding this comment

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

.rst ending not needed :)
#4804

ax3l added a commit to ax3l/WarpX that referenced this pull request Mar 26, 2024
lucafedeli88 pushed a commit that referenced this pull request Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: post-processing post-processing tools component: QED QED module enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants