aboutsummaryrefslogtreecommitdiff
path: root/Source/QED/QuantumSyncEngineWrapper.h
blob: af3731f6c186583bd7bbec786c04853091e9786d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef WARPX_quantum_sync_engine_wrapper_h_
#define WARPX_quantum_sync_engine_wrapper_h_

#include "QedWrapperCommons.h"

//QS ENGINE from PICSAR
#include "quantum_sync_engine.hpp"

using WarpXQuantumSynchrotronWrapper =
    picsar::multi_physics::quantum_synchrotron_engine<amrex::Real, DummyStruct>;

using WarpXQuantumSynchrotronWrapperCtrl =
    picsar::multi_physics::quantum_synchrotron_engine_ctrl<amrex::Real>;

// Struct to hold engine data ================

struct QuantumSynchrotronEngineInnards
{
    // Control parameters
    WarpXQuantumSynchrotronWrapperCtrl ctrl;

    //Lookup table data
    amrex::Gpu::ManagedDeviceVector<amrex::Real> KKfunc_coords;
    amrex::Gpu::ManagedDeviceVector<amrex::Real> KKfunc_data; 
    //______
};

// Functors ==================================

// These functors provide the core elementary functions of the library
// Can be included in GPU kernels

/* \brief Functor to initialize the optical depth of leptons for the
*   Quantum Synchrotron process */
class QuantumSynchrotronGetOpticalDepth
{
public:
    QuantumSynchrotronGetOpticalDepth ()
    {};

    AMREX_GPU_DEVICE
    amrex::Real operator() () const;
};
//____________________________________________

// Evolution of the optical depth (returns true if
// an event occurs)
class QuantumSynchrotronEvolveOpticalDepth
{
public:
    QuantumSynchrotronEvolveOpticalDepth(
        QuantumSynchrotronEngineInnards* _innards):
        innards{_innards}{};

    AMREX_GPU_DEVICE
    bool 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;

private:
    QuantumSynchrotronEngineInnards* innards;
};

// Factory class =============================

/* \brief Wrapper for the Quantum Synchrotron engine of the PICSAR library */
class QuantumSynchrotronEngine
{
public:
    QuantumSynchrotronEngine ();

    /* \brief Builds the functor to initialize the optical depth */
    QuantumSynchrotronGetOpticalDepth build_optical_depth_functor ();

    /* \brief Builds the functor to evolve the optical depth */
    QuantumSynchrotronEvolveOpticalDepth build_evolve_functor ();

    /* \brief Computes the Lookup tables using the default settings 
     *  provided by the PICSAR library */
    void computes_lookup_tables_default ();

    /* \brief Checks if lookup tables are properly initialized */
    bool are_lookup_tables_initialized () const;

private:
    bool lookup_tables_initialized = false;

    QuantumSynchrotronEngineInnards innards;

    //Private function which actually computes the lookup tables
    void computes_lookup_tables (
        WarpXQuantumSynchrotronWrapperCtrl ctrl);
};

//============================================

#endif //WARPX_quantum_sync_engine_wrapper_h_