diff --git a/src/Classic/Solvers/CSRIGFWakeFunction.cpp b/src/Classic/Solvers/CSRIGFWakeFunction.cpp index c2de6108d8e58058bd97c1ad0f8abc3fa1fd701c..5777f660b0c5d0e91b40847124d5b84aa79c1187 100644 --- a/src/Classic/Solvers/CSRIGFWakeFunction.cpp +++ b/src/Classic/Solvers/CSRIGFWakeFunction.cpp @@ -1,3 +1,19 @@ +// +// Class CSRIGFWakeFunction +// +// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. +// +// OPAL 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. +// +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. +// #include "AbstractObjects/OpalData.h" #include "Solvers/CSRIGFWakeFunction.hh" #include "Solvers/RootFinderForCSR.h" @@ -14,8 +30,8 @@ #include <fstream> #include <cmath> -CSRIGFWakeFunction::CSRIGFWakeFunction(const std::string &name, ElementBase *element, std::vector<Filter *> filters, const unsigned int &N): - WakeFunction(name, element, N), +CSRIGFWakeFunction::CSRIGFWakeFunction(const std::string &name, std::vector<Filter *> filters, const unsigned int &N): + WakeFunction(name, N), filters_m(filters.begin(), filters.end()), lineDensity_m(), dlineDensitydz_m(), diff --git a/src/Classic/Solvers/CSRIGFWakeFunction.hh b/src/Classic/Solvers/CSRIGFWakeFunction.hh index 0cfcee24a7715fce283d5b4c8367011cb4f32807..8a01daaee7ad879f0ee17b36121ff816949e9e80 100644 --- a/src/Classic/Solvers/CSRIGFWakeFunction.hh +++ b/src/Classic/Solvers/CSRIGFWakeFunction.hh @@ -1,3 +1,19 @@ +// +// Class CSRIGFWakeFunction +// +// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. +// +// OPAL 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. +// +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. +// #ifndef CSRIGFWAKEFUNCTION_HH #define CSRIGFWAKEFUNCTION_HH @@ -12,7 +28,7 @@ class ElementBase; class CSRIGFWakeFunction: public WakeFunction { public: - CSRIGFWakeFunction(const std::string &name, ElementBase *element, std::vector<Filter *> filters, const unsigned int &N); + CSRIGFWakeFunction(const std::string &name, std::vector<Filter *> filters, const unsigned int &N); void apply(PartBunchBase<double, 3> *bunch); diff --git a/src/Classic/Solvers/CSRWakeFunction.cpp b/src/Classic/Solvers/CSRWakeFunction.cpp index 168ede078a70f896c1f4def7efdbfdc477c63a9f..5e17e8e1aa0794fa2e698531054ff2b68eb9bbc9 100644 --- a/src/Classic/Solvers/CSRWakeFunction.cpp +++ b/src/Classic/Solvers/CSRWakeFunction.cpp @@ -1,3 +1,19 @@ +// +// Class CSRWakeFunction +// +// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. +// +// OPAL 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. +// +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. +// #include "Solvers/CSRWakeFunction.hh" #include "Solvers/RootFinderForCSR.h" @@ -16,8 +32,8 @@ #include <cmath> -CSRWakeFunction::CSRWakeFunction(const std::string &name, ElementBase *element, std::vector<Filter *> filters, const unsigned int &N): - WakeFunction(name, element, N), +CSRWakeFunction::CSRWakeFunction(const std::string &name, std::vector<Filter *> filters, const unsigned int &N): + WakeFunction(name, N), filters_m(filters.begin(), filters.end()), lineDensity_m(), dlineDensitydz_m(), diff --git a/src/Classic/Solvers/CSRWakeFunction.hh b/src/Classic/Solvers/CSRWakeFunction.hh index 368dd37c2526ee71e7aa3834779194fcd894b744..a416fb8fec99f157c6f601f63928d21f07bfd4a2 100644 --- a/src/Classic/Solvers/CSRWakeFunction.hh +++ b/src/Classic/Solvers/CSRWakeFunction.hh @@ -1,3 +1,19 @@ +// +// Class CSRWakeFunction +// +// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. +// +// OPAL 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. +// +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. +// #ifndef CSRWAKEFUNCTION_HH #define CSRWAKEFUNCTION_HH @@ -12,7 +28,7 @@ class ElementBase; class CSRWakeFunction: public WakeFunction { public: - CSRWakeFunction(const std::string &name, ElementBase *element, std::vector<Filter *> filters, const unsigned int &N); + CSRWakeFunction(const std::string &name, std::vector<Filter *> filters, const unsigned int &N); void apply(PartBunchBase<double, 3> *bunch); diff --git a/src/Classic/Solvers/GreenWakeFunction.cpp b/src/Classic/Solvers/GreenWakeFunction.cpp index 868f680c6bb9dfa3cb5a5fb9c33a6e9d800c0a9a..e429f4a5e402481e5f4ec028eb91b2d53aa91b66 100644 --- a/src/Classic/Solvers/GreenWakeFunction.cpp +++ b/src/Classic/Solvers/GreenWakeFunction.cpp @@ -1,3 +1,19 @@ +// +// Class GreenWakeFunction +// +// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. +// +// OPAL 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. +// +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. +// #include "Solvers/GreenWakeFunction.hh" #include "Algorithms/PartBunchBase.h" #include "Utilities/GeneralClassicException.h" @@ -19,13 +35,10 @@ /** - * @brief just a Testfunction! Calculate the energy of the Wakefunction with the lambda - * * * @todo In this code one can only apply either the longitudinal wakefield or the transversal wakefield. One should implement that both wakefields can be applied to the particle beam * @todo NBins must be set equal to MT of the fieldsolver. This should be changed. (the length of lineDensity_m must be NBins and not to MT) * - * @param[in] ref * @param[in] NBIN number of Bins * @param[in] Z0 impedance of the tube * @param[in] radius radius of the tube @@ -37,7 +50,6 @@ * @param[in] fname read wake from file */ GreenWakeFunction::GreenWakeFunction(const std::string &name, - ElementBase *element, std::vector<Filter *> filters, int NBIN, double Z0, @@ -48,7 +60,7 @@ GreenWakeFunction::GreenWakeFunction(const std::string &name, int direction, bool constLength, std::string fname): - WakeFunction(name, element, NBIN), + WakeFunction(name, NBIN), lineDensity_m(), //~ FftWField_m(0), NBin_m(NBIN), @@ -510,4 +522,4 @@ void GreenWakeFunction::setWakeFromFile(int NBin_m, double spacing) { const std::string GreenWakeFunction::getType() const { return "GreenWakeFunction"; -} +} \ No newline at end of file diff --git a/src/Classic/Solvers/GreenWakeFunction.hh b/src/Classic/Solvers/GreenWakeFunction.hh index a9bac2b33c2021b1fdf6f121e6764766206bbd93..52f6e0748bfdcff22e16c72e4fa673b892a9ce9c 100644 --- a/src/Classic/Solvers/GreenWakeFunction.hh +++ b/src/Classic/Solvers/GreenWakeFunction.hh @@ -1,3 +1,19 @@ +// +// Class GreenWakeFunction +// +// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. +// +// OPAL 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. +// +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. +// #ifndef GREENWAKEFUNCTION_HH #define GREENWAKEFUNCTION_HH @@ -25,7 +41,6 @@ public: //IFF: changed direction to int (was double) //IFF: changed acMode to int (was double) GreenWakeFunction(const std::string &name, - ElementBase *element, std::vector<Filter *> filters, int NBIN, double Z0, diff --git a/src/Classic/Solvers/WakeFunction.hh b/src/Classic/Solvers/WakeFunction.hh index d4ab99225dfb3443c76390769f03d753a038a113..b8a71f25ed83fff6ae8f7c8f0b82be223732b8a8 100644 --- a/src/Classic/Solvers/WakeFunction.hh +++ b/src/Classic/Solvers/WakeFunction.hh @@ -1,3 +1,19 @@ +// +// Class WakeFunction +// +// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. +// +// OPAL 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. +// +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. +// #ifndef WAKEFUNCTION_HH #define WAKEFUNCTION_HH @@ -11,7 +27,7 @@ class PartBunchBase; class WakeFunction { public: - WakeFunction(std::string name, ElementBase */*elref*/, unsigned int n): + WakeFunction(std::string name, unsigned int n): nBins_m(n), name_m(name) { }; diff --git a/src/Structure/OpalWake.cpp b/src/Structure/OpalWake.cpp index effe5cb1cf02f2968fdd95915e1fd50dcb6b2fba..c1bc997034d83d48bfb1951f2d10026d65da0e96 100644 --- a/src/Structure/OpalWake.cpp +++ b/src/Structure/OpalWake.cpp @@ -1,18 +1,20 @@ -// ------------------------------------------------------------------------ -// $RCSfile: OpalWake.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.3.4.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: OpalWake +// Class OpalWake // The class for the OPAL WAKE command. // -// $Date: 2003/08/11 22:09:00 $ -// $Author: A. Adelmann $ +// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. +// +// OPAL 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. +// +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // -// ------------------------------------------------------------------------ #include "Structure/OpalWake.h" #include "Solvers/GreenWakeFunction.hh" @@ -20,19 +22,12 @@ #include "Solvers/CSRIGFWakeFunction.hh" #include "AbstractObjects/OpalData.h" #include "Attributes/Attributes.h" -#include "Physics/Physics.h" #include "Utilities/OpalException.h" #include "AbsBeamline/ElementBase.h" #include "Utilities/OpalFilter.h" extern Inform *gmsg; -using namespace Physics; - - -// Class OpalWake -// ------------------------------------------------------------------------ - // The attributes of class OpalWake. namespace { enum { @@ -57,7 +52,7 @@ OpalWake::OpalWake(): "on an element."), wf_m(0) { itsAttr[TYPE] = Attributes::makeUpperCaseString - ("TYPE", "Specifies the wake function: 1D-CSR, 1D-CSR-IGF, LONG-SHORT-RANGE, TRANSV-SHORT-RANGE, LONG-TRANSV-SHORT-RANGE"); + ("TYPE", "Specifies the wake function: 1D-CSR, 1D-CSR-IGF, LONG-SHORT-RANGE, TRANSV-SHORT-RANGE"); itsAttr[NBIN] = Attributes::makeReal ("NBIN", "Number of bins for the line density calculation"); @@ -75,10 +70,10 @@ OpalWake::OpalWake(): ("RADIUS", "The radius of the beam pipe [m]"); itsAttr[SIGMA] = Attributes::makeReal - ("SIGMA", "Material constant dependant on the beam pipe material"); + ("SIGMA", "Material constant dependant on the beam pipe material"); itsAttr[TAU] = Attributes::makeReal - ("TAU", "Material constant dependant on the beam pipe material"); + ("TAU", "Material constant dependant on the beam pipe material"); itsAttr[FILTERS] = Attributes::makeStringArray ("FILTERS", "List of filters to apply on line density"); @@ -107,8 +102,7 @@ OpalWake::OpalWake(const std::string &name, OpalWake *parent): OpalWake::~OpalWake() { - if (wf_m) - delete wf_m; + delete wf_m; } @@ -149,14 +143,13 @@ void OpalWake::update() { } -void OpalWake::initWakefunction(ElementBase &element) { +void OpalWake::initWakefunction(const ElementBase &element) { *gmsg << "* ************* W A K E ************************************************************\n"; *gmsg << "OpalWake::initWakefunction "; *gmsg << "for element " << element.getName() << "\n"; *gmsg << "* **********************************************************************************" << endl; - itsElement_m = &element; std::vector<std::string> filters_str = Attributes::getStringArray(itsAttr[FILTERS]); std::vector<Filter *> filters; @@ -168,8 +161,8 @@ void OpalWake::initWakefunction(ElementBase &element) { filters.push_back(f->filter_m); } } - - if (Attributes::getString(itsAttr[TYPE]) == "1D-CSR") { + std::string type = Attributes::getString(itsAttr[TYPE]); + if (type == "1D-CSR") { if (filters.size() == 0 && Attributes::getReal(itsAttr[NBIN]) <= 7) { throw OpalException("OpalWake::initWakeFunction", @@ -177,11 +170,10 @@ void OpalWake::initWakefunction(ElementBase &element) { } wf_m = new CSRWakeFunction(getOpalName(), - itsElement_m, filters, (int)(Attributes::getReal(itsAttr[NBIN]))); - } else if (Attributes::getString(itsAttr[TYPE]) == "1D-CSR-IGF") { + } else if (type == "1D-CSR-IGF") { if (filters.size() == 0 && Attributes::getReal(itsAttr[NBIN]) <= 7) { throw OpalException("OpalWake::initWakeFunction", @@ -189,15 +181,13 @@ void OpalWake::initWakefunction(ElementBase &element) { } wf_m = new CSRIGFWakeFunction(getOpalName(), - itsElement_m, filters, (int)(Attributes::getReal(itsAttr[NBIN]))); - } else if (Attributes::getString(itsAttr[TYPE]) == "LONG-SHORT-RANGE") { + } else if (type == "LONG-SHORT-RANGE") { int acMode = Attributes::getString(itsAttr[CONDUCT]) == "DC"? 2: 1; wf_m = new GreenWakeFunction(getOpalName(), - itsElement_m, filters, (int)(Attributes::getReal(itsAttr[NBIN])), Attributes::getReal(itsAttr[Z0]), @@ -209,11 +199,10 @@ void OpalWake::initWakefunction(ElementBase &element) { Attributes::getBool(itsAttr[CONST_LENGTH]), Attributes::getString(itsAttr[FNAME])); - } else if (Attributes::getString(itsAttr[TYPE]) == "TRANSV-SHORT-RANGE") { - int acMode = Attributes::getString(itsAttr[CONDUCT]) == "DC"? 2: 1; + } else if (type == "TRANSV-SHORT-RANGE") { + int acMode = Attributes::getString(itsAttr[CONDUCT]) == "DC" ? 2: 1; wf_m = new GreenWakeFunction(getOpalName(), - itsElement_m, filters, (int)(Attributes::getReal(itsAttr[NBIN])), Attributes::getReal(itsAttr[Z0]), @@ -225,8 +214,12 @@ void OpalWake::initWakefunction(ElementBase &element) { Attributes::getBool(itsAttr[CONST_LENGTH]), Attributes::getString(itsAttr[FNAME])); - } else if (Attributes::getString(itsAttr[TYPE]) == "LONG-TRANSV-SHORT-RANGE") { - //FIXME: NOT IMPLEMENTED YET!!! + } else if (type == "LONG-TRANSV-SHORT-RANGE") { + throw OpalException("OpalWake::initWakeFunction", + "LONG-TRANSV-SHORT-RANGE wake is not implemented"); + } else if (type.empty() == false) { + throw OpalException("OpalWake::initWakeFunction", + type + " is not a valid wake type"); } else { wf_m = 0; INFOMSG("no wakefunction attached" << endl); diff --git a/src/Structure/OpalWake.h b/src/Structure/OpalWake.h index 307ab2ed2a8aa3d4825cb354cb265a517baa973d..ed8f4305e777133186d688a3b152455dca30911a 100644 --- a/src/Structure/OpalWake.h +++ b/src/Structure/OpalWake.h @@ -1,36 +1,28 @@ -#ifndef OPAL_Wake_HH -#define OPAL_Wake_HH - -// ------------------------------------------------------------------------ -// $RCSfile: OpalWake.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: OpalWake +// Class OpalWake +// The class for the OPAL WAKE command. // -// ------------------------------------------------------------------------ +// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:33:44 $ -// $Author: Andreas Adelmann $ +// This file is part of OPAL. // -// ------------------------------------------------------------------------ +// OPAL 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. +// +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. +// +#ifndef OPAL_Wake_HH +#define OPAL_Wake_HH #include "AbstractObjects/Definition.h" -#include "Algorithms/PartData.h" class ElementBase; class WakeFunction; -// Class OpalWake -// ------------------------------------------------------------------------ -/// The WAKE definition. -// A WAKE definition is used by most physics commands to define the -// particle charge and the reference momentum, together with some other -// data. - class OpalWake: public Definition { public: @@ -60,7 +52,7 @@ public: int getNumberOfBins(); - void initWakefunction(ElementBase &element); + void initWakefunction(const ElementBase &element); WakeFunction *wf_m; @@ -72,16 +64,6 @@ private: // Clone constructor. OpalWake(const std::string &name, OpalWake *parent); - - // The particle reference data. - PartData reference; - - // The conversion from GeV to eV. - static const double energy_scale; - - // the element the wake is attached to - ElementBase *itsElement_m; - }; inline std::ostream &operator<<(std::ostream &os, const OpalWake &b) { diff --git a/tests/classic_src/Solvers/GreenWakeFunctionTest.cpp b/tests/classic_src/Solvers/GreenWakeFunctionTest.cpp index b839e4d8009c6adc1e2a0670f7400b738bfe66c8..aee1d0150bbda76aa670fc6423d388e3f561f825 100644 --- a/tests/classic_src/Solvers/GreenWakeFunctionTest.cpp +++ b/tests/classic_src/Solvers/GreenWakeFunctionTest.cpp @@ -31,7 +31,7 @@ TEST(GreenWakeFunctionTest, TestApply) std::vector<double> relativeErrorEnergy = {1e-9, 1}; for (int acmode : acmodes) { - GreenWakeFunction gwf("opal", nullptr, filters, nbin, Z0, radius, sigma, acmode, tau, 0, const_length, fname); + GreenWakeFunction gwf("opal", filters, nbin, Z0, radius, sigma, acmode, tau, 0, const_length, fname); double spacing = 1e-6; //IFF: charge in testLambda.h in 1um spacings // determine K and charge