Skip to content

Commit 6469715

Browse files
committed
Merge pull request ComputationalRadiationPhysics#852 from BeyondEspresso/topic-update-TWTS-polarization-BeyondEspresso
[BG fields] Add in-plane polarization to TWTS laser
2 parents 0c54095 + d099ca5 commit 6469715

File tree

5 files changed

+626
-129
lines changed

5 files changed

+626
-129
lines changed

examples/Bunch/include/simulation_defines/param/fieldBackground.param

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,26 @@ namespace picongpu
3535
class FieldBackgroundE
3636
{
3737
public:
38-
38+
3939
/* Add this additional field for pushing particles */
4040
static const bool InfluenceParticlePusher = PARAM_INCLUDE_FIELDBACKGROUND;
4141

4242
/* We use this to calculate your SI input back to our unit system */
4343
PMACC_ALIGN(unitField, const float3_64);
4444

4545
/* TWTS E-fields need to be initialized on host,
46-
* so they can look up global grid dimensions. */
47-
PMACC_ALIGN(twtsFieldE, const templates::twts::EField);
48-
46+
* so they can look up global grid dimensions.
47+
*
48+
* Note: No PMACC_ALIGN(...) used, since this *additional* memory alignment would require
49+
* roughly double the number of registers in the corresponding kernel on the device.
50+
*/
51+
const templates::twts::EField twtsFieldE;
52+
4953
/* Constructor is host-only, because of subGrid and halfSimSize initialization */
50-
HINLINE FieldBackgroundE( const float3_64 unitField ) : unitField(unitField),
51-
54+
HINLINE FieldBackgroundE( const float3_64 unitField ) :
55+
56+
unitField(unitField),
57+
5258
twtsFieldE(
5359
/* focus_y [m], the distance to the laser focus in y-direction */
5460
30.0e-6,
@@ -78,10 +84,9 @@ namespace picongpu
7884
operator()( const DataSpace<simDim>& cellIdx,
7985
const uint32_t currentStep ) const
8086
{
81-
/* example 1: TWTS background pulse */
82-
/** unit: meter */
87+
/* unit: meter */
8388
const double WAVE_LENGTH_SI = 0.8e-6;
84-
89+
8590
/** UNITCONV */
8691
/* const double UNITCONV_Intens_to_A0 = SI::ELECTRON_CHARGE_SI
8792
* SI::ELECTRON_CHARGE_SI * 2.0 * WAVE_LENGTH_SI * WAVE_LENGTH_SI / (4.0 * PI * PI
@@ -92,24 +97,27 @@ namespace picongpu
9297
* SI::ELECTRON_MASS_SI * SI::SPEED_OF_LIGHT_SI
9398
* SI::SPEED_OF_LIGHT_SI / SI::ELECTRON_CHARGE_SI;
9499

95-
/** unit: W / m^2 */
96-
/* const double _PEAK_INTENSITY_SI = 3.4e19 * 1.0e4; */
97-
/** unit: none */
98-
/* const double _A0 = _PEAK_INTENSITY_SI * UNITCONV_Intens_to_A0; */
100+
/* unit: W / m^2
101+
* const double _PEAK_INTENSITY_SI = 3.4e19 * 1.0e4;
102+
* unit: none
103+
* const double _A0 = _PEAK_INTENSITY_SI * UNITCONV_Intens_to_A0;
104+
*/
99105

100-
/** unit: none */
106+
/* unit: none */
101107
const double _A0 = 1.0;
102108

103-
/** unit: Volt /meter */
104-
/*\todo #738 implement math::vector, native type operations */
109+
/* unit: Volt /meter
110+
*\todo #738 implement math::vector, native type operations
111+
*/
105112
const float3_64 invUnitField = float3_64(1.0 / unitField[0],
106113
1.0 / unitField[1],
107114
1.0 / unitField[2] );
108-
115+
109116
/* laser amplitude in picongpu units [ unit: (Volt /meter) / unitField-factor ]
110-
* Note: the laser amplitude is included in all field components
117+
* Note: the laser amplitude is included in all field components
111118
* polarization and other properties are established by the peak amplitude
112-
* normalized twtsFieldE(...) */
119+
* normalized twtsFieldE(...)
120+
*/
113121
const float3_X amplitude = precisionCast<float_X>(
114122
float_64(_A0 * UNITCONV_A0_to_Amplitude_SI) * invUnitField );
115123

@@ -125,14 +133,20 @@ namespace picongpu
125133
static const bool InfluenceParticlePusher = PARAM_INCLUDE_FIELDBACKGROUND;
126134

127135
/* TWTS B-fields need to be initialized on host,
128-
* so they can look up global grid dimensions. */
129-
PMACC_ALIGN(twtsFieldB, const templates::twts::BField);
130-
136+
* so they can look up global grid dimensions.
137+
*
138+
* Note: No PMACC_ALIGN(...) used, since this *additional* memory alignment would require
139+
* roughly double the number of registers in the corresponding kernel on the device.
140+
*/
141+
const templates::twts::BField twtsFieldB;
142+
131143
/* We use this to calculate your SI input back to our unit system */
132144
PMACC_ALIGN(unitField, const float3_64);
133-
134-
HINLINE FieldBackgroundB( const float3_64 unitField ) : unitField(unitField),
135-
145+
146+
HINLINE FieldBackgroundB( const float3_64 unitField ) :
147+
148+
unitField(unitField),
149+
136150
twtsFieldB(
137151
/* focus_y [m], the distance to the laser focus in y-direction */
138152
30.0e-6,
@@ -162,9 +176,9 @@ namespace picongpu
162176
operator()( const DataSpace<simDim>& cellIdx,
163177
const uint32_t currentStep ) const
164178
{
165-
/** unit: meter */
179+
/* unit: meter */
166180
const double WAVE_LENGTH_SI = 0.8e-6;
167-
181+
168182
/** UNITCONV */
169183
/* const double UNITCONV_Intens_to_A0 = SI::ELECTRON_CHARGE_SI
170184
* SI::ELECTRON_CHARGE_SI * 2.0 * WAVE_LENGTH_SI * WAVE_LENGTH_SI / (4.0 * PI * PI
@@ -175,10 +189,11 @@ namespace picongpu
175189
* SI::ELECTRON_MASS_SI * SI::SPEED_OF_LIGHT_SI
176190
* SI::SPEED_OF_LIGHT_SI / SI::ELECTRON_CHARGE_SI;
177191

178-
/** unit: W / m^2 */
179-
/* const double _PEAK_INTENSITY_SI = 3.4e19 * 1.0e4; */
180-
/** unit: none */
181-
/* const double _A0 = _PEAK_INTENSITY_SI * UNITCONV_Intens_to_A0; */
192+
/* unit: W / m^2
193+
* const double _PEAK_INTENSITY_SI = 3.4e19 * 1.0e4;
194+
* unit: none
195+
* const double _A0 = _PEAK_INTENSITY_SI * UNITCONV_Intens_to_A0;
196+
*/
182197

183198
/** unit: none */
184199
const double _A0 = 1.0;
@@ -187,14 +202,15 @@ namespace picongpu
187202
const float3_64 invUnitField = float3_64( 1.0 / unitField[0],
188203
1.0 / unitField[1],
189204
1.0 / unitField[2] );
190-
205+
191206
/* laser amplitude in picongpu units [ unit: (Volt/meter) / unitField-factor ]
192-
* Note: the laser amplitude is included in all field components
207+
* Note: the laser amplitude is included in all field components
193208
* polarization and other properties are established by the peak amplitude
194-
* normalized twtsFieldB(...) */
209+
* normalized twtsFieldB(...)
210+
*/
195211
const float3_X amplitude = precisionCast<float_X>(
196212
float_64(_A0 * UNITCONV_A0_to_Amplitude_SI) * invUnitField );
197-
213+
198214
/* Note: twtsFieldB(...) is normalized, such that peak amplitude equals unity. */
199215
return amplitude * twtsFieldB( cellIdx, currentStep );
200216
}
@@ -208,7 +224,7 @@ namespace picongpu
208224

209225
/* We use this to calculate your SI input back to our unit system */
210226
PMACC_ALIGN(unitField, const float3_64);
211-
227+
212228
HDINLINE FieldBackgroundJ( const float3_64 unitField ) : unitField(unitField)
213229
{}
214230

src/picongpu/include/fields/background/templates/TWTS/BField.hpp

Lines changed: 67 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,39 @@
2929

3030
namespace picongpu
3131
{
32-
/** Load pre-defined background field */
32+
/* Load pre-defined background field */
3333
namespace templates
3434
{
35-
/** Traveling-wave Thomson scattering laser pulse */
35+
/* Traveling-wave Thomson scattering laser pulse */
3636
namespace twts
3737
{
3838

3939
class BField
4040
{
4141
public:
4242
typedef float_X float_T;
43-
43+
44+
enum PolarizationType
45+
{
46+
/* The linear polarization of the TWTS laser is defined
47+
* relative to the plane of the pulse front tilt (reference plane).
48+
*
49+
* Polarisation is normal to the reference plane.
50+
* Use Ex-fields (and corresponding B-fields) in TWTS laser internal coordinate system.
51+
*/
52+
LINEAR_X = 1u,
53+
/* Polarization lies within the reference plane.
54+
* Use Ey-fields (and corresponding B-fields) in TWTS laser internal coordinate system.
55+
*/
56+
LINEAR_YZ = 2u,
57+
};
58+
4459
/* Center of simulation volume in number of cells */
4560
PMACC_ALIGN(halfSimSize,DataSpace<simDim>);
4661
/* y-position of TWTS coordinate origin inside the simulation coordinates [meter]
47-
The other origin coordinates (x and z) default to globally centered values
48-
with respect to the simulation volume. */
62+
* The other origin coordinates (x and z) default to globally centered values
63+
* with respect to the simulation volume.
64+
*/
4965
const PMACC_ALIGN(focus_y_SI,float_64);
5066
/* Laser wavelength [meter] */
5167
const PMACC_ALIGN(wavelength_SI,float_64);
@@ -69,14 +85,17 @@ class BField
6985
/* TWTS laser time delay */
7086
PMACC_ALIGN(tdelay,float_64);
7187
/* Should the TWTS laser time delay be chosen automatically, such that
72-
the laser gradually enters the simulation volume? [Default: TRUE] */
88+
* the laser gradually enters the simulation volume? [Default: TRUE]
89+
*/
7390
const PMACC_ALIGN(auto_tdelay,bool);
74-
91+
/* Polarization of TWTS laser */
92+
const PMACC_ALIGN(pol,PolarizationType);
93+
7594
/** Magnetic field of the TWTS laser
7695
*
7796
* \param focus_y_SI the distance to the laser focus in y-direction [m]
7897
* \param wavelength_SI central wavelength [m]
79-
* \param pulselength_SI sigma of std. gauss for intensity (E^2),
98+
* \param pulselength_SI sigma of std. gauss for intensity (E^2),
8099
* pulselength_SI = FWHM_of_Intensity / 2.35482 [seconds (sigma)]
81100
* \param w_x beam waist: distance from the axis where the pulse electric field
82101
* decreases to its 1/e^2-th part at the focus position of the laser [m]
@@ -88,6 +107,8 @@ class BField
88107
* \param tdelay_user manual time delay if auto_tdelay is false
89108
* \param auto_tdelay calculate the time delay such that the TWTS pulse is not
90109
* inside the simulation volume at simulation start timestep = 0 [default = true]
110+
* \param pol determines the TWTS laser polarization, which is either normal or parallel
111+
* to the laser pulse front tilt plane [ default= LINEAR_X , LINEAR_YZ ]
91112
*/
92113
HINLINE
93114
BField( const float_64 focus_y_SI,
@@ -98,9 +119,10 @@ class BField
98119
const float_X phi = 90.*(PI / 180.),
99120
const float_X beta_0 = 1.0,
100121
const float_64 tdelay_user_SI = 0.0,
101-
const bool auto_tdelay = true );
102-
103-
122+
const bool auto_tdelay = true,
123+
const PolarizationType pol = LINEAR_X );
124+
125+
104126
/** Specify your background field B(r,t) here
105127
*
106128
* \param cellIdx The total cell id counted from the start at t=0
@@ -109,21 +131,41 @@ class BField
109131
operator()( const DataSpace<simDim>& cellIdx,
110132
const uint32_t currentStep ) const;
111133

112-
/** Calculate the By(r,t) field here
134+
/** Calculate the By(r,t) field, when electric field vector (Ex,0,0)
135+
* is normal to the pulse-front-tilt plane (y,z)
113136
*
114137
* \param pos Spatial position of the target field.
115138
* \param time Absolute time (SI, including all offsets and transformations)
116139
* for calculating the field */
117140
HDINLINE float_T
118141
calcTWTSBy( const float3_64& pos, const float_64 time ) const;
119142

120-
/** Calculate the Bz(r,t) field here
143+
/** Calculate the Bz(r,t) field, when electric field vector (Ex,0,0)
144+
* is normal to the pulse-front-tilt plane (y,z)
145+
*
146+
* \param pos Spatial position of the target field.
147+
* \param time Absolute time (SI, including all offsets and transformations)
148+
* for calculating the field */
149+
HDINLINE float_T
150+
calcTWTSBz_Ex( const float3_64& pos, const float_64 time ) const;
151+
152+
/** Calculate the By(r,t) field, when electric field vector (0,Ey,0)
153+
* lies within the pulse-front-tilt plane (y,z)
154+
*
155+
* \param pos Spatial position of the target field.
156+
* \param time Absolute time (SI, including all offsets and transformations)
157+
* for calculating the field */
158+
HDINLINE float_T
159+
calcTWTSBx( const float3_64& pos, const float_64 time ) const;
160+
161+
/** Calculate the Bz(r,t) field here (electric field vector (0,Ey,0)
162+
* lies within the pulse-front-tilt plane (y,z)
121163
*
122164
* \param pos Spatial position of the target field.
123165
* \param time Absolute time (SI, including all offsets and transformations)
124166
* for calculating the field */
125167
HDINLINE float_T
126-
calcTWTSBz( const float3_64& pos, const float_64 time ) const;
168+
calcTWTSBz_Ey( const float3_64& pos, const float_64 time ) const;
127169

128170
/** Calculate the B-field vector of the TWTS laser in SI units.
129171
* \tparam T_dim Specializes for the simulation dimension
@@ -134,7 +176,17 @@ class BField
134176
getTWTSBfield_Normalized(
135177
const PMacc::math::Vector<floatD_64,detail::numComponents>& eFieldPositions_SI,
136178
const float_64 time) const;
137-
179+
180+
/** Calculate the B-field vector of the "in-plane" polarized TWTS laser in SI units.
181+
* \tparam T_dim Specializes for the simulation dimension
182+
* \param cellIdx The total cell id counted from the start at timestep 0
183+
* \return B-field vector of the rotated TWTS field in SI units */
184+
template<unsigned T_dim>
185+
HDINLINE float3_X
186+
getTWTSBfield_Normalized_Ey(
187+
const PMacc::math::Vector<floatD_64,detail::numComponents>& eFieldPositions_SI,
188+
const float_64 time) const;
189+
138190
};
139191

140192
} /* namespace twts */

0 commit comments

Comments
 (0)