From b43b397fdf205fb815394477a157e144e3183d0d Mon Sep 17 00:00:00 2001 From: Marco Garten Date: Sun, 8 Sep 2024 11:38:05 -0700 Subject: [PATCH] Remove additional string for Twiss input (#698) Improve maintainability by removing additional string "from_cs" that allows for beam initialization from Twiss parameters. --- docs/source/usage/parameters.rst | 18 +++++++++--------- examples/fodo/input_fodo_twiss.in | 2 +- src/initialization/InitDistribution.cpp | 7 +------ 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/docs/source/usage/parameters.rst b/docs/source/usage/parameters.rst index fb1dfb330..d21b1f2ab 100644 --- a/docs/source/usage/parameters.rst +++ b/docs/source/usage/parameters.rst @@ -43,8 +43,8 @@ Initial Beam Distributions * ``beam.muypy`` (``float``, dimensionless, default: ``0``) correlation Y-Py * ``beam.mutpt`` (``float``, dimensionless, default: ``0``) correlation T-Pt - * Courant-Snyder / Twiss parameters. - To enable input via CS / Twiss parameters, add the suffix ``_from_cs`` or ``from_twiss`` to the name of the distribution. + * Courant-Snyder (Twiss) parameters. + To enable input via Courant-Snyder (Twiss) parameters, add the suffix ``from_twiss`` to the name of the distribution. Use the following parameters to characterize it: * ``beam.alphaX`` (``float``, dimensionless, default: ``0``) CS / Twiss :math:`\alpha` for X @@ -59,21 +59,21 @@ Initial Beam Distributions The following distributions are available: - * ``waterbag`` or ``waterbag_from_cs``/``waterbag_from_twiss`` for initial Waterbag distribution. + * ``waterbag`` or ``waterbag_from_twiss`` for initial Waterbag distribution. - * ``kurth6d`` or ``kurth6d_from_cs``/``kurth6d_from_twiss`` for initial 6D Kurth distribution. + * ``kurth6d`` or ``kurth6d_from_twiss`` for initial 6D Kurth distribution. - * ``gaussian`` or ``gaussian_from_cs``/``gaussian_from_twiss`` for initial 6D Gaussian (normal) distribution. + * ``gaussian`` or ``gaussian_from_twiss`` for initial 6D Gaussian (normal) distribution. - * ``kvdist`` or ``kvdist_from_cs``/``kvdist_from_twiss`` for initial K-V distribution in the transverse plane. + * ``kvdist`` or ``kvdist_from_twiss`` for initial K-V distribution in the transverse plane. The distribution is uniform in t and Gaussian in pt. - * ``kurth4d`` or ``kurth4d_from_cs``/``kurth4d_from_twiss`` for initial 4D Kurth distribution in the transverse plane. + * ``kurth4d`` or ``kurth4d_from_twiss`` for initial 4D Kurth distribution in the transverse plane. The distribution is uniform in t and Gaussian in pt. - * ``semigaussian`` or ``semigaussian_from_cs``/``semigaussian_from_twiss`` for initial Semi-Gaussian distribution. The distribution is uniform within a cylinder in (x,y,z) and Gaussian in momenta (px,py,pt). + * ``semigaussian`` or ``semigaussian_from_twiss`` for initial Semi-Gaussian distribution. The distribution is uniform within a cylinder in (x,y,z) and Gaussian in momenta (px,py,pt). - * ``triangle`` or ``triangle_from_cs``/``triangle_from_twiss`` a triangle distribution for laser-plasma acceleration related applications. + * ``triangle`` or ``triangle_from_twiss`` a triangle distribution for laser-plasma acceleration related applications. A ramped, triangular current profile with a Gaussian energy spread (possibly correlated). The transverse distribution is a 4D waterbag. diff --git a/examples/fodo/input_fodo_twiss.in b/examples/fodo/input_fodo_twiss.in index a94f19e4a..5e8fcd670 100644 --- a/examples/fodo/input_fodo_twiss.in +++ b/examples/fodo/input_fodo_twiss.in @@ -6,7 +6,7 @@ beam.units = static beam.kin_energy = 2.0e3 beam.charge = 1.0e-9 beam.particle = electron -beam.distribution = waterbag_from_cs +beam.distribution = waterbag_from_twiss beam.alphaX = -1.5905003499999992 beam.alphaY = 1.5905003499999992 beam.alphaT = 0.0 diff --git a/src/initialization/InitDistribution.cpp b/src/initialization/InitDistribution.cpp index 50f7b852e..61cdd77aa 100644 --- a/src/initialization/InitDistribution.cpp +++ b/src/initialization/InitDistribution.cpp @@ -266,19 +266,14 @@ namespace impactx pp_dist.get("distribution", distribution_type); std::string base_dist_type = distribution_type; - // Position of the underscore for splitting off the suffix in case the distribution name either ends in "_from_twiss" or "_from_cs" + // Position of the underscore for splitting off the suffix in case the distribution name either ends in "_from_twiss" std::size_t str_pos_from_twiss = distribution_type.rfind("_from_twiss"); - std::size_t str_pos_from_cs = distribution_type.rfind("_from_cs"); bool initialize_from_twiss = false; if (str_pos_from_twiss != std::string::npos) { // "_from_twiss" is found // Calculate suffix and base type, consider length of "_from_twiss" = 12 base_dist_type = distribution_type.substr(0, str_pos_from_twiss); initialize_from_twiss = true; - } else if (str_pos_from_cs != std::string::npos) { // "_from_cs" is found - // Calculate suffix and base type, consider length of "_from_cs" = 8 - base_dist_type = distribution_type.substr(0, str_pos_from_cs); - initialize_from_twiss = true; } /* After separating a potential suffix from its base type, check if the base distribution type is in the set of