ARTEMIS
LaserProfiles.H
Go to the documentation of this file.
1 /* Copyright 2019-2020 Luca Fedeli, Maxence Thevenet
2  *
3  * This file is part of WarpX.
4  *
5  * License: BSD-3-Clause-LBNL
6  */
7 #ifndef WARPX_LaserProfiles_H_
8 #define WARPX_LaserProfiles_H_
9 
10 #include <AMReX_Gpu.H>
11 #include <AMReX_ParmParse.H>
12 #include <AMReX_Parser.H>
13 #include <AMReX_REAL.H>
14 #include <AMReX_Vector.H>
15 
16 #include <functional>
17 #include <limits>
18 #include <map>
19 #include <memory>
20 #include <string>
21 #include <utility>
22 
23 
24 namespace WarpXLaserProfiles {
25 
31 {
32  amrex::Real wavelength;
33  amrex::Real e_max;
34  amrex::Vector<amrex::Real> p_X;// ! Polarization
36 };
37 
38 
50 {
51 public:
63  virtual void
64  init (
65  const amrex::ParmParse& ppl,
66  CommonLaserParameters params) = 0;
67 
75  virtual void
77  amrex::Real t) = 0;
78 
89  virtual void
91  const int np,
92  amrex::Real const * AMREX_RESTRICT const Xp,
93  amrex::Real const * AMREX_RESTRICT const Yp,
94  amrex::Real t,
95  amrex::Real * AMREX_RESTRICT const amplitude) const = 0;
96 
97  virtual ~ILaserProfile(){}
98 };
99 
104 {
105 
106 public:
107  void
108  init (
109  const amrex::ParmParse& ppl,
110  CommonLaserParameters params) override final;
111 
112  //No update needed
113  void
114  update (amrex::Real /*t */) override final {}
115 
116  void
118  const int np,
119  amrex::Real const * AMREX_RESTRICT const Xp,
120  amrex::Real const * AMREX_RESTRICT const Yp,
121  amrex::Real t,
122  amrex::Real * AMREX_RESTRICT const amplitude) const override final;
123 
124 private:
125  struct {
126  amrex::Real waist = std::numeric_limits<amrex::Real>::quiet_NaN();
127  amrex::Real duration = std::numeric_limits<amrex::Real>::quiet_NaN();
128  amrex::Real t_peak = std::numeric_limits<amrex::Real>::quiet_NaN();
129  amrex::Real focal_distance = std::numeric_limits<amrex::Real>::quiet_NaN();
130  amrex::Real zeta = 0;
131  amrex::Real beta = 0;
132  amrex::Real phi2 = 0;
133  amrex::Real phi0 = 0;
134 
136  amrex::Real theta_stc;
138 
140 };
141 
146 {
147 
148 public:
149  void
150  init (
151  const amrex::ParmParse& ppl,
152  CommonLaserParameters params) override final;
153 
154  //No update needed
155  void
156  update (amrex::Real /*t */) override final {}
157 
158  void
160  const int np,
161  amrex::Real const * AMREX_RESTRICT const Xp,
162  amrex::Real const * AMREX_RESTRICT const Yp,
163  amrex::Real t,
164  amrex::Real * AMREX_RESTRICT const amplitude) const override final;
165 
166 private:
167  struct {
168  amrex::Real waist = std::numeric_limits<amrex::Real>::quiet_NaN();
169  amrex::Real duration = std::numeric_limits<amrex::Real>::quiet_NaN();
170  amrex::Real focal_distance = std::numeric_limits<amrex::Real>::quiet_NaN();
172 
174 };
175 
180 {
181 
182 public:
183  void
184  init (
185  const amrex::ParmParse& ppl,
186  CommonLaserParameters params) override final;
187 
188  //No update needed
189  void
190  update (amrex::Real /*t */) override final {}
191 
192  void
194  const int np,
195  amrex::Real const * AMREX_RESTRICT const Xp,
196  amrex::Real const * AMREX_RESTRICT const Yp,
197  amrex::Real t,
198  amrex::Real * AMREX_RESTRICT const amplitude) const override final;
199 
200 private:
201  struct{
202  std::string field_function;
204 
206 };
207 
215 {
216 
217 public:
218  void
219  init (
220  const amrex::ParmParse& ppl,
221  CommonLaserParameters params) override final;
222 
227  void
228  update (amrex::Real t) override final;
229 
243  void
245  const int np,
246  amrex::Real const * AMREX_RESTRICT const Xp,
247  amrex::Real const * AMREX_RESTRICT const Yp,
248  amrex::Real t,
249  amrex::Real * AMREX_RESTRICT const amplitude) const override final;
250 
263  const int idx_t_left,
264  const int np,
265  amrex::Real const * AMREX_RESTRICT const Xp,
266  amrex::Real const * AMREX_RESTRICT const Yp,
267  amrex::Real t,
268  amrex::Real * AMREX_RESTRICT const amplitude) const;
269 
282  const int idx_t_left,
283  const int np,
284  amrex::Real const * AMREX_RESTRICT const Xp,
285  amrex::Real const * AMREX_RESTRICT const Yp,
286  amrex::Real t,
287  amrex::Real * AMREX_RESTRICT const amplitude) const;
288 
289 private:
305  void parse_txye_file(std::string txye_file_name);
306 
312  std::pair<int,int> find_left_right_time_indices(amrex::Real t) const;
313 
321  void read_data_t_chuck(int t_begin, int t_end);
322 
327  struct{
329  std::string txye_file_name;
331  bool is_grid_uniform = false;
335  int nt, nx, ny;
360  amrex::Real t_delay = amrex::Real(0.0);
361 
363 
365 };
366 
371 const
372 std::map<
373 std::string,
374 std::function<std::unique_ptr<ILaserProfile>()>
375 >
377 {
378  {"gaussian",
379  [] () {return std::make_unique<GaussianLaserProfile>();} },
380  {"harris",
381  [] () {return std::make_unique<HarrisLaserProfile>();} },
382  {"parse_field_function",
383  [] () {return std::make_unique<FieldFunctionLaserProfile>();} },
384  {"from_txye_file",
385  [] () {return std::make_unique<FromTXYEFileLaserProfile>();} }
386 };
387 
388 } //WarpXLaserProfiles
389 
390 #endif //WARPX_LaserProfiles_H_
#define AMREX_RESTRICT
Definition: LaserProfiles.H:180
struct WarpXLaserProfiles::FieldFunctionLaserProfile::@6 m_params
amrex::Parser m_parser
Definition: LaserProfiles.H:205
void init(const amrex::ParmParse &ppl, CommonLaserParameters params) override final
Definition: LaserProfileFieldFunction.cpp:28
std::string field_function
Definition: LaserProfiles.H:202
void update(amrex::Real) override final
Definition: LaserProfiles.H:190
void fill_amplitude(const int np, amrex::Real const *AMREX_RESTRICT const Xp, amrex::Real const *AMREX_RESTRICT const Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT const amplitude) const override final
Definition: LaserProfileFieldFunction.cpp:39
Definition: LaserProfiles.H:215
void read_data_t_chuck(int t_begin, int t_end)
Load field data within the temporal range [t_begin, t_end)
Definition: LaserProfileFromTXYEFile.cpp:279
void fill_amplitude(const int np, amrex::Real const *AMREX_RESTRICT const Xp, amrex::Real const *AMREX_RESTRICT const Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT const amplitude) const override final
compute field amplitude at particles' position for a laser beam loaded from an E(x,...
Definition: LaserProfileFromTXYEFile.cpp:111
bool is_grid_uniform
Definition: LaserProfiles.H:331
amrex::Real t_delay
Definition: LaserProfiles.H:360
int nt
Definition: LaserProfiles.H:335
void update(amrex::Real t) override final
Reads new field data chunk from file if needed.
Definition: LaserProfileFromTXYEFile.cpp:93
struct WarpXLaserProfiles::FromTXYEFileLaserProfile::@7 m_params
m_params contains all the internal parameters used by this laser profile
amrex::Vector< amrex::Real > h_y_coords
Definition: LaserProfiles.H:348
int first_time_index
Definition: LaserProfiles.H:353
CommonLaserParameters m_common_params
Definition: LaserProfiles.H:364
std::pair< int, int > find_left_right_time_indices(amrex::Real t) const
Finds left and right time indices corresponding to time t.
Definition: LaserProfileFromTXYEFile.cpp:260
int nx
Definition: LaserProfiles.H:335
amrex::Gpu::DeviceVector< amrex::Real > d_y_coords
Definition: LaserProfiles.H:349
int ny
Definition: LaserProfiles.H:335
void internal_fill_amplitude_nonuniform(const int idx_t_left, const int np, amrex::Real const *AMREX_RESTRICT const Xp, amrex::Real const *AMREX_RESTRICT const Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT const amplitude) const
Function to fill the amplitude in case of a non-uniform grid. This function cannot be private due to ...
Definition: LaserProfileFromTXYEFile.cpp:443
amrex::Gpu::DeviceVector< amrex::Real > d_x_coords
Definition: LaserProfiles.H:344
amrex::Vector< amrex::Real > t_coords
Definition: LaserProfiles.H:339
amrex::Gpu::DeviceVector< amrex::Real > E_data
Definition: LaserProfiles.H:357
amrex::Vector< amrex::Real > h_x_coords
Definition: LaserProfiles.H:343
int time_chunk_size
Definition: LaserProfiles.H:351
int last_time_index
Definition: LaserProfiles.H:355
std::string txye_file_name
Definition: LaserProfiles.H:329
void internal_fill_amplitude_uniform(const int idx_t_left, const int np, amrex::Real const *AMREX_RESTRICT const Xp, amrex::Real const *AMREX_RESTRICT const Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT const amplitude) const
Function to fill the amplitude in case of a uniform grid. This function cannot be private due to rest...
Definition: LaserProfileFromTXYEFile.cpp:329
void init(const amrex::ParmParse &ppl, CommonLaserParameters params) override final
Definition: LaserProfileFromTXYEFile.cpp:46
void parse_txye_file(std::string txye_file_name)
parse a field file in the binary 'txye' format (whose details are given below).
Definition: LaserProfileFromTXYEFile.cpp:144
Definition: LaserProfiles.H:104
amrex::Real phi2
Definition: LaserProfiles.H:132
void fill_amplitude(const int np, amrex::Real const *AMREX_RESTRICT const Xp, amrex::Real const *AMREX_RESTRICT const Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT const amplitude) const override final
Definition: LaserProfileGaussian.cpp:99
amrex::Real zeta
Definition: LaserProfiles.H:130
amrex::Real theta_stc
Direction of the spatio-temporal couplings.
Definition: LaserProfiles.H:136
amrex::Real phi0
Definition: LaserProfiles.H:133
amrex::Real focal_distance
Definition: LaserProfiles.H:129
struct WarpXLaserProfiles::GaussianLaserProfile::@4 m_params
amrex::Real t_peak
Definition: LaserProfiles.H:128
amrex::Real duration
Definition: LaserProfiles.H:127
void init(const amrex::ParmParse &ppl, CommonLaserParameters params) override final
Definition: LaserProfileGaussian.cpp:33
CommonLaserParameters m_common_params
Definition: LaserProfiles.H:139
amrex::Real waist
Definition: LaserProfiles.H:126
amrex::Vector< amrex::Real > stc_direction
Definition: LaserProfiles.H:135
void update(amrex::Real) override final
Definition: LaserProfiles.H:114
amrex::Real beta
Definition: LaserProfiles.H:131
Definition: LaserProfiles.H:146
void init(const amrex::ParmParse &ppl, CommonLaserParameters params) override final
Definition: LaserProfileHarris.cpp:23
amrex::Real waist
Definition: LaserProfiles.H:168
void fill_amplitude(const int np, amrex::Real const *AMREX_RESTRICT const Xp, amrex::Real const *AMREX_RESTRICT const Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT const amplitude) const override final
Definition: LaserProfileHarris.cpp:51
CommonLaserParameters m_common_params
Definition: LaserProfiles.H:173
void update(amrex::Real) override final
Definition: LaserProfiles.H:156
amrex::Real focal_distance
Definition: LaserProfiles.H:170
amrex::Real duration
Definition: LaserProfiles.H:169
struct WarpXLaserProfiles::HarrisLaserProfile::@5 m_params
Definition: LaserProfiles.H:50
virtual void update(amrex::Real t)=0
virtual void fill_amplitude(const int np, amrex::Real const *AMREX_RESTRICT const Xp, amrex::Real const *AMREX_RESTRICT const Yp, amrex::Real t, amrex::Real *AMREX_RESTRICT const amplitude) const =0
virtual void init(const amrex::ParmParse &ppl, CommonLaserParameters params)=0
virtual ~ILaserProfile()
Definition: LaserProfiles.H:97
Definition: LaserProfiles.H:24
const std::map< std::string, std::function< std::unique_ptr< ILaserProfile >)>> laser_profiles_dictionary
Definition: LaserProfiles.H:376
Definition: LaserProfiles.H:31
amrex::Real e_max
central wavelength
Definition: LaserProfiles.H:33
amrex::Real wavelength
Definition: LaserProfiles.H:32
amrex::Vector< amrex::Real > p_X
maximum electric field at peak
Definition: LaserProfiles.H:34
amrex::Vector< amrex::Real > nvec
Definition: LaserProfiles.H:35