aboutsummaryrefslogtreecommitdiff
path: root/Source/QED/BreitWheelerEngineWrapper.cpp
diff options
context:
space:
mode:
authorGravatar Luca Fedeli <luca.fedeli@cea.fr> 2019-10-09 15:15:19 +0200
committerGravatar Luca Fedeli <luca.fedeli@cea.fr> 2019-10-09 15:15:19 +0200
commit431818ad7bb72bc5396c7a870024f310de6f055c (patch)
treea89da87860080f52e401d168a71b1e96ac40545f /Source/QED/BreitWheelerEngineWrapper.cpp
parent540773fa9cc32e546a8afd09627e75ddaa3a0cfd (diff)
downloadWarpX-431818ad7bb72bc5396c7a870024f310de6f055c.tar.gz
WarpX-431818ad7bb72bc5396c7a870024f310de6f055c.tar.zst
WarpX-431818ad7bb72bc5396c7a870024f310de6f055c.zip
Added functions to generate tables and evolve optical depth
Diffstat (limited to 'Source/QED/BreitWheelerEngineWrapper.cpp')
-rw-r--r--Source/QED/BreitWheelerEngineWrapper.cpp84
1 files changed, 82 insertions, 2 deletions
diff --git a/Source/QED/BreitWheelerEngineWrapper.cpp b/Source/QED/BreitWheelerEngineWrapper.cpp
index b654cc9b0..72fe06d63 100644
--- a/Source/QED/BreitWheelerEngineWrapper.cpp
+++ b/Source/QED/BreitWheelerEngineWrapper.cpp
@@ -2,8 +2,6 @@
//This file provides a wrapper aroud the breit_wheeler engine
//provided by the PICSAR library
-using namespace picsar::multi_physics;
-
// Functors ==================================
// Initialization of the optical depth
@@ -16,13 +14,95 @@ BreitWheelerGetOpticalDepth::operator() () const
}
//____________________________________________
+// Evolution of the optical depth (returns true if
+// an event occurs)
+AMREX_GPU_DEVICE
+bool BreitWheelerEvolveOpticalDepth::operator()(
+ amrex::Real px, amrex::Real py, amrex::Real pz,
+ amrex::Real ex, amrex::Real ey, amrex::Real ez,
+ amrex::Real bx, amrex::Real by, amrex::Real bz,
+ amrex::Real dt, amrex::Real& opt_depth) const
+{
+ bool has_event_happend = false;
+ amrex::Real dummy_lambda = 1.0;
+ amrex::Real unused_event_time = 0.0;
+
+ const auto table = picsar::multi_physics::lookup_1d<amrex::Real>
+ (innards->TTfunc_data.size(),
+ innards->TTfunc_coords.data(),
+ innards->TTfunc_data.data());
+
+ WarpXBreitWheelerWrapper::internal_evolve_opt_depth_and_determine_event(
+ px, py, pz,
+ ex, ey, ez,
+ bx, by, bz,
+ dt, opt_depth,
+ has_event_happend, unused_event_time,
+ dummy_lambda,
+ table,
+ innards->ctrl);
+
+ return has_event_happend;
+}
+
// Factory class =============================
BreitWheelerEngine::BreitWheelerEngine(){}
+//Builds the functor to initialize the optical depth
BreitWheelerGetOpticalDepth BreitWheelerEngine::build_optical_depth_functor()
{
return BreitWheelerGetOpticalDepth();
}
+//Builds the functor to evolve the optical depth
+BreitWheelerEvolveOpticalDepth BreitWheelerEngine::build_evolve_functor()
+{
+ AMREX_ALWAYS_ASSERT(lookup_tables_initialized);
+
+ return BreitWheelerEvolveOpticalDepth(&innards);
+}
+
+
+//Initializes the Lookup tables using the default settings
+//provided by the library
+void BreitWheelerEngine::computes_lookup_tables_default()
+{
+ //A control parameters structure
+ //with the default values provided by the library
+ WarpXBreitWheelerWrapperCtrl ctrl_default;
+
+ computes_lookup_tables(ctrl_default);
+
+ lookup_tables_initialized = true;
+}
+
+bool BreitWheelerEngine::are_lookup_tables_initialized() const
+{
+ return lookup_tables_initialized;
+}
+
+//Private function which actually computes the lookup tables
+void BreitWheelerEngine::computes_lookup_tables(
+ WarpXBreitWheelerWrapperCtrl ctrl)
+{
+ //Lambda is not actually used if S.I. units are enabled
+ WarpXBreitWheelerWrapper bw_engine(std::move(DummyStruct()), 1.0, ctrl);
+
+ bw_engine.compute_dN_dt_lookup_table();
+ //bw_engine.compute_cumulative_pair_table();
+
+ auto bw_innards_picsar = bw_engine.export_innards();
+
+ //Copy data in a GPU-friendly data-structure
+ innards.ctrl = bw_innards_picsar.bw_ctrl;
+ innards.TTfunc_coords.assign(bw_innards_picsar.TTfunc_table_coords_ptr,
+ bw_innards_picsar.TTfunc_table_coords_ptr +
+ bw_innards_picsar.TTfunc_table_coords_how_many);
+ innards.TTfunc_data.assign(bw_innards_picsar.TTfunc_table_data_ptr,
+ bw_innards_picsar.TTfunc_table_data_ptr +
+ bw_innards_picsar.TTfunc_table_data_how_many);
+ //____
+}
+
//============================================