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

always use PhysConstSI in parser #978

Merged
merged 3 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions docs/source/run/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ in the input script with ``my_constants``.

Thereby, the following constants are predefined:

============ =================== ================= ====================
**variable** **name** **SI value** **normalized value**
q_e elementary charge 1.602176634e-19 1
m_e electron mass 9.1093837015e-31 1
m_p proton mass 1.67262192369e-27 1836.15267343
epsilon0 vacuum permittivity 8.8541878128e-12 1
mu0 vacuum permeability 1.25663706212e-06 1
clight speed of light 299'792'458. 1
============ =================== ================= ====================
============ ========================= =====================
**variable** **name** **Value**
q_e elementary charge 1.602176634e-19
m_e electron mass 9.1093837015e-31
m_p proton mass 1.67262192369e-27
epsilon0 vacuum permittivity 8.8541878128e-12
mu0 vacuum permeability 1.25663706212e-06
clight speed of light 299'792'458.
hbar reduced Planck constant 1.054571817e-34
r_e classical electron radius 2.817940326204929e-15
============ ========================= =====================

For a list of supported functions see the
`AMReX documentation <https://amrex-codes.github.io/amrex/docs_html/Basics.html#parser>`__.
Expand Down
2 changes: 1 addition & 1 deletion src/Hipace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Hipace_early_init::Hipace_early_init (Hipace* instance)
} else {
m_phys_const = make_constants_SI();
}
Parser::addConstantsToParser(m_phys_const);
Parser::addConstantsToParser();
Parser::replaceAmrexParamsWithParser();

queryWithParser(pph, "depos_order_xy", m_depos_order_xy);
Expand Down
21 changes: 10 additions & 11 deletions src/utils/Parser.H
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,17 @@ namespace Parser
// {"true", 1},
// {"false", 0}

/** \brief add Physical constants to Parser constants
*
* \param[in] phys_const the constants to add
*/
/** \brief add Physical constants to Parser constants */
inline void
addConstantsToParser (const PhysConst& phys_const) {
hipace_constants.insert({"clight", phys_const.c});
hipace_constants.insert({"epsilon0", phys_const.ep0});
hipace_constants.insert({"mu0", phys_const.mu0});
hipace_constants.insert({"q_e", phys_const.q_e});
hipace_constants.insert({"m_e", phys_const.m_e});
hipace_constants.insert({"m_p", phys_const.m_p});
addConstantsToParser () {
hipace_constants.insert({"clight", PhysConstSI::c });
hipace_constants.insert({"epsilon0", PhysConstSI::ep0 });
hipace_constants.insert({"mu0", PhysConstSI::mu0 });
hipace_constants.insert({"q_e", PhysConstSI::q_e });
hipace_constants.insert({"m_e", PhysConstSI::m_e });
hipace_constants.insert({"m_p", PhysConstSI::m_p });
hipace_constants.insert({"hbar", PhysConstSI::hbar});
hipace_constants.insert({"r_e", PhysConstSI::r_e});
}

/** \brief replace ParmParse input with a Parsed version
Expand Down