From 84d56f5ef6efde3b50113fa580e8010f30e9e796 Mon Sep 17 00:00:00 2001 From: Max Lehmann Date: Wed, 29 May 2024 09:49:06 +0200 Subject: [PATCH 1/6] add laser metadata dump routine to Gauss laser --- .../incidentField/profiles/BaseParam.def | 39 ++++++++++++++++--- .../incidentField/profiles/GaussianPulse.def | 28 ++++++++++--- 2 files changed, 55 insertions(+), 12 deletions(-) diff --git a/include/picongpu/fields/incidentField/profiles/BaseParam.def b/include/picongpu/fields/incidentField/profiles/BaseParam.def index 1edff6533d..5a158660d5 100644 --- a/include/picongpu/fields/incidentField/profiles/BaseParam.def +++ b/include/picongpu/fields/incidentField/profiles/BaseParam.def @@ -190,6 +190,11 @@ namespace picongpu static constexpr float_64 POLARISATION_DIRECTION_Z = 0.0; /** @} */ + static std::string originToString(Origin origin) + { + return origin == Origin::Zero ? "zero" : "center"; + } + template static nlohmann::json metadata() { @@ -199,12 +204,34 @@ namespace picongpu // point for customisation. auto result = nlohmann::json::object(); - result["polarisation"]["direction"] = vector{ - {My::POLARISATION_DIRECTION_X, - My::POLARISATION_DIRECTION_Y, - My::POLARISATION_DIRECTION_Z}}; - result["polarisation"]["type"] - = My::Polarisation == PolarisationType::Linear ? "linear" : "circular"; + + result["wavelength"] = {{"value", My::WAVE_LENGTH_SI}, {"unit", "m"}}; + result["amplitude"] = {{"value", My::AMPLITUDE_SI}, {"unit", "V/m"}}; + result["pulse_duration"] = {{"value", My::PULSE_DURATION_SI}, {"unit", "s"}}; + result["laser_phase"] = {{"value", My::LASER_PHASE}, {"unit", "rad"}}; + result["direction"] + = {{"value", vector{{My::DIRECTION_X, My::DIRECTION_Y, My::DIRECTION_Z}}}, + {"unit", "none"}}; + result["focus_position"] + = {{"value", + vector{ + {My::FOCUS_POSITION_X_SI, My::FOCUS_POSITION_Y_SI, My::FOCUS_POSITION_Z_SI}}}, + {"unit", "m"}}; + result["focus_origin"] + = {{"type", + vector{ + originToString(My::FOCUS_ORIGIN_X), + originToString(My::FOCUS_ORIGIN_Y), + originToString(My::FOCUS_ORIGIN_Z)}}}; + result["time_delay"] = {{"value", My::TIME_DELAY_SI}, {"unit", "s"}}; + result["polarisation"] + = {{"direction", + vector{ + {My::POLARISATION_DIRECTION_X, + My::POLARISATION_DIRECTION_Y, + My::POLARISATION_DIRECTION_Z}}}, + {"type", My::Polarisation == PolarisationType::Linear ? "linear" : "circular"}}; + return result; } }; diff --git a/include/picongpu/fields/incidentField/profiles/GaussianPulse.def b/include/picongpu/fields/incidentField/profiles/GaussianPulse.def index 4c25ec4799..56db1a698f 100644 --- a/include/picongpu/fields/incidentField/profiles/GaussianPulse.def +++ b/include/picongpu/fields/incidentField/profiles/GaussianPulse.def @@ -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. * @@ -25,7 +25,6 @@ #include - namespace picongpu::fields::incidentField::profiles { namespace defaults @@ -76,8 +75,25 @@ namespace picongpu::fields::incidentField::profiles { auto baseMetadata = BaseParam::metadata(); 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::MODENUMBER}, {"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 <= MODENUMBER; ++i) + { + laguerreModesJson.push_back(LAGUERREMODES_t{}[i]); + laguerrePhasesJson.push_back(LAGUERREPHASES_t{}[i]); + } + + gaussianMetadata["Laguerre modes"] = {{"value", laguerreModesJson}, {"unit", "none"}}; + gaussianMetadata["Laguerre phases"] = {{"value", laguerrePhasesJson}, {"unit", "none"}}; + baseMetadata["Gaussian parameters"] = gaussianMetadata; return baseMetadata; } From 7af3fbf024d980f30ea909aa06c56ab3593ff362 Mon Sep 17 00:00:00 2001 From: Max Lehmann Date: Wed, 26 Jun 2024 10:32:54 +0200 Subject: [PATCH 2/6] updated the picongpu-metadata.json.reference --- .../picongpu-metadata.json.reference | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/share/picongpu/tests/metadataFromLaserWakefield/picongpu-metadata.json.reference b/share/picongpu/tests/metadataFromLaserWakefield/picongpu-metadata.json.reference index 2b08863c81..de150c3feb 100644 --- a/share/picongpu/tests/metadataFromLaserWakefield/picongpu-metadata.json.reference +++ b/share/picongpu/tests/metadataFromLaserWakefield/picongpu-metadata.json.reference @@ -11,6 +11,37 @@ ], "YMin": [ { + "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, @@ -18,6 +49,18 @@ 0.0 ], "type": "circular" + }, + "pulse_duration": { + "unit": "s", + "value": 5e-15 + }, + "time_delay": { + "unit": "s", + "value": 0.0 + }, + "wavelength": { + "unit": "m", + "value": 8e-07 } } ], From ac475371b8b0ee16469936aa5725fccbde6bd824 Mon Sep 17 00:00:00 2001 From: PrometheusPi Date: Wed, 25 Sep 2024 15:11:52 +0200 Subject: [PATCH 3/6] update laser metadata dumper to new data structure --- .../fields/incidentField/profiles/GaussianPulse.def | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/picongpu/fields/incidentField/profiles/GaussianPulse.def b/include/picongpu/fields/incidentField/profiles/GaussianPulse.def index 56db1a698f..b89fa200e2 100644 --- a/include/picongpu/fields/incidentField/profiles/GaussianPulse.def +++ b/include/picongpu/fields/incidentField/profiles/GaussianPulse.def @@ -79,16 +79,16 @@ namespace picongpu::fields::incidentField::profiles // 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::MODENUMBER}, {"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 <= MODENUMBER; ++i) + for(uint32_t i = 0; i <= numModes; ++i) { - laguerreModesJson.push_back(LAGUERREMODES_t{}[i]); - laguerrePhasesJson.push_back(LAGUERREPHASES_t{}[i]); + laguerreModesJson.push_back(laguerreModes[i]); + laguerrePhasesJson.push_back(laguerrePhases[i]); } gaussianMetadata["Laguerre modes"] = {{"value", laguerreModesJson}, {"unit", "none"}}; From 11d4e41ae543e86716f09621564a5007eae5a6b9 Mon Sep 17 00:00:00 2001 From: PrometheusPi Date: Thu, 26 Sep 2024 13:23:51 +0200 Subject: [PATCH 4/6] update test for metadata dumper --- .../picongpu/param/incidentField.param | 16 ++++++------ .../picongpu-metadata.json.reference | 26 +++++++++++++++++++ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/share/picongpu/examples/LaserWakefield/include/picongpu/param/incidentField.param b/share/picongpu/examples/LaserWakefield/include/picongpu/param/incidentField.param index e9f17acd06..023cfdb38b 100644 --- a/share/picongpu/examples/LaserWakefield/include/picongpu/param/incidentField.param +++ b/share/picongpu/examples/LaserWakefield/include/picongpu/param/incidentField.param @@ -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 - 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(); - }; }; /** Special structure for parameters of Gaussian laser pulses. @@ -250,6 +242,14 @@ namespace picongpu static constexpr auto laguerreModes = floatN_X(1.0); static constexpr auto laguerrePhases = floatN_X(0.0); /** @} */ + + template + 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(); + }; }; diff --git a/share/picongpu/tests/metadataFromLaserWakefield/picongpu-metadata.json.reference b/share/picongpu/tests/metadataFromLaserWakefield/picongpu-metadata.json.reference index de150c3feb..7a20d1b21e 100644 --- a/share/picongpu/tests/metadataFromLaserWakefield/picongpu-metadata.json.reference +++ b/share/picongpu/tests/metadataFromLaserWakefield/picongpu-metadata.json.reference @@ -11,6 +11,32 @@ ], "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 From 7e6d09c3f943bfc1551f65e0f36371ec1ddce389 Mon Sep 17 00:00:00 2001 From: Richard Pausch Date: Fri, 27 Sep 2024 10:46:32 +0200 Subject: [PATCH 5/6] move getTimeDelay from hpp to def --- .../incidentField/profiles/BaseParam.def | 21 ++++++++++++++++++- .../incidentField/profiles/BaseParam.hpp | 18 ---------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/include/picongpu/fields/incidentField/profiles/BaseParam.def b/include/picongpu/fields/incidentField/profiles/BaseParam.def index 5a158660d5..6701758a76 100644 --- a/include/picongpu/fields/incidentField/profiles/BaseParam.def +++ b/include/picongpu/fields/incidentField/profiles/BaseParam.def @@ -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 + struct GetTimeDelay + { + static constexpr float_X value = 0.0; + }; + + template + struct GetTimeDelay + { + static constexpr float_X value = T::TIME_DELAY_SI; + }; + namespace profiles { /** Base structure for parameters of all lasers @@ -220,10 +238,11 @@ namespace picongpu result["focus_origin"] = {{"type", vector{ + originToString(My::FOCUS_ORIGIN_X), originToString(My::FOCUS_ORIGIN_Y), originToString(My::FOCUS_ORIGIN_Z)}}}; - result["time_delay"] = {{"value", My::TIME_DELAY_SI}, {"unit", "s"}}; + result["time_delay"] = {{"value", GetTimeDelay::value}, {"unit", "s"}}; result["polarisation"] = {{"direction", vector{ diff --git a/include/picongpu/fields/incidentField/profiles/BaseParam.hpp b/include/picongpu/fields/incidentField/profiles/BaseParam.hpp index 2d41d43b10..71b83fea38 100644 --- a/include/picongpu/fields/incidentField/profiles/BaseParam.hpp +++ b/include/picongpu/fields/incidentField/profiles/BaseParam.hpp @@ -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 - struct GetTimeDelay - { - static constexpr float_X value = 0.0; - }; - - template - struct GetTimeDelay - { - static constexpr float_X value = T::TIME_DELAY_SI; - }; - public: /** Time delay * From 7132138f71bc44a98bdde565ba5247339834e691 Mon Sep 17 00:00:00 2001 From: Richard Pausch Date: Fri, 27 Sep 2024 10:52:11 +0200 Subject: [PATCH 6/6] rename temeplate argument from My to T_Self --- .../incidentField/profiles/BaseParam.def | 38 ++++++++++--------- .../picongpu/param/incidentField.param | 4 +- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/include/picongpu/fields/incidentField/profiles/BaseParam.def b/include/picongpu/fields/incidentField/profiles/BaseParam.def index 6701758a76..f273373ac2 100644 --- a/include/picongpu/fields/incidentField/profiles/BaseParam.def +++ b/include/picongpu/fields/incidentField/profiles/BaseParam.def @@ -213,43 +213,45 @@ namespace picongpu return origin == Origin::Zero ? "zero" : "center"; } - template + template 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` and should use `BaseParam::metadata()` as a starting - // point for customisation. + // `template` and should use `BaseParam::metadata()` as a + // starting point for customisation. auto result = nlohmann::json::object(); - result["wavelength"] = {{"value", My::WAVE_LENGTH_SI}, {"unit", "m"}}; - result["amplitude"] = {{"value", My::AMPLITUDE_SI}, {"unit", "V/m"}}; - result["pulse_duration"] = {{"value", My::PULSE_DURATION_SI}, {"unit", "s"}}; - result["laser_phase"] = {{"value", My::LASER_PHASE}, {"unit", "rad"}}; + 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{{My::DIRECTION_X, My::DIRECTION_Y, My::DIRECTION_Z}}}, + = {{"value", + vector{{T_Self::DIRECTION_X, T_Self::DIRECTION_Y, T_Self::DIRECTION_Z}}}, {"unit", "none"}}; result["focus_position"] = {{"value", vector{ - {My::FOCUS_POSITION_X_SI, My::FOCUS_POSITION_Y_SI, My::FOCUS_POSITION_Z_SI}}}, + {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{ - - originToString(My::FOCUS_ORIGIN_X), - originToString(My::FOCUS_ORIGIN_Y), - originToString(My::FOCUS_ORIGIN_Z)}}}; - result["time_delay"] = {{"value", GetTimeDelay::value}, {"unit", "s"}}; + originToString(T_Self::FOCUS_ORIGIN_X), + originToString(T_Self::FOCUS_ORIGIN_Y), + originToString(T_Self::FOCUS_ORIGIN_Z)}}}; + result["time_delay"] = {{"value", GetTimeDelay::value}, {"unit", "s"}}; result["polarisation"] = {{"direction", vector{ - {My::POLARISATION_DIRECTION_X, - My::POLARISATION_DIRECTION_Y, - My::POLARISATION_DIRECTION_Z}}}, - {"type", My::Polarisation == PolarisationType::Linear ? "linear" : "circular"}}; + {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; } diff --git a/share/picongpu/examples/LaserWakefield/include/picongpu/param/incidentField.param b/share/picongpu/examples/LaserWakefield/include/picongpu/param/incidentField.param index 023cfdb38b..4ad08dbb86 100644 --- a/share/picongpu/examples/LaserWakefield/include/picongpu/param/incidentField.param +++ b/share/picongpu/examples/LaserWakefield/include/picongpu/param/incidentField.param @@ -243,12 +243,12 @@ namespace picongpu static constexpr auto laguerrePhases = floatN_X(0.0); /** @} */ - template + template 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(); + return profiles::defaults::GaussianPulseParam::metadata(); }; };