Skip to content
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

Add laser parameter output for --dump-metadata #4938

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 57 additions & 9 deletions include/picongpu/fields/incidentField/profiles/BaseParam.def
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@ namespace picongpu
Center
};

/** SFINAE deduction if the user parameter define the variable TIME_DELAY_SI
*
* This allows that time delay can be an optional variable a user must only define if needed.
* The default if it is not defined is 0.
* @{
*/
template<typename T, typename = void>
struct GetTimeDelay
{
static constexpr float_X value = 0.0;
};

template<typename T>
struct GetTimeDelay<T, decltype((void) T::TIME_DELAY_SI, void())>
{
static constexpr float_X value = T::TIME_DELAY_SI;
};

namespace profiles
{
/** Base structure for parameters of all lasers
Expand Down Expand Up @@ -190,21 +208,51 @@ namespace picongpu
static constexpr float_64 POLARISATION_DIRECTION_Z = 0.0;
/** @} */

template<typename My = BaseParam>
static std::string originToString(Origin origin)
{
return origin == Origin::Zero ? "zero" : "center";
}

template<typename T_Self = BaseParam>
static nlohmann::json metadata()
{
// We make this a function template in order to gain control over the type we are applying this
// to. A derived class of the BaseParam should similarly make their own `.metadata()` member a
// `template<typename My =Derived>` and should use `BaseParam::metadata<My>()` as a starting
// point for customisation.
// `template<typename T_Self =Derived>` and should use `BaseParam::metadata<T_Self>()` as a
// starting point for customisation.

auto result = nlohmann::json::object();
result["polarisation"]["direction"] = vector<float_64>{
{My::POLARISATION_DIRECTION_X,
My::POLARISATION_DIRECTION_Y,
My::POLARISATION_DIRECTION_Z}};
result["polarisation"]["type"]
= My::Polarisation == PolarisationType::Linear ? "linear" : "circular";

result["wavelength"] = {{"value", T_Self::WAVE_LENGTH_SI}, {"unit", "m"}};
result["amplitude"] = {{"value", T_Self::AMPLITUDE_SI}, {"unit", "V/m"}};
result["pulse_duration"] = {{"value", T_Self::PULSE_DURATION_SI}, {"unit", "s"}};
result["laser_phase"] = {{"value", T_Self::LASER_PHASE}, {"unit", "rad"}};
result["direction"]
= {{"value",
vector<float_64>{{T_Self::DIRECTION_X, T_Self::DIRECTION_Y, T_Self::DIRECTION_Z}}},
{"unit", "none"}};
result["focus_position"]
= {{"value",
vector<float_64>{
{T_Self::FOCUS_POSITION_X_SI,
T_Self::FOCUS_POSITION_Y_SI,
T_Self::FOCUS_POSITION_Z_SI}}},
{"unit", "m"}};
result["focus_origin"]
= {{"type",
vector<std::string>{
originToString(T_Self::FOCUS_ORIGIN_X),
originToString(T_Self::FOCUS_ORIGIN_Y),
originToString(T_Self::FOCUS_ORIGIN_Z)}}};
result["time_delay"] = {{"value", GetTimeDelay<T_Self>::value}, {"unit", "s"}};
result["polarisation"]
= {{"direction",
vector<float_64>{
{T_Self::POLARISATION_DIRECTION_X,
T_Self::POLARISATION_DIRECTION_Y,
T_Self::POLARISATION_DIRECTION_Z}}},
{"type", T_Self::Polarisation == PolarisationType::Linear ? "linear" : "circular"}};

return result;
}
};
Expand Down
18 changes: 0 additions & 18 deletions include/picongpu/fields/incidentField/profiles/BaseParam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,6 @@ namespace picongpu
return 0.0;
}

/** SFINAE deduction if the user parameter define the variable TIME_DELAY_SI
*
* This allows that time delay can be an optional variable a user must only define if needed.
* The default if it is not defined is 0.
* @{
*/
template<typename T, typename = void>
struct GetTimeDelay
{
static constexpr float_X value = 0.0;
};

template<typename T>
struct GetTimeDelay<T, decltype((void) T::TIME_DELAY_SI, void())>
{
static constexpr float_X value = T::TIME_DELAY_SI;
};

