-
Notifications
You must be signed in to change notification settings - Fork 226
[BG fields] Add refactored TWTS laser #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 19 commits
930ba25
0c25239
e3a13e8
2f5545d
95ceb05
af4a59c
700c164
7ac7597
c1d72e1
d8dd0e8
8c8a8dc
85610ae
0dada63
92d18e6
57c8188
ca2315f
f5066b6
1e03788
e25268e
bafe7f2
7477e0b
954e61e
2aa5941
f22f343
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,225 @@ | ||
| /** | ||
| * Copyright 2014-2015 Axel Huebl, Alexander Debus | ||
| * | ||
| * This file is part of PIConGPU. | ||
| * | ||
| * PIConGPU is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * PIConGPU is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with PIConGPU. | ||
| * If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| /** Load pre-defined templates */ | ||
| #include "fields/background/templates/TWTS/TWTS.hpp" | ||
|
|
||
| #ifndef PARAM_INCLUDE_FIELDBACKGROUND | ||
| #define PARAM_INCLUDE_FIELDBACKGROUND false | ||
| #endif | ||
|
|
||
| /** Load external background fields | ||
| * | ||
| */ | ||
| namespace picongpu | ||
| { | ||
| class FieldBackgroundE | ||
| { | ||
| public: | ||
|
|
||
| /* Add this additional field for pushing particles */ | ||
| static const bool InfluenceParticlePusher = PARAM_INCLUDE_FIELDBACKGROUND; | ||
|
|
||
| /* We use this to calculate your SI input back to our unit system */ | ||
| const float3_64 unitField; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use
or
|
||
|
|
||
| /* TWTS E-fields need to be initialized on host, | ||
| * so they can look up global grid dimensions. */ | ||
| const templates::twts::EField twtsFieldE; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use |
||
|
|
||
| /* Constructor is host-only, because of subGrid and halfSimSize initialization */ | ||
| HINLINE FieldBackgroundE( const float3_64 unitField ) : unitField(unitField), | ||
|
|
||
| twtsFieldE( | ||
| /* focus_y [m], the distance to the laser focus in y-direction */ | ||
| 30.0e-6, | ||
| /* wavelength [m] */ | ||
| 0.8e-6, | ||
| /* pulselength [s], sigma of std. gauss for intensity (E^2) */ | ||
| 10.0e-15 / 2.3548200450309493820231386529194, | ||
| /* w_x [m], cylindrically focused spot size */ | ||
| 5.0e-6, | ||
| /* w_y [m] */ | ||
| 0.01, | ||
| /* interaction angle between TWTS laser propagation vector and the y-axis [rad] */ | ||
| 60. * (PI/180.), | ||
| /* propagation speed of overlap [speed of light]. */ | ||
| 1.0, | ||
| /* manual time delay [s] if auto_tdelay is false */ | ||
| 39.3e-6 / SI::SPEED_OF_LIGHT_SI, | ||
| /* Should PIConGPU automatically choose a suitable time delay? [true/false] */ | ||
| false ) | ||
| {} | ||
|
|
||
| /** Specify your background field E(r,t) here | ||
| * | ||
| * \param cellIdx The total cell id counted from the start at t=0 | ||
| * \param currentStep The current time step */ | ||
| HDINLINE float3_X | ||
| operator()( const DataSpace<simDim>& cellIdx, | ||
| const uint32_t currentStep ) const | ||
| { | ||
| /* example 1: TWTS background pulse */ | ||
| /** unit: meter */ | ||
| const double WAVE_LENGTH_SI = 0.8e-6; | ||
|
|
||
| /** UNITCONV */ | ||
| /* const double UNITCONV_Intens_to_A0 = SI::ELECTRON_CHARGE_SI | ||
| * SI::ELECTRON_CHARGE_SI * 2.0 * WAVE_LENGTH_SI * WAVE_LENGTH_SI / (4.0 * PI * PI | ||
| * SI::ELECTRON_MASS_SI * SI::ELECTRON_MASS_SI * SI::SPEED_OF_LIGHT_SI | ||
| * SI::SPEED_OF_LIGHT_SI * SI::SPEED_OF_LIGHT_SI * SI::SPEED_OF_LIGHT_SI | ||
| * SI::SPEED_OF_LIGHT_SI * SI::EPS0_SI); */ | ||
| const double UNITCONV_A0_to_Amplitude_SI = -2.0 * PI / WAVE_LENGTH_SI | ||
| * SI::ELECTRON_MASS_SI * SI::SPEED_OF_LIGHT_SI | ||
| * SI::SPEED_OF_LIGHT_SI / SI::ELECTRON_CHARGE_SI; | ||
|
|
||
| /** unit: W / m^2 */ | ||
| /* const double _PEAK_INTENSITY_SI = 3.4e19 * 1.0e4; */ | ||
| /** unit: none */ | ||
| /* const double _A0 = _PEAK_INTENSITY_SI * UNITCONV_Intens_to_A0; */ | ||
|
|
||
| /** unit: none */ | ||
| const double _A0 = 1.0; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please do not begin variables with
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also consistent with
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. offline discussion -> post-poned to #739 |
||
|
|
||
| /** unit: Volt /meter */ | ||
| /*\todo #738 implement math::vector, native type operations */ | ||
| const float3_64 invUnitField = float3_64(1.0/unitField[0], | ||
| 1.0/unitField[1], | ||
| 1.0/unitField[2] ); | ||
|
|
||
| /* laser amplitude in picongpu units [ unit: (Volt /meter) / unitField-factor ] | ||
| * Note: the laser amplitude is included in all field components | ||
| * polarization and other properties are established by the peak amplitude | ||
| * normalized twtsFieldE(...) */ | ||
| const float3_X amplitude = precisionCast<float_X>( | ||
| float_64(_A0 * UNITCONV_A0_to_Amplitude_SI) * invUnitField ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the point-wise operation
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should do it (the second cast is not necessary): const float3_X AMPLITUDE_SI = precisionCast<float_X>(
_A0 * UNITCONV_A0_to_Amplitude_SI / unitField );you might have to define
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's what I tried first. Maybe the point-wise
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @psychocoderHPC interesting. is that a problem specific to 64bit vectors or did we intentionally not implement that?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. side note: something is wrong. either the name
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked to the code and see that not all vector/native type operations are implemented. @BeyondEspresso: Please open a issue if you found such things were you need a workarounds to solve a problem. After the issue is opened implement your work around and mark the code part with
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Name was wrong. |
||
|
|
||
| /* Note: twtsFieldE(...) is normalized, such that peak amplitude equals unity. */ | ||
| return amplitude * twtsFieldE( cellIdx, currentStep ); | ||
| } | ||
| }; | ||
|
|
||
| class FieldBackgroundB | ||
| { | ||
| public: | ||
| /* Add this additional field for pushing particles */ | ||
| static const bool InfluenceParticlePusher = PARAM_INCLUDE_FIELDBACKGROUND; | ||
|
|
||
| /* TWTS B-fields need to be initialized on host, | ||
| * so they can look up global grid dimensions. */ | ||
| templates::twts::BField twtsFieldB; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use |
||
|
|
||
| /* We use this to calculate your SI input back to our unit system */ | ||
| const float3_64 unitField; | ||
| HINLINE FieldBackgroundB( const float3_64 unitField ) : unitField(unitField), | ||
|
|
||
| twtsFieldB( | ||
| /* focus_y [m], the distance to the laser focus in y-direction */ | ||
| 30.0e-6, | ||
| /* wavelength [m] */ | ||
| 0.8e-6, | ||
| /* pulselength [s], sigma of std. gauss for intensity (E^2) */ | ||
| 10.0e-15 / 2.3548200450309493820231386529194, | ||
| /* w_x [m], cylindrically focused spot size */ | ||
| 5.0e-6, | ||
| /* w_y [m] */ | ||
| 0.01, | ||
| /* interaction angle between TWTS laser propagation vector and the y-axis [rad] */ | ||
| 60. * (PI/180.), | ||
| /* propagation speed of overlap [speed of light]. */ | ||
| 1.0, | ||
| /* manual time delay [s] if auto_tdelay is false */ | ||
| 39.3e-6 / SI::SPEED_OF_LIGHT_SI, | ||
| /* Should PIConGPU automatically choose a suitable time delay? [true/false] */ | ||
| false ) | ||
| {} | ||
|
|
||
| /** Specify your background field B(r,t) here | ||
| * | ||
| * \param cellIdx The total cell id counted from the start at t=0 | ||
| * \param currentStep The current time step */ | ||
| HDINLINE float3_X | ||
| operator()( const DataSpace<simDim>& cellIdx, | ||
| const uint32_t currentStep ) const | ||
| { | ||
| /** unit: meter */ | ||
| const double WAVE_LENGTH_SI = 0.8e-6; | ||
|
|
||
| /** UNITCONV */ | ||
| /* const double UNITCONV_Intens_to_A0 = SI::ELECTRON_CHARGE_SI | ||
| * SI::ELECTRON_CHARGE_SI * 2.0 * WAVE_LENGTH_SI * WAVE_LENGTH_SI / (4.0 * PI * PI | ||
| * SI::ELECTRON_MASS_SI * SI::ELECTRON_MASS_SI * SI::SPEED_OF_LIGHT_SI | ||
| * SI::SPEED_OF_LIGHT_SI * SI::SPEED_OF_LIGHT_SI * SI::SPEED_OF_LIGHT_SI | ||
| * SI::SPEED_OF_LIGHT_SI * SI::EPS0_SI); */ | ||
| const double UNITCONV_A0_to_Amplitude_SI = -2.0 * PI / WAVE_LENGTH_SI | ||
| * SI::ELECTRON_MASS_SI * SI::SPEED_OF_LIGHT_SI | ||
| * SI::SPEED_OF_LIGHT_SI / SI::ELECTRON_CHARGE_SI; | ||
|
|
||
| /** unit: W / m^2 */ | ||
| /* const double _PEAK_INTENSITY_SI = 3.4e19 * 1.0e4; */ | ||
| /** unit: none */ | ||
| /* const double _A0 = _PEAK_INTENSITY_SI * UNITCONV_Intens_to_A0; */ | ||
|
|
||
| /** unit: none */ | ||
| const double _A0 = 1.0; | ||
|
|
||
| /** unit: Volt /meter */ | ||
| const float3_64 invUnitField = float3_64(1.0/unitField[0], | ||
| 1.0/unitField[1], | ||
| 1.0/unitField[2]); | ||
|
|
||
| /* laser amplitude in picongpu units [ unit: (Volt /meter) / unitField-factor ] | ||
| * Note: the laser amplitude is included in all field components | ||
| * polarization and other properties are established by the peak amplitude | ||
| * normalized twtsFieldB(...) */ | ||
| const float3_X amplitude = precisionCast<float_X>( | ||
| float_64(_A0 * UNITCONV_A0_to_Amplitude_SI) * invUnitField ); | ||
|
|
||
| /* Note: twtsFieldB(...) is normalized, such that peak amplitude equals unity. */ | ||
| return amplitude * twtsFieldB( cellIdx, currentStep ); | ||
| } | ||
| }; | ||
|
|
||
| class FieldBackgroundJ | ||
| { | ||
| public: | ||
| /* Add this additional field? */ | ||
| static const bool activated = false; | ||
|
|
||
| /* We use this to calculate your SI input back to our unit system */ | ||
| const float3_64 unitField; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use |
||
| HDINLINE FieldBackgroundJ( const float3_64 unitField ) : unitField(unitField) | ||
| {} | ||
|
|
||
| /** Specify your background field J(r,t) here | ||
| * | ||
| * \param cellIdx The total cell id counted from the start at t=0 | ||
| * \param currentStep The current time step */ | ||
| HDINLINE float3_X | ||
| operator()( const DataSpace<simDim>& cellIdx, | ||
| const uint32_t currentStep ) const | ||
| { | ||
| return float3_X(0.0, 0.0, 0.0); | ||
| } | ||
| }; | ||
|
|
||
| } /* namespace picongpu */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| /** | ||
| * Copyright 2014-2015 Alexander Debus, Axel Huebl | ||
| * | ||
| * This file is part of PIConGPU. | ||
| * | ||
| * PIConGPU is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * PIConGPU is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with PIConGPU. | ||
| * If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
|
|
||
| #pragma once | ||
|
|
||
| #include "types.h" | ||
|
|
||
| #include "math/Vector.hpp" | ||
| #include "dimensions/DataSpace.hpp" | ||
| #include "fields/background/templates/TWTS/numComponents.hpp" | ||
|
|
||
| namespace picongpu | ||
| { | ||
| /** Load pre-defined background field */ | ||
| namespace templates | ||
| { | ||
| /** Traveling-wave Thomson scattering laser pulse */ | ||
| namespace twts | ||
| { | ||
|
|
||
| class BField | ||
| { | ||
| public: | ||
| typedef float_X float_T; | ||
|
|
||
| /* Center of simulation volume in number of cells */ | ||
| PMACC_ALIGN(halfSimSize,DataSpace<simDim>); | ||
| /* y-position of TWTS coordinate origin inside the simulation coordinates [meter] | ||
| The other origin coordinates (x and z) default to globally centered values | ||
| with respect to the simulation volume. */ | ||
| const PMACC_ALIGN(focus_y_SI,float_64); | ||
| /* Laser wavelength [meter] */ | ||
| const PMACC_ALIGN(wavelength_SI,float_64); | ||
| /* TWTS laser pulse duration [second] */ | ||
| const PMACC_ALIGN(pulselength_SI,float_64); | ||
| /* line focus height of TWTS pulse [meter] */ | ||
| const PMACC_ALIGN(w_x_SI,float_64); | ||
| /* line focus width of TWTS pulse [meter] */ | ||
| const PMACC_ALIGN(w_y_SI,float_64); | ||
| /* interaction angle between TWTS laser propagation vector and the y-axis [rad] */ | ||
| const PMACC_ALIGN(phi,float_X); | ||
| /* propagation speed of TWTS laser overlap | ||
| normalized to the speed of light. [Default: beta0=1.0] */ | ||
| const PMACC_ALIGN(beta_0,float_X); | ||
| /* If auto_tdelay=FALSE, then a user defined delay is used. [second] */ | ||
| const PMACC_ALIGN(tdelay_user_SI,float_64); | ||
| /* Make time step constant accessible to device. */ | ||
| const PMACC_ALIGN(dt,float_64); | ||
| /* Make length normalization constant accessible to device. */ | ||
| const PMACC_ALIGN(unit_length,float_64); | ||
| /* TWTS laser time delay */ | ||
| PMACC_ALIGN(tdelay,float_64); | ||
| /* Should the TWTS laser time delay be chosen automatically, such that | ||
| the laser gradually enters the simulation volume? [Default: TRUE] */ | ||
| const PMACC_ALIGN(auto_tdelay,bool); | ||
|
|
||
| HINLINE | ||
| BField( const float_64 focus_y_SI, | ||
| const float_64 wavelength_SI, | ||
| const float_64 pulselength_SI, | ||
| const float_64 w_x_SI, | ||
| const float_64 w_y_SI, | ||
| const float_X phi = 90.*(PI/180.), | ||
| const float_X beta_0 = 1.0, | ||
| const float_64 tdelay_user_SI = 0.0, | ||
| const bool auto_tdelay = true ); | ||
|
|
||
|
|
||
| /** Specify your background field B(r,t) here | ||
| * | ||
| * \param cellIdx The total cell id counted from the start at t=0 | ||
| * \param currentStep The current time step */ | ||
| HDINLINE float3_X | ||
| operator()( const DataSpace<simDim>& cellIdx, | ||
| const uint32_t currentStep ) const; | ||
|
|
||
| /** Calculate the By(r,t) field here | ||
| * | ||
| * \param pos Spatial position of the target field. | ||
| * \param time Absolute time (SI, including all offsets and transformations) | ||
| * for calculating the field */ | ||
| HDINLINE float_T | ||
| calcTWTSBy( const float3_64& pos, const float_64 time ) const; | ||
|
|
||
| /** Calculate the Bz(r,t) field here | ||
| * | ||
| * \param pos Spatial position of the target field. | ||
| * \param time Absolute time (SI, including all offsets and transformations) | ||
| * for calculating the field */ | ||
| HDINLINE float_T | ||
| calcTWTSBz( const float3_64& pos, const float_64 time ) const; | ||
|
|
||
| /** Calculate the B-field vector of the TWTS laser in SI units. | ||
| * \tparam T_dim Specializes for the simulation dimension | ||
| * \param cellIdx The total cell id counted from the start at timestep 0 | ||
| * \return B-field vector of the rotated TWTS field in SI units */ | ||
| template<unsigned T_dim> | ||
| HDINLINE float3_X | ||
| getTWTSBfield_Normalized( | ||
| const PMacc::math::Vector<floatD_64,detail::numComponents>& eFieldPositions_SI, | ||
| const float_64 time) const; | ||
|
|
||
| }; | ||
|
|
||
| } /* namespace twts */ | ||
| } /* namespace templates */ | ||
| } /* namespace picongpu */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BeyondEspresso you have become a very gentle developer in a steep curve, I like that! Nice and clean. 👍