diff options
author | 2022-10-10 20:36:14 +0200 | |
---|---|---|
committer | 2022-10-10 11:36:14 -0700 | |
commit | e9cc65ffeb0684a97618b67c2164d95ea497226c (patch) | |
tree | ed65f7ac86cc4e8945021dc36a79c8bc246c150d /Source/Particles/MultiParticleContainer.cpp | |
parent | 56e04c1b911f9399662c4ff9ecf6630d686cc220 (diff) | |
download | WarpX-e9cc65ffeb0684a97618b67c2164d95ea497226c.tar.gz WarpX-e9cc65ffeb0684a97618b67c2164d95ea497226c.tar.zst WarpX-e9cc65ffeb0684a97618b67c2164d95ea497226c.zip |
Partial refactoring of the utils directory (#3404)
* initial work to clean WarpX Utils
* remove AMRCore from Ionization tables
* progress
* refactoring of a part of the utils directory
* fix bug
* fixed bug
* fixed bug
* remove debug line accidentally slipped into the code
* remove debug line accidentally slipped into the code
* remove debug line accidentally slipped into the code
* cleaning
* fixed bug
Diffstat (limited to 'Source/Particles/MultiParticleContainer.cpp')
-rw-r--r-- | Source/Particles/MultiParticleContainer.cpp | 152 |
1 files changed, 98 insertions, 54 deletions
diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 662e0b45f..9c7563a3f 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -32,8 +32,10 @@ #include "Particles/RigidInjectedParticleContainer.H" #include "Particles/WarpXParticleContainer.H" #include "SpeciesPhysicalProperties.H" +#include "Utils/Parser/ParserUtils.H" #include "Utils/WarpXAlgorithmSelection.H" #include "Utils/WarpXProfilerWrapper.H" +#include "Utils/WarpXUtil.H" #ifdef AMREX_USE_EB # include "EmbeddedBoundary/ParticleScraper.H" # include "EmbeddedBoundary/ParticleBoundaryProcess.H" @@ -169,13 +171,15 @@ MultiParticleContainer::ReadParameters () // then the values for the external B on particles must // be provided in the input file. if (m_B_ext_particle_s == "constant") - getArrWithParser(pp_particles, "B_external_particle", m_B_external_particle); + utils::parser::getArrWithParser( + pp_particles, "B_external_particle", m_B_external_particle); // if the input string for E_external on particles is "constant" // then the values for the external E on particles must // be provided in the input file. if (m_E_ext_particle_s == "constant") - getArrWithParser(pp_particles, "E_external_particle", m_E_external_particle); + utils::parser::getArrWithParser( + pp_particles, "E_external_particle", m_E_external_particle); // if the input string for B_ext_particle_s is // "parse_b_ext_particle_function" then the mathematical expression @@ -186,20 +190,23 @@ MultiParticleContainer::ReadParameters () std::string str_Bx_ext_particle_function; std::string str_By_ext_particle_function; std::string str_Bz_ext_particle_function; - Store_parserString(pp_particles, "Bx_external_particle_function(x,y,z,t)", - str_Bx_ext_particle_function); - Store_parserString(pp_particles, "By_external_particle_function(x,y,z,t)", - str_By_ext_particle_function); - Store_parserString(pp_particles, "Bz_external_particle_function(x,y,z,t)", - str_Bz_ext_particle_function); + utils::parser::Store_parserString( + pp_particles, "Bx_external_particle_function(x,y,z,t)", + str_Bx_ext_particle_function); + utils::parser::Store_parserString( + pp_particles, "By_external_particle_function(x,y,z,t)", + str_By_ext_particle_function); + utils::parser::Store_parserString( + pp_particles, "Bz_external_particle_function(x,y,z,t)", + str_Bz_ext_particle_function); // Parser for B_external on the particle m_Bx_particle_parser = std::make_unique<amrex::Parser>( - makeParser(str_Bx_ext_particle_function,{"x","y","z","t"})); + utils::parser::makeParser(str_Bx_ext_particle_function,{"x","y","z","t"})); m_By_particle_parser = std::make_unique<amrex::Parser>( - makeParser(str_By_ext_particle_function,{"x","y","z","t"})); + utils::parser::makeParser(str_By_ext_particle_function,{"x","y","z","t"})); m_Bz_particle_parser = std::make_unique<amrex::Parser>( - makeParser(str_Bz_ext_particle_function,{"x","y","z","t"})); + utils::parser::makeParser(str_Bz_ext_particle_function,{"x","y","z","t"})); } @@ -212,19 +219,22 @@ MultiParticleContainer::ReadParameters () std::string str_Ex_ext_particle_function; std::string str_Ey_ext_particle_function; std::string str_Ez_ext_particle_function; - Store_parserString(pp_particles, "Ex_external_particle_function(x,y,z,t)", - str_Ex_ext_particle_function); - Store_parserString(pp_particles, "Ey_external_particle_function(x,y,z,t)", - str_Ey_ext_particle_function); - Store_parserString(pp_particles, "Ez_external_particle_function(x,y,z,t)", - str_Ez_ext_particle_function); + utils::parser::Store_parserString( + pp_particles, "Ex_external_particle_function(x,y,z,t)", + str_Ex_ext_particle_function); + utils::parser::Store_parserString( + pp_particles, "Ey_external_particle_function(x,y,z,t)", + str_Ey_ext_particle_function); + utils::parser::Store_parserString( + pp_particles, "Ez_external_particle_function(x,y,z,t)", + str_Ez_ext_particle_function); // Parser for E_external on the particle m_Ex_particle_parser = std::make_unique<amrex::Parser>( - makeParser(str_Ex_ext_particle_function,{"x","y","z","t"})); + utils::parser::makeParser(str_Ex_ext_particle_function,{"x","y","z","t"})); m_Ey_particle_parser = std::make_unique<amrex::Parser>( - makeParser(str_Ey_ext_particle_function,{"x","y","z","t"})); + utils::parser::makeParser(str_Ey_ext_particle_function,{"x","y","z","t"})); m_Ez_particle_parser = std::make_unique<amrex::Parser>( - makeParser(str_Ez_ext_particle_function,{"x","y","z","t"})); + utils::parser::makeParser(str_Ez_ext_particle_function,{"x","y","z","t"})); } @@ -233,11 +243,17 @@ MultiParticleContainer::ReadParameters () // must be provided in the input file. if (m_E_ext_particle_s == "repeated_plasma_lens" || m_B_ext_particle_s == "repeated_plasma_lens") { - getWithParser(pp_particles, "repeated_plasma_lens_period", m_repeated_plasma_lens_period); + utils::parser::getWithParser( + pp_particles, "repeated_plasma_lens_period", + m_repeated_plasma_lens_period); WARPX_ALWAYS_ASSERT_WITH_MESSAGE(m_repeated_plasma_lens_period > 0._rt, "The period of the repeated plasma lens must be greater than zero"); - getArrWithParser(pp_particles, "repeated_plasma_lens_starts", h_repeated_plasma_lens_starts); - getArrWithParser(pp_particles, "repeated_plasma_lens_lengths", h_repeated_plasma_lens_lengths); + utils::parser::getArrWithParser( + pp_particles, "repeated_plasma_lens_starts", + h_repeated_plasma_lens_starts); + utils::parser::getArrWithParser( + pp_particles, "repeated_plasma_lens_lengths", + h_repeated_plasma_lens_lengths); int n_lenses = static_cast<int>(h_repeated_plasma_lens_starts.size()); d_repeated_plasma_lens_starts.resize(n_lenses); @@ -253,10 +269,14 @@ MultiParticleContainer::ReadParameters () h_repeated_plasma_lens_strengths_B.resize(n_lenses); if (m_E_ext_particle_s == "repeated_plasma_lens") { - getArrWithParser(pp_particles, "repeated_plasma_lens_strengths_E", h_repeated_plasma_lens_strengths_E); + utils::parser::getArrWithParser( + pp_particles, "repeated_plasma_lens_strengths_E", + h_repeated_plasma_lens_strengths_E); } if (m_B_ext_particle_s == "repeated_plasma_lens") { - getArrWithParser(pp_particles, "repeated_plasma_lens_strengths_B", h_repeated_plasma_lens_strengths_B); + utils::parser::getArrWithParser( + pp_particles, "repeated_plasma_lens_strengths_B", + h_repeated_plasma_lens_strengths_B); } d_repeated_plasma_lens_strengths_E.resize(n_lenses); @@ -373,18 +393,26 @@ MultiParticleContainer::ReadParameters () pp_qed_schwinger.get("ele_product_species", m_qed_schwinger_ele_product_name); pp_qed_schwinger.get("pos_product_species", m_qed_schwinger_pos_product_name); #if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) - getWithParser(pp_qed_schwinger, "y_size",m_qed_schwinger_y_size); + utils::parser::getWithParser( + pp_qed_schwinger, "y_size",m_qed_schwinger_y_size); #endif - queryWithParser(pp_qed_schwinger, "threshold_poisson_gaussian", - m_qed_schwinger_threshold_poisson_gaussian); - queryWithParser(pp_qed_schwinger, "xmin", m_qed_schwinger_xmin); - queryWithParser(pp_qed_schwinger, "xmax", m_qed_schwinger_xmax); + utils::parser::queryWithParser( + pp_qed_schwinger, "threshold_poisson_gaussian", + m_qed_schwinger_threshold_poisson_gaussian); + utils::parser::queryWithParser( + pp_qed_schwinger, "xmin", m_qed_schwinger_xmin); + utils::parser::queryWithParser( + pp_qed_schwinger, "xmax", m_qed_schwinger_xmax); #if defined(WARPX_DIM_3D) - queryWithParser(pp_qed_schwinger, "ymin", m_qed_schwinger_ymin); - queryWithParser(pp_qed_schwinger, "ymax", m_qed_schwinger_ymax); + utils::parser::queryWithParser( + pp_qed_schwinger, "ymin", m_qed_schwinger_ymin); + utils::parser::queryWithParser( + pp_qed_schwinger, "ymax", m_qed_schwinger_ymax); #endif - queryWithParser(pp_qed_schwinger, "zmin", m_qed_schwinger_zmin); - queryWithParser(pp_qed_schwinger, "zmax", m_qed_schwinger_zmax); + utils::parser::queryWithParser( + pp_qed_schwinger, "zmin", m_qed_schwinger_zmin); + utils::parser::queryWithParser( + pp_qed_schwinger, "zmax", m_qed_schwinger_zmax); } #endif initialized = true; @@ -1055,7 +1083,8 @@ void MultiParticleContainer::InitQuantumSync () //If specified, use a user-defined energy threshold for photon creation ParticleReal temp; constexpr auto mec2 = PhysConst::c * PhysConst::c * PhysConst::m_e; - if(queryWithParser(pp_qed_qs, "photon_creation_energy_threshold", temp)){ + if(utils::parser::queryWithParser( + pp_qed_qs, "photon_creation_energy_threshold", temp)){ temp *= mec2; m_quantum_sync_photon_creation_energy_threshold = temp; } @@ -1069,7 +1098,7 @@ void MultiParticleContainer::InitQuantumSync () // considered for Synchrotron emission. If a lepton has chi < chi_min, // the optical depth is not evolved and photon generation is ignored amrex::Real qs_minimum_chi_part; - getWithParser(pp_qed_qs, "chi_min", qs_minimum_chi_part); + utils::parser::getWithParser(pp_qed_qs, "chi_min", qs_minimum_chi_part); pp_qed_qs.query("lookup_table_mode", lookup_table_mode); @@ -1127,7 +1156,7 @@ void MultiParticleContainer::InitBreitWheeler () // considered for pair production. If a photon has chi < chi_min, // the optical depth is not evolved and photon generation is ignored amrex::Real bw_minimum_chi_part; - if(!queryWithParser(pp_qed_bw, "chi_min", bw_minimum_chi_part)) + if(!utils::parser::queryWithParser(pp_qed_bw, "chi_min", bw_minimum_chi_part)) amrex::Abort("qed_bw.chi_min should be provided!"); pp_qed_bw.query("lookup_table_mode", lookup_table_mode); @@ -1189,7 +1218,7 @@ MultiParticleContainer::QuantumSyncGenerateTable () // considered for Synchrotron emission. If a lepton has chi < chi_min, // the optical depth is not evolved and photon generation is ignored amrex::Real qs_minimum_chi_part; - getWithParser(pp_qed_qs, "chi_min", qs_minimum_chi_part); + utils::parser::getWithParser(pp_qed_qs, "chi_min", qs_minimum_chi_part); if(ParallelDescriptor::IOProcessor()){ PicsarQuantumSyncCtrl ctrl; @@ -1202,14 +1231,17 @@ MultiParticleContainer::QuantumSyncGenerateTable () //Minimun chi for the table. If a lepton has chi < tab_dndt_chi_min, //chi is considered as if it were equal to tab_dndt_chi_min - getWithParser(pp_qed_qs, "tab_dndt_chi_min", ctrl.dndt_params.chi_part_min); + utils::parser::getWithParser( + pp_qed_qs, "tab_dndt_chi_min", ctrl.dndt_params.chi_part_min); //Maximum chi for the table. If a lepton has chi > tab_dndt_chi_max, //chi is considered as if it were equal to tab_dndt_chi_max - getWithParser(pp_qed_qs, "tab_dndt_chi_max", ctrl.dndt_params.chi_part_max); + utils::parser::getWithParser( + pp_qed_qs, "tab_dndt_chi_max", ctrl.dndt_params.chi_part_max); //How many points should be used for chi in the table - getWithParser(pp_qed_qs, "tab_dndt_how_many", ctrl.dndt_params.chi_part_how_many); + utils::parser::getWithParser( + pp_qed_qs, "tab_dndt_how_many", ctrl.dndt_params.chi_part_how_many); //------ //--- sub-table 2 (2D) @@ -1219,23 +1251,28 @@ MultiParticleContainer::QuantumSyncGenerateTable () //Minimun chi for the table. If a lepton has chi < tab_em_chi_min, //chi is considered as if it were equal to tab_em_chi_min - getWithParser(pp_qed_qs, "tab_em_chi_min", ctrl.phot_em_params.chi_part_min); + utils::parser::getWithParser( + pp_qed_qs, "tab_em_chi_min", ctrl.phot_em_params.chi_part_min); //Maximum chi for the table. If a lepton has chi > tab_em_chi_max, //chi is considered as if it were equal to tab_em_chi_max - getWithParser(pp_qed_qs, "tab_em_chi_max", ctrl.phot_em_params.chi_part_max); + utils::parser::getWithParser( + pp_qed_qs, "tab_em_chi_max", ctrl.phot_em_params.chi_part_max); //How many points should be used for chi in the table - getWithParser(pp_qed_qs, "tab_em_chi_how_many", ctrl.phot_em_params.chi_part_how_many); + utils::parser::getWithParser( + pp_qed_qs, "tab_em_chi_how_many", ctrl.phot_em_params.chi_part_how_many); //The other axis of the table is the ratio between the quantum //parameter of the emitted photon and the quantum parameter of the //lepton. This parameter is the minimum ratio to consider for the table. - getWithParser(pp_qed_qs, "tab_em_frac_min", ctrl.phot_em_params.frac_min); + utils::parser::getWithParser( + pp_qed_qs, "tab_em_frac_min", ctrl.phot_em_params.frac_min); //This parameter is the number of different points to consider for the second //axis - getWithParser(pp_qed_qs, "tab_em_frac_how_many", ctrl.phot_em_params.frac_how_many); + utils::parser::getWithParser( + pp_qed_qs, "tab_em_frac_how_many", ctrl.phot_em_params.frac_how_many); //==================== m_shr_p_qs_engine->compute_lookup_tables(ctrl, qs_minimum_chi_part); @@ -1270,7 +1307,7 @@ MultiParticleContainer::BreitWheelerGenerateTable () // considered for pair production. If a photon has chi < chi_min, // the optical depth is not evolved and photon generation is ignored amrex::Real bw_minimum_chi_part; - getWithParser(pp_qed_bw, "chi_min", bw_minimum_chi_part); + utils::parser::getWithParser(pp_qed_bw, "chi_min", bw_minimum_chi_part); if(ParallelDescriptor::IOProcessor()){ PicsarBreitWheelerCtrl ctrl; @@ -1283,14 +1320,17 @@ MultiParticleContainer::BreitWheelerGenerateTable () //Minimun chi for the table. If a photon has chi < tab_dndt_chi_min, //an analytical approximation is used. - getWithParser(pp_qed_bw, "tab_dndt_chi_min", ctrl.dndt_params.chi_phot_min); + utils::parser::getWithParser( + pp_qed_bw, "tab_dndt_chi_min", ctrl.dndt_params.chi_phot_min); //Maximum chi for the table. If a photon has chi > tab_dndt_chi_max, //an analytical approximation is used. - getWithParser(pp_qed_bw, "tab_dndt_chi_max", ctrl.dndt_params.chi_phot_max); + utils::parser::getWithParser( + pp_qed_bw, "tab_dndt_chi_max", ctrl.dndt_params.chi_phot_max); //How many points should be used for chi in the table - getWithParser(pp_qed_bw, "tab_dndt_how_many", ctrl.dndt_params.chi_phot_how_many); + utils::parser::getWithParser( + pp_qed_bw, "tab_dndt_how_many", ctrl.dndt_params.chi_phot_how_many); //------ //--- sub-table 2 (2D) @@ -1300,19 +1340,23 @@ MultiParticleContainer::BreitWheelerGenerateTable () //Minimun chi for the table. If a photon has chi < tab_pair_chi_min //chi is considered as it were equal to chi_phot_tpair_min - getWithParser(pp_qed_bw, "tab_pair_chi_min", ctrl.pair_prod_params.chi_phot_min); + utils::parser::getWithParser( + pp_qed_bw, "tab_pair_chi_min", ctrl.pair_prod_params.chi_phot_min); //Maximum chi for the table. If a photon has chi > tab_pair_chi_max //chi is considered as it were equal to chi_phot_tpair_max - getWithParser(pp_qed_bw, "tab_pair_chi_max", ctrl.pair_prod_params.chi_phot_max); + utils::parser::getWithParser( + pp_qed_bw, "tab_pair_chi_max", ctrl.pair_prod_params.chi_phot_max); //How many points should be used for chi in the table - getWithParser(pp_qed_bw, "tab_pair_chi_how_many", ctrl.pair_prod_params.chi_phot_how_many); + utils::parser::getWithParser( + pp_qed_bw, "tab_pair_chi_how_many", ctrl.pair_prod_params.chi_phot_how_many); //The other axis of the table is the fraction of the initial energy //'taken away' by the most energetic particle of the pair. //This parameter is the number of different fractions to consider - getWithParser(pp_qed_bw, "tab_pair_frac_how_many", ctrl.pair_prod_params.frac_how_many); + utils::parser::getWithParser( + pp_qed_bw, "tab_pair_frac_how_many", ctrl.pair_prod_params.frac_how_many); //==================== m_shr_p_bw_engine->compute_lookup_tables(ctrl, bw_minimum_chi_part); |