public:
/** Time delay
*
Expand Down
28 changes: 22 additions & 6 deletions include/picongpu/fields/incidentField/profiles/GaussianPulse.def
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright 2013-2024 Axel Huebl, Heiko Burau, Anton Helm, Rene Widera,
* Richard Pausch, Alexander Debus, Sergei Bastrakov,
Julian Lenz
/* Copyright 2013-2024 Axel Huebl, Heiko Burau, Anton Helm,
* Rene Widera, Richard Pausch, Alexander Debus,
* Sergei Bastrakov, Julian Lenz
*
* This file is part of PIConGPU.
*
Expand All @@ -25,7 +25,6 @@

#include <nlohmann/json.hpp>


namespace picongpu::fields::incidentField::profiles
{
namespace defaults
Expand Down Expand Up @@ -76,8 +75,25 @@ namespace picongpu::fields::incidentField::profiles
{
auto baseMetadata = BaseParam::metadata<My>();
auto gaussianMetadata = nlohmann::json::object();
gaussianMetadata["W0"] = W0_SI;
gaussianMetadata["PULSE_INIT"] = PULSE_INIT;

// Adding units to Gaussian-specific parameters
gaussianMetadata["W0"] = {{"value", My::W0_SI}, {"unit", "m"}};
gaussianMetadata["PULSE_INIT"] = {{"value", My::PULSE_INIT}, {"unit", "none"}};
gaussianMetadata["Mode number"] = {{"value", My::numModes}, {"unit", "none"}};

// Adding Laguerre modes and phases
nlohmann::json laguerreModesJson = nlohmann::json::array();
nlohmann::json laguerrePhasesJson = nlohmann::json::array();

for(uint32_t i = 0; i <= numModes; ++i)
{
laguerreModesJson.push_back(laguerreModes[i]);
laguerrePhasesJson.push_back(laguerrePhases[i]);
}

gaussianMetadata["Laguerre modes"] = {{"value", laguerreModesJson}, {"unit", "none"}};
gaussianMetadata["Laguerre phases"] = {{"value", laguerrePhasesJson}, {"unit", "none"}};

baseMetadata["Gaussian parameters"] = gaussianMetadata;
return baseMetadata;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,6 @@ namespace picongpu
static constexpr float_64 POLARISATION_DIRECTION_Y = 0.0;
static constexpr float_64 POLARISATION_DIRECTION_Z = 0.0;
/** @} */

template<typename My = LwfaGaussianPulseBaseParams>
static auto metadata()
{
// static member functions do not bind to the derived type when inherited, so we have to refer to
// our type explicitly
return profiles::BaseParam::metadata<My>();
};
};

/** Special structure for parameters of Gaussian laser pulses.
Expand Down Expand Up @@ -250,6 +242,14 @@ namespace picongpu
static constexpr auto laguerreModes = floatN_X<numModes + 1>(1.0);
static constexpr auto laguerrePhases = floatN_X<numModes + 1>(0.0);
/** @} */

template<typename T_Self = GaussianPulseParam>
static auto metadata()
{
// static member functions do not bind to the derived type when inherited, so we have to refer to
// our type explicitly
return profiles::defaults::GaussianPulseParam::metadata<T_Self>();
};
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,82 @@
],
"YMin": [
{
"Gaussian parameters": {
"Laguerre modes": {
"unit": "none",
"value": [
1.0
]
},
"Laguerre phases": {
"unit": "none",
"value": [
0.0
]
},
"Mode number": {
"unit": "none",
"value": 0
},
"PULSE_INIT": {
"unit": "none",
"value": 15.0
},
"W0": {
"unit": "m",
"value": 4.246609082647506e-06
}
},
"amplitude": {
"unit": "V/m",
"value": 32107010989706.094
},
"direction": {
"unit": "none",
"value": [
0.0,
1.0,
0.0
]
},
"focus_origin": {
"type": [
"center",
"zero",
"center"
]
},
"focus_position": {
"unit": "m",
"value": [
0.0,
4.62e-05,
0.0
]
},
"laser_phase": {
"unit": "rad",
"value": 0.0
},
"polarisation": {
"direction": [
1.0,
0.0,
0.0
],
"type": "circular"
},
"pulse_duration": {
"unit": "s",
"value": 5e-15
},
"time_delay": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The time delay was actually outputted correctly for my LWFA test - strange

"unit": "s",
"value": 0.0
},
"wavelength": {
"unit": "m",
"value": 8e-07
}
}
],
Expand Down