From f97eb3249d9e0491ea1f8e24930a8a591a825fab Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Wed, 13 Nov 2019 19:21:10 +0100 Subject: bugfixing & update examples --- Source/Particles/MultiParticleContainer.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 55768c6fc..6f2d025a8 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -682,11 +682,14 @@ void MultiParticleContainer::InitBreitWheeler () std::string filename; std::tie(generate_table, filename, ctrl) = ParseBreitWheelerParams(); - //Only temporary for test purposes, will be removed + //Use dummy tables for test purposes if required ParmParse pp("qed_bw"); - bool ignore_tables = false; - pp.query("ignore_tables_for_test", ignore_tables); - if(ignore_tables) return; + bool use_dummy_builtin_tables = false; + pp.query("use_dummy_builtin_tables", use_dummy_builtin_tables); + if(use_dummy_builtin_tables) + { + m_shr_p_bw_engine->init_dummy_tables(); + } //_________________________________________________ if(generate_table && ParallelDescriptor::IOProcessor()){ @@ -821,13 +824,6 @@ MultiParticleContainer::ParseBreitWheelerParams () // the optical depth is not evolved and pair generation is ignored pp.query("chi_min", ctrl.chi_phot_min); - //Only temporary for test purposes, will be removed - bool ignore_tables = false; - pp.query("ignore_tables_for_test", ignore_tables); - if(ignore_tables) - return std::make_tuple(false, "__DUMMY__", ctrl); - //_________________________________________________ - pp.query("generate_table", generate_table); if(generate_table){ -- cgit v1.2.3 From 6e302ea47d46005ae2f8f13f79109aeb2a4617f3 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Wed, 13 Nov 2019 19:33:57 +0100 Subject: bugfixing --- Source/Particles/MultiParticleContainer.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 6f2d025a8..139bc63c7 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -689,6 +689,7 @@ void MultiParticleContainer::InitBreitWheeler () if(use_dummy_builtin_tables) { m_shr_p_bw_engine->init_dummy_tables(); + return; } //_________________________________________________ -- cgit v1.2.3 From 0b31863966a01203454f0cbe80f227e9cd1a3e2c Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Thu, 14 Nov 2019 10:40:48 +0100 Subject: Added built-in tables for QS --- Examples/Modules/qed/quantum_synchrotron/inputs.2d_test_tau_init | 2 +- Source/Particles/MultiParticleContainer.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Examples/Modules/qed/quantum_synchrotron/inputs.2d_test_tau_init b/Examples/Modules/qed/quantum_synchrotron/inputs.2d_test_tau_init index 03a2a5798..da6e16d06 100644 --- a/Examples/Modules/qed/quantum_synchrotron/inputs.2d_test_tau_init +++ b/Examples/Modules/qed/quantum_synchrotron/inputs.2d_test_tau_init @@ -91,7 +91,7 @@ positrons.do_qed_quantum_sync = 1 #######QED ENGINE PARAMETERS##### qed_qs.chi_min = 0.001 -qed_qs.ignore_tables_for_test = 1 +qed_bw.use_dummy_builtin_tables = 1 #qed_qs.generate_table = 1 #qed_qs.tab_dndt_chi_min = 0.001 #qed_qs.tab_dndt_chi_max = 100 diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 139bc63c7..4cb4c948e 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -648,9 +648,12 @@ void MultiParticleContainer::InitQuantumSync () //Only temporary for test purposes, will be removed ParmParse pp("qed_qs"); - bool ignore_tables = false; - pp.query("ignore_tables_for_test", ignore_tables); - if(ignore_tables) return; + bool use_dummy_builtin_tables = false; + pp.query("use_dummy_builtin_tables", use_dummy_builtin_tables); + if(use_dummy_builtin_tables){ + m_shr_p_qs_engine->init_dummy_tables(); + return; + } //_________________________________________________ -- cgit v1.2.3 From ae887b0688dcece1b7b4c3e5340c365c759d05e4 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Thu, 14 Nov 2019 11:23:00 +0100 Subject: bugfixing --- Source/Particles/MultiParticleContainer.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 4cb4c948e..91aa181b7 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -644,9 +644,8 @@ void MultiParticleContainer::InitQuantumSync () bool generate_table; PicsarQuantumSynchrotronCtrl ctrl; std::string filename; - std::tie(generate_table, filename, ctrl) = ParseQuantumSyncParams(); - //Only temporary for test purposes, will be removed + //Use dummy tables for test purposes if required ParmParse pp("qed_qs"); bool use_dummy_builtin_tables = false; pp.query("use_dummy_builtin_tables", use_dummy_builtin_tables); @@ -656,6 +655,7 @@ void MultiParticleContainer::InitQuantumSync () } //_________________________________________________ + std::tie(generate_table, filename, ctrl) = ParseQuantumSyncParams(); if(generate_table && ParallelDescriptor::IOProcessor()){ m_shr_p_qs_engine->compute_lookup_tables(ctrl); @@ -683,7 +683,6 @@ void MultiParticleContainer::InitBreitWheeler () bool generate_table; PicsarBreitWheelerCtrl ctrl; std::string filename; - std::tie(generate_table, filename, ctrl) = ParseBreitWheelerParams(); //Use dummy tables for test purposes if required ParmParse pp("qed_bw"); @@ -696,6 +695,8 @@ void MultiParticleContainer::InitBreitWheeler () } //_________________________________________________ + std::tie(generate_table, filename, ctrl) = ParseBreitWheelerParams(); + if(generate_table && ParallelDescriptor::IOProcessor()){ m_shr_p_bw_engine->compute_lookup_tables(ctrl); Vector all_data = m_shr_p_bw_engine->export_lookup_tables_data(); @@ -732,13 +733,6 @@ MultiParticleContainer::ParseQuantumSyncParams () // the optical depth is not evolved and photon generation is ignored pp.query("chi_min", ctrl.chi_part_min); - //Only temporary for test purposes, will be removed - bool ignore_tables = false; - pp.query("ignore_tables_for_test", ignore_tables); - if(ignore_tables) - return std::make_tuple(false, "__DUMMY__", ctrl); - //_________________________________________________ - pp.query("generate_table", generate_table); if(generate_table){ int t_int = 0; -- cgit v1.2.3 From ca54ee7f4f3a20ecf9f878c0a00330e8b29a3161 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Fri, 15 Nov 2019 15:33:24 +0100 Subject: simplified parsing inputfile --- .../qed/breit_wheeler/inputs.2d_test_tau_init | 13 +- .../inputs.3d_test_optical_depth_evolution | 7 +- .../quantum_synchrotron/inputs.2d_test_tau_init | 13 +- Source/Particles/MultiParticleContainer.H | 21 +- Source/Particles/MultiParticleContainer.cpp | 413 ++++++++++----------- 5 files changed, 217 insertions(+), 250 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Examples/Modules/qed/breit_wheeler/inputs.2d_test_tau_init b/Examples/Modules/qed/breit_wheeler/inputs.2d_test_tau_init index 2c7d8f71c..d5b6ff26a 100644 --- a/Examples/Modules/qed/breit_wheeler/inputs.2d_test_tau_init +++ b/Examples/Modules/qed/breit_wheeler/inputs.2d_test_tau_init @@ -65,16 +65,5 @@ photons.do_qed_breit_wheeler = 1 ################################# #######QED ENGINE PARAMETERS##### -qed_bw.chi_min = 0.01 -qed_bw.use_dummy_builtin_tables = 1 -#qed_bw.generate_table = 1 -#qed_bw.tab_dndt_chi_min = 0.01 -#qed_bw.tab_dndt_chi_max = 100 -#qed_bw.tab_dndt_how_many = 200 -#qed_bw.tab_pair_chi_min = 0.01 -#qed_bw.tab_pair_chi_max = 100 -#qed_bw.tab_pair_chi_how_many = 30 -#qed_bw.tab_pair_frac_how_many = 30 -#qed_bw.save_table_in = "bw_table" -#qed_bw.load_table_from = "bw_table" +qed_bw.lookup_table_mode = "dummy_builtin" ################################# diff --git a/Examples/Modules/qed/breit_wheeler/inputs.3d_test_optical_depth_evolution b/Examples/Modules/qed/breit_wheeler/inputs.3d_test_optical_depth_evolution index f497c2241..09d77a26b 100644 --- a/Examples/Modules/qed/breit_wheeler/inputs.3d_test_optical_depth_evolution +++ b/Examples/Modules/qed/breit_wheeler/inputs.3d_test_optical_depth_evolution @@ -144,8 +144,9 @@ p4.do_qed_breit_wheeler = 1 ################################# ##########QED TABLES#################### -qed_bw.use_dummy_builtin_tables = 1 -#qed_bw.generate_table = 0 +qed_bw.lookup_table_mode = "dummy_builtin" + +#qed_bw.lookup_table_mode = "generate" #qed_bw.chi_min = 0.001 #qed_bw.tab_dndt_chi_min = 0.1 #qed_bw.tab_dndt_chi_max = 200 @@ -155,6 +156,8 @@ qed_bw.use_dummy_builtin_tables = 1 #qed_bw.tab_pair_chi_how_many = 2 #qed_bw.tab_pair_prob_how_many = 2 #qed_bw.save_table_in = "bw_micro_table" + +#qed_bw.lookup_table_mode = "load" #qed_bw.load_table_from = "bw_micro_table" ################################# diff --git a/Examples/Modules/qed/quantum_synchrotron/inputs.2d_test_tau_init b/Examples/Modules/qed/quantum_synchrotron/inputs.2d_test_tau_init index 377e05ff5..f46571669 100644 --- a/Examples/Modules/qed/quantum_synchrotron/inputs.2d_test_tau_init +++ b/Examples/Modules/qed/quantum_synchrotron/inputs.2d_test_tau_init @@ -90,16 +90,5 @@ positrons.do_qed_quantum_sync = 1 ################################# #######QED ENGINE PARAMETERS##### -qed_qs.chi_min = 0.001 -qed_qs.use_dummy_builtin_tables = 1 -#qed_qs.generate_table = 1 -#qed_qs.tab_dndt_chi_min = 0.001 -#qed_qs.tab_dndt_chi_max = 100 -#qed_qs.tab_dndt_how_many = 200 -#qed_qs.tab_em_chi_min = 0.01 -#qed_qs.tab_em_chi_max = 100 -#qed_qs.tab_em_chi_how_many = 2 -#qed_qs.tab_em_prob_how_many = 2 -#qed_qs.save_table_in = "qs_table" -#qed_qs.load_table_from = "qs_table" +qed_qs.lookup_table_mode = "dummy_builtin" ################################# diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index 06898a5c1..f6d6acafb 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -20,8 +20,6 @@ #include #include #include -#include -#include // // MultiParticleContainer holds multiple (nspecies or npsecies+1 when @@ -257,22 +255,17 @@ protected: void InitBreitWheeler (); /** - * Parses inputfile parameters for Quantum Synchrotron engine - * @return {a tuple containing a flag which is true if tables - * have to be generate, a filename (where tables should be stored - * or read from) and control parameters.} + * Called by InitQuantumSync if a new table has + * to be generated. */ - std::tuple - ParseQuantumSyncParams (); + void QuantumSyncGenerateTable(); /** - * Parses inputfile parameters for Breit Wheeler engine - * @return {a tuple containing a flag which is true if tables - * have to be generate, a filename (where tables should be stored - * or read from) and control parameters.} + * Called by InitBreitWheeler if a new table has + * to be generated. */ - std::tuple - ParseBreitWheelerParams (); + void BreitWheelerGenerateTable(); + #endif private: diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 91aa181b7..80e15bb0e 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -641,260 +641,253 @@ void MultiParticleContainer::InitQED () void MultiParticleContainer::InitQuantumSync () { - bool generate_table; - PicsarQuantumSynchrotronCtrl ctrl; - std::string filename; - - //Use dummy tables for test purposes if required + std::string lookup_table_mode; ParmParse pp("qed_qs"); - bool use_dummy_builtin_tables = false; - pp.query("use_dummy_builtin_tables", use_dummy_builtin_tables); - if(use_dummy_builtin_tables){ - m_shr_p_qs_engine->init_dummy_tables(); - return; + pp.query("lookup_table_mode", lookup_table_mode); + if(lookup_table_mode.empty()){ + amrex::Abort("Quantum Synchrotron table mode should be provided"); } - //_________________________________________________ - - std::tie(generate_table, filename, ctrl) = ParseQuantumSyncParams(); - - if(generate_table && ParallelDescriptor::IOProcessor()){ - m_shr_p_qs_engine->compute_lookup_tables(ctrl); - Vector all_data = m_shr_p_qs_engine->export_lookup_tables_data(); - WarpXUtilIO::WriteBinaryDataOnFile(filename, all_data); - } - ParallelDescriptor::Barrier(); - Vector table_data; - ParallelDescriptor::ReadAndBcastFile(filename, table_data); - ParallelDescriptor::Barrier(); - - //No need to initialize from raw data for the processor that - //has just generated the table - if(!generate_table || !ParallelDescriptor::IOProcessor()){ + if(lookup_table_mode == "generate"){ +#ifndef WARPX_QED_TABLE_GEN + amrex::Error("Error: Compile with QED_TABLE_GEN=TRUE to enable table generation!\n"); +#else + QuantumSyncGenerateTable(); +#endif + } + else if(lookup_table_mode == "load"){ + std::string load_table_name; + pp.query("load_table_from", load_table_name); + if(load_table_name.empty()){ + amrex::Abort("Quantum Synchrotron table name should be provided"); + } + Vector table_data; + ParallelDescriptor::ReadAndBcastFile(load_table_name, table_data); + ParallelDescriptor::Barrier(); m_shr_p_qs_engine->init_lookup_tables_from_raw_data(table_data); } + else if(lookup_table_mode == "dummy_builtin"){ + m_shr_p_qs_engine->init_dummy_tables(); + } + else{ + amrex::Abort("Unknown Quantum Synchrotron table mode"); + } - if(!m_shr_p_qs_engine->are_lookup_tables_initialized()) - amrex::Error("Table initialization has failed!\n"); + if(!m_shr_p_qs_engine->are_lookup_tables_initialized()){ + amrex::Abort("Table initialization has failed!"); + } } void MultiParticleContainer::InitBreitWheeler () { - bool generate_table; - PicsarBreitWheelerCtrl ctrl; - std::string filename; - - //Use dummy tables for test purposes if required + std::string lookup_table_mode; ParmParse pp("qed_bw"); - bool use_dummy_builtin_tables = false; - pp.query("use_dummy_builtin_tables", use_dummy_builtin_tables); - if(use_dummy_builtin_tables) - { - m_shr_p_bw_engine->init_dummy_tables(); - return; + pp.query("lookup_table_mode", lookup_table_mode); + if(lookup_table_mode.empty()){ + amrex::Abort("Breit Wheeler table mode should be provided"); } - //_________________________________________________ - std::tie(generate_table, filename, ctrl) = ParseBreitWheelerParams(); - - if(generate_table && ParallelDescriptor::IOProcessor()){ - m_shr_p_bw_engine->compute_lookup_tables(ctrl); - Vector all_data = m_shr_p_bw_engine->export_lookup_tables_data(); - WarpXUtilIO::WriteBinaryDataOnFile(filename, all_data); + if(lookup_table_mode == "generate"){ +#ifndef WARPX_QED_TABLE_GEN + amrex::Error("Error: Compile with QED_TABLE_GEN=TRUE to enable table generation!\n"); +#else + BreitWheelerGenerateTable(); +#endif } - ParallelDescriptor::Barrier(); - - Vector table_data; - ParallelDescriptor::ReadAndBcastFile(filename, table_data); - ParallelDescriptor::Barrier(); - - //No need to initialize from raw data for the processor that - //has just generated the table - if(!generate_table || !ParallelDescriptor::IOProcessor()){ + else if(lookup_table_mode == "load"){ + std::string load_table_name; + pp.query("load_table_from", load_table_name); + if(load_table_name.empty()){ + amrex::Abort("Breit Wheeler table name should be provided"); + } + Vector table_data; + ParallelDescriptor::ReadAndBcastFile(load_table_name, table_data); + ParallelDescriptor::Barrier(); m_shr_p_bw_engine->init_lookup_tables_from_raw_data(table_data); } + else if(lookup_table_mode == "dummy_builtin"){ + m_shr_p_bw_engine->init_dummy_tables(); + } + else{ + amrex::Abort("Unknown Breit Wheeler table mode"); + } - if(!m_shr_p_bw_engine->are_lookup_tables_initialized()) - amrex::Error("Table initialization has failed!\n"); + if(!m_shr_p_bw_engine->are_lookup_tables_initialized()){ + amrex::Abort("Table initialization has failed!"); + } } -std::tuple -MultiParticleContainer::ParseQuantumSyncParams () +void +MultiParticleContainer::QuantumSyncGenerateTable () { - PicsarQuantumSynchrotronCtrl ctrl = - m_shr_p_qs_engine->get_default_ctrl(); - bool generate_table{false}; - std::string table_name; - ParmParse pp("qed_qs"); + PicsarQuantumSynchrotronCtrl ctrl; + int t_int; + // Engine paramenter: chi_part_min is the minium chi parameter to be // considered by the engine. If a lepton has chi < chi_part_min, // the optical depth is not evolved and photon generation is ignored - pp.query("chi_min", ctrl.chi_part_min); - - pp.query("generate_table", generate_table); - if(generate_table){ - int t_int = 0; - - //==Table parameters== - - //--- sub-table 1 (1D) - //These parameters are used to pre-compute a function - //which appears in the evolution of the optical depth - - //Minimun chi for the table. If a lepton has chi < chi_part_tdndt_min, - ///chi is considered as it were equal to chi_part_tdndt_min - pp.query("tab_dndt_chi_min", ctrl.chi_part_tdndt_min); - - //Maximum chi for the table. If a lepton has chi > chi_part_tdndt_max, - ///chi is considered as it were equal to chi_part_tdndt_max - pp.query("tab_dndt_chi_max", ctrl.chi_part_tdndt_max); - - //How many points should be used for chi in the table - pp.query("tab_dndt_how_many", t_int); - ctrl.chi_part_tdndt_how_many= t_int; - //------ - - //--- sub-table 2 (2D) - //These parameters are used to pre-compute a function - //which is used to extract the properties of the generated - //photons. + if(!pp.query("chi_min", ctrl.chi_part_min)) + amrex::Abort("qed_qs.chi_min should be provided!"); + + //==Table parameters== + + //--- sub-table 1 (1D) + //These parameters are used to pre-compute a function + //which appears in the evolution of the optical depth + + //Minimun chi for the table. If a lepton has chi < chi_part_tdndt_min, + //chi is considered as it were equal to chi_part_tdndt_min + if(!pp.query("tab_dndt_chi_min", ctrl.chi_part_tdndt_min)) + amrex::Abort("qed_qs.tab_dndt_chi_min should be provided!"); + + //Maximum chi for the table. If a lepton has chi > chi_part_tdndt_max, + //chi is considered as it were equal to chi_part_tdndt_max + if(!pp.query("tab_dndt_chi_max", ctrl.chi_part_tdndt_max)) + amrex::Abort("qed_qs.tab_dndt_chi_max should be provided!"); + + //How many points should be used for chi in the table + if(!pp.query("tab_dndt_how_many", t_int)) + amrex::Abort("qed_qs.tab_dndt_how_many should be provided!"); + ctrl.chi_part_tdndt_how_many = t_int; + //------ + + //--- sub-table 2 (2D) + //These parameters are used to pre-compute a function + //which is used to extract the properties of the generated + //photons. + + //Minimun chi for the table. If a lepton has chi < chi_part_tem_min, + //chi is considered as it were equal to chi_part_tem_min + if(!pp.query("tab_em_chi_min", ctrl.chi_part_tem_min)) + amrex::Abort("qed_qs.tab_em_chi_min should be provided!"); + + //Maximum chi for the table. If a lepton has chi > chi_part_tem_max, + //chi is considered as it were equal to chi_part_tem_max + if(!pp.query("tab_em_chi_max", ctrl.chi_part_tem_max)) + amrex::Abort("qed_qs.tab_em_chi_max should be provided!"); + + //How many points should be used for chi in the table + if(!pp.query("tab_em_chi_how_many", t_int)) + amrex::Abort("qed_qs.tab_em_chi_how_many should be provided!"); + ctrl.chi_part_tem_how_many = t_int; + + //The other axis of the table is a cumulative probability distribution + //(corresponding to different energies of the generated particles) + //This parameter is the number of different points to consider + if(!pp.query("tab_em_prob_how_many", t_int)) + amrex::Abort("qed_qs.tab_em_prob_how_many should be provided!"); + ctrl.prob_tem_how_many = t_int; + //==================== - //Minimun chi for the table. If a lepton has chi < chi_part_tem_min, - ///chi is considered as it were equal to chi_part_tem_min - pp.query("tab_em_chi_min", ctrl.chi_part_tem_min); - - //Maximum chi for the table. If a lepton has chi > chi_part_tem_max, - ///chi is considered as it were equal to chi_part_tem_max - pp.query("tab_em_chi_max", ctrl.chi_part_tem_max); - - //How many points should be used for chi in the table - pp.query("tab_em_chi_how_many", t_int); - ctrl.chi_part_tem_how_many = t_int; - - //The other axis of the table is a cumulative probability distribution - //(corresponding to different energies of the generated particles) - //This parameter is the number of different points to consider - pp.query("tab_em_prob_how_many", t_int); - ctrl.prob_tem_how_many = t_int; - //==================== - - pp.query("save_table_in", table_name); - - } + std::string table_name; + pp.query("save_table_in", table_name); + if(table_name.empty()) + amrex::Abort("qed_qs.save_table_in should be provided!"); - std::string load_table_name; - pp.query("load_table_from", load_table_name); - if(!load_table_name.empty()){ - if(generate_table && ParallelDescriptor::IOProcessor()){ - amrex::Print() << "Warning, Quantum Synchrotron table will be loaded, not generated. \n"; - } - table_name = load_table_name; - generate_table = false; + if(ParallelDescriptor::IOProcessor()){ + m_shr_p_qs_engine->compute_lookup_tables(ctrl); + WarpXUtilIO::WriteBinaryDataOnFile(table_name, + m_shr_p_qs_engine->export_lookup_tables_data()); } + ParallelDescriptor::Barrier(); -#ifndef WARPX_QED_TABLE_GEN - if(generate_table){ - amrex::Error("Error: Compile with QED_TABLE_GEN=TRUE to enable table generation!\n"); - } -#endif + Vector table_data; + ParallelDescriptor::ReadAndBcastFile(table_name, table_data); + ParallelDescriptor::Barrier(); - if(table_name.empty()){ - amrex::Error("Error: Quantum Synchrotron table has either to be generated or to be loaded.\n"); + //No need to initialize from raw data for the processor that + //has just generated the table + if(!ParallelDescriptor::IOProcessor()){ + m_shr_p_qs_engine->init_lookup_tables_from_raw_data(table_data); } - - return std::make_tuple(generate_table, table_name, ctrl); } -std::tuple -MultiParticleContainer::ParseBreitWheelerParams () +void +MultiParticleContainer::BreitWheelerGenerateTable () { - PicsarBreitWheelerCtrl ctrl = - m_shr_p_bw_engine->get_default_ctrl(); - bool generate_table{false}; - std::string table_name; - ParmParse pp("qed_bw"); + PicsarBreitWheelerCtrl ctrl; + int t_int; + // Engine paramenter: chi_phot_min is the minium chi parameter to be // considered by the engine. If a photon has chi < chi_phot_min, // the optical depth is not evolved and pair generation is ignored - pp.query("chi_min", ctrl.chi_phot_min); - - pp.query("generate_table", generate_table); - if(generate_table){ - - int t_int; + if(!pp.query("chi_min", ctrl.chi_phot_min)) + amrex::Abort("qed_bw.chi_min should be provided!"); + + //==Table parameters== + + //--- sub-table 1 (1D) + //These parameters are used to pre-compute a function + //which appears in the evolution of the optical depth + + //Minimun chi for the table. If a photon has chi < chi_phot_tdndt_min, + //an analytical approximation is used. + if(!pp.query("tab_dndt_chi_min", ctrl.chi_phot_tdndt_min)) + amrex::Abort("qed_bw.tab_dndt_chi_min should be provided!"); + + //Maximum chi for the table. If a photon has chi > chi_phot_tdndt_min, + //an analytical approximation is used. + if(!pp.query("tab_dndt_chi_max", ctrl.chi_phot_tdndt_max)) + amrex::Abort("qed_bw.tab_dndt_chi_max should be provided!"); + + //How many points should be used for chi in the table + if(!pp.query("tab_dndt_how_many", t_int)) + amrex::Abort("qed_bw.tab_dndt_how_many should be provided!"); + ctrl.chi_phot_tdndt_how_many = t_int; + //------ + + //--- sub-table 2 (2D) + //These parameters are used to pre-compute a function + //which is used to extract the properties of the generated + //particles. + + //Minimun chi for the table. If a photon has chi < chi_phot_tpair_min + //chi is considered as it were equal to chi_phot_tpair_min + if(!pp.query("tab_pair_chi_min", ctrl.chi_phot_tpair_min)) + amrex::Abort("qed_bw.tab_pair_chi_min should be provided!"); + + //Maximum chi for the table. If a photon has chi > chi_phot_tpair_max + //chi is considered as it were equal to chi_phot_tpair_max + if(!pp.query("tab_pair_chi_max", ctrl.chi_phot_tpair_max)) + amrex::Abort("qed_bw.tab_pair_chi_max should be provided!"); + + //How many points should be used for chi in the table + if(!pp.query("tab_pair_chi_how_many", t_int)) + amrex::Abort("qed_bw.tab_pair_chi_how_many should be provided!"); + ctrl.chi_phot_tpair_how_many = t_int; + + //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 + if(!pp.query("tab_pair_frac_how_many", t_int)) + amrex::Abort("qed_bw.tab_pair_frac_how_many should be provided!"); + ctrl.chi_frac_tpair_how_many = t_int; + //==================== - //==Table parameters== - - //--- sub-table 1 (1D) - //These parameters are used to pre-compute a function - //which appears in the evolution of the optical depth - - //Minimun chi for the table. If a photon has chi < chi_phot_tdndt_min, - //an analytical approximation is used. - pp.query("tab_dndt_chi_min", ctrl.chi_phot_tdndt_min); - - //Maximum chi for the table. If a photon has chi > chi_phot_tdndt_min, - //an analytical approximation is used. - pp.query("tab_dndt_chi_max", ctrl.chi_phot_tdndt_max); - - //How many points should be used for chi in the table - pp.query("tab_dndt_how_many", t_int); - ctrl.chi_phot_tdndt_how_many = t_int; - //------ - - //--- sub-table 2 (2D) - //These parameters are used to pre-compute a function - //which is used to extract the properties of the generated - //particles. - - //Minimun chi for the table. If a photon has chi < chi_phot_tpair_min - //chi is considered as it were equal to chi_phot_tpair_min - pp.query("tab_pair_chi_min", ctrl.chi_phot_tpair_min); - - //Maximum chi for the table. If a photon has chi > chi_phot_tpair_max - //chi is considered as it were equal to chi_phot_tpair_max - pp.query("tab_pair_chi_max", ctrl.chi_phot_tpair_max); - - //How many points should be used for chi in the table - pp.query("tab_pair_chi_how_many", t_int); - ctrl.chi_phot_tpair_how_many = t_int; - - //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 - pp.query("tab_pair_frac_how_many", t_int); - ctrl.chi_frac_tpair_how_many = t_int; - //==================== - - pp.query("save_table_in", table_name); - } + std::string table_name; + pp.query("save_table_in", table_name); + if(table_name.empty()) + amrex::Abort("qed_bw.save_table_in should be provided!"); - std::string load_table_name; - pp.query("load_table_from", load_table_name); - if(!load_table_name.empty()){ - if(generate_table && ParallelDescriptor::IOProcessor()){ - amrex::Print() << "Warning, Breit Wheeler table will be loaded, not generated. \n"; - } - table_name = load_table_name; - generate_table = false; + if(ParallelDescriptor::IOProcessor()){ + m_shr_p_bw_engine->compute_lookup_tables(ctrl); + WarpXUtilIO::WriteBinaryDataOnFile(table_name, + m_shr_p_bw_engine->export_lookup_tables_data()); } + ParallelDescriptor::Barrier(); -#ifndef WARPX_QED_TABLE_GEN - if(generate_table){ - if(ParallelDescriptor::IOProcessor()){ - amrex::Error("Error: Compile with QED_TABLE_GEN=TRUE to enable table generation!\n"); - } - } -#endif + Vector table_data; + ParallelDescriptor::ReadAndBcastFile(table_name, table_data); + ParallelDescriptor::Barrier(); - if(table_name.empty()){ - amrex::Error("Error: Breit Wheeler table has either to be generated or to be loaded.\n"); + //No need to initialize from raw data for the processor that + //has just generated the table + if(!ParallelDescriptor::IOProcessor()){ + m_shr_p_bw_engine->init_lookup_tables_from_raw_data(table_data); } - - return std::make_tuple(generate_table, table_name, ctrl); } #endif -- cgit v1.2.3 From 3db770f461eb3a2c47eb2cf15f68eac00cf2191d Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Fri, 15 Nov 2019 15:55:58 +0100 Subject: added messages related to table initialization --- Source/Particles/MultiParticleContainer.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 80e15bb0e..465ca16f2 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -649,6 +649,7 @@ void MultiParticleContainer::InitQuantumSync () } if(lookup_table_mode == "generate"){ + amrex::Print() << "Quantum Synchrotron table will be generated. \n" ; #ifndef WARPX_QED_TABLE_GEN amrex::Error("Error: Compile with QED_TABLE_GEN=TRUE to enable table generation!\n"); #else @@ -656,6 +657,7 @@ void MultiParticleContainer::InitQuantumSync () #endif } else if(lookup_table_mode == "load"){ + amrex::Print() << "Quantum Synchrotron table will be read from file. \n" ; std::string load_table_name; pp.query("load_table_from", load_table_name); if(load_table_name.empty()){ @@ -667,7 +669,8 @@ void MultiParticleContainer::InitQuantumSync () m_shr_p_qs_engine->init_lookup_tables_from_raw_data(table_data); } else if(lookup_table_mode == "dummy_builtin"){ - m_shr_p_qs_engine->init_dummy_tables(); + amrex::Print() << "Built-in Quantum Synchrotron dummy table will be used. \n" ; + m_shr_p_qs_engine->init_dummy_tables(); } else{ amrex::Abort("Unknown Quantum Synchrotron table mode"); @@ -688,6 +691,7 @@ void MultiParticleContainer::InitBreitWheeler () } if(lookup_table_mode == "generate"){ + amrex::Print() << "Breit Wheeler table will be generated. \n" ; #ifndef WARPX_QED_TABLE_GEN amrex::Error("Error: Compile with QED_TABLE_GEN=TRUE to enable table generation!\n"); #else @@ -695,6 +699,7 @@ void MultiParticleContainer::InitBreitWheeler () #endif } else if(lookup_table_mode == "load"){ + amrex::Print() << "Breit Wheeler table will be read from file. \n" ; std::string load_table_name; pp.query("load_table_from", load_table_name); if(load_table_name.empty()){ @@ -706,7 +711,8 @@ void MultiParticleContainer::InitBreitWheeler () m_shr_p_bw_engine->init_lookup_tables_from_raw_data(table_data); } else if(lookup_table_mode == "dummy_builtin"){ - m_shr_p_bw_engine->init_dummy_tables(); + amrex::Print() << "Built-in Breit Wheeler dummy table will be used. \n" ; + m_shr_p_bw_engine->init_dummy_tables(); } else{ amrex::Abort("Unknown Breit Wheeler table mode"); -- cgit v1.2.3 From 1fc33bf3bf88c65de43b87f8dc55391549e41338 Mon Sep 17 00:00:00 2001 From: Luca Fedeli Date: Fri, 15 Nov 2019 16:12:50 +0100 Subject: bugfixing --- Source/Particles/MultiParticleContainer.cpp | 246 ++++++++++++++-------------- 1 file changed, 122 insertions(+), 124 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 465ca16f2..bf1ffb74e 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -727,78 +727,77 @@ void MultiParticleContainer::QuantumSyncGenerateTable () { ParmParse pp("qed_qs"); - - PicsarQuantumSynchrotronCtrl ctrl; - int t_int; - - // Engine paramenter: chi_part_min is the minium chi parameter to be - // considered by the engine. If a lepton has chi < chi_part_min, - // the optical depth is not evolved and photon generation is ignored - if(!pp.query("chi_min", ctrl.chi_part_min)) - amrex::Abort("qed_qs.chi_min should be provided!"); - - //==Table parameters== - - //--- sub-table 1 (1D) - //These parameters are used to pre-compute a function - //which appears in the evolution of the optical depth - - //Minimun chi for the table. If a lepton has chi < chi_part_tdndt_min, - //chi is considered as it were equal to chi_part_tdndt_min - if(!pp.query("tab_dndt_chi_min", ctrl.chi_part_tdndt_min)) - amrex::Abort("qed_qs.tab_dndt_chi_min should be provided!"); - - //Maximum chi for the table. If a lepton has chi > chi_part_tdndt_max, - //chi is considered as it were equal to chi_part_tdndt_max - if(!pp.query("tab_dndt_chi_max", ctrl.chi_part_tdndt_max)) - amrex::Abort("qed_qs.tab_dndt_chi_max should be provided!"); - - //How many points should be used for chi in the table - if(!pp.query("tab_dndt_how_many", t_int)) - amrex::Abort("qed_qs.tab_dndt_how_many should be provided!"); - ctrl.chi_part_tdndt_how_many = t_int; - //------ - - //--- sub-table 2 (2D) - //These parameters are used to pre-compute a function - //which is used to extract the properties of the generated - //photons. - - //Minimun chi for the table. If a lepton has chi < chi_part_tem_min, - //chi is considered as it were equal to chi_part_tem_min - if(!pp.query("tab_em_chi_min", ctrl.chi_part_tem_min)) - amrex::Abort("qed_qs.tab_em_chi_min should be provided!"); - - //Maximum chi for the table. If a lepton has chi > chi_part_tem_max, - //chi is considered as it were equal to chi_part_tem_max - if(!pp.query("tab_em_chi_max", ctrl.chi_part_tem_max)) - amrex::Abort("qed_qs.tab_em_chi_max should be provided!"); - - //How many points should be used for chi in the table - if(!pp.query("tab_em_chi_how_many", t_int)) - amrex::Abort("qed_qs.tab_em_chi_how_many should be provided!"); - ctrl.chi_part_tem_how_many = t_int; - - //The other axis of the table is a cumulative probability distribution - //(corresponding to different energies of the generated particles) - //This parameter is the number of different points to consider - if(!pp.query("tab_em_prob_how_many", t_int)) - amrex::Abort("qed_qs.tab_em_prob_how_many should be provided!"); - ctrl.prob_tem_how_many = t_int; - //==================== - std::string table_name; pp.query("save_table_in", table_name); if(table_name.empty()) - amrex::Abort("qed_qs.save_table_in should be provided!"); + amrex::Abort("qed_qs.save_table_in should be provided!"); if(ParallelDescriptor::IOProcessor()){ + PicsarQuantumSynchrotronCtrl ctrl; + int t_int; + + // Engine paramenter: chi_part_min is the minium chi parameter to be + // considered by the engine. If a lepton has chi < chi_part_min, + // the optical depth is not evolved and photon generation is ignored + if(!pp.query("chi_min", ctrl.chi_part_min)) + amrex::Abort("qed_qs.chi_min should be provided!"); + + //==Table parameters== + + //--- sub-table 1 (1D) + //These parameters are used to pre-compute a function + //which appears in the evolution of the optical depth + + //Minimun chi for the table. If a lepton has chi < chi_part_tdndt_min, + //chi is considered as it were equal to chi_part_tdndt_min + if(!pp.query("tab_dndt_chi_min", ctrl.chi_part_tdndt_min)) + amrex::Abort("qed_qs.tab_dndt_chi_min should be provided!"); + + //Maximum chi for the table. If a lepton has chi > chi_part_tdndt_max, + //chi is considered as it were equal to chi_part_tdndt_max + if(!pp.query("tab_dndt_chi_max", ctrl.chi_part_tdndt_max)) + amrex::Abort("qed_qs.tab_dndt_chi_max should be provided!"); + + //How many points should be used for chi in the table + if(!pp.query("tab_dndt_how_many", t_int)) + amrex::Abort("qed_qs.tab_dndt_how_many should be provided!"); + ctrl.chi_part_tdndt_how_many = t_int; + //------ + + //--- sub-table 2 (2D) + //These parameters are used to pre-compute a function + //which is used to extract the properties of the generated + //photons. + + //Minimun chi for the table. If a lepton has chi < chi_part_tem_min, + //chi is considered as it were equal to chi_part_tem_min + if(!pp.query("tab_em_chi_min", ctrl.chi_part_tem_min)) + amrex::Abort("qed_qs.tab_em_chi_min should be provided!"); + + //Maximum chi for the table. If a lepton has chi > chi_part_tem_max, + //chi is considered as it were equal to chi_part_tem_max + if(!pp.query("tab_em_chi_max", ctrl.chi_part_tem_max)) + amrex::Abort("qed_qs.tab_em_chi_max should be provided!"); + + //How many points should be used for chi in the table + if(!pp.query("tab_em_chi_how_many", t_int)) + amrex::Abort("qed_qs.tab_em_chi_how_many should be provided!"); + ctrl.chi_part_tem_how_many = t_int; + + //The other axis of the table is a cumulative probability distribution + //(corresponding to different energies of the generated particles) + //This parameter is the number of different points to consider + if(!pp.query("tab_em_prob_how_many", t_int)) + amrex::Abort("qed_qs.tab_em_prob_how_many should be provided!"); + ctrl.prob_tem_how_many = t_int; + //==================== + m_shr_p_qs_engine->compute_lookup_tables(ctrl); WarpXUtilIO::WriteBinaryDataOnFile(table_name, m_shr_p_qs_engine->export_lookup_tables_data()); } - ParallelDescriptor::Barrier(); + ParallelDescriptor::Barrier(); Vector table_data; ParallelDescriptor::ReadAndBcastFile(table_name, table_data); ParallelDescriptor::Barrier(); @@ -814,78 +813,77 @@ void MultiParticleContainer::BreitWheelerGenerateTable () { ParmParse pp("qed_bw"); - - PicsarBreitWheelerCtrl ctrl; - int t_int; - - // Engine paramenter: chi_phot_min is the minium chi parameter to be - // considered by the engine. If a photon has chi < chi_phot_min, - // the optical depth is not evolved and pair generation is ignored - if(!pp.query("chi_min", ctrl.chi_phot_min)) - amrex::Abort("qed_bw.chi_min should be provided!"); - - //==Table parameters== - - //--- sub-table 1 (1D) - //These parameters are used to pre-compute a function - //which appears in the evolution of the optical depth - - //Minimun chi for the table. If a photon has chi < chi_phot_tdndt_min, - //an analytical approximation is used. - if(!pp.query("tab_dndt_chi_min", ctrl.chi_phot_tdndt_min)) - amrex::Abort("qed_bw.tab_dndt_chi_min should be provided!"); - - //Maximum chi for the table. If a photon has chi > chi_phot_tdndt_min, - //an analytical approximation is used. - if(!pp.query("tab_dndt_chi_max", ctrl.chi_phot_tdndt_max)) - amrex::Abort("qed_bw.tab_dndt_chi_max should be provided!"); - - //How many points should be used for chi in the table - if(!pp.query("tab_dndt_how_many", t_int)) - amrex::Abort("qed_bw.tab_dndt_how_many should be provided!"); - ctrl.chi_phot_tdndt_how_many = t_int; - //------ - - //--- sub-table 2 (2D) - //These parameters are used to pre-compute a function - //which is used to extract the properties of the generated - //particles. - - //Minimun chi for the table. If a photon has chi < chi_phot_tpair_min - //chi is considered as it were equal to chi_phot_tpair_min - if(!pp.query("tab_pair_chi_min", ctrl.chi_phot_tpair_min)) - amrex::Abort("qed_bw.tab_pair_chi_min should be provided!"); - - //Maximum chi for the table. If a photon has chi > chi_phot_tpair_max - //chi is considered as it were equal to chi_phot_tpair_max - if(!pp.query("tab_pair_chi_max", ctrl.chi_phot_tpair_max)) - amrex::Abort("qed_bw.tab_pair_chi_max should be provided!"); - - //How many points should be used for chi in the table - if(!pp.query("tab_pair_chi_how_many", t_int)) - amrex::Abort("qed_bw.tab_pair_chi_how_many should be provided!"); - ctrl.chi_phot_tpair_how_many = t_int; - - //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 - if(!pp.query("tab_pair_frac_how_many", t_int)) - amrex::Abort("qed_bw.tab_pair_frac_how_many should be provided!"); - ctrl.chi_frac_tpair_how_many = t_int; - //==================== - std::string table_name; pp.query("save_table_in", table_name); if(table_name.empty()) - amrex::Abort("qed_bw.save_table_in should be provided!"); + amrex::Abort("qed_bw.save_table_in should be provided!"); if(ParallelDescriptor::IOProcessor()){ + PicsarBreitWheelerCtrl ctrl; + int t_int; + + // Engine paramenter: chi_phot_min is the minium chi parameter to be + // considered by the engine. If a photon has chi < chi_phot_min, + // the optical depth is not evolved and pair generation is ignored + if(!pp.query("chi_min", ctrl.chi_phot_min)) + amrex::Abort("qed_bw.chi_min should be provided!"); + + //==Table parameters== + + //--- sub-table 1 (1D) + //These parameters are used to pre-compute a function + //which appears in the evolution of the optical depth + + //Minimun chi for the table. If a photon has chi < chi_phot_tdndt_min, + //an analytical approximation is used. + if(!pp.query("tab_dndt_chi_min", ctrl.chi_phot_tdndt_min)) + amrex::Abort("qed_bw.tab_dndt_chi_min should be provided!"); + + //Maximum chi for the table. If a photon has chi > chi_phot_tdndt_min, + //an analytical approximation is used. + if(!pp.query("tab_dndt_chi_max", ctrl.chi_phot_tdndt_max)) + amrex::Abort("qed_bw.tab_dndt_chi_max should be provided!"); + + //How many points should be used for chi in the table + if(!pp.query("tab_dndt_how_many", t_int)) + amrex::Abort("qed_bw.tab_dndt_how_many should be provided!"); + ctrl.chi_phot_tdndt_how_many = t_int; + //------ + + //--- sub-table 2 (2D) + //These parameters are used to pre-compute a function + //which is used to extract the properties of the generated + //particles. + + //Minimun chi for the table. If a photon has chi < chi_phot_tpair_min + //chi is considered as it were equal to chi_phot_tpair_min + if(!pp.query("tab_pair_chi_min", ctrl.chi_phot_tpair_min)) + amrex::Abort("qed_bw.tab_pair_chi_min should be provided!"); + + //Maximum chi for the table. If a photon has chi > chi_phot_tpair_max + //chi is considered as it were equal to chi_phot_tpair_max + if(!pp.query("tab_pair_chi_max", ctrl.chi_phot_tpair_max)) + amrex::Abort("qed_bw.tab_pair_chi_max should be provided!"); + + //How many points should be used for chi in the table + if(!pp.query("tab_pair_chi_how_many", t_int)) + amrex::Abort("qed_bw.tab_pair_chi_how_many should be provided!"); + ctrl.chi_phot_tpair_how_many = t_int; + + //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 + if(!pp.query("tab_pair_frac_how_many", t_int)) + amrex::Abort("qed_bw.tab_pair_frac_how_many should be provided!"); + ctrl.chi_frac_tpair_how_many = t_int; + //==================== + m_shr_p_bw_engine->compute_lookup_tables(ctrl); WarpXUtilIO::WriteBinaryDataOnFile(table_name, m_shr_p_bw_engine->export_lookup_tables_data()); } - ParallelDescriptor::Barrier(); + ParallelDescriptor::Barrier(); Vector table_data; ParallelDescriptor::ReadAndBcastFile(table_name, table_data); ParallelDescriptor::Barrier(); -- cgit v1.2.3