diff --git a/src/AbstractObjects/CMakeLists.txt b/src/AbstractObjects/CMakeLists.txt index b8f7d852fc8937f184da0a7f87878e9c4e410ab8..f82966d64b7ca761c68adafbd5d5c7b8ab4707f8 100644 --- a/src/AbstractObjects/CMakeLists.txt +++ b/src/AbstractObjects/CMakeLists.txt @@ -6,7 +6,6 @@ set (_SRCS BeamSequence.cpp Definition.cpp Directory.cpp - Editor.cpp Element.cpp Invalidator.cpp OpalData.cpp @@ -33,7 +32,6 @@ set (HDRS BeamSequence.h Definition.h Directory.h - Editor.h Element.h Expressions.h Invalidator.h diff --git a/src/AbstractObjects/Editor.cpp b/src/AbstractObjects/Editor.cpp deleted file mode 100644 index ed2a9a1924141a83580ae3599983509e57651e5e..0000000000000000000000000000000000000000 --- a/src/AbstractObjects/Editor.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Editor.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Editor -// The base class for all OPAL sequence editor commands. -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:35 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "AbstractObjects/Editor.h" - - -// Class Editor -// ------------------------------------------------------------------------ - -Editor::~Editor() -{} - - -const std::string Editor::getCategory() const { - return "EDITOR"; -} - - -bool Editor::shouldTrace() const { - return true; - -} - -bool Editor::shouldUpdate() const { - return false; -} - - -Editor::Editor(const std::string &name, Editor *parent): - Object(name, parent) -{} - - -Editor::Editor(int size, const char *name, const char *help): - Object(size, name, help) -{} diff --git a/src/AbstractObjects/Editor.h b/src/AbstractObjects/Editor.h deleted file mode 100644 index 9f24fe677cbad1461063b1bd9368f273197c9e22..0000000000000000000000000000000000000000 --- a/src/AbstractObjects/Editor.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef OPAL_Editor_HH -#define OPAL_Editor_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Editor.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Editor -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:35 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "AbstractObjects/Object.h" - - -// Class Editor -// ------------------------------------------------------------------------ -/// The base class for all OPAL sequence editor commands. -// It implements the common behaviour of editor commands, it can also -// be used via dynamic casting to determine whether an object represents -// an editor command. - -class Editor: public Object { - -public: - - virtual ~Editor(); - - /// Return the object category as a string. - // Return the string "EDITOR". - virtual const std::string getCategory() const; - - /// Trace flag. - // If true, the object's execute() function should be traced. - // Always true for editor commands. - virtual bool shouldTrace() const; - - /// Update flag. - // If true, the data structure should be updated before calling execute(). - // Always false for editor commands. - virtual bool shouldUpdate() const; - -protected: - - /// Constructor for exemplars. - Editor(int size, const char *name, const char *help); - - /// Constructor for cloning. - Editor(const std::string &name, Editor *parent); - -private: - - // Not implemented. - Editor(); - Editor(const Editor &); - void operator=(const Editor &); -}; - -#endif // OPAL_Editor_HH diff --git a/src/Algorithms/CMakeLists.txt b/src/Algorithms/CMakeLists.txt index a2d20fcc9965dc321143b45c45a16c176e82f74a..8488641b91f502d1fdbc8d8f42977224e68139a8 100644 --- a/src/Algorithms/CMakeLists.txt +++ b/src/Algorithms/CMakeLists.txt @@ -4,14 +4,12 @@ set (_SRCS IndexMap.cpp Hamiltonian.cpp lomb.cpp - NilTracker.cpp MapAnalyser.cpp MultiBunchHandler.cpp OrbitThreader.cpp ParallelCyclotronTracker.cpp ParallelTTracker.cpp StepSizeConfig.cpp - ThickMapper.cpp ThickTracker.cpp ) @@ -29,12 +27,10 @@ set (HDRS lomb.h MapAnalyser.h MultiBunchHandler.h - NilTracker.h OrbitThreader.h ParallelCyclotronTracker.h ParallelTTracker.h StepSizeConfig.h - ThickMapper.h ThickTracker.h ) diff --git a/src/Algorithms/NilTracker.cpp b/src/Algorithms/NilTracker.cpp deleted file mode 100644 index 3b166c02fa661ffc41a5a16a236914f13bd0446a..0000000000000000000000000000000000000000 --- a/src/Algorithms/NilTracker.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// Class NilTracker -// :FIXME: Add class description -// -// Copyright (c) 200x - 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 "Algorithms/NilTracker.h" - -NilTracker::NilTracker(const Beamline &beamline, - const PartData &reference, - bool revBeam, - bool revTrack): - Tracker(beamline, reference, revBeam, revTrack) -{ } - - -NilTracker::~NilTracker() { - -} - -void NilTracker::execute() { - -} \ No newline at end of file diff --git a/src/Algorithms/NilTracker.h b/src/Algorithms/NilTracker.h deleted file mode 100644 index ce453a7699432c9f262b70170aea90491c6b141c..0000000000000000000000000000000000000000 --- a/src/Algorithms/NilTracker.h +++ /dev/null @@ -1,98 +0,0 @@ -// -// Class NilTracker -// :FIXME: Add class description -// -// Copyright (c) 200x - 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 OPAL_NILTRACKER_H -#define OPAL_NILTRACKER_H - - -#define NIL_VISITELEMENT(elem) virtual void visit##elem(const elem &) { } - -#include "Algorithms/Tracker.h" - -class BMultipoleField; -template <class T, unsigned Dim> -class PartBunchBase; -class BeamBeam; -class BeamStripping; -class CCollimator; -class Corrector; -class Degrader; -class Diagnostic; -class Drift; -class ElementBase; -class FlexibleCollimator; -class Lambertson; -class Marker; -class Monitor; -class Multipole; -class ParallelPlate; -class Probe; -class RBend; -class RFCavity; -class RFQuadrupole; -class SBend; -class Separator; -class Septum; -class Solenoid; -class TravelingWave; - -class NilTracker: public Tracker { - -public: - /// Constructor. - explicit NilTracker(const Beamline &beamline, - const PartData &reference, - bool revBeam, - bool revTrack); - - virtual ~NilTracker(); - - NIL_VISITELEMENT(Beamline) - NIL_VISITELEMENT(BeamBeam) - NIL_VISITELEMENT(BeamStripping) - NIL_VISITELEMENT(CCollimator) - NIL_VISITELEMENT(Corrector) - NIL_VISITELEMENT(Degrader) - NIL_VISITELEMENT(Diagnostic) - NIL_VISITELEMENT(Drift) - NIL_VISITELEMENT(FlexibleCollimator) - NIL_VISITELEMENT(Lambertson) - NIL_VISITELEMENT(Marker) - NIL_VISITELEMENT(Monitor) - NIL_VISITELEMENT(Multipole) - NIL_VISITELEMENT(ParallelPlate) - NIL_VISITELEMENT(Probe) - NIL_VISITELEMENT(RBend) - NIL_VISITELEMENT(RFCavity) - NIL_VISITELEMENT(RFQuadrupole) - NIL_VISITELEMENT(SBend) - NIL_VISITELEMENT(Separator) - NIL_VISITELEMENT(Septum) - NIL_VISITELEMENT(Solenoid) - NIL_VISITELEMENT(TravelingWave) - - virtual void execute(); - -private: - - NilTracker(); - NilTracker(const NilTracker &); - - void operator=(const NilTracker &); -}; - -#endif // OPAL_NILTRACKER_H \ No newline at end of file diff --git a/src/Algorithms/ParallelCyclotronTracker.cpp b/src/Algorithms/ParallelCyclotronTracker.cpp index 2d6b0c6b6a32e155291a28469dccbc64af1af823..2fcbf31ec52e3cc6124386477dbb103e0ba07f8b 100644 --- a/src/Algorithms/ParallelCyclotronTracker.cpp +++ b/src/Algorithms/ParallelCyclotronTracker.cpp @@ -42,10 +42,8 @@ #include "AbsBeamline/Corrector.h" #include "AbsBeamline/Cyclotron.h" #include "AbsBeamline/Degrader.h" -#include "AbsBeamline/Diagnostic.h" #include "AbsBeamline/Drift.h" #include "AbsBeamline/ElementBase.h" -#include "AbsBeamline/Lambertson.h" #include "AbsBeamline/Offset.h" #include "AbsBeamline/Marker.h" #include "AbsBeamline/Monitor.h" @@ -60,11 +58,9 @@ #include "AbsBeamline/RBend.h" #include "AbsBeamline/Ring.h" #include "AbsBeamline/RFCavity.h" -#include "AbsBeamline/RFQuadrupole.h" #include "AbsBeamline/SBend.h" #include "AbsBeamline/SBend3D.h" #include "AbsBeamline/ScalingFFAMagnet.h" -#include "AbsBeamline/Separator.h" #include "AbsBeamline/Septum.h" #include "AbsBeamline/Solenoid.h" #include "AbsBeamline/Stripper.h" @@ -568,14 +564,6 @@ void ParallelCyclotronTracker::visitCyclotron(const Cyclotron &cycl) { buildupFieldList(BcParameter, ElementBase::CYCLOTRON, cycl_m); } -/** - * Not implemented and most probable never used - * - */ -void ParallelCyclotronTracker::visitBeamBeam(const BeamBeam &) { - *gmsg << "In BeamBeam tracker is missing " << endl; -} - void ParallelCyclotronTracker::visitBeamStripping(const BeamStripping &bstp) { *gmsg << "* ------------------------------ Beam Stripping ------------------------------" << endl; @@ -677,16 +665,6 @@ void ParallelCyclotronTracker::visitDegrader(const Degrader °) { } -/** - * - * - * @param diag - */ -void ParallelCyclotronTracker::visitDiagnostic(const Diagnostic &diag) { - *gmsg << "In Diagnostic; L= " << diag.getElementLength() << endl; - myElements.push_back(dynamic_cast<Diagnostic *>(diag.clone())); -} - /** * * @@ -706,16 +684,6 @@ void ParallelCyclotronTracker::visitFlexibleCollimator(const FlexibleCollimator } -/** - * - * - * @param lamb - */ -void ParallelCyclotronTracker::visitLambertson(const Lambertson &lamb) { - *gmsg << "In Lambertson; L= " << lamb.getElementLength() << endl; - myElements.push_back(dynamic_cast<Lambertson *>(lamb.clone())); -} - void ParallelCyclotronTracker::visitOffset(const Offset & off) { if (opalRing_m == NULL) throw OpalException( @@ -1010,16 +978,6 @@ void ParallelCyclotronTracker::visitRFCavity(const RFCavity &as) { buildupFieldList(BcParameter, ElementBase::RFCAVITY, elptr); } -/** - * - * - * @param rfq - */ -void ParallelCyclotronTracker::visitRFQuadrupole(const RFQuadrupole &rfq) { - *gmsg << "In RFQuadrupole; L = " << rfq.getElementLength() << " however the element is missing " << endl; - myElements.push_back(dynamic_cast<RFQuadrupole *>(rfq.clone())); -} - /** * * @@ -1030,16 +988,6 @@ void ParallelCyclotronTracker::visitSBend(const SBend &bend) { myElements.push_back(dynamic_cast<SBend *>(bend.clone())); } -/** - * - * - * @param sep - */ -void ParallelCyclotronTracker::visitSeparator(const Separator &sep) { - *gmsg << "In Separator L= " << sep.getElementLength() << " however the element is missing " << endl; - myElements.push_back(dynamic_cast<Separator *>(sep.clone())); -} - /** * * @@ -1097,15 +1045,6 @@ void ParallelCyclotronTracker::visitSolenoid(const Solenoid &solenoid) { } } -/** - * - * - * @param pplate - */ -void ParallelCyclotronTracker::visitParallelPlate(const ParallelPlate &/*pplate*/) { - //do nothing -} - /** * * diff --git a/src/Algorithms/ParallelCyclotronTracker.h b/src/Algorithms/ParallelCyclotronTracker.h index 52c285982f5a4ee82ba18053afcc916563d7fec0..0b744c8b25117a6e0ea495394d0c50d07c6a1790 100644 --- a/src/Algorithms/ParallelCyclotronTracker.h +++ b/src/Algorithms/ParallelCyclotronTracker.h @@ -94,9 +94,6 @@ public: /// Apply the algorithm to a RFCavity. virtual void visitRFCavity(const RFCavity &); - /// Apply the algorithm to a BeamBeam. - virtual void visitBeamBeam(const BeamBeam &); - /// Apply the algorithm to a Beam Stripping. virtual void visitBeamStripping(const BeamStripping &); @@ -109,18 +106,12 @@ public: /// Apply the algorithm to a Degrader virtual void visitDegrader(const Degrader &); - /// Apply the algorithm to a Diagnostic. - virtual void visitDiagnostic(const Diagnostic &); - /// Apply the algorithm to a Drift. virtual void visitDrift(const Drift &); /// Apply the algorithm to a flexible collimator virtual void visitFlexibleCollimator(const FlexibleCollimator &); - /// Apply the algorithm to a Lambertson. - virtual void visitLambertson(const Lambertson &); - /// Apply the algorithm to a Marker. virtual void visitMarker(const Marker &); @@ -151,9 +142,6 @@ public: /// Apply the algorithm to a RBend. virtual void visitRBend(const RBend &); - /// Apply the algorithm to a RFQuadrupole. - virtual void visitRFQuadrupole(const RFQuadrupole &); - /// Apply the algorithm to a SBend. virtual void visitSBend(const SBend &); @@ -163,9 +151,6 @@ public: /// Apply the algorithm to a ScalingFFAMagnet. virtual void visitScalingFFAMagnet(const ScalingFFAMagnet &bend); - /// Apply the algorithm to a Separator. - virtual void visitSeparator(const Separator &); - /// Apply the algorithm to a Septum. virtual void visitSeptum(const Septum &); @@ -175,9 +160,6 @@ public: /// Apply the algorithm to a charge stripper. virtual void visitStripper(const Stripper &); - /// Apply the algorithm to a ParallelPlate, it is empty for cyclotrontracker . - virtual void visitParallelPlate(const ParallelPlate &); - /// Apply the algorithm to a VariabelRFCavity. virtual void visitVariableRFCavity(const VariableRFCavity &cav); diff --git a/src/Algorithms/ParallelTTracker.h b/src/Algorithms/ParallelTTracker.h index ec619302a7ed13ac460922e95f7a08daade3c1d2..6a808e7645bb144b957a47373680b8c80529ac6a 100644 --- a/src/Algorithms/ParallelTTracker.h +++ b/src/Algorithms/ParallelTTracker.h @@ -34,16 +34,13 @@ #include "Algorithms/OrbitThreader.h" #include "Algorithms/IndexMap.h" -#include "AbsBeamline/BeamBeam.h" #include "AbsBeamline/BeamStripping.h" #include "AbsBeamline/CCollimator.h" #include "AbsBeamline/Corrector.h" -#include "AbsBeamline/Diagnostic.h" #include "AbsBeamline/Degrader.h" #include "AbsBeamline/Drift.h" #include "AbsBeamline/FlexibleCollimator.h" #include "AbsBeamline/ElementBase.h" -#include "AbsBeamline/Lambertson.h" #include "AbsBeamline/Marker.h" #include "AbsBeamline/Monitor.h" #include "AbsBeamline/Multipole.h" @@ -53,12 +50,9 @@ #include "AbsBeamline/RBend3D.h" #include "AbsBeamline/RFCavity.h" #include "AbsBeamline/TravelingWave.h" -#include "AbsBeamline/RFQuadrupole.h" #include "AbsBeamline/SBend.h" -#include "AbsBeamline/Separator.h" #include "AbsBeamline/Septum.h" #include "AbsBeamline/Solenoid.h" -#include "AbsBeamline/ParallelPlate.h" #include "Beamlines/Beamline.h" #include "Elements/OpalBeamline.h" @@ -103,9 +97,6 @@ public: virtual ~ParallelTTracker(); - /// Apply the algorithm to a BeamBeam. - virtual void visitBeamBeam(const BeamBeam &); - /// Apply the algorithm to a BeamStripping. virtual void visitBeamStripping(const BeamStripping &); @@ -119,18 +110,12 @@ public: /// Apply the algorithm to a Degrader. virtual void visitDegrader(const Degrader &); - /// Apply the algorithm to a Diagnostic. - virtual void visitDiagnostic(const Diagnostic &); - /// Apply the algorithm to a Drift. virtual void visitDrift(const Drift &); /// Apply the algorithm to a flexible collimator virtual void visitFlexibleCollimator(const FlexibleCollimator &); - /// Apply the algorithm to a Lambertson. - virtual void visitLambertson(const Lambertson &); - /// Apply the algorithm to a Marker. virtual void visitMarker(const Marker &); @@ -158,15 +143,9 @@ public: /// Apply the algorithm to a RFCavity. virtual void visitTravelingWave(const TravelingWave &); - /// Apply the algorithm to a RFQuadrupole. - virtual void visitRFQuadrupole(const RFQuadrupole &); - /// Apply the algorithm to a SBend. virtual void visitSBend(const SBend &); - /// Apply the algorithm to a Separator. - virtual void visitSeparator(const Separator &); - /// Apply the algorithm to a Septum. virtual void visitSeptum(const Septum &); @@ -176,9 +155,6 @@ public: /// Apply the algorithm to a Solenoid. virtual void visitSource(const Source &); - /// Apply the algorithm to a ParallelPlate. - virtual void visitParallelPlate(const ParallelPlate &); - /// Apply the algorithm to a beam line. // overwrite the execute-methode from DefaultVisitor virtual void visitBeamline(const Beamline &); @@ -292,9 +268,6 @@ private: void evenlyDistributeParticles(); }; -inline void ParallelTTracker::visitBeamBeam(const BeamBeam &bb) { - itsOpalBeamline_m.visit(bb, *this, itsBunch_m); -} inline void ParallelTTracker::visitBeamStripping(const BeamStripping &bstp) { itsOpalBeamline_m.visit(bstp, *this, itsBunch_m); @@ -315,11 +288,6 @@ inline void ParallelTTracker::visitDegrader(const Degrader °) { } -inline void ParallelTTracker::visitDiagnostic(const Diagnostic &diag) { - itsOpalBeamline_m.visit(diag, *this, itsBunch_m); -} - - inline void ParallelTTracker::visitDrift(const Drift &drift) { itsOpalBeamline_m.visit(drift, *this, itsBunch_m); } @@ -330,11 +298,6 @@ inline void ParallelTTracker::visitFlexibleCollimator(const FlexibleCollimator & } -inline void ParallelTTracker::visitLambertson(const Lambertson &lamb) { - itsOpalBeamline_m.visit(lamb, *this, itsBunch_m); -} - - inline void ParallelTTracker::visitMarker(const Marker &marker) { itsOpalBeamline_m.visit(marker, *this, itsBunch_m); } @@ -376,20 +339,11 @@ inline void ParallelTTracker::visitTravelingWave(const TravelingWave &as) { } -inline void ParallelTTracker::visitRFQuadrupole(const RFQuadrupole &rfq) { - itsOpalBeamline_m.visit(rfq, *this, itsBunch_m); -} - inline void ParallelTTracker::visitSBend(const SBend &bend) { itsOpalBeamline_m.visit(bend, *this, itsBunch_m); } -inline void ParallelTTracker::visitSeparator(const Separator &sep) { - itsOpalBeamline_m.visit(sep, *this, itsBunch_m); -} - - inline void ParallelTTracker::visitSeptum(const Septum &sept) { itsOpalBeamline_m.visit(sept, *this, itsBunch_m); } @@ -403,10 +357,6 @@ inline void ParallelTTracker::visitSource(const Source &source) { itsOpalBeamline_m.visit(source, *this, itsBunch_m); } -inline void ParallelTTracker::visitParallelPlate(const ParallelPlate &pplate) { - itsOpalBeamline_m.visit(pplate, *this, itsBunch_m); -} - inline void ParallelTTracker::kickParticles(const BorisPusher &pusher) { int localNum = itsBunch_m->getLocalNum(); for (int i = 0; i < localNum; ++i) diff --git a/src/Algorithms/ThickMapper.cpp b/src/Algorithms/ThickMapper.cpp deleted file mode 100644 index 152ea508735bf8caf1a8f05a6dae56c14c0edcd1..0000000000000000000000000000000000000000 --- a/src/Algorithms/ThickMapper.cpp +++ /dev/null @@ -1,761 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: ThickMapper.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.3.4.3 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ThickMapper -// The visitor class for building a map of given order for a beamline -// using a finite-length lenses for all elements. -// Multipole-like elements are done by expanding the Lie series. -// -// ------------------------------------------------------------------------ -// -// $Date: 2004/11/12 20:10:11 $ -// $Author: adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Algorithms/ThickMapper.h" - -#include "AbsBeamline/CCollimator.h" -#include "AbsBeamline/Corrector.h" -#include "AbsBeamline/Degrader.h" -#include "AbsBeamline/Diagnostic.h" -#include "AbsBeamline/Drift.h" -#include "AbsBeamline/ElementBase.h" -#include "AbsBeamline/FlexibleCollimator.h" -#include "AbsBeamline/Lambertson.h" -#include "AbsBeamline/Marker.h" -#include "AbsBeamline/Monitor.h" -#include "AbsBeamline/Multipole.h" -#include "AbsBeamline/Probe.h" -#include "AbsBeamline/RBend.h" -#include "AbsBeamline/RFCavity.h" -#include "AbsBeamline/RFQuadrupole.h" -#include "AbsBeamline/SBend.h" -#include "AbsBeamline/Separator.h" -#include "AbsBeamline/Septum.h" -#include "AbsBeamline/Solenoid.h" -#include "AbsBeamline/ParallelPlate.h" - -#include "BeamlineGeometry/Euclid3D.h" -#include "BeamlineGeometry/PlanarArcGeometry.h" -#include "BeamlineGeometry/RBendGeometry.h" -#include "Beamlines/Beamline.h" - -#include "Fields/BMultipoleField.h" -#include "FixedAlgebra/FTps.h" -#include "FixedAlgebra/FTpsMath.h" -#include "FixedAlgebra/FVps.h" - -#include "Physics/Physics.h" - -class Beamline; -class PartData; - -#define PSdim 6 -typedef FVector<double, PSdim> Vector; -typedef FMatrix<double, PSdim, PSdim> Matrix; -typedef FTps<double, PSdim> Series; -typedef FVps<double, PSdim> Map, VSeries; -typedef FMatrix<FTps<double, PSdim>, PSdim, PSdim> MxSeries; - -namespace { - Vector implicitIntStep(const Vector &zin, const VSeries &f, const MxSeries gradf, double ds, - int nx = 20); - Vector implicitInt4(const Vector &zin, const VSeries &f, double s, double ds, - int nx = 20, int cx = 4); -}; - -// Class ThickMapper -// ------------------------------------------------------------------------ - -ThickMapper::ThickMapper(const Beamline &beamline, - const PartData &reference, - bool backBeam, bool backTrack): - Mapper(beamline, reference, backBeam, backTrack) -{} - - -ThickMapper::~ThickMapper() -{} - - -void ThickMapper::visitBeamBeam(const BeamBeam &) { - // *** MISSING *** Map for beam-beam. -} - -void ThickMapper::visitBeamStripping(const BeamStripping &) { - // *** MISSING *** Map for beam Stripping. -} - -void ThickMapper::visitCCollimator(const CCollimator &coll) { - applyDrift(flip_s * coll.getElementLength()); -} - - -void ThickMapper::visitCorrector(const Corrector &corr) { - double length = flip_s * corr.getElementLength(); - - // Drift through first half of length. - if(length != 0.0) applyDrift(length / 2.0); - - // Apply kick. - double scale = - (flip_s * flip_B * itsReference.getQ() * Physics::c) / itsReference.getP(); - const BDipoleField &field = corr.getField(); - itsMap[PX] -= field.getBy() * scale; - itsMap[PY] += field.getBx() * scale; - - // Drift through second half of length. - if(length != 0.0) applyDrift(length / 2.0); -} - -void ThickMapper::visitDegrader(const Degrader °) { - applyDrift(flip_s * deg.getElementLength()); -} - -void ThickMapper::visitDiagnostic(const Diagnostic &diag) { - // The diagnostic has no effect on the map. - applyDrift(flip_s * diag.getElementLength()); -} - - -void ThickMapper::visitDrift(const Drift &drift) { - applyDrift(flip_s * drift.getElementLength()); -} - -void ThickMapper::visitFlexibleCollimator(const FlexibleCollimator &coll) { - applyDrift(flip_s * coll.getElementLength()); -} - -void ThickMapper::visitLambertson(const Lambertson &lamb) { - // Assume the particle go through the magnet's window. - applyDrift(flip_s * lamb.getElementLength()); -} - - -void ThickMapper::visitMarker(const Marker &/*marker*/) { - // Do nothing. -} - - -void ThickMapper::visitMonitor(const Monitor &corr) { - applyDrift(flip_s * corr.getElementLength()); -} - - -void ThickMapper::visitMultipole(const Multipole &mult) { - //std::cerr << "==> In ThickMapper::visitMultipole(const Multipole &mult)" << std::endl; - // Geometry and Field - double length = flip_s * mult.getElementLength(); - double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP(); - const BMultipoleField &field = mult.getField(); - int order = field.order(); - - if(length == 0.0) { - // Thin multipole, field coefficients are integral(B*dl). - scale *= flip_s; - applyThinMultipole(field, scale); - } else { - // Finite-length multipole, field coefficients are B. - // Apply entrance fringe field. - applyEntranceFringe(0.0, 0.0, field, scale); - - // Remove closed orbit from map. - Vector co = itsMap.constantTerm(); - itsMap.setMinOrder(1); - - // Construct the Hamiltonian H about that closed orbit. - // (1) Define variables. - static const Series px = Series::makeVariable(PX); - static const Series py = Series::makeVariable(PY); - static const Series pt = Series::makeVariable(PT) + 1.0; // 1 + \delta = p/p0 - static const Map ident; - Map translate = co + ident; - // (2) Construct kinematic terms. - double kin = itsReference.getM() / itsReference.getP(); // = 1/(beta*gamma) - Series E_trans = sqrt((pt * pt + kin * kin).substitute(translate), order) / itsReference.getBeta(); - Series pz_trans = sqrt((pt * pt - px * px - py * py).substitute(translate), order); - // (3) Build vector potential in straight reference frame. - Series As = buildMultipoleVectorPotential(field) * scale; - As.setTruncOrder(Series::EXACT); - // (4) Build Hamiltonian. - Series H_trans = E_trans - pz_trans + As.substitute(translate); - - // Propagate closed orbit. - // Build J.grad(H). - VSeries JgradH; - for(int i = 0; i < PSdim; i += 2) { - JgradH[ i ] = H_trans.derivative(i + 1); - JgradH[i+1] = -H_trans.derivative(i); - } - // Do integration to propagate closed orbit using implicitInt4(). - static const Vector zeroV; - Vector new_co = co + implicitInt4(zeroV, JgradH, length, 0.5 * length); - - // Propagate map. - H_trans.setMinOrder(2); // Can do this because we assume zin is on the closed orbit. - itsMap = ExpMap((-length) * H_trans).substitute(itsMap); - - // Add new closed orbit to propagated map. - itsMap += new_co; - - // Apply exit fringe field. - applyExitFringe(0.0, 0.0, field, scale); - } - //std::cerr << "==> Leaving ThickMapper::visitMultipole(...)" << std::endl; -} - -void ThickMapper::visitProbe(const Probe &/*prob*/) { - // Do nothing. -} - -void ThickMapper::visitRBend(const RBend &bend) { - //std::cerr << "==> In ThickMapper::visitRBend(const RBend &bend)" << std::endl; - // Geometry and Field. - const RBendGeometry &geometry = bend.getGeometry(); - double length = flip_s * geometry.getElementLength(); - double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP(); - const BMultipoleField &field = bend.getField(); - int order = field.order(); - double beta_inv = 1.0 / itsReference.getBeta(); - - // Compute slices and stepsize. - int nSlices = (int) bend.getSlices(); - double stepsize = bend.getStepsize(); - if(stepsize != 0.0) { - int nst = (int) ceil(length / stepsize); - nSlices = std::max(nSlices, nst); - } - double d_ell = length / nSlices; - - if(length == 0.0) { - // Thin RBend. - double half_angle = flip_s * geometry.getBendAngle() / 2.0; - Euclid3D rotat = Euclid3D::YRotation(- half_angle); - applyTransform(rotat, 0.0); // Transform from in-plane to mid-plane. - applyThinMultipole(field, scale); // Apply multipole kick. - applyTransform(rotat, 0.0); // Transform from mid-plane to out-plane. - } else { - // Finite-length RBend. - // Define variables, ... - static const Series x = Series::makeVariable(X); - static const Series px = Series::makeVariable(PX); - static const Series py = Series::makeVariable(PY); - static const Series de = Series::makeVariable(PT); - static const Series de2 = de * de; - static const Series pxy2 = px * px + py * py; - static const Map ident; - // kinematic terms, ... - double kin = itsReference.getM() / itsReference.getP(); // mc^2/pc = 1/(beta*gamma) - double kin2 = kin * kin; - // and the vector potential, actually -As in straight reference frame. - Series As = buildMultipoleVectorPotential(field) * scale; - As.setTruncOrder(Series::EXACT); - - if(back_path) { - // Apply rotation global to local. - applyTransform(Inverse(geometry.getExitPatch())); - // Apply entrance fringe field. - applyEntranceFringe(bend.getExitFaceRotation(), scale, field, scale); - } else { - // Apply rotation global to local. - applyTransform(geometry.getEntrancePatch()); - // Apply exit fringe field. - applyEntranceFringe(bend.getEntryFaceRotation(), scale, field, scale); - } - - // Remove closed orbit from map. - Vector co = itsMap.constantTerm(); - itsMap.setMinOrder(1); - - // Propagate closed orbit and map. - for(int slice = 0; slice < nSlices; ++slice) { - // Construct translated Hamiltonian about closed orbit. - double p1 = 1.0 + co[PT]; - Series de12 = p1 * p1 + 2.0 * p1 * de + de2; - Series H_trans = beta_inv * sqrt(de12 + kin2, order) - - sqrt(de12 - co[PX] * co[PX] - co[PY] * co[PY] - - 2.0 * (co[PX] * px + co[PY] * py) - pxy2, order) - + As.substitute(co + ident); - // Build J.grad(H). - VSeries JgradH; - for(int i = 0; i < PSdim; i += 2) { - JgradH[ i ] = H_trans.derivative(i + 1); - JgradH[i+1] = -H_trans.derivative(i); - } - // Do integration to propagate closed orbit using implicitInt4(). - static const Vector zeroV; - Vector new_co = co + implicitInt4(zeroV, JgradH, d_ell, 0.5 * d_ell); - // Propagate map using mid-point of closed-orbit path. - Vector mid_co = (co + new_co) / 2.0; - p1 = 1.0 + mid_co[PT]; - de12 = p1 * p1 + 2.0 * p1 * de + de2; - H_trans = beta_inv * sqrt(de12 + kin2, order) - - sqrt(de12 - mid_co[PX] * mid_co[PX] - mid_co[PY] * mid_co[PY] - - 2.0 * (mid_co[PX] * px + mid_co[PY] * py) - pxy2, order) - + As.substitute(mid_co + ident); - H_trans.setMinOrder(2); // Can do this because we expand about the closed orbit. - itsMap = ExpMap((-d_ell) * H_trans).substitute(itsMap); - // Set closed-orbit to new value. - co = new_co; - } - - // Add new closed orbit to propagated map. - itsMap += co; - - if(back_path) { - // Apply exit fringe field. - applyExitFringe(bend.getEntryFaceRotation(), scale, field, scale); - // Transform from local to global. - applyTransform(Inverse(geometry.getEntrancePatch())); - } else { - // Apply entrance fringe field. - applyEntranceFringe(bend.getExitFaceRotation(), scale, field, scale); - // Transform from local to global. - applyTransform(geometry.getExitPatch()); - } - } -} - - -void ThickMapper::visitRFCavity(const RFCavity &as) { - double length = flip_s * as.getElementLength(); - - // Drift through half length. - if(length != 0.0) applyDrift(length / 2.0); - - // Apply accelerating voltage. - double freq = as.getFrequency(); - double kin = itsReference.getM() / itsReference.getP(); - double peak = flip_s * as.getAmplitude() / itsReference.getP(); - - Series pt = itsMap[PT] + 1.0; - Series speed = (Physics::c * pt) / sqrt(pt * pt + kin * kin); - Series phase = as.getPhase() + freq * itsMap[T] / speed; - itsMap[PT] += peak * sin(phase) / pt; - - // Drift through half length. - if(length != 0.0) applyDrift(length / 2.0); -} - - -void ThickMapper::visitRFQuadrupole(const RFQuadrupole &rfq) { - // *** MISSING *** Map for RF quadrupole. - applyDrift(flip_s * rfq.getElementLength()); -} - - -void ThickMapper::visitSBend(const SBend &bend) { - //std::cerr << "==> In ThickMapper::visitSBend(const SBend &bend)" << std::endl; - // Geometry and Field. - const PlanarArcGeometry &geometry = bend.getGeometry(); - double length = flip_s * geometry.getElementLength(); - double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP(); - const BMultipoleField &field = bend.getField(); - int order = field.order(); - double beta_inv = 1.0 / itsReference.getBeta(); - - // Compute slices and stepsize. - int nSlices = (int) bend.getSlices(); - double stepsize = bend.getStepsize(); - if(stepsize != 0.0) { - int nst = (int) ceil(length / stepsize); - nSlices = std::max(nSlices, nst); - } - double d_ell = length / nSlices; - - if(length == 0.0) { - // Thin SBend. - double half_angle = geometry.getBendAngle() / 2.0; - Euclid3D rotat = Euclid3D::YRotation(- half_angle); - applyTransform(rotat, 0.0); // Transform from in-plane to mid-plane. - applyThinSBend(field, scale, 0.0); // Apply multipole kick. - applyTransform(rotat, 0.0); // Transform from mid-plane to out-plane. - } else { - // Finite-length SBend. - // Define variables, ... - static const Series x = Series::makeVariable(X); - static const Series px = Series::makeVariable(PX); - static const Series py = Series::makeVariable(PY); - static const Series de = Series::makeVariable(PT); - static const Series de2 = de * de; - static const Series pxy2 = px * px + py * py; - static const Map ident; - // kinematic terms, ... - double h = geometry.getCurvature(); - double kin = itsReference.getM() / itsReference.getP(); // mc^2/pc = 1/(beta*gamma) - double kin2 = kin * kin; - Series hx1 = (1.0 + h * x); - // and the vector potential, actually -(1+h*x)*As in reference frame of curvature h. - Series As = buildSBendVectorPotential(field, h) * scale; - As.setTruncOrder(Series::EXACT); - - // Apply entrance fringe field. - applyEntranceFringe(bend.getEntryFaceRotation(), - bend.getEntryFaceCurvature(), field, scale); - - // Remove closed orbit from map. - Vector co = itsMap.constantTerm(); - itsMap.setMinOrder(1); - - // Propagate closed orbit and map. - for(int slice = 0; slice < nSlices; ++slice) { - // Construct translated Hamiltonian about closed orbit. - double p1 = 1.0 + co[PT]; - Series de12 = p1 * p1 + 2.0 * p1 * de + de2; - Series H_trans = beta_inv * sqrt(de12 + kin2, order) - - (hx1 + h * co[X]) - * sqrt(de12 - co[PX] * co[PX] - co[PY] * co[PY] - - 2.0 * (co[PX] * px + co[PY] * py) - pxy2, order) - + As.substitute(co + ident); - // Build J.grad(H). - VSeries JgradH; - for(int i = 0; i < PSdim; i += 2) { - JgradH[ i ] = H_trans.derivative(i + 1); - JgradH[i+1] = -H_trans.derivative(i); - } - // Do integration to propagate closed orbit using implicitInt4(). - static const Vector zeroV; - Vector new_co = co + implicitInt4(zeroV, JgradH, d_ell, 0.5 * d_ell); - // Propagate map using mid-point of closed-orbit path. - Vector mid_co = (co + new_co) / 2.0; - p1 = 1.0 + mid_co[PT]; - de12 = p1 * p1 + 2.0 * p1 * de + de2; - H_trans = beta_inv * sqrt(de12 + kin2, order) - - (hx1 + h * mid_co[X]) - * sqrt(de12 - mid_co[PX] * mid_co[PX] - mid_co[PY] * mid_co[PY] - - 2.0 * (mid_co[PX] * px + mid_co[PY] * py) - pxy2, order) - + As.substitute(mid_co + ident); - H_trans.setMinOrder(2); // Can do this because we expand about the closed orbit. - itsMap = ExpMap((-d_ell) * H_trans).substitute(itsMap); - // Set closed-orbit to new value. - co = new_co; - } - - // Add new closed orbit to propagated map. - itsMap += co; - - // Apply exit fringe field. - applyExitFringe(bend.getExitFaceRotation(), - bend.getExitFaceCurvature(), field, scale); - } - //std::cerr << "==> Leaving ThickMapper::visitSBend(...)" << std::endl; -} - - -void ThickMapper::visitSeparator(const Separator &sep) { - double length = flip_s * sep.getElementLength(); - - if(length != 0.0) { - // Drift through first half of length. - applyDrift(length / 2.0); - - // electrostatic kick. - double scale = (length * itsReference.getQ()) / itsReference.getP(); - double Ex = scale * sep.getEx(); - double Ey = scale * sep.getEy(); - Series pt = 1.0 + itsMap[PT]; - itsMap[PX] += Ex / pt; - itsMap[PY] += Ey / pt; - - // Drift through second half of length. - applyDrift(length / 2.0); - } -} - - -void ThickMapper::visitSeptum(const Septum &sept) { - // Assume the particle go through the magnet's window. - applyDrift(flip_s * sept.getElementLength()); -} - - -void ThickMapper::visitSolenoid(const Solenoid &solenoid) { - double length = flip_s * solenoid.getElementLength(); - - if(length != 0.0) { - double ks = (flip_B * itsReference.getQ() * solenoid.getBz() * Physics::c) / - (2.0 * itsReference.getP()); - - if(ks) { - double kin = itsReference.getM() / itsReference.getP(); - double refTime = length / itsReference.getBeta(); - - Series pt = itsMap[PT] + 1.0; - Series px = itsMap[PX] + ks * itsMap[Y]; - Series py = itsMap[PY] - ks * itsMap[X]; - Series pz = sqrt(pt * pt - px * px - py * py); - Series E = sqrt(pt * pt + kin * kin); - - Series k = ks / pz; - Series C = cos(k * length); - Series S = sin(k * length); - - Series xt = C * itsMap[X] + S * itsMap[Y]; - Series yt = C * itsMap[Y] - S * itsMap[X]; - Series pxt = C * itsMap[PX] + S * itsMap[PY]; - Series pyt = C * itsMap[PY] - S * itsMap[PX]; - - itsMap[X] = C * xt + (S / k) * pxt; - itsMap[Y] = C * yt + (S / k) * pyt; - itsMap[PX] = C * pxt - (S * k) * xt; - itsMap[PY] = C * pyt - (S * k) * yt; - itsMap[T] += pt * (refTime / E - length / pz); - } else { - applyDrift(length); - } - } -} - - -void ThickMapper::visitParallelPlate(const ParallelPlate &/*pplate*/) { - // Do nothing. -} - - -void ThickMapper::applyDrift(double length) { - if(length != 0.0) { - // HACK: fix a maximum order for computations. - int order = 6; - - // Remove closed orbit from map. - Vector co = itsMap.constantTerm(); - itsMap.setMinOrder(1); - - // Construct the Hamiltonian H about that closed orbit. - // (1) Define variables. - static const Series px = Series::makeVariable(PX); - static const Series py = Series::makeVariable(PY); - static const Series pt = Series::makeVariable(PT) + 1.0; - static const Series x = Series::makeVariable(X); - static const Map ident; - Map translate = co + ident; - // (2) Construct kinematic terms. - double kin = itsReference.getM() / itsReference.getP(); // 1/(beta*gamma) - Series E_trans = sqrt((pt * pt + kin * kin).substitute(translate), order) - / itsReference.getBeta(); - Series pz_trans = sqrt((pt * pt - px * px - py * py).substitute(translate), order); - // (3) Build Hamiltonian. - Series H_trans = E_trans - pz_trans; - - // Propagate closed orbit. - // Build J.grad(H). - VSeries JgradH; - for(int i = 0; i < PSdim; i += 2) { - JgradH[ i ] = H_trans.derivative(i + 1); - JgradH[i+1] = -H_trans.derivative(i); - } - // Do integration to propagate closed orbit using implicitInt4(). - static const Vector zeroV; - Vector new_co = co + implicitInt4(zeroV, JgradH, length, 0.5 * length); - - // Propagate map. - H_trans.setMinOrder(2); // Can do this because we assume zin is on the closed orbit. - itsMap = ExpMap((-length) * H_trans).substitute(itsMap); - - // Add new closed orbit to propagated map. - itsMap += new_co; - } -} - - -void ThickMapper::applyEntranceFringe(double angle, double /*curve*/, - const BMultipoleField &field, double scale) { - // *** MISSING *** Higher order terms for entrance fringe. - double ca = cos(angle); - double sa = sin(angle); - double ta = tan(angle); - - int order = field.order(); - static const Series x = Series::makeVariable(X); - Series by = field.normal(order); - for(int i = order; --i >= 1;) by = by * x + field.normal(i); - by *= scale; - - const Series p = itsMap[PT] + 1.0; - // rotate to magnet face - Series ps = sqrt(p * p - itsMap[PX] * itsMap[PX] - itsMap[PY] * itsMap[PY], order); - itsMap[X] = itsMap[X] / (ca * (1.0 - ta * itsMap[PX] / ps)); - itsMap[PX] = ca * itsMap[PX] + sa * ps; - Series ellovpp = sa * itsMap[X] / ps; - itsMap[Y] += ellovpp * itsMap[PY]; - itsMap[T] -= ellovpp * p; - // fringe - Series psy = sqrt(p * p - itsMap[PX] * itsMap[PX], order); - itsMap[PY] -= by.substitute(itsMap) * itsMap[Y] * itsMap[PX] / psy; - // rotate from magnet face - ps = sqrt(p * p - itsMap[PX] * itsMap[PX] - itsMap[PY] * itsMap[PY], order); - itsMap[X] = itsMap[X] / (ca * (1.0 + ta * itsMap[PX] / ps)); - itsMap[PX] = ca * itsMap[PX] - sa * ps; - ellovpp = sa * itsMap[X] / ps; - itsMap[Y] -= ellovpp * itsMap[PY]; - itsMap[T] += ellovpp * p; - // edge effect - itsMap[PX] += by.substitute(itsMap) * ta * itsMap[X]; -} - - -void ThickMapper::applyExitFringe(double angle, double /*curve*/, - const BMultipoleField &field, double scale) { - // *** MISSING *** Higher order terms for exit fringe. - double ca = cos(angle); - double sa = sin(angle); - double ta = tan(angle); - - int order = field.order(); - static const Series x = Series::makeVariable(X); - Series by = field.normal(order); - for(int i = order; --i >= 1;) by = by * x + field.normal(i); - by *= scale; - - const Series p = itsMap[PT] + 1.0; - // edge effect - itsMap[PX] += by.substitute(itsMap) * ta * itsMap[X]; - // rotate to magnet face - Series ps = sqrt(p * p - itsMap[PX] * itsMap[PX] - itsMap[PY] * itsMap[PY], order); - itsMap[X] = itsMap[X] / (ca * (1.0 + ta * itsMap[PX] / ps)); - itsMap[PX] = ca * itsMap[PX] - sa * ps; - Series ellovpp = sa * itsMap[X] / ps; - itsMap[Y] -= ellovpp * itsMap[PY]; - itsMap[T] += ellovpp * p; - // fringe - Series psy = sqrt(p * p - itsMap[PX] * itsMap[PX], order); - itsMap[PY] += by.substitute(itsMap) * itsMap[Y] * itsMap[PX] / psy; - // rotate from magnet face - ps = sqrt(p * p - itsMap[PX] * itsMap[PX] - itsMap[PY] * itsMap[PY], order); - itsMap[X] = itsMap[X] / (ca * (1.0 - ta * itsMap[PX] / ps)); - itsMap[PX] = ca * itsMap[PX] + sa * ps; - ellovpp = sa * itsMap[X] / ps; - itsMap[Y] += ellovpp * itsMap[PY]; - itsMap[T] -= ellovpp * p; -} - -namespace { - Vector implicitInt4(const Vector &zin, const VSeries &f, double s, double ds, int nx, int cx) { - //std::cerr << "==> In implicitInt4(zin,f,s,ds,nx,cx) ..." << std::endl; - // Default: nx = 20, cx = 4 - - // This routine integrates the N-dimensional autonomous differential equation - // z' = f(z) for a distance s, in steps of size ds. It uses a "Yoshida-fied" - // version of implicitInt2 to obtain zf accurate through fourth-order in the - // step-size ds. When f derives from a Hamiltonian---i.e., f = J.grad(H)--- - // then this routine performs symplectic integration. The optional arguments - // nx and cx have the same meaning as in implicitInt2(). - - // The Yoshida constants: 2ya+yb=1; 2ya^3+yb^3=0. - static const double yt = pow(2., 1 / 3.); - static const double ya = 1 / (2. - yt); - static const double yb = -yt * ya; - - // Build matrix grad(f). - MxSeries gradf; - for(int i = 0; i < PSdim; ++i) - for(int j = 0; j < PSdim; ++j) - gradf[i][j] = f[i].derivative(j); - - // Initialize accumulated length, current step-size, and number of cuts. - double as = std::abs(s), st = 0., dsc = std::abs(ds); - if(s < 0.) dsc = -dsc; - int ci = 0; - - // Integrate each step. - Vector zf = zin; - while(std::abs(st) < as) { - Vector zt; - bool ok = true; - try { - if(std::abs(st + dsc) > as) dsc = s - st; - zt = ::implicitIntStep(zf, f, gradf, ya * dsc, nx); - zt = ::implicitIntStep(zt, f, gradf, yb * dsc, nx); - zt = ::implicitIntStep(zt, f, gradf, ya * dsc, nx); - } catch(ConvergenceError &cnverr) { - if(++ci > cx) { - std::string msg = "Convergence not achieved within " + std::to_string(cx) + " cuts of step-size!"; - throw ConvergenceError("ThickMapper::implicitInt4()", msg); - } - //std::cerr << " cutting step size in half" << std::endl; - dsc *= 0.5; - ok = false; - } - if(ok) {zf = zt; st += dsc;} - } - - //std::cerr << "==> Leaving implicitInt4(zin,f,s,ds,nx,cx)" << std::endl; - return zf; - } - - Vector implicitIntStep(const Vector &zin, const VSeries &f, const MxSeries gradf, double ds, int nx) { - //std::cerr << "==> In implicitIntStep(zin,f,gradf,ds,nx) ..." << std::endl; - //std::cerr << " ds = " << ds << std::endl; - //std::cerr << " zin =\n" << zin << std::endl; - // This routine integrates the N-dimensional autonomous differential equation - // z' = f(z) for a single step of size ds, using Newton's method to solve the - // implicit equation zf = zin + ds*f((zin+zf)/2). For reasons of efficiency, - // its arguments include the matrix gradf = grad(f). The (optional) argument - // nx limits the number of Newton iterations. This routine returns a result - // zf accurate through second-order in the step-size ds. When f derives from - // a Hamiltonian---i.e., f=J.grad(H)---then this routine performs symplectic - // integration. - - // Set up flags, etc., for convergence (bounce) test. - FVector<bool, PSdim> bounce(false); - Vector dz, dz_old; - int bcount = 0; - static const double thresh = 1.e-8; - - // Use second-order Runge-Kutta integration to determine a good initial guess. - double ds2 = 0.5 * ds; - Vector z = f.constantTerm(zin); - z = zin + ds2 * (z + f.constantTerm(zin + ds * z)); - - // Newton iterations: - // z :-> [I-ds/2.grad(f)]^{-1}.[zin+ds.f((zin+z)/2)-ds/2.grad(f).z] - Vector zf; - int ni = 0; - while(bcount < PSdim) { - if(ni == nx) { - std::string msg = "Convergence not achieved within " + std::to_string(nx) + " iterations!"; - throw ConvergenceError("ThickMapper::implicitIntStep()", msg); - } - - // Build gf = -ds/2.grad(f)[(zin+z)/2] and idgf_inv = [I-ds/2.grad(f)]^{-1}[(zin+z)/2]. - Vector zt = 0.5 * (zin + z); - Matrix gf, idgf, idgf_inv; - for(int i = 0; i < PSdim; ++i) - for(int j = 0; j < PSdim; ++j) - gf[i][j] = -ds2 * gradf[i][j].evaluate(zt); - idgf = gf; - for(int i = 0; i < PSdim; ++i) idgf[i][i] += 1.; - FLUMatrix<double, PSdim> lu(idgf); - idgf_inv = lu.inverse(); - - // Execute Newton step. - zf = idgf_inv * (zin + ds * f.constantTerm(zt) + gf * z); - - //std::cerr << " -(ds/2)grad(f) =\n" << gf << std::endl; - //std::cerr << " f =\n" << f.constantTerm(zt) << std::endl; - //std::cerr << "zk =\n" << zf << std::endl; - - // Test for convergence ("bounce" test). - dz_old = dz; - dz = zf - z; - if(ni) { // (we need at least two iterations before testing makes sense) - for(int i = 0; i < PSdim; ++i) { - if(!bounce[i] && (dz[i] == 0. || (std::abs(dz[i]) < thresh && std::abs(dz[i]) >= std::abs(dz_old[i])))) - {bounce[i] = true; ++bcount;} - } - } - z = zf; - ++ni; - } - - //std::cerr << " zf =\n" << zf << std::endl; - //std::cerr << "==> Leaving implicitIntStep(zin,f,gradf,ds,nx)" << std::endl; - return zf; - } -}; \ No newline at end of file diff --git a/src/Algorithms/ThickMapper.h b/src/Algorithms/ThickMapper.h deleted file mode 100644 index dffafc134b15f63a960f41aefcbb14aec6002811..0000000000000000000000000000000000000000 --- a/src/Algorithms/ThickMapper.h +++ /dev/null @@ -1,179 +0,0 @@ -#ifndef OPAL_ThickMapper_HH -#define OPAL_ThickMapper_HH - -// ------------------------------------------------------------------------ -// $RCSfile: ThickMapper.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1.4.2 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ThickMapper -// -// ------------------------------------------------------------------------ -// -// $Date: 2004/11/12 20:10:11 $ -// $Author: adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Algorithms/Mapper.h" - -class BMultipoleField; -class PlanarArcGeometry; - - -// Class ThickMapper -// ------------------------------------------------------------------------ -/// Build a map using a finite-length lens for each element. -// Multipole-like elements are done by expanding the Lie series. -// [p] -// Phase space coordinates numbering: -// [tab 3 b] -// [row]number [&]name [&]unit [/row] -// [row]0 [&]$x$ [&]metres [/row] -// [row]1 [&]$p_x/p_r$ [&]1 [/row] -// [row]2 [&]$y$ [&]metres [/row] -// [row]3 [&]$p_y/p_r$ [&]1 [/row] -// [row]4 [&]$v*delta_t$ [&]metres [/row] -// [row]5 [&]$delta_p/p_r$ [&]1 [/row] -// [/tab][p] -// Where $p_r$ is the constant reference momentum defining the reference -// frame velocity, $m$ is the rest mass of the particles, and $v$ is the -// instantaneous velocity of the particle. -// [p] -// Other units used: -// [tab 2 b] -// [row]quantity [&]unit [/row] -// [row]reference momentum [&]electron-volts [/row] -// [row]velocity [&]metres/second [/row] -// [row]accelerating voltage [&]volts [/row] -// [row]separator voltage [&]volts [/row] -// [row]frequencies [&]hertz [/row] -// [row]phase lags [&]$2*pi$ [/row] -// [/tab][p] -// Approximations used: -// [ul] -// [li] All elements are represented by maps for finite-length elements. -// For multipole-like elements the Lie series is used. -// [li] Geometric transformations ignore rotations about transverse axes and -// translations along the design orbit and truncate after second order. -// [li] Beam-beam elements are two-dimensional, and the second moment <x,y> -// of the opposite bunches vanish. -// [/ul] -// -// On going through an element, we increment the map using the following steps: -// Remove the closed orbit from the map. -// Construct the Hamiltonian H about that closed orbit. -// To do this properly, we must expand the square-root AFTER we translate -// its argument. In addition, note that the vector potential will be -// computed to an order determined by the number of field coefficients -// handed to it, and this may or may not agree with the order of the map. -// So as to avoid artificially truncating our map, we make the vector -// potential exact. Then when we add it to the Hamiltonian, after -// translating it according to the closed orbit, the Hamiltonian's -// truncation order will remain unchanged. -// Compute the map exp(-l:H:)z for the present element. -// Propagate the map by sustituting it into the map for the present element. -// exp(:f:) exp(:g:)z = G(F(z)) -// ||| ||| -// curr.map element -// To complete the map, we propagate the closed orbit and add that to the map. - -class ThickMapper: public Mapper { - -public: - - /// Constructor. - // The beam line to be tracked is "bl". - // The particle reference data are taken from "data". - // If [b]revBeam[/b] is true, the beam runs from s = C to s = 0. - // If [b]revTrack[/b] is true, we track against the beam. - explicit ThickMapper(const Beamline &bl, const PartData &data, - bool backBeam, bool backTrack); - - virtual ~ThickMapper(); - - /// Apply the algorithm to a BeamBeam. - virtual void visitBeamBeam(const BeamBeam &); - - /// Apply the algorithm to a BeamStripping. - virtual void visitBeamStripping(const BeamStripping &); - - /// Apply the algorithm to a collimator. - virtual void visitCCollimator(const CCollimator &); - - /// Apply the algorithm to a Corrector. - virtual void visitCorrector(const Corrector &); - - /// Apply the algorithm to a Degrader. - virtual void visitDegrader(const Degrader &); - - /// Apply the algorithm to a Diagnostic. - virtual void visitDiagnostic(const Diagnostic &); - - /// Apply the algorithm to a Drift. - virtual void visitDrift(const Drift &); - - /// Apply the algorithm to a flexible collimator - virtual void visitFlexibleCollimator(const FlexibleCollimator &); - - /// Apply the algorithm to a Lambertson. - virtual void visitLambertson(const Lambertson &); - - /// Apply the algorithm to a Marker. - virtual void visitMarker(const Marker &); - - /// Apply the algorithm to a Monitor. - virtual void visitMonitor(const Monitor &); - - /// Apply the algorithm to a Multipole. - virtual void visitMultipole(const Multipole &); - - /// Apply the algorithm to a Probe. - virtual void visitProbe(const Probe &); - - /// Apply the algorithm to a RBend. - virtual void visitRBend(const RBend &); - - /// Apply the algorithm to a RFCavity. - virtual void visitRFCavity(const RFCavity &); - - /// Apply the algorithm to a RFQuadrupole. - virtual void visitRFQuadrupole(const RFQuadrupole &); - - /// Apply the algorithm to a SBend. - virtual void visitSBend(const SBend &); - - /// Apply the algorithm to a Separator. - virtual void visitSeparator(const Separator &); - - /// Apply the algorithm to a Septum. - virtual void visitSeptum(const Septum &); - - /// Apply the algorithm to a Solenoid. - virtual void visitSolenoid(const Solenoid &); - - /// Apply the algorithm to a ParallelPlate. - virtual void visitParallelPlate(const ParallelPlate &); - -private: - - // Not implemented. - ThickMapper(); - ThickMapper(const ThickMapper &); - void operator=(const ThickMapper &); - - // Apply drift length. - void applyDrift(double length); - - // Fringe fields for entrance and exit of a magnetic element. - void applyEntranceFringe(double edge, double curve, - const BMultipoleField &field, double scale); - void applyExitFringe(double edge, double curve, - const BMultipoleField &field, double scale); - -}; - -#endif // OPAL_ThickMapper_HH \ No newline at end of file diff --git a/src/Algorithms/ThickTracker.h b/src/Algorithms/ThickTracker.h index 1703e0baa1773c176f7429a841b007d663982af9..7ea954f78927ba0e627aa8660e2f671f38ea0ebc 100644 --- a/src/Algorithms/ThickTracker.h +++ b/src/Algorithms/ThickTracker.h @@ -31,27 +31,21 @@ #include "MapAnalyser.h" #include "Algorithms/IndexMap.h" -#include "AbsBeamline/BeamBeam.h" #include "AbsBeamline/BeamStripping.h" #include "AbsBeamline/CCollimator.h" #include "AbsBeamline/Corrector.h" -#include "AbsBeamline/Diagnostic.h" #include "AbsBeamline/Degrader.h" #include "AbsBeamline/Drift.h" #include "AbsBeamline/FlexibleCollimator.h" #include "AbsBeamline/ElementBase.h" -#include "AbsBeamline/Lambertson.h" #include "AbsBeamline/Marker.h" #include "AbsBeamline/Monitor.h" #include "AbsBeamline/Multipole.h" -#include "AbsBeamline/ParallelPlate.h" #include "AbsBeamline/Probe.h" #include "AbsBeamline/RFCavity.h" -#include "AbsBeamline/RFQuadrupole.h" #include "AbsBeamline/RBend.h" #include "AbsBeamline/RBend3D.h" #include "AbsBeamline/SBend.h" -#include "AbsBeamline/Separator.h" #include "AbsBeamline/Septum.h" #include "AbsBeamline/Solenoid.h" #include "AbsBeamline/TravelingWave.h" @@ -92,7 +86,6 @@ class PartBunchBase; // [row]reference momentum [&]electron-volts [/row] // [row]velocity [&]metres/second [/row] // [row]accelerating voltage [&]volts [/row] -// [row]separator voltage [&]volts [/row] // [row]frequencies [&]hertz [/row] // [row]phase lags [&]$2*pi$ [/row] // [/tab][p] @@ -148,9 +141,6 @@ public: virtual ~ThickTracker(); - /// Apply the algorithm to a BeamBeam. - virtual void visitBeamBeam(const BeamBeam &); - /// Apply the algorithm to a BeamStripping. virtual void visitBeamStripping(const BeamStripping &); @@ -163,18 +153,12 @@ public: /// Apply the algorithm to a Degrader. virtual void visitDegrader(const Degrader &); - /// Apply the algorithm to a Diagnostic. - virtual void visitDiagnostic(const Diagnostic &); - /// Apply the algorithm to a Drift. virtual void visitDrift(const Drift &); /// Apply the algorithm to a flexible collimator virtual void visitFlexibleCollimator(const FlexibleCollimator &); - /// Apply the algorithm to a Lambertson. - virtual void visitLambertson(const Lambertson &); - /// Apply the algorithm to a Marker. virtual void visitMarker(const Marker &); @@ -195,24 +179,15 @@ public: /// Apply the algorithm to a RFCavity. virtual void visitTravelingWave(const TravelingWave &); - /// Apply the algorithm to a RFQuadrupole. - virtual void visitRFQuadrupole(const RFQuadrupole &); - /// Apply the algorithm to a SBend. virtual void visitSBend(const SBend &); - /// Apply the algorithm to a Separator. - virtual void visitSeparator(const Separator &); - /// Apply the algorithm to a Septum. virtual void visitSeptum(const Septum &); /// Apply the algorithm to a Solenoid. virtual void visitSolenoid(const Solenoid &); - /// Apply the algorithm to a ParallelPlate. - virtual void visitParallelPlate(const ParallelPlate &); - /// Apply the algorithm to a beam line. // overwrite the execute-methode from DefaultVisitor virtual void visitBeamline(const Beamline &); @@ -381,10 +356,6 @@ private: IpplTimings::TimerRef mapTracking_m; ///< track particles trough maps of elements_m }; -inline void ThickTracker::visitBeamBeam(const BeamBeam &/*bb*/) { -// itsOpalBeamline_m.visit(bb, *this, itsBunch_m); - this->throwElementError_m("BeamBeam"); -} inline void ThickTracker::visitBeamStripping(const BeamStripping &bstp) { itsOpalBeamline_m.visit(bstp, *this, itsBunch_m); @@ -408,12 +379,6 @@ inline void ThickTracker::visitDegrader(const Degrader &/*deg*/) { } -inline void ThickTracker::visitDiagnostic(const Diagnostic &/*diag*/) { -// itsOpalBeamline_m.visit(diag, *this, itsBunch_m); - this->throwElementError_m("Diagnostic"); -} - - inline void ThickTracker::visitDrift(const Drift &drift) { itsOpalBeamline_m.visit(drift, *this, itsBunch_m); @@ -434,11 +399,6 @@ inline void ThickTracker::visitFlexibleCollimator(const FlexibleCollimator &/*co } -inline void ThickTracker::visitLambertson(const Lambertson &/*lamb*/) { -// itsOpalBeamline_m.visit(lamb, *this, itsBunch_m); - this->throwElementError_m("Lambertson"); -} - inline void ThickTracker::visitMarker(const Marker &/*marker*/) { // itsOpalBeamline_m.visit(marker, *this, itsBunch_m); @@ -494,11 +454,6 @@ inline void ThickTracker::visitTravelingWave(const TravelingWave &/*as*/) { } -inline void ThickTracker::visitRFQuadrupole(const RFQuadrupole &/*rfq*/) { -// itsOpalBeamline_m.visit(rfq, *this, itsBunch_m); - this->throwElementError_m("RFQuadrupole"); -} - inline void ThickTracker::visitSBend(const SBend &bend) { itsOpalBeamline_m.visit(bend, *this, itsBunch_m); @@ -552,12 +507,6 @@ inline void ThickTracker::visitSBend(const SBend &bend) { } -inline void ThickTracker::visitSeparator(const Separator &/*sep*/) { -// itsOpalBeamline_m.visit(sep, *this, itsBunch_m); - this->throwElementError_m("Separator"); -} - - inline void ThickTracker::visitSeptum(const Septum &/*sept*/) { // itsOpalBeamline_m.visit(sept, *this, itsBunch_m); this->throwElementError_m("Septum"); @@ -570,9 +519,4 @@ inline void ThickTracker::visitSolenoid(const Solenoid &/*solenoid*/) { } -inline void ThickTracker::visitParallelPlate(const ParallelPlate &/*pplate*/) { -// itsOpalBeamline_m.visit(pplate, *this, itsBunch_m); - this->throwElementError_m("ParallelPlate"); -} - #endif // OPAL_ThickTracker_HH \ No newline at end of file diff --git a/src/BasicActions/CMakeLists.txt b/src/BasicActions/CMakeLists.txt index 35275257638990040e5f807ba3fc7ca89d3890df..3e0b094366d694a7a0f159a4a83212c36f648401 100644 --- a/src/BasicActions/CMakeLists.txt +++ b/src/BasicActions/CMakeLists.txt @@ -1,21 +1,17 @@ set (_SRCS Call.cpp - Dump.cpp DumpFields.cpp DumpEMFields.cpp Echo.cpp Help.cpp Option.cpp - Save.cpp Select.cpp - Show.cpp Stop.cpp Quit.cpp PSystem.cpp System.cpp Title.cpp Value.cpp - What.cpp ) include_directories ( @@ -28,20 +24,16 @@ set (HDRS Call.h DumpFields.h DumpEMFields.h - Dump.h Echo.h Help.h Option.h PSystem.h Quit.h - Save.h Select.h - Show.h Stop.h System.h Title.h Value.h - What.h ) install (FILES ${HDRS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/BasicActions") diff --git a/src/BasicActions/Dump.cpp b/src/BasicActions/Dump.cpp deleted file mode 100644 index 955ab445716672aa213d75bca389949f0cfcc9b4..0000000000000000000000000000000000000000 --- a/src/BasicActions/Dump.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Dump.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Dump -// The class for the OPAL "DUMP" command. -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:37 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "BasicActions/Dump.h" - -#include "Utility/IpplInfo.h" -#include "AbstractObjects/OpalData.h" -#include "AbstractObjects/ObjectFunction.h" -#include <iostream> - - -// Ancillary class DumpObject -// Dump an object to standard error. -// ------------------------------------------------------------------------ - -struct DumpObject: ObjectFunction { - virtual void operator()(Object *) const; -}; - - -void DumpObject::operator()(Object *object) const { - ERRORMSG(*object << endl); -} - - -// Class Dump -// ------------------------------------------------------------------------ - -Dump::Dump(): - Action(0, "DUMP", - "The \"DUMP\" statement dumps the data structure of OPAL.") -{} - - -Dump::Dump(const std::string &name, Dump *parent): - Action(name, parent) -{} - - -Dump::~Dump() -{} - - -void Dump::execute() { - // Dump complete directory in alphabetical order to cerr. - OpalData::getInstance()->apply(DumpObject()); -} - - -Dump *Dump::clone(const std::string &name) { - return new Dump(name, this); -} diff --git a/src/BasicActions/Dump.h b/src/BasicActions/Dump.h deleted file mode 100644 index ef17b6c1fbeb286034c85895e92faf9bf740e306..0000000000000000000000000000000000000000 --- a/src/BasicActions/Dump.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef OPAL_Dump_HH -#define OPAL_Dump_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Dump.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Dump -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:37 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "AbstractObjects/Action.h" - - -// Class Dump -// ------------------------------------------------------------------------ -/// The DUMP command. - -class Dump: public Action { - -public: - - /// Exemplar constructor. - Dump(); - - virtual ~Dump(); - - /// Make clone. - virtual Dump *clone(const std::string &name); - - /// Execute the command. - virtual void execute(); - -private: - - // Not implemented. - Dump(const Dump &); - void operator=(const Dump &); - - // Clone constructor. - Dump(const std::string &name, Dump *parent); -}; - -#endif // OPAL_Dump_H diff --git a/src/BasicActions/Option.cpp b/src/BasicActions/Option.cpp index adacaf7f86fafd60abb2b992d491e5cdc96b8bd3..bb80d744adab2da32ee70438c8133eb25bc3e20e 100644 --- a/src/BasicActions/Option.cpp +++ b/src/BasicActions/Option.cpp @@ -1,21 +1,22 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Option.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: Option -// The class for the OPAL OPTION command. +// Class Option +// The OPTION command. +// The user interface allowing setting of OPAL options. +// The actual option flags are contained in namespace Options. // -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:33:37 $ -// $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/>. // -// ------------------------------------------------------------------------ - #include "BasicActions/Option.h" #include "Attributes/Attributes.h" #include "Parser/FileStream.h" @@ -39,9 +40,6 @@ using namespace Options; std::string DumpFrameToString(DumpFrame df); -// Class Option -// ------------------------------------------------------------------------ - namespace { // The attributes of class Option. enum { @@ -65,7 +63,6 @@ namespace { EBDUMP, CSRDUMP, AUTOPHASE, - PPDEBUG, SURFDUMPFREQ, NUMBLOCKS, RECYCLEBLOCKS, @@ -197,10 +194,6 @@ Option::Option(): "acceleration. Defines the number of refinements of the " "search range", autoPhase); - itsAttr[PPDEBUG] = Attributes::makeBool - ("PPDEBUG", "If true, use special initial velocity distribution " - "for parallel plate and print special debug output", ppdebug); - itsAttr[SURFDUMPFREQ] = Attributes::makeReal ("SURFDUMPFREQ", "The frequency to dump surface-particle " "interaction data, its default value is -1 (no dump).", @@ -302,7 +295,6 @@ Option::Option(const std::string &name, Option *parent): Attributes::setBool(itsAttr[EBDUMP], ebDump); Attributes::setBool(itsAttr[CSRDUMP], csrDump); Attributes::setReal(itsAttr[AUTOPHASE], autoPhase); - Attributes::setBool(itsAttr[PPDEBUG], ppdebug); Attributes::setReal(itsAttr[SURFDUMPFREQ], surfDumpFreq); Attributes::setBool(itsAttr[CZERO], cZero); Attributes::setBool(itsAttr[CLOTUNEONLY], cloTuneOnly); @@ -347,7 +339,6 @@ void Option::execute() { rhoDump = Attributes::getBool(itsAttr[RHODUMP]); ebDump = Attributes::getBool(itsAttr[EBDUMP]); csrDump = Attributes::getBool(itsAttr[CSRDUMP]); - ppdebug = Attributes::getBool(itsAttr[PPDEBUG]); enableHDF5 = Attributes::getBool(itsAttr[ENABLEHDF5]); version = Attributes::getReal(itsAttr[VERSION]); #ifdef ENABLE_AMR diff --git a/src/BasicActions/Option.h b/src/BasicActions/Option.h index 13bef0bfd21be87eef5e548bda410ee5c12c466e..e88187aacd587d80d9b421fd1fd55c359c76062c 100644 --- a/src/BasicActions/Option.h +++ b/src/BasicActions/Option.h @@ -1,31 +1,27 @@ -#ifndef OPAL_Option_HH -#define OPAL_Option_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Option.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: Option +// Class Option +// The OPTION command. +// The user interface allowing setting of OPAL options. +// The actual option flags are contained in namespace Options. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// ------------------------------------------------------------------------ +// This file is part of OPAL. // -// $Date: 2000/03/27 09:33:37 $ -// $Author: Andreas Adelmann $ +// 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_Option_HH +#define OPAL_Option_HH #include "AbstractObjects/Action.h" -// Class Option -// ------------------------------------------------------------------------ -/// The OPTION command. -// The user interface allowing setting of OPAL options. -// The actual option flags are contained in namespace Options. - class Option: public Action { public: diff --git a/src/BasicActions/Save.cpp b/src/BasicActions/Save.cpp deleted file mode 100644 index 3a23a96dfc67cb5d9e877613fc0cdd779177e20d..0000000000000000000000000000000000000000 --- a/src/BasicActions/Save.cpp +++ /dev/null @@ -1,200 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Save.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.3 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Save -// The base class for the OPAL SAVE command. -// -// Note by JMJ 6/4/2000: -// According to some old version of the manual this should have a PATTERNS option -// to allow only a certain set of parameters to be saved. -// Not so, it seems to just save everything. I opale changes to the print method -// of the ConcreteVar class to partly compensate for this deficiency: that allows -// you to get the variables used in matching in OPAL input syntax, at least on the -// main output file. -// -// ------------------------------------------------------------------------ -// -// $Date: 2001/08/14 07:02:44 $ -// $Author: jowett $ -// -// ------------------------------------------------------------------------ - -#include "BasicActions/Save.h" -#include "AbstractObjects/BeamSequence.h" -#include "AbstractObjects/Definition.h" -#include "AbstractObjects/Element.h" -#include "AbstractObjects/OpalData.h" -#include "AbstractObjects/ObjectFunction.h" -#include "AbstractObjects/ValueDefinition.h" -#include "Attributes/Attributes.h" -#include "Utilities/OpalException.h" -#include "Utilities/Options.h" -#include "Utilities/Util.h" -#include <fstream> -#include <string> -#include "OPALconfig.h" - -extern Inform *gmsg; - -// Functors for flagging objects and saving special categories. -// ------------------------------------------------------------------------ - -namespace SaveNS { - - // Functor for flagging an object. - // ---------------------------------------------------------------------- - struct ObjectFlagger: ObjectFunction { - virtual void operator()(Object *) const; - }; - - void ObjectFlagger::operator()(Object *object) const { - // Only output objects which have a parent, and which are not built-in. - object->setFlag(object->getParent() != 0 && ! object->isBuiltin()); - } - - // Functor for saving an element. - // ---------------------------------------------------------------------- - struct ElementWriter: ObjectFunction { - ElementWriter(std::ostream &ostr): os(ostr) { } - virtual void operator()(Object *) const; - private: - std::ostream &os; - }; - - void ElementWriter::operator()(Object *object) const { - if(object->isFlagged() && dynamic_cast<Element *>(object) && - ! dynamic_cast<BeamSequence *>(object)) { - if(object->getOpalName()[0] != '#') { - (*this)(object->getParent()); - os << object;//->print(*gmsg); - object->setFlag(false); - } - } - } - - // Functor for saving a parameter. - // ---------------------------------------------------------------------- - struct ParameterWriter: ObjectFunction { - ParameterWriter(std::ostream &ostr): os(ostr) { } - virtual void operator()(Object *) const; - private: - std::ostream &os; - }; - - void ParameterWriter::operator()(Object *object) const { - if(object->isFlagged() && dynamic_cast<ValueDefinition *>(object)) { - os << object;//->print(*gmsg); - object->setFlag(false); - } - } - - // Functor for saving a special definition. - // ---------------------------------------------------------------------- - struct SpecialWriter: ObjectFunction { - SpecialWriter(std::ostream &ostr): os(ostr) { } - virtual void operator()(Object *) const; - private: - std::ostream &os; - }; - - void SpecialWriter::operator()(Object *object) const { - if(object->isFlagged() && dynamic_cast<Definition *>(object)) { - (*this)(object->getParent()); - os << object;//->print(*gmsg); - object->setFlag(false); - } - } -} - - -using namespace SaveNS; - - - -// Class Save -// ------------------------------------------------------------------------ - -Save::Save(): - Action(1, "SAVE", - "The \"SAVE\" statement prints a list of all definitions,\n" - "starting with constants, variables, and vectors," - "followed by elements, and finally all sequences.") { - itsAttr[0] = Attributes::makeString - ("FILE", "Name of file to be written", "SAVE"); - - registerOwnership(AttributeHandler::STATEMENT); -} - - -Save::Save(const std::string &name, Save *parent): - Action(name, parent) -{} - - -Save::~Save() -{} - - -Save *Save::clone(const std::string &name) { - return new Save(name, this); -} - - -void Save::execute() { - std::string file = Attributes::getString(itsAttr[0]); - std::ofstream os(file.c_str()); - - if(os.bad()) { - throw OpalException("Save::execute()", - "Unable to open output stream \"" + file + "\"."); - } else { - // Flag all objects to be saved. - OpalData::getInstance()->apply(ObjectFlagger()); - - - // Now save all objects according to categories. - //JMJ adding some comment tags to saved output 25/10/2000 - //JMJ more of those 18/12/2000 - - std::string comchar = "// "; - - os << comchar << "<OPAL Version " << OPAL_PROJECT_VERSION << " GIT version " - << Util::getGitRevision() << " (c) PSI, http://amas.web.psi.ch" - << std::endl << ";" << std::endl ; - - os << comchar << "<Parameter definitions> ;" << std::endl ; - OpalData::getInstance()->apply(ParameterWriter(os)); - os << comchar << "</Parameter definitions> ;" - << std::endl << ";" << std::endl ; - - os << comchar << "<Element definitions> ;" << std::endl ; - OpalData::getInstance()->apply(ElementWriter(os)); - os << comchar << "</Element definitions> ;" - << std::endl << ";" << std::endl ; - - os << comchar << "<Line (and split element) definitions> ;" - << std::endl ; - - os << comchar << "</Line (and split element) definitions> ;" - << std::endl << ";" << std::endl ; - - os << comchar << "<Special definitions> ;" << std::endl ; - OpalData::getInstance()->apply(SpecialWriter(os)); - os << comchar << "</Special definitions> ;" - << std::endl << ";" << std::endl ; - - os << comchar << "<OPAL Version " << OPAL_PROJECT_VERSION << " GIT version " - << Util::getGitRevision() << " (c) PSI, http://amas.web.psi.ch" - << std::endl << ";" << std::endl ; - } -} - - -void Save::parse(Statement &statement) { - parseShortcut(statement); -} diff --git a/src/BasicActions/Save.h b/src/BasicActions/Save.h deleted file mode 100644 index b4da0edd234f0b0265e6651f3071da217a5d6b46..0000000000000000000000000000000000000000 --- a/src/BasicActions/Save.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef OPAL_Save_HH -#define OPAL_Save_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Save.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Save -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:37 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "AbstractObjects/Action.h" - - -// Class Save -// ------------------------------------------------------------------------ -/// The SAVE command. - -class Save: public Action { - -public: - - /// Exemplar constructor. - Save(); - - virtual ~Save(); - - /// Make clone. - virtual Save *clone(const std::string &name); - - /// Execute the command. - virtual void execute(); - - /// Parse command (special for one-attribute command). - void parse(Statement &); - -private: - - // Not implemented. - Save(const Save &); - void operator=(const Save &); - - // Clone constructor. - Save(const std::string &name, Save *parent); -}; - -#endif // OPAL_Save_H diff --git a/src/BasicActions/Show.cpp b/src/BasicActions/Show.cpp deleted file mode 100644 index ecc605259e2245d165741ad4bf9aca4046eb775f..0000000000000000000000000000000000000000 --- a/src/BasicActions/Show.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Show.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Show -// The class for OPAL SHOW commands. -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:37 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "BasicActions/Show.h" -#include "AbstractObjects/OpalData.h" -#include "AbstractObjects/Object.h" -#include "Attributes/Attributes.h" -#include <iostream> - - -// Class Show -// ------------------------------------------------------------------------ - -Show::Show(): - Action(1, "SHOW", - "The \"SHOW\" statement displays all object names matching a " - " regular expression.") { - itsAttr[0] = Attributes::makeString - ("PATTERN", "Regular expression for pattern match"); - - registerOwnership(AttributeHandler::STATEMENT); -} - - -Show::Show(const std::string &name, Show *parent): - Action(name, parent) -{} - - -Show::~Show() -{} - - -Show *Show::clone(const std::string &name) { - return new Show(name, this); -} - - -void Show::execute() { - if(itsAttr[0]) { - std::string pattern = Attributes::getString(itsAttr[0]); - OpalData::getInstance()->printNames(std::cerr, pattern); - } else { - printHelp(std::cerr); - } -} - - -void Show::parse(Statement &statement) { - parseShortcut(statement); -} \ No newline at end of file diff --git a/src/BasicActions/Show.h b/src/BasicActions/Show.h deleted file mode 100644 index a408920c3ab7bbae8256a45a80a53832524eec48..0000000000000000000000000000000000000000 --- a/src/BasicActions/Show.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef OPAL_Show_HH -#define OPAL_Show_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Show.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Show -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:37 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "AbstractObjects/Action.h" - - -// Class Show -// ----------------------------------------------------------------------- -/// The SHOW command. - -class Show: public Action { - -public: - - /// Exemplar constructor. - Show(); - - virtual ~Show(); - - /// Make clone. - virtual Show *clone(const std::string &name); - - /// Execute the command. - virtual void execute(); - - /// Parse command (special for one-attribute command). - virtual void parse(Statement &); - -private: - - // Not implemented. - Show(const Show &); - void operator=(const Show &); - - // Clone constructor. - Show(const std::string &name, Show *parent); -}; - -#endif // OPAL_Show_HH diff --git a/src/BasicActions/What.cpp b/src/BasicActions/What.cpp deleted file mode 100644 index b7b7d4a42db2de624e4b9f5e4ad60f65c9bf94e4..0000000000000000000000000000000000000000 --- a/src/BasicActions/What.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: What.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: What -// The class for the OPAL WHAT command. -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:37 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "BasicActions/What.h" -#include "AbstractObjects/OpalData.h" -#include "Attributes/Attributes.h" -#include <iostream> - - -// Class What -// ------------------------------------------------------------------------ - -What::What(): - Action(1, "WHAT", - "The \"WHAT\" statement displays the definition and attribute" - " values of an object.") { - itsAttr[0] = Attributes::makeString - ("NAME", "Name of object to be displayed"); - - registerOwnership(AttributeHandler::STATEMENT); -} - - -What::What(const std::string &name, What *parent): - Action(name, parent) -{} - - -What::~What() -{} - - -What *What::clone(const std::string &name) { - return new What(name, this); -} - - -void What::execute() { - if(itsAttr[0]) { - std::string name = Attributes::getString(itsAttr[0]); - - if(Object *object = OpalData::getInstance()->find(name)) { - std::cerr << *object << std::endl; - } else { - std::cerr << '\n' << *this << "\nUnknown object \"" << name << "\".\n" - << std::endl; - } - } else { - printHelp(std::cerr); - } -} - - -void What::parse(Statement &statement) { - parseShortcut(statement); -} \ No newline at end of file diff --git a/src/BasicActions/What.h b/src/BasicActions/What.h deleted file mode 100644 index 8f53910ac55532e219def8c5fcfcc5c45c694c68..0000000000000000000000000000000000000000 --- a/src/BasicActions/What.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef OPAL_What_HH -#define OPAL_What_HH - -// ------------------------------------------------------------------------ -// $RCSfile: What.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: What -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:37 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "AbstractObjects/Action.h" - - -// Class What -// ------------------------------------------------------------------------ -/// The WHAT command. - -class What: public Action { - -public: - - /// Exemplar constructor. - What(); - - virtual ~What(); - - /// Make clone. - virtual What *clone(const std::string &name); - - /// Execute the command. - virtual void execute(); - - /// Parse command (special for one-attribute command). - virtual void parse(Statement &); - -private: - - // Not implemented. - What(const What &); - void operator=(const What &); - - // Clone constructor. - What(const std::string &name, What *parent); -}; - -#endif // OPAL_What_HH diff --git a/src/Classic/AbsBeamline/BeamBeam.cpp b/src/Classic/AbsBeamline/BeamBeam.cpp deleted file mode 100644 index f6d41f3acb9edd071fddbe1c359cbd38f1002f04..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/BeamBeam.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: BeamBeam.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: BeamBeam -// Defines the abstract interface for a beam-beam interaction. -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/BeamBeam.h" -#include "AbsBeamline/BeamlineVisitor.h" - - -// Class BeamBeam -// ------------------------------------------------------------------------ - -BeamBeam::BeamBeam(): - Component() -{} - - -BeamBeam::BeamBeam(const BeamBeam &right): - Component(right) -{} - - -BeamBeam::BeamBeam(const std::string &name): - Component(name) -{} - - -BeamBeam::~BeamBeam() { -} - - -void BeamBeam::accept(BeamlineVisitor &visitor) const { - visitor.visitBeamBeam(*this); -} - -void BeamBeam::initialise(PartBunchBase<double, 3> *bunch, double & /*startField*/, double &/*endField*/) { - RefPartBunch_m = bunch; -} - -void BeamBeam::finalise() { -} - -bool BeamBeam::bends() const { - return false; -} - -void BeamBeam::getDimensions(double & /*zBegin*/, double & /*zEnd*/) const { -} - - -ElementBase::ElementType BeamBeam::getType() const { - return BEAMBEAM; -} - diff --git a/src/Classic/AbsBeamline/BeamBeam.h b/src/Classic/AbsBeamline/BeamBeam.h deleted file mode 100644 index f61c4fd6d8198d582f05594164d7c967dc690994..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/BeamBeam.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef CLASSIC_BeamBeam_HH -#define CLASSIC_BeamBeam_HH - -// ------------------------------------------------------------------------ -// $RCSfile: BeamBeam.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: BeamBeam -// Defines the abstract interface for a beam-beam interaction. -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/Component.h" - - -class Matrix3D; -class Vector3D; - - -// Class BeamBeam -// ------------------------------------------------------------------------ -/// Abstract beam-beam interaction. -// Class BeamBeam defines the abstract interface for beam-beam interactions. - - -class BeamBeam: public Component { - -public: - - /// Constructor with given name. - explicit BeamBeam(const std::string &name); - - BeamBeam(); - BeamBeam(const BeamBeam &right); - virtual ~BeamBeam(); - - /// Apply visitor to BeamBeam. - virtual void accept(BeamlineVisitor &) const; - - /// Get bunch charge. - // Return the number of particles times the particle charge in the - // opposite bunch. Units are proton charges. - virtual double getBunchCharge() const = 0; - - /// Get moments. - // Return the moment matrix for the opposite bunch - // (the matrix of second momenta). Units are square metres. - virtual const Matrix3D &getBunchMoment() const = 0; - - /// Get displacement. - // Return the displacement vector for position of opposite bunch. - // Units are metres. - virtual const Vector3D &getBunchDisplacement() const = 0; - - virtual void initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField); - - virtual void finalise(); - - virtual bool bends() const; - - virtual ElementBase::ElementType getType() const; - - virtual void getDimensions(double &zBegin, double &zEnd) const; - -private: - - // Not implemented. - void operator=(const BeamBeam &); -}; - -#endif // CLASSIC_BeamBeam_HH \ No newline at end of file diff --git a/src/Classic/AbsBeamline/BeamlineVisitor.h b/src/Classic/AbsBeamline/BeamlineVisitor.h index 485edbba48f1f93d01112a6a29d75f1f073a3f67..5f7584a1eed0e48a07022f737298eadc8808eff6 100644 --- a/src/Classic/AbsBeamline/BeamlineVisitor.h +++ b/src/Classic/AbsBeamline/BeamlineVisitor.h @@ -41,16 +41,13 @@ class Beamline; class FlaggedElmPtr; // Specific element classes interacting with a BeamlineVisitor -class BeamBeam; class BeamStripping; class CCollimator; class Corrector; class Cyclotron; class Degrader; -class Diagnostic; class Drift; class FlexibleCollimator; -class Lambertson; class Marker; class Monitor; class Multipole; @@ -59,18 +56,14 @@ class MultipoleTStraight; class MultipoleTCurvedConstRadius; class MultipoleTCurvedVarRadius; class Offset; -class ParallelPlate; -class Patch; class Probe; class RBend; class RBend3D; class RFCavity; -class RFQuadrupole; class Ring; class SBend; class SBend3D; class ScalingFFAMagnet; -class Separator; class Septum; class Solenoid; class Source; @@ -80,9 +73,6 @@ class VariableRFCavity; class VariableRFCavityFringeField; class VerticalFFAMagnet; -// Integrators. -class Integrator; - class BeamlineVisitor { public: @@ -93,9 +83,6 @@ public: /// Execute the algorithm on the attached beam line. virtual void execute() = 0; - /// Apply the algorithm to a beam-beam interaction. - virtual void visitBeamBeam(const BeamBeam &) = 0; - /// Apply the algorithm to a beam stripping interaction. virtual void visitBeamStripping(const BeamStripping &) = 0; @@ -111,9 +98,6 @@ public: /// Apply the algorithm to a diagnostic. virtual void visitDegrader(const Degrader &) = 0; - /// Apply the algorithm to a diagnostic. - virtual void visitDiagnostic(const Diagnostic &) = 0; - /// Apply the algorithm to a drift space. virtual void visitDrift(const Drift &) = 0; @@ -126,9 +110,6 @@ public: /// Apply the algorithm to a cyclotron. virtual void visitCyclotron(const Cyclotron &) = 0; - /// Apply the algorithm to a Lambertson septum magnet. - virtual void visitLambertson(const Lambertson &) = 0; - /// Apply the algorithm to an Offset (placement). virtual void visitOffset(const Offset &) = 0; @@ -153,9 +134,6 @@ public: /// Apply the algorithm to an arbitrary curved Multipole of variable radius. virtual void visitMultipoleTCurvedVarRadius(const MultipoleTCurvedVarRadius &) = 0; - /// Apply the algorithm to a patch. - virtual void visitPatch(const Patch &) = 0; - /// Apply the algorithm to a probe. virtual void visitProbe(const Probe &) = 0; @@ -178,18 +156,12 @@ public: /// Apply the algorithm to a RF cavity. virtual void visitTravelingWave(const TravelingWave &) = 0; - /// Apply the algorithm to a RF quadrupole. - virtual void visitRFQuadrupole(const RFQuadrupole &) = 0; - /// Apply the algorithm to a sector bend. virtual void visitSBend(const SBend &) = 0; /// Apply the algorithm to a Sector Bend with 3D field map. virtual void visitSBend3D(const SBend3D &) = 0; - /// Apply the algorithm to an electrostatic separator. - virtual void visitSeparator(const Separator &) = 0; - /// Apply the algorithm to a septum magnet. virtual void visitSeptum(const Septum &) = 0; @@ -208,15 +180,9 @@ public: /// Apply the algorithm to a FlaggedElmPtr. virtual void visitFlaggedElmPtr(const FlaggedElmPtr &) = 0; - /// Apply the algorithm to an ParallelPlate. - virtual void visitParallelPlate(const ParallelPlate &) = 0; - /// Apply the algorithm to a particle stripper. virtual void visitStripper(const Stripper &) = 0; - /// Apply the algorithm to a generic integrator. - virtual void visitIntegrator(const Integrator &) = 0; - /// Apply the algorithm to a vertical FFA magnet virtual void visitVerticalFFAMagnet(const VerticalFFAMagnet &) = 0; diff --git a/src/Classic/AbsBeamline/CMakeLists.txt b/src/Classic/AbsBeamline/CMakeLists.txt index d6e3a10a2e34af8d366ac73cac2f0ac58ad5687a..3502baf7fec4d4ce48b6a8d2c086c7bd0585f93a 100644 --- a/src/Classic/AbsBeamline/CMakeLists.txt +++ b/src/Classic/AbsBeamline/CMakeLists.txt @@ -3,7 +3,6 @@ add_subdirectory(MultipoleTFunctions) set (_SRCS AttributeSet.cpp - BeamBeam.cpp BeamlineVisitor.cpp BeamStripping.cpp Bend2D.cpp @@ -13,13 +12,9 @@ set (_SRCS Corrector.cpp Cyclotron.cpp Degrader.cpp - Diagnostic.cpp Drift.cpp ElementBase.cpp - ElementImage.cpp FlexibleCollimator.cpp - Integrator.cpp - Lambertson.cpp Marker.cpp Monitor.cpp Multipole.cpp @@ -29,19 +24,15 @@ set (_SRCS MultipoleTCurvedConstRadius.cpp MultipoleTCurvedVarRadius.cpp Offset.cpp - ParallelPlate.cpp - Patch.cpp PluginElement.cpp Probe.cpp RBend.cpp RBend3D.cpp RFCavity.cpp - RFQuadrupole.cpp Ring.cpp SBend.cpp SBend3D.cpp ScalingFFAMagnet.cpp - Separator.cpp Septum.cpp Solenoid.cpp Source.cpp @@ -60,7 +51,6 @@ add_opal_sources (${_SRCS}) set (HDRS AttributeSet.h - BeamBeam.h BeamlineVisitor.h BeamStripping.h Bend2D.h @@ -70,13 +60,9 @@ set (HDRS Corrector.h Cyclotron.h Degrader.h - Diagnostic.h Drift.h ElementBase.h - ElementImage.h FlexibleCollimator.h - Integrator.h - Lambertson.h Marker.h Monitor.h Multipole.h @@ -86,19 +72,15 @@ set (HDRS MultipoleTCurvedConstRadius.h MultipoleTCurvedVarRadius.h Offset.h - ParallelPlate.h - Patch.h PluginElement.h Probe.h RBend.h RBend3D.h RFCavity.h - RFQuadrupole.h Ring.h SBend3D.h SBend.h ScalingFFAMagnet.h - Separator.h Septum.h Solenoid.h Source.h diff --git a/src/Classic/AbsBeamline/Diagnostic.cpp b/src/Classic/AbsBeamline/Diagnostic.cpp deleted file mode 100644 index cdbc0c50aa34e4aaa7c4ce93bd9ea1464b65d9c9..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/Diagnostic.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Diagnostic.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Diagnostic -// Defines the abstract interface for a beam diagnostic. -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/Diagnostic.h" -#include "AbsBeamline/BeamlineVisitor.h" - - -// Class Diagnostic -// ------------------------------------------------------------------------ - -Diagnostic::Diagnostic(): - Component() -{ } - - -Diagnostic::Diagnostic(const Diagnostic &rhs): - Component(rhs) -{ } - - -Diagnostic::Diagnostic(const std::string &name): - Component(name) -{ } - - -Diagnostic::~Diagnostic() -{ } - - -void Diagnostic::accept(BeamlineVisitor &visitor) const { - visitor.visitDiagnostic(*this); -} - -void Diagnostic::initialise(PartBunchBase<double, 3> *bunch, double &/*startField*/, double &/*endField*/) { - RefPartBunch_m = bunch; -} - -void Diagnostic::finalise() -{ } - -bool Diagnostic::bends() const { - return false; -} - -ElementBase::ElementType Diagnostic::getType() const { - return DIAGNOSTIC; -} - -void Diagnostic::getDimensions(double &/*zBegin*/, double &/*zEnd*/) const -{ } diff --git a/src/Classic/AbsBeamline/Diagnostic.h b/src/Classic/AbsBeamline/Diagnostic.h deleted file mode 100644 index 6440ed6e0a8e53e1853ca0b951c59d424020aa50..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/Diagnostic.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef CLASSIC_Diagnostic_HH -#define CLASSIC_Diagnostic_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Diagnostic.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Diagnostic -// *** MISSING *** Diagnostic interface is still incomplete. -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/Component.h" - - -// Class Diagnostic -// ------------------------------------------------------------------------ -/// Interface for beam diagnostics. -// Class Diagnostic defines the abstract interface for a beam diagnostic. - -class Diagnostic: public Component { - -public: - - /// Constructor with given name. - explicit Diagnostic(const std::string &name); - - Diagnostic(); - Diagnostic(const Diagnostic &rhs); - virtual ~Diagnostic(); - - /// Apply visitor to Diagnostic. - virtual void accept(BeamlineVisitor &) const override; - - virtual void initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) override; - - virtual void finalise() override; - - virtual bool bends() const override; - - virtual ElementBase::ElementType getType() const override; - - virtual void getDimensions(double &zBegin, double &zEnd) const override; - -private: - - // Not implemented. - void operator=(const Diagnostic &); -}; - -#endif // CLASSIC_Diagnostic_HH diff --git a/src/Classic/AbsBeamline/ElementBase.cpp b/src/Classic/AbsBeamline/ElementBase.cpp index 8116211ae81f01819991422d63b875b7d91a6206..b81bcb39be4d061c61e1e12a4dd36e1b8d582cb8 100644 --- a/src/Classic/AbsBeamline/ElementBase.cpp +++ b/src/Classic/AbsBeamline/ElementBase.cpp @@ -61,7 +61,6 @@ // along with OPAL. If not, see <https://www.gnu.org/licenses/>. // #include "AbsBeamline/ElementBase.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/Channel.h" #include <string> @@ -191,8 +190,6 @@ const ConstChannel *ElementBase::getConstChannel(const std::string &aKey) const std::string ElementBase::getTypeString(ElementBase::ElementType type) { switch (type) { - case BEAMBEAM: - return "BeamBeam"; case BEAMLINE: return "Beamline"; case BEAMSTRIPPING: @@ -205,14 +202,8 @@ std::string ElementBase::getTypeString(ElementBase::ElementType type) { return "Cyclotron"; case DEGRADER: return "Degrader"; - case DIAGNOSTIC: - return "Diagnostic"; case DRIFT: return "Drift"; - case INTEGRATOR: - return "Integrator"; - case LAMBERTSON: - return "Lambertson"; case MARKER: return "Marker"; case MONITOR: @@ -221,26 +212,18 @@ std::string ElementBase::getTypeString(ElementBase::ElementType type) { return "Multipole"; case OFFSET: return "Offset"; - case PARALLELPLATE: - return "ParallelPlate"; - case PATCH: - return "Patch"; case PROBE: return "Probe"; case RBEND: return "RBend"; case RFCAVITY: return "RFCavity"; - case RFQUADRUPOLE: - return "RFQuadrupole"; case RING: return "Ring"; case SBEND3D: return "SBend3D"; case SBEND: return "SBend"; - case SEPARATOR: - return "Separator"; case SEPTUM: return "Septum"; case SOLENOID: @@ -257,12 +240,6 @@ std::string ElementBase::getTypeString(ElementBase::ElementType type) { } } -ElementImage *ElementBase::getImage() const { - std::string type = getTypeString(); - return new ElementImage(getName(), type, userAttribs); -} - - ElementBase *ElementBase::copyStructure() { if(isSharable()) { return this; diff --git a/src/Classic/AbsBeamline/ElementBase.h b/src/Classic/AbsBeamline/ElementBase.h index 121089b1ca4a4fc37d9eec23aa3176e0909209e2..7cf48099982bf5ad407dfda2a6cad3d0a907d0c6 100644 --- a/src/Classic/AbsBeamline/ElementBase.h +++ b/src/Classic/AbsBeamline/ElementBase.h @@ -80,8 +80,6 @@ class BeamlineVisitor; class BoundaryGeometry; class Channel; class ConstChannel; -class ElementImage; - class ParticleMatterInteractionHandler; class WakeFunction; @@ -108,35 +106,27 @@ public: , CONIC_ELLIPTICAL }; - enum ElementType {BEAMBEAM - , BEAMLINE + enum ElementType {BEAMLINE , BEAMSTRIPPING , CCOLLIMATOR , CORRECTOR , CYCLOTRON , DEGRADER - , DIAGNOSTIC , DRIFT , FLEXIBLECOLLIMATOR - , INTEGRATOR - , LAMBERTSON , MARKER , MONITOR , MPSPLITINTEGRATOR , MULTIPOLE , MULTIPOLET , OFFSET - , PARALLELPLATE - , PATCH , PROBE , RBEND , RBEND3D , RFCAVITY - , RFQUADRUPOLE , RING , SBEND3D , SBEND - , SEPARATOR , SEPTUM , SOLENOID , SOURCE @@ -267,11 +257,6 @@ public: // If the attribute does not exist, it returns NULL. virtual const ConstChannel *getConstChannel(const std::string &aKey) const; - /// Construct an image. - // Return the image of the element, containing the name and type std::string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /// Apply visitor. // This method must be overridden by derived classes. It should call the // method of the visitor corresponding to the element class. diff --git a/src/Classic/AbsBeamline/ElementImage.cpp b/src/Classic/AbsBeamline/ElementImage.cpp deleted file mode 100644 index 09111ec75b60f6860039d9325bc46fc099ac3f8f..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/ElementImage.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: ElementImage.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ElementImage -// Contains two std::strings, representing the element name and type, and a -// map of its attributes used to represent this element's state. -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ -// - -#include "AbsBeamline/ElementImage.h" - - -// Class ElementImage -// ------------------------------------------------------------------------ - - -ElementImage::ElementImage(): - AttributeSet() -{} - -ElementImage::ElementImage(const ElementImage &right): - AttributeSet(right), - elementName(right.elementName), - elementType(right.elementType) -{} - -ElementImage::ElementImage(const std::string &name, const std::string &type, - const AttributeSet &attrib): - AttributeSet(attrib), - elementName(name), - elementType(type) -{} - -ElementImage::~ElementImage() -{} - - -const ElementImage &ElementImage::operator=(const ElementImage &right) { - AttributeSet::operator=(right); - elementName = right.elementName; - elementType = right.elementType; - return *this; -} - - -const std::string &ElementImage::getName() const { - return elementName; -} - - -void ElementImage::setName(const std::string &name) { - elementName = name; -} - - -const std::string &ElementImage::getType() const { - return elementType; -} - - -void ElementImage::setType(const std::string &type) { - elementType = type; -} diff --git a/src/Classic/AbsBeamline/ElementImage.h b/src/Classic/AbsBeamline/ElementImage.h deleted file mode 100644 index 11851befbc1f8d8a9cfc7ecb27be9847988daea1..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/ElementImage.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef CLASSIC_ElementImage_HH -#define CLASSIC_ElementImage_HH - -// ------------------------------------------------------------------------ -// $RCSfile: ElementImage.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ElementImage -// Contains two std::strings, representing the element name and type, and a -// map of attributes used to represent this element's state. -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/AttributeSet.h" -#include <string> - -// Class ElementImage -// ------------------------------------------------------------------------ -/// An image of an element. -// Class ElementImage implements an image of an element. It contains two -// std::strings, the name and the type of the element, and a map of name versus -// value for all attributes of the element. - -class ElementImage: public AttributeSet { - -public: - - /// Constructor. - // This constructor takes the [b]name[/b] and [b]type[/b] std::strings as - // arguments, as well as an AttributeSet mapping attribute names to - // values. - ElementImage(const std::string &name, const std::string &type, - const AttributeSet &map); - - ElementImage(); - ElementImage(const ElementImage &); - virtual ~ElementImage(); - - /// Assignment operator. - const ElementImage &operator=(const ElementImage &); - - /// Set element name. - void setName(const std::string &name); - - /// Get element name. - const std::string &getName() const; - - /// Set element type std::string. - void setType(const std::string &type); - - /// Get element type std::string. - const std::string &getType() const; - -private: - - // String representing element name - std::string elementName; - - // String representing element type - std::string elementType; -}; - -#endif // CLASSIC_ElementImage_HH diff --git a/src/Classic/AbsBeamline/Integrator.cpp b/src/Classic/AbsBeamline/Integrator.cpp deleted file mode 100644 index b41929cd0b3c6390c77d8f19a96d068c33dcad16..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/Integrator.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Integrator.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Integrator -// Integrator is a pure abstract class. It forms the base class for all -// special propagators through an element or a beamline. -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/Integrator.h" - - -// Class Integrator -// ------------------------------------------------------------------------ - -Integrator::Integrator(ElementBase *elem): - ElementBase(elem->getName()), itsElement(elem) -{} - - -Integrator::Integrator(const Integrator &rhs): - ElementBase(rhs.getName()), itsElement(rhs.itsElement) -{} - - -Integrator::~Integrator() -{} - - -void Integrator::makeSharable() { - shareFlag = true; - itsElement->makeSharable(); -} diff --git a/src/Classic/AbsBeamline/Integrator.h b/src/Classic/AbsBeamline/Integrator.h deleted file mode 100644 index d185c1e1964a06cbb56042eff1a4685e8a6ddc52..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/Integrator.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef CLASSIC_Integrator_HH -#define CLASSIC_Integrator_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Integrator.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Integrator -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/ElementBase.h" -#include "MemoryManagement/Pointer.h" - -template <class T, unsigned Dim> -class PartBunchBase; -class PartData; -class OpalParticle; - -template <class T, int N> class FVps; - - -// Class Integrator -// ------------------------------------------------------------------------ -/// Base class for special integrators. -// Integrator is a pure abstract class. It forms the base class for all -// special propagators through an element or a beam line. If present, it -// overrides a complete Component or Beamline object. - -class Integrator: public ElementBase { - -public: - - explicit Integrator(ElementBase *); - Integrator(const Integrator &rhs); - virtual ~Integrator(); - - /// Return the embedded element. - inline ElementBase *getElement() const; - - /// Set sharable flag. - // The whole structure depending on [b]this[/b] is marked as sharable. - // After this call a [b]copyStructure()[/b] call reuses the element. - virtual void makeSharable(); - - /// Track a particle. - // The first argument describes the particle's phase space position, - // the second argument describes the particle's momentum and mass, - // [b]revBeam[/b] true, means that the beam runs backwards, and - // [b]revTrack[/b] true, means that we track against the beam. - virtual void trackParticle(OpalParticle &, const PartData &, - bool revBeam, bool revTrack) const = 0; - - /// Track a particle bunch. - // The first argument describes the particles in the bunch, - // the second argument describes the reference momentum and mass, - // [b]revBeam[/b] true, means that the beam runs backwards, and - // [b]revTrack[/b] true, means that we track against the beam. - virtual void trackBunch(PartBunchBase<double, 3> *, const PartData &, - bool revBeam, bool revTrack) const = 0; - - /// Track a map. - // The first argument describes the map to be tracked, - // the second argument describes the reference momentum and mass, - // [b]revBeam[/b] true, means that the beam runs backwards, and - // [b]revTrack[/b] true, means that we track against the beam. - virtual void trackMap(FVps<double, 6> &, const PartData &, - bool revBeam, bool revTrack) const = 0; - -protected: - - /// Pointer to the replaced element. - Pointer<ElementBase> itsElement; - -private: - - // Not implemented. - Integrator(); - void operator=(const Integrator &); -}; - - -// Implementation. -// ------------------------------------------------------------------------ - -inline ElementBase *Integrator::getElement() const { - return &*itsElement; -} - -#endif // CLASSIC_Integrator_HH diff --git a/src/Classic/AbsBeamline/Lambertson.cpp b/src/Classic/AbsBeamline/Lambertson.cpp deleted file mode 100644 index 5bc4e529a079d42c6f1b38f0a6d4988c09ae1b98..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/Lambertson.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Lambertson.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Lambertson -// Defines the abstract interface for a Lambertson septum magnet. -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/Lambertson.h" -#include "AbsBeamline/BeamlineVisitor.h" - - -// Class Lambertson -// ------------------------------------------------------------------------ - -Lambertson::Lambertson(): - Component() -{ } - - -Lambertson::Lambertson(const Lambertson &rhs): - Component(rhs) -{ } - - -Lambertson::Lambertson(const std::string &name): - Component(name) -{ } - - -Lambertson::~Lambertson() -{ } - - -void Lambertson::accept(BeamlineVisitor &visitor) const { - visitor.visitLambertson(*this); -} - -void Lambertson::initialise(PartBunchBase<double, 3> *bunch, double &/*startField*/, double &/*endField*/) { - RefPartBunch_m = bunch; -} - -void Lambertson::finalise() -{ } - -bool Lambertson::bends() const { - return false; -} - -void Lambertson::getDimensions(double &/*zBegin*/, double &/*zEnd*/) const { -} - -ElementBase::ElementType Lambertson::getType() const { - return LAMBERTSON; -} diff --git a/src/Classic/AbsBeamline/Lambertson.h b/src/Classic/AbsBeamline/Lambertson.h deleted file mode 100644 index c5fab9d2036a8c80fe3944710f57a712a6710a66..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/Lambertson.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef CLASSIC_Lambertson_HH -#define CLASSIC_Lambertson_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Lambertson.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Lambertson -// *** MISSING *** Lambertson interface is still incomplete. -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/Component.h" - - -// Class Lambertson -// ------------------------------------------------------------------------ -/// Interface for a Lambertson septum. -// Class Lambertson defines the abstract interface for a Lambertson -// septum magnet. - -class Lambertson: public Component { - -public: - - /// Constructor with given name. - explicit Lambertson(const std::string &name); - - Lambertson(); - Lambertson(const Lambertson &); - virtual ~Lambertson(); - - /// Apply visitor to Lambertson. - virtual void accept(BeamlineVisitor &) const override; - - virtual void initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) override; - - virtual void finalise() override; - - virtual bool bends() const override; - - virtual ElementBase::ElementType getType() const override; - - virtual void getDimensions(double &zBegin, double &zEnd) const override; - -private: - - // Not implemented. - void operator=(const Lambertson &); -}; - -#endif // CLASSIC_Lambertson_HH diff --git a/src/Classic/AbsBeamline/ParallelPlate.cpp b/src/Classic/AbsBeamline/ParallelPlate.cpp deleted file mode 100644 index d0ff4641eb7b0ed6f834def4f065f35145b98e9c..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/ParallelPlate.cpp +++ /dev/null @@ -1,171 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: ParallelPlate.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ParallelPlate -// Defines the abstract interface for Parallel Plate. For benchmarking the -// Secondary emisssion model -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2010/10/12 15:32:31 $ -// $Author: Chuan Wang $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/ParallelPlate.h" -#include "AbsBeamline/BeamlineVisitor.h" -#include "Algorithms/PartBunchBase.h" -#include "Physics/Physics.h" - -#include <iostream> -#include <fstream> - -extern Inform *gmsg; - -// Class ParallelPlate -// ------------------------------------------------------------------------ - -ParallelPlate::ParallelPlate(): - ParallelPlate("") -{} - - -ParallelPlate::ParallelPlate(const ParallelPlate &right): - Component(right), - filename_m(right.filename_m), - scale_m(right.scale_m), - phase_m(right.phase_m), - frequency_m(right.frequency_m), - length_m(right.length_m), - ptime_m(0.0) { -} - - -ParallelPlate::ParallelPlate(const std::string &name): - Component(name), - filename_m(""), - scale_m(1.0), - phase_m(0.0), - frequency_m(0.0), - length_m(0.0), - ptime_m(0.0) { -} - - -ParallelPlate::~ParallelPlate() { - - -} - - -void ParallelPlate::accept(BeamlineVisitor &visitor) const { - visitor.visitParallelPlate(*this); -} - - -std::string ParallelPlate::getFieldMapFN() const { - return ""; -} - -void ParallelPlate::setAmplitude(double vPeak) { - scale_m = vPeak; -} - -double ParallelPlate::getAmplitude() const { - return scale_m ; -} - -void ParallelPlate::setFrequency(double freq) { - frequency_m = freq; -} - -double ParallelPlate::getFrequency()const { - return frequency_m; -} - -void ParallelPlate::setPhase(double phase) { - phase_m = phase; -} - -double ParallelPlate::getPhase() const { - return phase_m; -} - -// void ParallelPlate::setElementLength(double length) { -// length_m = length; -// } - -// double ParallelPlate::getElementLength() const { -// return length_m; -// } - - -bool ParallelPlate::apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) { - return applyToReferenceParticle(RefPartBunch_m->R[i], RefPartBunch_m->P[i], t, E, B); -} - -bool ParallelPlate::apply(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) { - return applyToReferenceParticle(R, P, t, E, B); -} - -bool ParallelPlate::applyToReferenceParticle(const Vector_t &R, const Vector_t &/*P*/, const double &t, Vector_t &E, Vector_t &B) { - const double phase = frequency_m * t + phase_m; - Vector_t tmpE(0.0, 0.0, -1.0), tmpB(0.0, 0.0, 0.0); - ptime_m = t; - - //Here we don't check if the particle is outof bounds, just leave the matter to the particle Boundary collision model in BoundaryGeometry - if ((R(2) >= 0.0) - && (R(2) < length_m)) { - E += scale_m / length_m * sin(phase) * tmpE; //Here scale_m should be Voltage between the parallel plates(V). - B = tmpB; //B field is always zero for our parallel plate elements used for benchmarking. - return false; - } - return true; -} - -void ParallelPlate::initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) { - - length_m = getElementLength(); - RefPartBunch_m = bunch; - startField = 0.0; - - endField = length_m; - -} - -// In current version ,not implemented yet. -void ParallelPlate::initialise(PartBunchBase<double, 3> *bunch) { - - Inform msg("ParallelPlate initialization for cyclotron tracker "); - - RefPartBunch_m = bunch; - // ElementEdge_m = startField; - msg << " Currently parallelplate initialization for cyclotron tracker is empty! " << endl; - -} - - - -void ParallelPlate::finalise() -{} - -bool ParallelPlate::bends() const { - return false; -} - -void ParallelPlate::getDimensions(double &zBegin, double &zEnd) const { - zBegin = 0.0; - zEnd = length_m; -} - - -ElementBase::ElementType ParallelPlate::getType() const { - return PARALLELPLATE; -} diff --git a/src/Classic/AbsBeamline/ParallelPlate.h b/src/Classic/AbsBeamline/ParallelPlate.h deleted file mode 100644 index ccf7a869e66debcc35dbf78690a126623bce723e..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/ParallelPlate.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef CLASSIC_ParallelPlate_HH -#define CLASSIC_ParallelPlate_HH - -// ------------------------------------------------------------------------ -// $RCSfile: ParallelPlate.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ParallelPlate -// Defines the abstract interface for parallel plate element. -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2010/10/12 $ -// $Author: ChuanWang $ -// -// ------------------------------------------------------------------------ - - -#include "AbsBeamline/Component.h" - -template <class T, unsigned Dim> -class PartBunchBase; - -// Class ParallelPlate -// ------------------------------------------------------------------------ -/// Interface for RF cavity. -// Class ParallelPlate defines the abstract interface for RF cavities. - - -class ParallelPlate: public Component { - -public: - - //enum CavityType { SW, SGSW }; - /// Constructor with given name. - explicit ParallelPlate(const std::string &name); - - ParallelPlate(); - ParallelPlate(const ParallelPlate &); - virtual ~ParallelPlate(); - - /// Apply visitor to ParallelPlate. - virtual void accept(BeamlineVisitor &) const override; - - - - void getDimensions(double &zBegin, double &zEnd) const override; - - ElementBase::ElementType getType() const override; - - std::string getFieldMapFN() const; - - void setAmplitude(double vPeak); - double getAmplitude() const ; - - void setFrequency(double freq); - double getFrequency() const ; - - void setPhase(double phase); - double getPhase() const ; - - // void setElementLength(double length); - // double getElementLength() const; - - virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override; - - virtual bool apply(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override; - - virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override; - - virtual void initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) override; - - virtual void initialise(PartBunchBase<double, 3> *bunch); - - virtual void finalise() override; - - virtual bool bends() const override; - - -private: - std::string filename_m; /**< The name of the inputfile*/ - - double scale_m; /**< scale multiplier*/ - double phase_m; /**< phase shift of time varying field(degrees)*/ - double frequency_m; /**< Read in frequency of time varying field(MHz)*/ - double length_m; /**< Read in distance/length of Parallel Plate*/ - double ptime_m; - - // Not implemented. - void operator=(const ParallelPlate &); -}; - -#endif // CLASSIC_ParallelPlate_HH diff --git a/src/Classic/AbsBeamline/Patch.cpp b/src/Classic/AbsBeamline/Patch.cpp deleted file mode 100644 index 76b048677871a495d3fecf04a6029fb7d9457b61..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/Patch.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Patch.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Patch -// Defines the abstract interface for a geometry patch. -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/Patch.h" -#include "AbsBeamline/BeamlineVisitor.h" - - -// Class Patch -// ------------------------------------------------------------------------ - -Patch::Patch(): - Component() -{} - - -Patch::Patch(const Patch &rhs): - Component(rhs) -{} - - -Patch::Patch(const std::string &name): - Component(name) -{} - - -Patch::~Patch() -{} - - -void Patch::accept(BeamlineVisitor &visitor) const { - visitor.visitPatch(*this); -} - -void Patch::initialise(PartBunchBase<double, 3> *bunch, double &/*startField*/, double &/*endField*/) { - RefPartBunch_m = bunch; -} - -void Patch::finalise() -{} - -bool Patch::bends() const { - return false; -} - -void Patch::getDimensions(double &/*zBegin*/, double &/*zEnd*/) const { - -} - - -ElementBase::ElementType Patch::getType() const { - return PATCH; -} diff --git a/src/Classic/AbsBeamline/Patch.h b/src/Classic/AbsBeamline/Patch.h deleted file mode 100644 index a04c8fe9fe691b9ea70c0e178c696c4d47876c0e..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/Patch.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef CLASSIC_Patch_HH -#define CLASSIC_Patch_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Patch.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Patch -// Defines the abstract interface for a geometry patch. -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/Component.h" - - -// Class Patch -// ------------------------------------------------------------------------ -/// Interface for a geometric patch. -// Class Patch defines the abstract interface for geometric patches, -// i.e. a geometric transform representing a misalignment of local -// coordinate systems of two subsequent element with each other. - -class Patch: public Component { - -public: - - /// Constructor with given name. - explicit Patch(const std::string &name); - - Patch(); - Patch(const Patch &); - virtual ~Patch(); - - /// Apply visitor to patch. - virtual void accept(BeamlineVisitor &) const override; - - /// Get patch transform. - virtual const Euclid3D &getPatch() const = 0; - - virtual void initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) override; - - virtual void finalise() override; - - virtual bool bends() const override; - - virtual ElementBase::ElementType getType() const override; - - virtual void getDimensions(double &zBegin, double &zEnd) const override; - -private: - - // Not implemented. - void operator=(const Patch &); -}; - -#endif // CLASSIC_Patch_HH diff --git a/src/Classic/AbsBeamline/RFQuadrupole.cpp b/src/Classic/AbsBeamline/RFQuadrupole.cpp deleted file mode 100644 index 687b6f78eee46a5df91065aa7dda28e0eb1acbd7..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/RFQuadrupole.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: RFQuadrupole.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: RFQuadrupole -// Defines the abstract interface for a RF quadrupole. -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/RFQuadrupole.h" -#include "AbsBeamline/BeamlineVisitor.h" - -extern Inform *gmsg; - -// Class RFQuadrupole -// ------------------------------------------------------------------------ - -RFQuadrupole::RFQuadrupole(): - Component() -{} - - -RFQuadrupole::RFQuadrupole(const RFQuadrupole &rhs): - Component(rhs) -{} - - -RFQuadrupole::RFQuadrupole(const std::string &name): - Component(name) -{} - - -RFQuadrupole::~RFQuadrupole() -{} - - -void RFQuadrupole::accept(BeamlineVisitor &visitor) const { - visitor.visitRFQuadrupole(*this); -} - -void RFQuadrupole::initialise(PartBunchBase<double, 3> *bunch, double &/*startField*/, double &/*endField*/) { - RefPartBunch_m = bunch; -} - -void RFQuadrupole::finalise() -{} - -bool RFQuadrupole::bends() const { - return false; -} - - -void RFQuadrupole::getDimensions(double &/*zBegin*/, double &/*zEnd*/) const { - -} - - -ElementBase::ElementType RFQuadrupole::getType() const { - return RFQUADRUPOLE; -} diff --git a/src/Classic/AbsBeamline/RFQuadrupole.h b/src/Classic/AbsBeamline/RFQuadrupole.h deleted file mode 100644 index e9b0ce3f60e1e29b1d59e7bb3bed3ae9930aad9f..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/RFQuadrupole.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef CLASSIC_RFQuadrupole_HH -#define CLASSIC_RFQuadrupole_HH - -// ------------------------------------------------------------------------ -// $RCSfile: RFQuadrupole.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// Class: RFQuadrupole -// *** MISSING *** RFQuadrupole interface is incomplete. -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/Component.h" - - -// Class RFQuadrupole -// ------------------------------------------------------------------------ -/// Interface for RF Quadrupole. -// Class RFQuadrupole defines the abstract interface for a RF Quadrupole. - -class RFQuadrupole: public Component { - -public: - - /// Constructor with given name. - explicit RFQuadrupole(const std::string &name); - - RFQuadrupole(); - RFQuadrupole(const RFQuadrupole &); - virtual ~RFQuadrupole(); - - /// Apply visitor to RFQuadrupole. - virtual void accept(BeamlineVisitor &) const override; - - virtual void initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) override; - - virtual void finalise() override; - - virtual bool bends() const override; - - virtual ElementBase::ElementType getType() const override; - - virtual void getDimensions(double &zBegin, double &zEnd) const override; - -private: - - // Not implemented. - void operator=(const RFQuadrupole &); -}; - -#endif // CLASSIC_RFQuadrupole_HH diff --git a/src/Classic/AbsBeamline/Separator.cpp b/src/Classic/AbsBeamline/Separator.cpp deleted file mode 100644 index df8c4fa0e459c072327bb92b82d6309de656ff9a..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/Separator.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Separator.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Separator -// Defines the abstract interface for an separator. -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/Separator.h" -#include "AbsBeamline/BeamlineVisitor.h" - - -// Class Separator -// ------------------------------------------------------------------------ - -Separator::Separator(): - Component() -{} - - -Separator::Separator(const Separator &right): - Component(right) -{} - - -Separator::Separator(const std::string &name): - Component(name) -{} - - -Separator::~Separator() -{} - - -void Separator::accept(BeamlineVisitor &visitor) const { - visitor.visitSeparator(*this); -} - -void Separator::initialise(PartBunchBase<double, 3> *bunch, double &/*startField*/, double &/*endField*/) { - RefPartBunch_m = bunch; -} - -void Separator::finalise() -{} - -bool Separator::bends() const { - return false; -} - -void Separator::getDimensions(double &/*zBegin*/, double &/*zEnd*/) const { - -} - - -ElementBase::ElementType Separator::getType() const { - return SEPARATOR; -} diff --git a/src/Classic/AbsBeamline/Separator.h b/src/Classic/AbsBeamline/Separator.h deleted file mode 100644 index 3366704c767f7638f77a281b072de294582bdcd1..0000000000000000000000000000000000000000 --- a/src/Classic/AbsBeamline/Separator.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef CLASSIC_Separator_HH -#define CLASSIC_Separator_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Separator.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Separator -// Defines the abstract interface for an separator. -// -// ------------------------------------------------------------------------ -// Class category: AbsBeamline -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:31 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/Component.h" - - -// Class Separator -// ------------------------------------------------------------------------ -/// Interface for electrostatic separator. -// Class Separator defines the abstract interface for electrostatic -// separators. - -class Separator: public Component { - -public: - - /// Constructor with given name. - explicit Separator(const std::string &name); - - Separator(); - Separator(const Separator &); - virtual ~Separator(); - - /// Apply visitor to Separator. - virtual void accept(BeamlineVisitor &) const override; - - /// Get horizontal component Ex of field in V/m. - virtual double getEx() const = 0; - - /// Get vertical component Ey of field in V/m. - virtual double getEy() const = 0; - - virtual void initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) override; - - virtual void finalise() override; - - virtual bool bends() const override; - - virtual ElementBase::ElementType getType() const override; - - virtual void getDimensions(double &zBegin, double &zEnd) const override; - -private: - - // Not implemented. - void operator=(const Separator &); -}; - -#endif // CLASSIC_Separator_HH diff --git a/src/Classic/AbsBeamline/SpecificElementVisitor.h b/src/Classic/AbsBeamline/SpecificElementVisitor.h index 9ff6f1645c092fb1ee4c67d8645e840b649f3709..f64540f916e8b70e5f8b472e4d8502e8dc3b99f0 100644 --- a/src/Classic/AbsBeamline/SpecificElementVisitor.h +++ b/src/Classic/AbsBeamline/SpecificElementVisitor.h @@ -22,17 +22,14 @@ #include "AbsBeamline/BeamlineVisitor.h" -#include "AbsBeamline/BeamBeam.h" #include "AbsBeamline/BeamStripping.h" #include "AbsBeamline/CCollimator.h" #include "AbsBeamline/Corrector.h" #include "AbsBeamline/Cyclotron.h" -#include "AbsBeamline/Diagnostic.h" #include "AbsBeamline/Drift.h" #include "AbsBeamline/Degrader.h" #include "AbsBeamline/ElementBase.h" #include "AbsBeamline/FlexibleCollimator.h" -#include "AbsBeamline/Lambertson.h" #include "AbsBeamline/Offset.h" #include "AbsBeamline/Marker.h" #include "AbsBeamline/Monitor.h" @@ -41,7 +38,6 @@ #include "AbsBeamline/MultipoleTStraight.h" #include "AbsBeamline/MultipoleTCurvedConstRadius.h" #include "AbsBeamline/MultipoleTCurvedVarRadius.h" -#include "AbsBeamline/Patch.h" #include "AbsBeamline/Probe.h" #include "AbsBeamline/RBend.h" #include "AbsBeamline/Ring.h" @@ -49,16 +45,13 @@ #include "AbsBeamline/VariableRFCavity.h" #include "AbsBeamline/VariableRFCavityFringeField.h" #include "AbsBeamline/TravelingWave.h" -#include "AbsBeamline/RFQuadrupole.h" #include "AbsBeamline/SBend.h" #include "AbsBeamline/SBend3D.h" #include "AbsBeamline/ScalingFFAMagnet.h" #include "AbsBeamline/VerticalFFAMagnet.h" -#include "AbsBeamline/Separator.h" #include "AbsBeamline/Septum.h" #include "AbsBeamline/Solenoid.h" #include "AbsBeamline/Source.h" -#include "AbsBeamline/ParallelPlate.h" #include "AbsBeamline/Stripper.h" #include "Beamlines/Beamline.h" @@ -89,9 +82,6 @@ public: virtual void execute(); - /// Apply the algorithm to a beam-beam. - virtual void visitBeamBeam(const BeamBeam &); - /// Apply the algorithm to a beam stripping. virtual void visitBeamStripping(const BeamStripping &); @@ -113,18 +103,12 @@ public: /// Apply the algorithm to a drift. virtual void visitDegrader(const Degrader &); - /// Apply the algorithm to a diagnostic. - virtual void visitDiagnostic(const Diagnostic &); - /// Apply the algorithm to a drift. virtual void visitDrift(const Drift &); /// Apply the algorithm to a flexible collimator virtual void visitFlexibleCollimator(const FlexibleCollimator &); - /// Apply the algorithm to a Lambertson. - virtual void visitLambertson(const Lambertson &); - /// Apply the algorithm to a marker. virtual void visitMarker(const Marker &); @@ -149,9 +133,6 @@ public: /// Apply the algorithm to an Offset. virtual void visitOffset(const Offset &); - /// Apply the algorithm to a patch. - virtual void visitPatch(const Patch &pat); - /// Apply the algorithm to a probe. virtual void visitProbe(const Probe &prob); @@ -174,18 +155,12 @@ public: /// Apply the algorithm to a RF cavity. virtual void visitTravelingWave(const TravelingWave &); - /// Apply the algorithm to a RF quadrupole. - virtual void visitRFQuadrupole(const RFQuadrupole &); - /// Apply the algorithm to a sector bend. virtual void visitSBend(const SBend &); /// Apply the algorithm to a sector bend. virtual void visitSBend3D(const SBend3D &); - /// Apply the algorithm to a separator. - virtual void visitSeparator(const Separator &); - /// Apply the algorithm to a septum. virtual void visitSeptum(const Septum &); @@ -201,9 +176,6 @@ public: /// Apply the algorithm to a spiral sector magnet. virtual void visitVerticalFFAMagnet(const VerticalFFAMagnet &); - /// Apply the algorithm to a ParallelPlate. - virtual void visitParallelPlate(const ParallelPlate &); - /// Apply the algorithm to a charge stripper. virtual void visitStripper(const Stripper &); @@ -213,9 +185,6 @@ public: /// Apply the algorithm to a FlaggedElmPtr. virtual void visitFlaggedElmPtr(const FlaggedElmPtr &); - /// Apply the algorithm to a generic integrator. - virtual void visitIntegrator(const Integrator &); - size_t size() const; typedef std::list<const ELEM*> ElementList_t; @@ -250,11 +219,6 @@ template<class ELEM> void SpecificElementVisitor<ELEM>::execute() { } -template<class ELEM> -void SpecificElementVisitor<ELEM>::visitBeamBeam(const BeamBeam &element) { - CastsTrait<ELEM, BeamBeam>::apply(allElementsOfTypeE, element); -} - template<class ELEM> void SpecificElementVisitor<ELEM>::visitBeamStripping(const BeamStripping &element) { CastsTrait<ELEM, BeamStripping>::apply(allElementsOfTypeE, element); @@ -290,11 +254,6 @@ void SpecificElementVisitor<ELEM>::visitDegrader(const Degrader &element) { CastsTrait<ELEM, Degrader>::apply(allElementsOfTypeE, element); } -template<class ELEM> -void SpecificElementVisitor<ELEM>::visitDiagnostic(const Diagnostic &element) { - CastsTrait<ELEM, Diagnostic>::apply(allElementsOfTypeE, element); -} - template<class ELEM> void SpecificElementVisitor<ELEM>::visitDrift(const Drift &element) { CastsTrait<ELEM, Drift>::apply(allElementsOfTypeE, element); @@ -305,11 +264,6 @@ void SpecificElementVisitor<ELEM>::visitFlexibleCollimator(const FlexibleCollima CastsTrait<ELEM, FlexibleCollimator>::apply(allElementsOfTypeE, element); } -template<class ELEM> -void SpecificElementVisitor<ELEM>::visitLambertson(const Lambertson &element) { - CastsTrait<ELEM, Lambertson>::apply(allElementsOfTypeE, element); -} - template<class ELEM> void SpecificElementVisitor<ELEM>::visitMarker(const Marker &element) { CastsTrait<ELEM, Marker>::apply(allElementsOfTypeE, element); @@ -350,11 +304,6 @@ void SpecificElementVisitor<ELEM>::visitOffset(const Offset &element) { CastsTrait<ELEM, Offset>::apply(allElementsOfTypeE, element); } -template<class ELEM> -void SpecificElementVisitor<ELEM>::visitPatch(const Patch &element) { - CastsTrait<ELEM, Patch>::apply(allElementsOfTypeE, element); -} - template<class ELEM> void SpecificElementVisitor<ELEM>::visitProbe(const Probe &element) { CastsTrait<ELEM, Probe>::apply(allElementsOfTypeE, element); @@ -393,11 +342,6 @@ void SpecificElementVisitor<ELEM>::visitTravelingWave(const TravelingWave &eleme CastsTrait<ELEM, TravelingWave>::apply(allElementsOfTypeE, element); } -template<class ELEM> -void SpecificElementVisitor<ELEM>::visitRFQuadrupole(const RFQuadrupole &element) { - CastsTrait<ELEM, RFQuadrupole>::apply(allElementsOfTypeE, element); -} - template<class ELEM> void SpecificElementVisitor<ELEM>::visitSBend(const SBend &element) { CastsTrait<ELEM, SBend>::apply(allElementsOfTypeE, element); @@ -418,11 +362,6 @@ void SpecificElementVisitor<ELEM>::visitVerticalFFAMagnet(const VerticalFFAMagne CastsTrait<ELEM, VerticalFFAMagnet>::apply(allElementsOfTypeE, element); } -template<class ELEM> -void SpecificElementVisitor<ELEM>::visitSeparator(const Separator &element) { - CastsTrait<ELEM, Separator>::apply(allElementsOfTypeE, element); -} - template<class ELEM> void SpecificElementVisitor<ELEM>::visitSeptum(const Septum &element) { CastsTrait<ELEM, Septum>::apply(allElementsOfTypeE, element); @@ -438,11 +377,6 @@ void SpecificElementVisitor<ELEM>::visitSource(const Source &element) { CastsTrait<ELEM, Source>::apply(allElementsOfTypeE, element); } -template<class ELEM> -void SpecificElementVisitor<ELEM>::visitParallelPlate(const ParallelPlate &element) { - CastsTrait<ELEM, ParallelPlate>::apply(allElementsOfTypeE, element); -} - template<class ELEM> void SpecificElementVisitor<ELEM>::visitStripper(const Stripper &element) { CastsTrait<ELEM, Stripper>::apply(allElementsOfTypeE, element); @@ -459,10 +393,6 @@ void SpecificElementVisitor<ELEM>::visitFlaggedElmPtr(const FlaggedElmPtr &eleme wrappedElement->accept(*this); } -template<class ELEM> -void SpecificElementVisitor<ELEM>::visitIntegrator(const Integrator & /*elem*/) { -} - template<class ELEM> size_t SpecificElementVisitor<ELEM>::size() const{ return allElementsOfTypeE.size(); diff --git a/src/Classic/Algorithms/AbstractMapper.cpp b/src/Classic/Algorithms/AbstractMapper.cpp deleted file mode 100644 index 45a6ab7017573dd0f9a63600f41854dcdfb1a0cf..0000000000000000000000000000000000000000 --- a/src/Classic/Algorithms/AbstractMapper.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: AbstractMapper.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1.2.3 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: AbstractMapper -// This abstract visitor class defines part of the interface for building -// the transfer map for a beamline. -// -// ------------------------------------------------------------------------ -// Class category: Algorithms -// ------------------------------------------------------------------------ -// -// $Date: 2004/11/12 18:57:53 $ -// $Author: adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Algorithms/AbstractMapper.h" -#include "Fields/BMultipoleField.h" -#include "FixedAlgebra/FTps.h" - -typedef FTps<double, 6> Series; - -// namespace { -// void printSciForm(std::ostream &os, double num, int prec = 14, int fw = 22) { -// std::streamsize old_prec = os.precision(prec); // Save old, -// os.setf(std::ios::scientific, std::ios::floatfield); // and set new formats. -// os << std::setw(fw) << num; // Print number. -// os.precision(old_prec); // Restore old formats. -// os.setf(std::ios::fixed, std::ios::floatfield); -// } -// } - -// Class AbstractMapper -// ------------------------------------------------------------------------ - -AbstractMapper::AbstractMapper(const Beamline &beamline, - const PartData &reference, - bool backBeam, bool backTrack): - DefaultVisitor(beamline, backBeam, backTrack), - itsReference(reference) -{} - - -AbstractMapper::~AbstractMapper() -{} - - -Series AbstractMapper:: -buildMultipoleVectorPotential(const BMultipoleField &field) { - int order = field.order(); - - if(order > 0) { - static const Series x = Series::makeVariable(X); - static const Series y = Series::makeVariable(Y); - Series kx = + field.normal(order) / double(order); - Series ky = - field.skew(order) / double(order); - - while(order > 1) { - Series kxt = x * kx - y * ky; - Series kyt = x * ky + y * kx; - order--; - kx = kxt + field.normal(order) / double(order); - ky = kyt - field.skew(order) / double(order); - } - - Series As = x * kx - y * ky; - As.setTruncOrder(As.getMaxOrder()); - return As; - } else { - return Series(0.0); - } -} - -Series AbstractMapper:: -buildSBendVectorPotential(const BMultipoleField &field, double h) { - //std::cerr << "==> In AbstractMapper::buildSBendVectorPotential(const BMultipoleField &field, double h)" - // << std::endl; - int order = field.order(); - Series As; - - //std::cerr << " h = "; printSciForm(std::cerr,h); - //std::cerr << "\n" << order << std::endl; - //std::cerr << std::endl; - //for (int m = 1; m <= order; ++m) { - // std::cerr << " B(" << m << ") = "; printSciForm(std::cerr, field.normal(m)); - // std::cerr << " A(" << m << ") = "; printSciForm(std::cerr, field.skew(m)); - // std::cerr << std::endl; - //} - - if(order > 0) { - static const Series x = Series::makeVariable(X); - static const Series y = Series::makeVariable(Y); - - // Construct terms constant and linear in y. - Series Ae = + field.normal(order); // Term even in y. - Series Ao = - field.skew(order); // Term odd in y. - - for(int i = order; --i >= 1;) { - Ae = Ae * x + field.normal(i); - Ao = Ao * x - field.skew(i); - } - Ae.setTruncOrder(Ae.getMaxOrder()); - Ao.setTruncOrder(Ao.getMaxOrder()); - - Series hx1 = 1. + h * x; // normalized radius - Ae = + (Ae * hx1).integral(X); - Ao = - (Ao * hx1); - // Add terms up to maximum order. - As = Ae + y * Ao; - - int k = 2; - if(k <= order) { - Series yp = y * y / 2.0; - - while(true) { - // Terms even in y. - Ae = Ae.derivative(X); - Ae = h * Ae / hx1 - Ae.derivative(X); - As += Ae * yp; - if(++k > order) break; - yp *= y / double(k); - - // Terms odd in y. - Ao = Ao.derivative(X); - Ao = h * Ao / hx1 - Ao.derivative(X); - As += Ao * yp; - if(++k > order) break; - yp *= y / double(k); - } - } - } - //std::cerr << " As = " << As << std::endl; - //std::cerr << "==> Leaving AbstractMapper::buildSBendVectorPotential(...)" << std::endl; - - return As; -} diff --git a/src/Classic/Algorithms/AbstractMapper.h b/src/Classic/Algorithms/AbstractMapper.h deleted file mode 100644 index 0458db0ac11d58bba1466d13a63b0b40063a7fad..0000000000000000000000000000000000000000 --- a/src/Classic/Algorithms/AbstractMapper.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef CLASSIC_AbstractMapper_HH -#define CLASSIC_AbstractMapper_HH - -// ------------------------------------------------------------------------ -// $RCSfile: AbstractMapper.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1.2.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: AbstractMapper -// -// ------------------------------------------------------------------------ -// Class category: Algorithms -// ------------------------------------------------------------------------ -// -// $Date: 2004/11/12 18:57:53 $ -// $Author: adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Algorithms/DefaultVisitor.h" -#include "Algorithms/PartData.h" - -class BMultipoleField; -template <class T, int N> class LinearMap; -template <class T, int N> class FTps; -template <class T, int N> class FVps; - - -// Class AbstractMapper -// ------------------------------------------------------------------------ -/// Build transfer map. -// An abstract visitor class implementing the default behaviour for all -// visitors capable of tracking a transfer map through a beam line. -// It implements access to the accumulated map, and keeps track of the -// beam reference data. -// This class redefines all visitXXX() methods for elements as pure -// to force their implementation in derived classes. - -class AbstractMapper: public DefaultVisitor { - -public: - - // Particle coordinate numbers. - enum { X, PX, Y, PY, T, PT }; - - /// Constructor. - // The beam line to be tracked is [b]bl[/b]. - // The particle reference data are taken from [b]data[/b]. - // If [b]revBeam[/b] is true, the beam runs from s = C to s = 0. - // If [b]revTrack[/b] is true, we track against the beam. - AbstractMapper(const Beamline &bl, const PartData &data, - bool revBeam, bool revTrack); - - virtual ~AbstractMapper(); - - - /// Return the linear part of the accumulated map. - virtual void getMap(LinearMap<double, 6> &) const = 0; - - /// Return the full map accumulated so far. - virtual void getMap(FVps<double, 6> &) const = 0; - - /// Reset the linear part of the accumulated map for restart. - virtual void setMap(const LinearMap<double, 6> &) = 0; - - /// Reset the full map for restart. - virtual void setMap(const FVps<double, 6> &) = 0; - -protected: - - /// Construct the vector potential for a Multipole. - FTps<double, 6> buildMultipoleVectorPotential(const BMultipoleField &); - - /// Construct the vector potential for an SBend. - FTps<double, 6> buildSBendVectorPotential(const BMultipoleField &, double h); - - /// The reference information. - const PartData itsReference; - -private: - - // Not implemented. - AbstractMapper(); - AbstractMapper(const AbstractMapper &); - void operator=(const AbstractMapper &); -}; - -#endif // CLASSIC_AbstractMapper_HH \ No newline at end of file diff --git a/src/Classic/Algorithms/CMakeLists.txt b/src/Classic/Algorithms/CMakeLists.txt index 840e6aa1490dcbf7b2f95e365f819bebe3bda34c..667609f81644199d7f0e6a7b2314b58e26f00a84 100644 --- a/src/Classic/Algorithms/CMakeLists.txt +++ b/src/Classic/Algorithms/CMakeLists.txt @@ -1,12 +1,9 @@ set (_SRCS - AbstractMapper.cpp AbstractTimeDependence.cpp AbstractTracker.cpp CoordinateSystemTrafo.cpp DefaultVisitor.cpp Flagger.cpp - LinearMapper.cpp - Mapper.cpp PartBunch.cpp PartBins.cpp PartBinsCyc.cpp @@ -14,9 +11,6 @@ set (_SRCS OpalParticle.cpp PolynomialTimeDependence.cpp SplineTimeDependence.cpp - Surveyor.cpp - ThinMapper.cpp - ThinTracker.cpp Tracker.cpp Quaternion.cpp ) @@ -32,15 +26,12 @@ include_directories ( add_opal_sources (${_SRCS}) set (HDRS - AbstractMapper.h AbstractTimeDependence.h AbstractTracker.h CoordinateSystemTrafo.h DefaultVisitor.h Flagger.h - LinearMapper.h ListElem.h - Mapper.h PartBinsCyc.h PartBins.h PartBunch.h @@ -50,11 +41,7 @@ set (HDRS PBunchDefs.h PolynomialTimeDependence.h Quaternion.h - rbendmap.h SplineTimeDependence.h - Surveyor.h - ThinMapper.h - ThinTracker.h Tracker.h Vektor.h ) diff --git a/src/Classic/Algorithms/DefaultVisitor.cpp b/src/Classic/Algorithms/DefaultVisitor.cpp index dac6d0994b8ceb9cc90308a57f2cb06a5c4b0376..0a7f19a8e3106fb9bdb975141817b8d380a0b0df 100644 --- a/src/Classic/Algorithms/DefaultVisitor.cpp +++ b/src/Classic/Algorithms/DefaultVisitor.cpp @@ -22,18 +22,14 @@ // #include "Algorithms/DefaultVisitor.h" -#include "AbsBeamline/BeamBeam.h" #include "AbsBeamline/BeamStripping.h" #include "AbsBeamline/CCollimator.h" #include "AbsBeamline/Corrector.h" #include "AbsBeamline/Cyclotron.h" #include "AbsBeamline/Degrader.h" -#include "AbsBeamline/Diagnostic.h" #include "AbsBeamline/Drift.h" #include "AbsBeamline/ElementBase.h" #include "AbsBeamline/FlexibleCollimator.h" -#include "AbsBeamline/Integrator.h" -#include "AbsBeamline/Lambertson.h" #include "AbsBeamline/Marker.h" #include "AbsBeamline/Monitor.h" #include "AbsBeamline/Multipole.h" @@ -42,17 +38,13 @@ #include "AbsBeamline/MultipoleTCurvedVarRadius.h" #include "AbsBeamline/MultipoleTStraight.h" #include "AbsBeamline/Offset.h" -#include "AbsBeamline/ParallelPlate.h" -#include "AbsBeamline/Patch.h" #include "AbsBeamline/Probe.h" #include "AbsBeamline/RBend.h" #include "AbsBeamline/RBend3D.h" #include "AbsBeamline/RFCavity.h" -#include "AbsBeamline/RFQuadrupole.h" #include "AbsBeamline/SBend.h" #include "AbsBeamline/SBend3D.h" #include "AbsBeamline/ScalingFFAMagnet.h" -#include "AbsBeamline/Separator.h" #include "AbsBeamline/Septum.h" #include "AbsBeamline/Solenoid.h" #include "AbsBeamline/Source.h" @@ -89,11 +81,6 @@ void DefaultVisitor::execute() { itsLine.accept(*this); } - -void DefaultVisitor::visitBeamBeam(const BeamBeam &bb) { - applyDefault(bb); -} - void DefaultVisitor::visitBeamStripping(const BeamStripping &bstp) { applyDefault(bstp); } @@ -118,10 +105,6 @@ void DefaultVisitor::visitDegrader(const Degrader °) { applyDefault(deg); } -void DefaultVisitor::visitDiagnostic(const Diagnostic &diag) { - applyDefault(diag); -} - void DefaultVisitor::visitDrift(const Drift &drf) { applyDefault(drf); } @@ -130,10 +113,6 @@ void DefaultVisitor::visitFlexibleCollimator(const FlexibleCollimator &coll) { applyDefault(coll); } -void DefaultVisitor::visitLambertson(const Lambertson &lamb) { - applyDefault(lamb); -} - void DefaultVisitor::visitMarker(const Marker &mark) { applyDefault(mark); } @@ -171,10 +150,6 @@ void DefaultVisitor::visitRing(const Ring &ring) { } -void DefaultVisitor::visitPatch(const Patch &patch) { - applyDefault(patch); -} - void DefaultVisitor::visitProbe(const Probe &probe) { applyDefault(probe); } @@ -206,11 +181,6 @@ void DefaultVisitor::visitTravelingWave(const TravelingWave &trw) { } -void DefaultVisitor::visitRFQuadrupole(const RFQuadrupole &quad) { - applyDefault(quad); -} - - void DefaultVisitor::visitSBend(const SBend &bend) { applyDefault(bend); } @@ -229,11 +199,6 @@ void DefaultVisitor::visitVerticalFFAMagnet(const VerticalFFAMagnet &mag) { applyDefault(mag); } -void DefaultVisitor::visitSeparator(const Separator &sep) { - applyDefault(sep); -} - - void DefaultVisitor::visitSeptum(const Septum &sept) { applyDefault(sept); } @@ -248,10 +213,6 @@ void DefaultVisitor::visitSource(const Source &sou) { } -void DefaultVisitor::visitParallelPlate(const ParallelPlate &pplate) { - applyDefault(pplate); -} - void DefaultVisitor::visitStripper(const Stripper &stripper) { applyDefault(stripper); } @@ -274,11 +235,5 @@ void DefaultVisitor::visitFlaggedElmPtr(const FlaggedElmPtr &fep) { } -void DefaultVisitor::visitIntegrator(const Integrator &i) { - // Default: cannot use integrator. - i.getElement()->accept(*this); -} - - void DefaultVisitor::applyDefault(const ElementBase &) {} \ No newline at end of file diff --git a/src/Classic/Algorithms/DefaultVisitor.h b/src/Classic/Algorithms/DefaultVisitor.h index 153c00362e86d059a4cb9800fd95bb41d483aa09..be82b115aea68532b793b8047b2c2b0fac0864b2 100644 --- a/src/Classic/Algorithms/DefaultVisitor.h +++ b/src/Classic/Algorithms/DefaultVisitor.h @@ -45,9 +45,6 @@ public: /// Apply the algorithm to the top-level beamline. virtual void execute(); - /// Apply the algorithm to a beam-beam. - virtual void visitBeamBeam(const BeamBeam &); - /// Apply the algorithm to a beam stripping. virtual void visitBeamStripping(const BeamStripping &); @@ -69,18 +66,12 @@ public: /// Apply the algorithm to a drift. virtual void visitDegrader(const Degrader &); - /// Apply the algorithm to a diagnostic. - virtual void visitDiagnostic(const Diagnostic &); - /// Apply the algorithm to a drift. virtual void visitDrift(const Drift &); /// Apply the algorithm to a flexible collimator virtual void visitFlexibleCollimator(const FlexibleCollimator &); - /// Apply the algorithm to a Lambertson. - virtual void visitLambertson(const Lambertson &); - /// Apply the algorithm to a marker. virtual void visitMarker(const Marker &); @@ -105,9 +96,6 @@ public: /// Apply the algorithm to an Offset. virtual void visitOffset(const Offset &); - /// Apply the algorithm to a patch. - virtual void visitPatch(const Patch &pat); - /// Apply the algorithm to a probe. virtual void visitProbe(const Probe &prob); @@ -129,9 +117,6 @@ public: /// Apply the algorithm to a RF cavity. virtual void visitTravelingWave(const TravelingWave &); - /// Apply the algorithm to a RF quadrupole. - virtual void visitRFQuadrupole(const RFQuadrupole &); - /// Apply the algorithm to a sector bend. virtual void visitSBend(const SBend &); @@ -144,9 +129,6 @@ public: /// Apply the algorithm to a RF cavity. virtual void visitVerticalFFAMagnet(const VerticalFFAMagnet &); - /// Apply the algorithm to a separator. - virtual void visitSeparator(const Separator &); - /// Apply the algorithm to a septum. virtual void visitSeptum(const Septum &); @@ -156,9 +138,6 @@ public: /// Apply the algorithm to a source. virtual void visitSource(const Source &); - /// Apply the algorithm to a ParallelPlate. - virtual void visitParallelPlate(const ParallelPlate &); - /// Apply the algorithm to a charge stripper. virtual void visitStripper(const Stripper &); @@ -168,9 +147,6 @@ public: /// Apply the algorithm to a FlaggedElmPtr. virtual void visitFlaggedElmPtr(const FlaggedElmPtr &); - /// Apply the algorithm to a generic integrator. - virtual void visitIntegrator(const Integrator &); - protected: // The top level beamline. diff --git a/src/Classic/Algorithms/LinearMapper.cpp b/src/Classic/Algorithms/LinearMapper.cpp deleted file mode 100644 index 4939f9e9e37c2c685e42a97011014fcc2b280e07..0000000000000000000000000000000000000000 --- a/src/Classic/Algorithms/LinearMapper.cpp +++ /dev/null @@ -1,737 +0,0 @@ -// -// Class LinearMapper -// Build a map using a linear map for each element. -// Phase space coordinates numbering: -// [tab 3 b] -// [row]number [&]name [&]unit [/row] -// [row]0 [&]x [&]metres [/row] -// [row]1 [&]p_x/p_r [&]1 [/row] -// [row]2 [&]y [&]metres [/row] -// [row]3 [&]p_y/p_r [&]1 [/row] -// [row]4 [&]v*delta_t [&]metres [/row] -// [row]5 [&]delta_p/p_r [&]1 [/row] -// [/tab][p] -// Where $p_r$ is the constant reference momentum defining the reference -// frame velocity, $m$ is the rest mass of the particles, and $v$ is the -// instantaneous velocity of the particle. -// [p] -// Other units used: -// [tab 2 b] -// [row]quantity [&]unit [/row] -// [row]reference momentum [&]electron-volts [/row] -// [row]velocity [&]metres/second [/row] -// [row]accelerating voltage [&]volts [/row] -// [row]separator voltage [&]volts [/row] -// [row]frequencies [&]hertz [/row] -// [row]phase lags [&]$2*pi$ [/row] -// [/tab][p] -// Approximations used: -// [ul] -// [li] All elements are represented by maps for finite-length elements. -// [li] Geometric transformations ignore rotations about transverse axes and -// translations along the design orbit and truncate after second order. -// [li] Beam-beam elements are two-dimensional, and the second moment <x,y> -// of the opposite bunches vanish. -// [/ul] -// -// Copyright (c) 200x - 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 "Algorithms/LinearMapper.h" - -#include "AbsBeamline/CCollimator.h" -#include "AbsBeamline/Corrector.h" -#include "AbsBeamline/Diagnostic.h" -#include "AbsBeamline/Drift.h" -#include "AbsBeamline/Degrader.h" -#include "AbsBeamline/ElementBase.h" -#include "AbsBeamline/FlexibleCollimator.h" -#include "AbsBeamline/Lambertson.h" -#include "AbsBeamline/Monitor.h" -#include "AbsBeamline/Multipole.h" -#include "AbsBeamline/Patch.h" -#include "AbsBeamline/Probe.h" -#include "AbsBeamline/RBend.h" -#include "AbsBeamline/RFCavity.h" -#include "AbsBeamline/RFQuadrupole.h" -#include "AbsBeamline/SBend.h" -#include "AbsBeamline/Separator.h" -#include "AbsBeamline/Septum.h" -#include "AbsBeamline/Solenoid.h" -#include "AbsBeamline/ParallelPlate.h" - -#include "BeamlineGeometry/Euclid3D.h" -#include "BeamlineGeometry/PlanarArcGeometry.h" -#include "BeamlineGeometry/RBendGeometry.h" -#include "Fields/BMultipoleField.h" -#include "FixedAlgebra/FTpsMath.h" -#include "FixedAlgebra/LinearFun.h" -#include "FixedAlgebra/LinearMath.h" -#include "Physics/Physics.h" - -#include <cmath> - -typedef FTps<double, 2> Series2; -typedef LinearFun<double, 6> Linear; - - -// Class LinearMapper -// ------------------------------------------------------------------------ - -LinearMapper::LinearMapper(const Beamline &beamline, const PartData &reference, - bool revBeam, bool revTrack): - AbstractMapper(beamline, reference, revBeam, revTrack) -{} - - -LinearMapper::~LinearMapper() -{} - - -void LinearMapper::getMap(LinearMap<double, 6> &map) const { - map = itsMap; -} - - -void LinearMapper::getMap(FVps<double, 6> &map) const { - map = FVps<double, 6>(itsMap); -} - - -void LinearMapper::setMap(const LinearMap<double, 6> &map) { - itsMap = map; -} - - -void LinearMapper::setMap(const FVps<double, 6> &map) { - itsMap = LinearMap<double, 6>(map); -} - - -void LinearMapper::visitBeamBeam(const BeamBeam &) { - // *** MISSING *** Map for beam-beam. -} - -void LinearMapper::visitBeamStripping(const BeamStripping &) { - // *** MISSING *** Map for beam stripping. -} - -void LinearMapper::visitCCollimator(const CCollimator &coll) { - applyDrift(flip_s * coll.getElementLength()); -} - - -void LinearMapper::visitComponent(const Component &comp) { - FVps<double, 6> map(itsMap); - comp.trackMap(map, itsReference, back_beam, back_track); - itsMap = LinearMap<double, 6>(map); -} - - -void LinearMapper::visitCorrector(const Corrector &corr) { - // Drift through first half of length. - double length = flip_s * corr.getElementLength(); - if(length) applyDrift(length / 2.0); - - // Apply kick. - double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP(); - const BDipoleField &field = corr.getField(); - itsMap[PX] -= field.getBy() * scale; - itsMap[PY] += field.getBx() * scale; - - // Drift through second half of length. - if(length) applyDrift(length / 2.0); -} - -void LinearMapper::visitDegrader(const Degrader °) { - applyDrift(flip_s * deg.getElementLength()); -} - -void LinearMapper::visitDiagnostic(const Diagnostic &diag) { - applyDrift(flip_s * diag.getElementLength()); -} - - -void LinearMapper::visitDrift(const Drift &drift) { - applyDrift(flip_s * drift.getElementLength()); -} - -void LinearMapper::visitFlexibleCollimator(const FlexibleCollimator &coll) { - applyDrift(flip_s * coll.getElementLength()); -} - -void LinearMapper::visitLambertson(const Lambertson &lamb) { - // Assume the particle go through the magnet's window. - applyDrift(flip_s * lamb.getElementLength()); -} - - -void LinearMapper::visitMarker(const Marker &/*marker*/) { - // Do nothing. -} - - -void LinearMapper::visitMonitor(const Monitor &corr) { - applyDrift(flip_s * corr.getElementLength()); -} - - -void LinearMapper::visitMultipole(const Multipole &multipole) { - double length = flip_s * multipole.getElementLength(); - double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP(); - const BMultipoleField &field = multipole.getField(); - - if(length) { - // Normal case: Finite-length multipole, field coefficients are B. - applyMultipoleBody(length, length, field, scale); - } else { - // Special case: Thin multipole, field coefficients are integral(B*dl). - scale *= flip_s; - applyThinMultipole(field, scale); - } -} - - -void LinearMapper::visitPatch(const Patch &patch) { - Euclid3D transform = patch.getPatch(); - if(back_track) transform = Inverse(transform); - applyTransform(transform, 0.0); -} - -void LinearMapper::visitProbe(const Probe &/*Prob*/) { - // Do nothing. -} - - -#include "Algorithms/rbendmap.h" - -void LinearMapper::visitRBend(const RBend &bend) { - visitRBend0(bend); -} - -void LinearMapper::visitRBend0(const RBend &bend) { - - const RBendGeometry &geometry = bend.getGeometry(); - double length = flip_s * geometry.getElementLength(); - double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP(); - const BMultipoleField &field = bend.getField(); - - if(length == 0.0) { - double half_angle = flip_s * geometry.getBendAngle() / 2.0; - Euclid3D rotat = Euclid3D::YRotation(- half_angle); - - // Transform from in-plane to mid-plane. - applyTransform(rotat, 0.0); - - // Apply multipole kick. - applyThinMultipole(field, scale); - - // Transform from mid-plane to out-plane. - applyTransform(rotat, 0.0); - } else { - double refLength = flip_s * geometry.getArcLength(); - scale *= flip_B; - if(back_track) { - // Transform from global to local. - applyTransform(Inverse(geometry.getExitPatch()), 0.0); - // Apply entrance fringe field. - applyEntranceFringe(bend.getExitFaceRotation(), field, scale); - - // Traverse rbend body. - applyMultipoleBody(length, refLength, field, scale); - - // Apply exit fringe field. - applyExitFringe(bend.getEntryFaceRotation(), field, scale); - - // Apply rotation local to global. - applyTransform(Inverse(geometry.getEntrancePatch()), 0.0); - } else { - // Apply rotation global to local. - applyTransform(geometry.getEntrancePatch(), 0.0); - - // Apply entrance fringe field. - applyEntranceFringe(bend.getEntryFaceRotation(), field, scale); - - // Traverse rbend body. - applyMultipoleBody(length, refLength, field, scale); - - // Apply exit fringe field. - applyExitFringe(bend.getExitFaceRotation(), field, scale); - - // Apply rotation local to global. - applyTransform(geometry.getExitPatch(), 0.0); - } - } -} - - -void LinearMapper::visitRFCavity(const RFCavity &as) { - // Drift through half length. - double length = flip_s * as.getElementLength(); - if(length) applyDrift(length / 2.0); - - // Apply accelerating voltage. - double freq = as.getFrequency(); - double peak = flip_s * as.getAmplitude() / itsReference.getP(); - Linear phase = as.getPhase() + (freq / Physics::c) * itsMap[T]; - itsMap[PT] += peak * sin(phase); - - // Drift through half length. - if(length) applyDrift(length / 2.0); -} - - -void LinearMapper::visitRFQuadrupole(const RFQuadrupole &rfq) { - // *** MISSING *** Map for RF Quadrupole. - applyDrift(flip_s * rfq.getElementLength()); -} - - -void LinearMapper::visitSBend(const SBend &bend) { - const PlanarArcGeometry &geometry = bend.getGeometry(); - double length = flip_s * geometry.getElementLength(); - double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP(); - const BMultipoleField &field = bend.getField(); - - if(length == 0.0) { - double half_angle = geometry.getBendAngle() / 2.0; - Euclid3D rotat = Euclid3D::YRotation(- half_angle); - - // Transform from in-plane to mid-plane. - applyTransform(rotat, 0.0); - - // Apply multipole kick. - // Curvature is unknown for zero-length bend. - applyThinMultipole(field, scale); - - // Transform from mid-plane to out-plane. - applyTransform(rotat, 0.0); - } else { - double h = geometry.getCurvature(); - double refLength = flip_s * geometry.getArcLength(); - - if(back_track) { - // Apply entrance fringe field. - applyEntranceFringe(bend.getExitFaceRotation(), field, scale); - - // Traverse sbend body. - applySBendBody(length, refLength, h, field, scale); - - // Apply exit fringe field. - applyExitFringe(bend.getEntryFaceRotation(), field, scale); - } else { - // Apply entrance fringe field. - applyEntranceFringe(bend.getEntryFaceRotation(), field, scale); - - // Traverse sbend body. - applySBendBody(length, refLength, h, field, scale); - - // Apply exit fringe field. - applyExitFringe(bend.getExitFaceRotation(), field, scale); - } - } -} - - -void LinearMapper::visitSeparator(const Separator &sep) { - // Drift through first half of length. - double length = flip_s * sep.getElementLength(); - if(length) applyDrift(length / 2.0); - - // Electrostatic kick. - double scale = (length * itsReference.getQ()) / itsReference.getP(); - double Ex = scale * sep.getEx(); - double Ey = scale * sep.getEy(); - Linear pt = 1.0 + itsMap[PT]; - itsMap[PX] += Ex / pt; - itsMap[PY] += Ey / pt; - - if(length) applyDrift(length / 2.0); -} - - -void LinearMapper::visitSeptum(const Septum &sept) { - // Assume the particle go through the magnet's window. - applyDrift(flip_s * sept.getElementLength()); -} - - -void LinearMapper::visitSolenoid(const Solenoid &solenoid) { - double length = flip_s * solenoid.getElementLength(); - - if(length) { - double ks = (flip_B * itsReference.getQ() * solenoid.getBz() * Physics::c) / - (2.0 * itsReference.getP()); - - if(ks) { - double C = std::cos(ks * length); - double S = std::sin(ks * length); - - Linear xt = C * itsMap[X] + S * itsMap[Y]; - Linear yt = C * itsMap[Y] - S * itsMap[X]; - Linear pxt = C * itsMap[PX] + S * itsMap[PY]; - Linear pyt = C * itsMap[PY] - S * itsMap[PX]; - - itsMap[X] = C * xt + (S / ks) * pxt; - itsMap[Y] = C * yt + (S / ks) * pyt; - itsMap[PX] = C * pxt - (S * ks) * xt; - itsMap[PY] = C * pyt - (S * ks) * yt; - - double kin = itsReference.getM() / itsReference.getP(); - itsMap[T] += length * itsMap[PT] * kin * kin; - } else { - applyDrift(length); - } - } -} - - -void LinearMapper::visitParallelPlate(const ParallelPlate &/*pplate*/) { - //do nothing -} - - -void LinearMapper::makeFocus -(double k, double L, double &c, double &s, double &d, double &f) { - double t = k * L * L; - if(std::abs(t) < 1.0e-4) { - c = 1.0 - t / 2.0; - s = L * (1.0 - t / 6.0); - d = L * L * (0.5 - t / 24.0); - f = L * L * L * ((1.0 / 6.0) - t / 120.0); - } else if(k > 0.0) { - double r = std::sqrt(k); - c = std::cos(r * L); - s = std::sin(r * L) / r; - d = (1.0 - c) / k; - f = (L - s) / k; - } else { - double r = std::sqrt(- k); - c = std::cosh(r * L); - s = std::sinh(r * L) / r; - d = (1.0 - c) / k; - f = (L - s) / k; - } -} - - -void LinearMapper::applyDrift(double length) { - double kin = itsReference.getM() / itsReference.getP(); - itsMap[X] += length * itsMap[PX]; - itsMap[Y] += length * itsMap[PY]; - itsMap[T] += length * itsMap[PT] * kin * kin; -} - - -void LinearMapper::applyEntranceFringe(double angle, - const BMultipoleField &field, - double scale) { - double hx = scale * field.normal(1); - double ex = hx * tan(angle); - double ey = hx * tan(angle + itsMap[PX][0]); - itsMap[PX] += ex * itsMap[X]; - itsMap[PY] -= ey * itsMap[Y]; -} - - -void LinearMapper::applyExitFringe(double angle, - const BMultipoleField &field, - double scale) { - double hx = scale * field.normal(1); - double ex = hx * tan(angle); - double ey = hx * tan(angle - itsMap[PX][0]); - itsMap[PX] += ex * itsMap[X]; - itsMap[PY] -= ey * itsMap[Y]; -} - - -void LinearMapper::applyLinearMap(double length, double refLength, double h, - const Series2 &Fx, const Series2 &Fy) { - // Extract the phase coordinates. - Linear x = itsMap[X]; - Linear px = itsMap[PX]; - Linear y = itsMap[Y]; - Linear py = itsMap[PY]; - Linear pt = itsMap[PT]; - - // Split position variables into constant and variable terms. - double x0 = x[0]; - double y0 = y[0]; - x[0] = 0.0; - y[0] = 0.0; - - // Extract coefficients for equations of motion. - // Indexing: 0 = constant, 1 = X, 2 = Y. - double kx = Fx[1]; - double ks = (Fx[2] - Fy[1]) / 2.0; - double ky = - Fy[2]; - Linear hx = h * (1.0 + pt) - Fx[0]; - double hy = Fy[0]; - - // Parameters for longitudinal motion. - double kin = itsReference.getM() / itsReference.getE(); - double refTime = refLength * kin * kin; - - // Test for zero skew quadrupole component. - if(ks == 0.0) { - // Transport coefficients. - double cx, sx, dx, fx, cy, sy, dy, fy; - makeFocus(kx, length, cx, sx, dx, fx); - makeFocus(ky, length, cy, sy, dy, fy); - double wx = - kx * sx; - double wy = - ky * sy; - - // Advance through field. - itsMap[X] = cx * x + sx * px + dx * hx; - itsMap[PX] = wx * x + cx * px + sx * hx; - itsMap[Y] = cy * y + sy * py + dy * hy; - itsMap[PY] = wy * y + cy * py + sy * hy; - itsMap[T] += h * (sx * x + dx * px + fx * hx); - } else { - // Find transformation to principal axes. - double s1 = (kx + ky) / 2.0; - double d1 = (kx - ky) / 2.0; - double root = std::sqrt(d1 * d1 + ks * ks); - double c2 = d1 / root; - double s2 = ks / root; - - // Transport coefficients. - double cu, su, du, fu, cv, sv, dv, fv; - double ku = s1 + (d1 * d1 - ks * ks) / root; - double kv = s1 - (d1 * d1 - ks * ks) / root; - makeFocus(ku, length, cu, su, du, fu); - makeFocus(kv, length, cv, sv, dv, fv); - double wu = - ku * su; - double wv = - kv * sv; - - // Rotate the coordinates to orientation of quadrupole. - Linear u = c2 * x - s2 * y; - Linear v = c2 * y + s2 * x; - Linear pu = c2 * px - s2 * py; - Linear pv = c2 * py + s2 * px; - Linear hu = c2 * (h + hx) - s2 * hy; - Linear hv = c2 * hy + s2 * (h + hx); - - // Advance through field. - itsMap[X] = ((cu + cv) * x + (cu - cv) * u + - (su + sv) * px + (su - sv) * pu + - (du + dv) * hx + (du - dv) * hu) / 2.0; - itsMap[PX] = ((wu + wv) * x + (wu - wv) * u + - (cu + cv) * px + (cu - cv) * pu + - (su + sv) * hx + (su - sv) * hu) / 2.0; - itsMap[Y] = ((cu + cv) * y - (cu - cv) * v + - (su + sv) * py - (su - sv) * pv + - (du + dv) * hy - (du - dv) * hv) / 2.0; - itsMap[PY] = ((wu + wv) * y - (wu - wv) * v + - (cu + cv) * py - (cu - cv) * pv + - (su + sv) * hy - (su - sv) * hv) / 2.0; - itsMap[T] += ((su + sv) * x + (su - sv) * u + - (du + dv) * px + (du - dv) * pu + - (fu + fv) * hx + (fu - fv) * hu) * (h / 2.0); - } - - // Add in constant terms. - itsMap[X] += x0; - itsMap[Y] += y0; - itsMap[T] += refTime * pt + length * h * x0; -} - - -Series2 -LinearMapper::buildSBendVectorPotential(const BMultipoleField &field, double h) { - //std::cerr << "==> In buildSBendVectorPotential(const BMultipoleField &field, double h)..." - // << std::endl; - // Check sanity. - if(h == 0.) { - std::cerr << " <*** ERROR ***> in LinearMapper::buildSBendVectorPotential():\n" - << " attempt to use an infinite radius of curvature." << std::endl; - throw DomainError("buildSBendVectorPotential(const BMultipoleField &, double)"); - } - - int order = field.order(); - Series2 As; - - //std::cerr << "order = " << order << std::endl; - //for (int m = 1; m <= order; ++m) { - //std::cerr << "Order " << m << ": " - // << field.normal(m) << " " << field.skew(m) << std::endl; - //} - - if(order > 0) { - static Series2 x = Series2::makeVariable(0); - static Series2 y = Series2::makeVariable(1); - - // Terms even/odd in y. - Series2 Ae = + field.normal(order); - Series2 Ao = - field.skew(order); - - int i = order; - while(i > 1) { - --i; - Ae = Ae * x + field.normal(i); - Ao = Ao * x - field.skew(i); - }; - Ae.setTruncOrder(Ae.getMaxOrder()); - Ao.setTruncOrder(Ao.getMaxOrder()); - - { - Series2 hx1 = 1. + h * x; - Ae = + (Ae * hx1).integral(0); - Ao = - (Ao * hx1); - } - // Add terms up to maximum order. - As = Ae + y * Ao; - - int k = 2; - if(k <= order) { - Series2 yp = y * y / 2.0; - Series2 radius = 1.0 / h + x; - - while(true) { - // Terms even in y. - Ae = Ae.derivative(0); - Ae = Ae / radius - Ae.derivative(0); // use following line to include case h==0. - // Ae = (h==0. ? 0. : Ae/radius) - Ae.derivative(0); - As += Ae * yp; - if(++k > order) break; - yp *= y / double(k); - - // Terms odd in y. - Ao = Ao.derivative(0); - Ao = Ao / radius - Ao.derivative(0); // use following line to include case h==0. - // Ao = (h==0. ? 0. : Ao/radius) - Ao.derivative(0); - As += Ao * yp; - if(++k > order) break; - yp *= y / double(k); - } - } - } - - //std::cerr << " As = " << As << std::endl; - double x0 = itsMap[X][0], y0 = itsMap[Y][0]; - if(x0 != 0. || y0 != 0.) { - FVps<double, 2> to_fixpt; - to_fixpt[0] += x0; - to_fixpt[1] += y0; - As = As.substitute(to_fixpt); - } - //std::cerr << " As(r-fp) = " << As << std::endl; - - return As; -} - - -void LinearMapper::applyMultipoleBody(double length, double refLength, - const BMultipoleField &field, double scale) { - // Determine normalised field coefficients around actual orbit. - // Fx and Fy are the normalised field coefficients, - // expressed as linear functions in x and y. - int order = field.order(); - - if(order > 0) { - static Series2 x = Series2::makeVariable(0); - static Series2 y = Series2::makeVariable(1); - - Series2 Fx = field.normal(order); - Series2 Fy = - field.skew(order); - - while(order > 1) { - Series2 Fxt = x * Fx - y * Fy; - Series2 Fyt = x * Fy + y * Fx; - --order; - Fx = Fxt + field.normal(order); - Fy = Fyt - field.skew(order); - }; - Fx.setTruncOrder(Fx.getMaxOrder()); - Fy.setTruncOrder(Fy.getMaxOrder()); - - Fx *= scale; - Fy *= scale; - - FVps<double, 2> to_fixpt; - to_fixpt[0] += itsMap[X][0]; - to_fixpt[1] += itsMap[Y][0]; - - Fx = Fx.substitute(to_fixpt); - Fy = Fy.substitute(to_fixpt); - applyLinearMap(length, refLength, 0.0, Fx, Fy); - } else applyDrift(length); -} - - -void LinearMapper::applySBendBody(double length, double refLength, double h, - const BMultipoleField &field, double scale) { - // Determine normalised field coefficients around actual orbit. - // As is the vector potential times (1 + h*x), - // expressed as a linear function in x and y. - Series2 As = buildSBendVectorPotential(field, h) * scale; - - // Fx and Fy are the normalised field coefficients times (1 + h*x). - Series2 Fx = + As.derivative(0); - Series2 Fy = - As.derivative(1); - applyLinearMap(length, refLength, h, Fx, Fy); -} - - -void LinearMapper::applyThinMultipole -(const BMultipoleField &field, double scale) { - int order = field.order(); - - if(order > 0) { - Linear x = itsMap[X]; - Linear y = itsMap[Y]; - Linear kx = + field.normal(order); - Linear ky = - field.skew(order); - - while(--order > 0) { - Linear kxt = x * kx - y * ky; - Linear kyt = x * ky + y * kx; - kx = kxt + field.normal(order); - ky = kyt - field.skew(order); - } - - itsMap[PX] -= kx * scale; - itsMap[PY] += ky * scale; - } -} - - -void LinearMapper::applyTransform(const Euclid3D &euclid, double refLength) { - if(! euclid.isIdentity()) { - Linear px1 = itsMap[PX]; - Linear py1 = itsMap[PY]; - Linear pt = itsMap[PT] + 1.0; - Linear pz1 = sqrt(pt * pt - px1 * px1 - py1 * py1); - - itsMap[PX] = euclid.M(0, 0) * px1 + euclid.M(1, 0) * py1 + euclid.M(2, 0) * pz1; - itsMap[PY] = euclid.M(0, 1) * px1 + euclid.M(1, 1) * py1 + euclid.M(2, 1) * pz1; - Linear pz2 = euclid.M(0, 2) * px1 + euclid.M(1, 2) * py1 + euclid.M(2, 2) * pz1; - - Linear x = itsMap[X] - euclid.getX(); - Linear y = itsMap[Y] - euclid.getY(); - Linear x2 = - euclid.M(0, 0) * x + euclid.M(1, 0) * y - euclid.M(2, 0) * euclid.getZ(); - Linear y2 = - euclid.M(0, 1) * x + euclid.M(1, 1) * y - euclid.M(2, 1) * euclid.getZ(); - Linear s2 = - euclid.M(0, 2) * x + euclid.M(1, 2) * y - euclid.M(2, 2) * euclid.getZ(); - Linear sByPz = s2 / pz2; - - double kin = itsReference.getM() / itsReference.getP(); - Linear E = sqrt(pt * pt + kin * kin); - double refTime = refLength / itsReference.getBeta(); - itsMap[X] = x2 - sByPz * itsMap[PX]; - itsMap[Y] = y2 - sByPz * itsMap[PY]; - itsMap[T] += pt * (refTime / E + sByPz); - } -} diff --git a/src/Classic/Algorithms/LinearMapper.h b/src/Classic/Algorithms/LinearMapper.h deleted file mode 100644 index 9d61cb9584b08d1a3aaa3ca5e0cfad5470c4fae1..0000000000000000000000000000000000000000 --- a/src/Classic/Algorithms/LinearMapper.h +++ /dev/null @@ -1,214 +0,0 @@ -// -// Class LinearMapper -// Build a map using a linear map for each element. -// Phase space coordinates numbering: -// [tab 3 b] -// [row]number [&]name [&]unit [/row] -// [row]0 [&]x [&]metres [/row] -// [row]1 [&]p_x/p_r [&]1 [/row] -// [row]2 [&]y [&]metres [/row] -// [row]3 [&]p_y/p_r [&]1 [/row] -// [row]4 [&]v*delta_t [&]metres [/row] -// [row]5 [&]delta_p/p_r [&]1 [/row] -// [/tab][p] -// Where $p_r$ is the constant reference momentum defining the reference -// frame velocity, $m$ is the rest mass of the particles, and $v$ is the -// instantaneous velocity of the particle. -// [p] -// Other units used: -// [tab 2 b] -// [row]quantity [&]unit [/row] -// [row]reference momentum [&]electron-volts [/row] -// [row]velocity [&]metres/second [/row] -// [row]accelerating voltage [&]volts [/row] -// [row]separator voltage [&]volts [/row] -// [row]frequencies [&]hertz [/row] -// [row]phase lags [&]$2*pi$ [/row] -// [/tab][p] -// Approximations used: -// [ul] -// [li] All elements are represented by maps for finite-length elements. -// [li] Geometric transformations ignore rotations about transverse axes and -// translations along the design orbit and truncate after second order. -// [li] Beam-beam elements are two-dimensional, and the second moment <x,y> -// of the opposite bunches vanish. -// [/ul] -// -// Copyright (c) 200x - 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 MAD_LinearMapper_HH -#define MAD_LinearMapper_HH - -#include "Algorithms/AbstractMapper.h" -#include "FixedAlgebra/LinearMap.h" - - -class BMultipoleField; -class Euclid3D; - -template <class T, int N> class FTps; -template <class T, int N> class FVps; - - -class LinearMapper: public AbstractMapper { - -public: - - /// Constructor. - // The beam line to be tracked is [b]bl[/b]. - // The particle reference data are taken from [b]data[/b]. - // If [b]revBeam[/b] is true, the beam runs from s = C to s = 0. - // If [b]revTrack[/b] is true, we track against the beam. - LinearMapper(const Beamline &beamline, const PartData &, - bool revBeam, bool revTrack); - - virtual ~LinearMapper(); - - /// Return the linear part of the accumulated map. - virtual void getMap(LinearMap<double, 6> &) const; - - /// Return the full map accumulated so far. - virtual void getMap(FVps<double, 6> &) const; - - /// Reset the linear part of the accumulated map for restart. - virtual void setMap(const LinearMap<double, 6> &); - - /// Reset the full map for restart. - virtual void setMap(const FVps<double, 6> &); - - /// Apply the algorithm to a BeamBeam. - virtual void visitBeamBeam(const BeamBeam &); - - /// Apply the algorithm to a beam stripping. - virtual void visitBeamStripping(const BeamStripping &); - - - /// Apply the algorithm to a collimator. - virtual void visitCCollimator(const CCollimator &); - - /// Apply the algorithm to an arbitrary component. - // This override calls the component to track the map. - virtual void visitComponent(const Component &); - - /// Apply the algorithm to a Corrector. - virtual void visitCorrector(const Corrector &); - - /// Apply the algorithm to a drift. - virtual void visitDegrader(const Degrader &); - - /// Apply the algorithm to a Diagnostic. - virtual void visitDiagnostic(const Diagnostic &); - - /// Apply the algorithm to a Drift. - virtual void visitDrift(const Drift &); - - /// Apply the algorithm to a flexible collimator - virtual void visitFlexibleCollimator(const FlexibleCollimator &); - - /// Apply the algorithm to a Lambertson. - virtual void visitLambertson(const Lambertson &); - - /// Apply the algorithm to a Marker. - virtual void visitMarker(const Marker &); - - /// Apply the algorithm to a Monitor. - virtual void visitMonitor(const Monitor &); - - /// Apply the algorithm to a Multipole. - virtual void visitMultipole(const Multipole &); - - /// Apply the algorithm to a patch. - virtual void visitPatch(const Patch &pat); - - /// Apply the algorithm to a probe. - virtual void visitProbe(const Probe &prob); - - /// Apply the algorithm to a RBend. - virtual void visitRBend0(const RBend &); - virtual void visitRBend(const RBend &); // exp(:-H:) version - /// Apply the algorithm to a RFCavity. - virtual void visitRFCavity(const RFCavity &); - - /// Apply the algorithm to a RFQuadrupole. - virtual void visitRFQuadrupole(const RFQuadrupole &); - - /// Apply the algorithm to a SBend. - virtual void visitSBend(const SBend &); - - /// Apply the algorithm to a Separator. - virtual void visitSeparator(const Separator &); - - /// Apply the algorithm to a Septum. - virtual void visitSeptum(const Septum &); - - /// Apply the algorithm to a Solenoid. - virtual void visitSolenoid(const Solenoid &); - - /// Apply the algorithm to a ParallelPlate. - virtual void visitParallelPlate(const ParallelPlate &); - -protected: - - /// Apply drift length. - // Propagate current map through a drift. - void applyDrift(double length); - - /// Transforms fringing fields. - void applyEntranceFringe(double edge, - const BMultipoleField &field, double scale); - void applyExitFringe(double edge, - const BMultipoleField &field, double scale); - - /// Apply linear map, defined by the linear expansions Fx and Fy. - void applyLinearMap(double length, double refLength, double h, - const FTps<double, 2> &Fx, const FTps<double, 2> &Fy); - - /// Apply body of SBend. - void applyMultipoleBody(double length, double refLength, - const BMultipoleField &field, double scale); - - /// Apply thin multipole kick (integrated over length) to all particles. - void applySBendBody(double length, double refLength, double h, - const BMultipoleField &field, double scale); - - /// Thin multipole kick. - // Apply a thin multipole kick (integrated over length) to current map. - void applyThinMultipole(const BMultipoleField &field, double factor); - - /// Apply transform. - // Propagate current map through a geometric transformation. - void applyTransform(const Euclid3D &, double refLength); - - /// Construct the vector potential for a SBend. - FTps<double, 2> - buildSBendVectorPotential(const BMultipoleField &, double h); - - - // The linear map being accumulated. - LinearMap <double, 6> itsMap; - -private: - - // Not implemented. - LinearMapper(); - LinearMapper(const LinearMapper &); - void operator=(const LinearMapper &); - - /// Helper function for finding first-order coefficients. - static void makeFocus - (double k, double L, double &c, double &s, double &d, double &f); - -}; - -#endif // MAD_LinearMapper_HH diff --git a/src/Classic/Algorithms/Mapper.cpp b/src/Classic/Algorithms/Mapper.cpp deleted file mode 100644 index 4b6de941d747eaa7a9a7bfa3754fa30b9e274bf5..0000000000000000000000000000000000000000 --- a/src/Classic/Algorithms/Mapper.cpp +++ /dev/null @@ -1,206 +0,0 @@ -// -// Class Mapper -// Build transfer map. The visitor class for building a VpsMap for a beamline -// using a thin-lens approximation for all elements. -// A visitor class implementing the default behaviour for all -// visitors capable of tracking a transfer map through a beam line. -// It implements some default behaviour for such visitors. -// [P] -// Phase space coordinates (in this order): -// [DL] -// [DT]x:[DD] -// horizontal displacement (metres). -// [DT]p_x/p_r:[DD] -// horizontal canonical momentum (no dimension). -// [DT]y:[DD] -// vertical displacement (metres). -// [DT]p_y/p_r:[DD] -// vertical canonical momentum (no dimension). -// [DT]delta_p/p_r:[DD] -// relative momentum error (no dimension). -// [DT]v*delta_t:[DD] -// time difference delta_t w.r.t. the reference frame which moves with -// uniform velocity -// [P] -// v_r = c*beta_r = p_r/m -// [P] -// along the design orbit, multiplied by the instantaneous velocity v of -// the particle (metres). -// [/DL] -// Where -// [DL] -// [DT]p_r:[DD] -// is the constant reference momentum defining the reference frame velocity. -// [DT]m:[DD] -// is the rest mass of the particles. -// [/DL] -// Other units used: -// [DL] -// [DT]reference momentum:[DD] -// electron-volts. -// [DT]accelerating voltage:[DD] -// volts. -// [DT]separator voltage:[DD] -// volts. -// [DT]frequencies:[DD] -// hertz. -// [DT]phase lags:[DD] -// multiples of (2*pi). -// [/DL] -// -// Copyright (c) 200x - 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 "Algorithms/Mapper.h" -#include "Fields/BMultipoleField.h" -#include "FixedAlgebra/FTpsMath.h" -#include "FixedAlgebra/LinearMap.h" -#include "FixedAlgebra/TransportMap.h" -#include "FixedAlgebra/FTps.h" - -typedef FTps<double, 6> Series; -typedef FVps<double, 6> Map; - - -Mapper::Mapper(const Beamline &beamline, const PartData &reference, - bool backBeam, bool backTrack): - AbstractMapper(beamline, reference, backBeam, backTrack), - itsMap() -{} - - -Mapper::~Mapper() -{} - - -void Mapper::getMap(LinearMap<double, 6> &map) const { - map = LinearMap<double, 6>(itsMap); -} - - -void Mapper::getMap(TransportMap<double, 6> &map) const { - map = TransportMap<double, 6>(itsMap); -} - - -void Mapper::getMap(Map &map) const { - map = itsMap; -} - - -void Mapper::setMap(const LinearMap<double, 6> &map) { - itsMap = Map(map); -} - - -void Mapper::setMap(const TransportMap<double, 6> &map) { - itsMap = Map(map); -} - - -void Mapper::setMap(const Map &map) { - itsMap = map; -} - - -void Mapper::visitComponent(const Component &comp) { - comp.trackMap(itsMap, itsReference, back_beam, back_track); -} - - -void Mapper::visitPatch(const Patch &patch) { - Euclid3D transform = patch.getPatch(); - if(back_path) transform = Inverse(transform); - applyTransform(transform); -} - - -void Mapper::applyDrift(double length) { - double kin = itsReference.getM() / itsReference.getP(); - double refTime = length / itsReference.getBeta(); - - Series px = itsMap[PX]; - Series py = itsMap[PY]; - Series pt = itsMap[PT] + 1.0; - Series pz = sqrt(pt * pt - px * px - py * py); - Series E = sqrt(pt * pt + kin * kin); - - itsMap[X] += length * px / pz; - itsMap[Y] += length * py / pz; - itsMap[T] += pt * (refTime / E - length / pz); -} - - -void Mapper::applyThinMultipole -(const BMultipoleField &field, double scale) { - int order = field.order(); - - if(order > 0) { - Series x = itsMap[X]; - Series y = itsMap[Y]; - Series kx = + field.normal(order); - Series ky = - field.skew(order); - - while(--order > 0) { - Series kxt = x * kx - y * ky; - Series kyt = x * ky + y * kx; - kx = kxt + field.normal(order); - ky = kyt - field.skew(order); - } - - itsMap[PX] -= kx * scale; - itsMap[PY] += ky * scale; - } -} - - -void Mapper::applyThinSBend -(const BMultipoleField &field, double scale, double h) { - Series As = buildSBendVectorPotential(field, h) * scale; - - // These substitutions work because As depends on x and y only, - // and not on px or py. - itsMap[PX] -= As.derivative(X).substitute(itsMap); - itsMap[PY] -= As.derivative(Y).substitute(itsMap); -} - - -void Mapper::applyTransform(const Euclid3D &euclid, double refLength) { - if(! euclid.isIdentity()) { - double kin = itsReference.getM() / itsReference.getP(); - double refTime = refLength / itsReference.getBeta(); - Series px = itsMap[PX]; - Series py = itsMap[PY]; - Series pt = itsMap[PT] + 1.0; - Series pz = sqrt(pt * pt - px * px - py * py); - - itsMap[PX] = euclid.M(0, 0) * px + euclid.M(1, 0) * py + euclid.M(2, 0) * pz; - itsMap[PY] = euclid.M(0, 1) * px + euclid.M(1, 1) * py + euclid.M(2, 1) * pz; - pz = euclid.M(0, 2) * px + euclid.M(1, 2) * py + euclid.M(2, 2) * pz; - - Series x = itsMap[X] - euclid.getX(); - Series y = itsMap[Y] - euclid.getY(); - Series x2 = - euclid.M(0, 0) * x + euclid.M(1, 0) * y - euclid.M(2, 0) * euclid.getZ(); - Series y2 = - euclid.M(0, 1) * x + euclid.M(1, 1) * y - euclid.M(2, 1) * euclid.getZ(); - Series s2 = - euclid.M(0, 2) * x + euclid.M(1, 2) * y - euclid.M(2, 2) * euclid.getZ(); - Series sByPz = s2 / pz; - - Series E = sqrt(pt * pt + kin * kin); - itsMap[X] = x2 - sByPz * itsMap[PX]; - itsMap[Y] = y2 - sByPz * itsMap[PY]; - itsMap[T] += pt * (refTime / E + sByPz); - } -} diff --git a/src/Classic/Algorithms/Mapper.h b/src/Classic/Algorithms/Mapper.h deleted file mode 100644 index ed0288674795217bd7359b694e8377e08ecb5f94..0000000000000000000000000000000000000000 --- a/src/Classic/Algorithms/Mapper.h +++ /dev/null @@ -1,147 +0,0 @@ -// -// Class Mapper -// Build transfer map. The visitor class for building a VpsMap for a beamline -// using a thin-lens approximation for all elements. -// A visitor class implementing the default behaviour for all -// visitors capable of tracking a transfer map through a beam line. -// It implements some default behaviour for such visitors. -// [P] -// Phase space coordinates (in this order): -// [DL] -// [DT]x:[DD] -// horizontal displacement (metres). -// [DT]p_x/p_r:[DD] -// horizontal canonical momentum (no dimension). -// [DT]y:[DD] -// vertical displacement (metres). -// [DT]p_y/p_r:[DD] -// vertical canonical momentum (no dimension). -// [DT]delta_p/p_r:[DD] -// relative momentum error (no dimension). -// [DT]v*delta_t:[DD] -// time difference delta_t w.r.t. the reference frame which moves with -// uniform velocity -// [P] -// v_r = c*beta_r = p_r/m -// [P] -// along the design orbit, multiplied by the instantaneous velocity v of -// the particle (metres). -// [/DL] -// Where -// [DL] -// [DT]p_r:[DD] -// is the constant reference momentum defining the reference frame velocity. -// [DT]m:[DD] -// is the rest mass of the particles. -// [/DL] -// Other units used: -// [DL] -// [DT]reference momentum:[DD] -// electron-volts. -// [DT]accelerating voltage:[DD] -// volts. -// [DT]separator voltage:[DD] -// volts. -// [DT]frequencies:[DD] -// hertz. -// [DT]phase lags:[DD] -// multiples of (2*pi). -// [/DL] -// -// Copyright (c) 200x - 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 CLASSIC_Mapper_HH -#define CLASSIC_Mapper_HH - -#include "Algorithms/AbstractMapper.h" -#include "AbsBeamline/Patch.h" -#include "FixedAlgebra/FTps.h" -#include "FixedAlgebra/FVps.h" -#include "Algorithms/PartData.h" - -class BMultipoleField; -class Euclid3D; -template <class T, int N> class LinearMap; -template <class T, int N> class TransportMap; - -class Mapper: public AbstractMapper { - -public: - - /// Constructor. - // The beam line to be tracked is [b]bl[/b]. - // The particle reference data are taken from [b]data[/b]. - // If [b]revBeam[/b] is true, the beam runs from s = C to s = 0. - // If [b]revTrack[/b] is true, we track against the beam. - Mapper(const Beamline &bl, const PartData &data, - bool revBeam, bool revTrack); - - virtual ~Mapper(); - - /// Return the linear part of the accumulated map. - virtual void getMap(LinearMap<double, 6> &) const; - - /// Return the second-order part of the accumulated map. - virtual void getMap(TransportMap<double, 6> &) const; - - /// Return the full map accumulated so far. - virtual void getMap(FVps<double, 6> &) const; - - /// Reset the linear part of the accumulated map for restart. - virtual void setMap(const LinearMap<double, 6> &); - - /// Reset the second-order part of the accumulated map for restart. - virtual void setMap(const TransportMap<double, 6> &); - - /// Reset the full map for restart. - virtual void setMap(const FVps<double, 6> &); - - - /// Apply the algorithm to an arbitrary component. - // This override calls the component to track the map. - virtual void visitComponent(const Component &); - - /// Apply the algorithm to a patch. - virtual void visitPatch(const Patch &pat); - -protected: - - /// Apply drift length. - // Propagate current map through a drift. - void applyDrift(double length); - - /// Thin multipole kick. - // Apply a thin multipole kick (integrated over length) to current map. - void applyThinMultipole(const BMultipoleField &field, double factor); - - /// Thin SBend kick. - // Special kick routine for thin SBend. - void applyThinSBend(const BMultipoleField &field, double scale, double h); - - /// Apply transform. - // Propagate current map through a geometric transformation. - void applyTransform(const Euclid3D &, double refLength = 0.0); - - /// The transfer map being built. - FVps<double, 6> itsMap; - -private: - - // Not implemented. - Mapper(); - Mapper(const Mapper &); - void operator=(const Mapper &); -}; - -#endif // CLASSIC_Mapper_HH diff --git a/src/Classic/Algorithms/Surveyor.cpp b/src/Classic/Algorithms/Surveyor.cpp deleted file mode 100644 index cca253dcc4cbbd32fd700e31a275e2a534c16329..0000000000000000000000000000000000000000 --- a/src/Classic/Algorithms/Surveyor.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Surveyor.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.3 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Surveyor -// The visitor class for printing the survey of a beamline. -// -// ------------------------------------------------------------------------ -// Class category: Algorithms -// ------------------------------------------------------------------------ -// -// $Date: 2000/05/03 08:16:05 $ -// $Author: mad $ -// -// ------------------------------------------------------------------------ - -#include "Algorithms/Surveyor.h" -#include "AbsBeamline/AttributeSet.h" -#include "AbsBeamline/Patch.h" - - -// Class Surveyor -// ------------------------------------------------------------------------ - -Surveyor::Surveyor(Beamline &beamline, bool revTrack): - DefaultVisitor(beamline, false, revTrack), - itsMap() -{} - - -Surveyor::Surveyor(Beamline &beamline, double x0, double y0, double z0, - double theta0, double phi0, double psi0, - bool revTrack): - DefaultVisitor(beamline, false, revTrack), - itsMap(x0, y0, z0, theta0, phi0, psi0) -{} - - -Surveyor::Surveyor(Beamline &beamline, const Euclid3D &init, bool revTrack): - DefaultVisitor(beamline, false, revTrack), itsMap(init) -{} - - -Surveyor::~Surveyor() -{} - - -void Surveyor::getMap(Euclid3D &map) const { - map = itsMap; -} - - -void Surveyor::setMap(const Euclid3D &map) { - itsMap = map; -} - - -void Surveyor::visitPatch(const Patch &patch) { - Euclid3D elementMap = patch.getPatch(); - if(back_path) elementMap = Inverse(elementMap); - itsMap.dotBy(elementMap); -} - - -void Surveyor::applyDefault(const ElementBase &element) { - Euclid3D elementMap = element.getGeometry().getTotalTransform(); - if(back_path) elementMap = Inverse(elementMap); - itsMap.dotBy(elementMap); -} diff --git a/src/Classic/Algorithms/Surveyor.h b/src/Classic/Algorithms/Surveyor.h deleted file mode 100644 index 273952aeb9b547cf0e16232ec8e56251d83643e6..0000000000000000000000000000000000000000 --- a/src/Classic/Algorithms/Surveyor.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef MAD_Surveyor_HH -#define MAD_Surveyor_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Surveyor.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Surveyor -// -// ------------------------------------------------------------------------ -// Class category: Algorithms -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "Algorithms/DefaultVisitor.h" -#include "BeamlineGeometry/Euclid3D.h" - - -// Class Surveyor -// ------------------------------------------------------------------------ -/// Survey algorithm. -// This visitor class computes the survey of a beam line. - -class Surveyor: public DefaultVisitor { - -public: - - /// Constructor. - // Assume zero initial conditions. - // The beam line to be tracked is [b]bl[/b]. - // If [b]revTrack[/b] is true, track from s = C to s = 0. - Surveyor(Beamline &bl, bool revTrack); - - /// Constructor. - // Use given initial conditions. - // The beam line to be tracked is [b]bl[/b]. - // If [b]revTrack[/b] is true, track from s = C to s = 0. - Surveyor(Beamline &bl, double x0, double y0, double z0, - double theta0, double phi0, double psi0, - bool revTrack = false); - - /// Constructor. - // Use given initial conditions in terms of an Euclid3D object. - // The beam line to be tracked is [b]bl[/b]. - // If [b]revTrack[/b] is true, track from s = C to s = 0. - Surveyor(Beamline &bl, const Euclid3D &init, bool revTrack); - - virtual ~Surveyor(); - - /// Return accumulated map. - void getMap(Euclid3D &) const; - - /// Reset accumulated map for restart. - void setMap(const Euclid3D &); - - - /// Apply the algorithm to a patch. - virtual void visitPatch(const Patch &pat); - -private: - - // Not implemented. - Surveyor(); - Surveyor(const Surveyor &); - void operator=(const Surveyor &); - - /// Default action. - // Apply the default to all element (advance the position and direction). - // All visitXXX() methods except visitPatch() call applyDefault() which - // is overridden here to propagate the survey through the element. - virtual void applyDefault(const ElementBase &element); - - /// The accumulated survey map. - Euclid3D itsMap; -}; - -#endif // __Surveyor_HH diff --git a/src/Classic/Algorithms/ThinMapper.cpp b/src/Classic/Algorithms/ThinMapper.cpp deleted file mode 100644 index a32b4d0f3d01ef44b280630c11a98cf58fd9f399..0000000000000000000000000000000000000000 --- a/src/Classic/Algorithms/ThinMapper.cpp +++ /dev/null @@ -1,339 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: ThinMapper.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ThinMapper -// The visitor class for building a map for a beamline -// using a thin-lens approximation for all elements. -// -// ------------------------------------------------------------------------ -// Class category: Algorithms -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "Algorithms/ThinMapper.h" -#include "AbsBeamline/CCollimator.h" -#include "AbsBeamline/Corrector.h" -#include "AbsBeamline/Diagnostic.h" -#include "AbsBeamline/Drift.h" -#include "AbsBeamline/Degrader.h" -#include "AbsBeamline/ElementBase.h" -#include "AbsBeamline/FlexibleCollimator.h" -#include "AbsBeamline/Lambertson.h" -#include "AbsBeamline/Marker.h" -#include "AbsBeamline/Monitor.h" -#include "AbsBeamline/Multipole.h" -#include "AbsBeamline/Probe.h" -#include "AbsBeamline/RBend.h" -#include "AbsBeamline/RFCavity.h" -#include "AbsBeamline/RFQuadrupole.h" -#include "AbsBeamline/SBend.h" -#include "AbsBeamline/Separator.h" -#include "AbsBeamline/Septum.h" -#include "AbsBeamline/Solenoid.h" -#include "AbsBeamline/ParallelPlate.h" - -#include "BeamlineGeometry/Euclid3D.h" -#include "BeamlineGeometry/Geometry.h" -#include "Beamlines/Beamline.h" -#include "Fields/BMultipoleField.h" -#include "FixedAlgebra/FTps.h" -#include "FixedAlgebra/FTpsMath.h" -#include "Physics/Physics.h" - -typedef FTps<double, 6> Series; - - -// Class ThinMapper -// ------------------------------------------------------------------------ - -ThinMapper::ThinMapper(const Beamline &beamline, const PartData &ref, - bool backBeam, bool backTrack): - Mapper(beamline, ref, backBeam, backTrack) -{} - - -ThinMapper::~ThinMapper() -{} - - -void ThinMapper::visitBeamBeam(const BeamBeam &/*bb*/) { - // *** MISSING *** Map algorithm on BeamBeam -} - -void ThinMapper::visitBeamStripping(const BeamStripping &/*bstp*/) { - // *** MISSING *** Map algorithm on BeamStripping -} - -void ThinMapper::visitDegrader(const Degrader °) { - applyDrift(flip_s * deg.getElementLength()); -} - -void ThinMapper::visitCCollimator(const CCollimator &coll) { - applyDrift(flip_s * coll.getElementLength()); -} - - -void ThinMapper::visitCorrector(const Corrector &corr) { - // Drift through first half of length. - double length = flip_s * corr.getElementLength(); - if(length) applyDrift(length / 2.0); - - // Apply kick. - double scale = (flip_s * flip_B * itsReference.getQ() * Physics::c) / - itsReference.getP(); - const BDipoleField &field = corr.getField(); - itsMap[PX] -= field.getBy() * scale; - itsMap[PY] += field.getBx() * scale; - - // Drift through second half of length. - if(length) applyDrift(length / 2.0); -} - - -void ThinMapper::visitDiagnostic(const Diagnostic &diag) { - // The diagnostic has no effect on the map. - applyDrift(flip_s * diag.getElementLength()); -} - - -void ThinMapper::visitDrift(const Drift &drift) { - applyDrift(flip_s * drift.getElementLength()); -} - -void ThinMapper::visitFlexibleCollimator(const FlexibleCollimator &coll) { - applyDrift(flip_s * coll.getElementLength()); -} - -void ThinMapper::visitLambertson(const Lambertson &lamb) { - // Assume that the reference orbit is in the magnet's window. - applyDrift(flip_s * lamb.getElementLength()); -} - - -void ThinMapper::visitMarker(const Marker &) { - // Do nothing. -} - - -void ThinMapper::visitMonitor(const Monitor &corr) { - applyDrift(flip_s * corr.getElementLength()); -} - - -void ThinMapper::visitMultipole(const Multipole &mult) { - double length = flip_s * mult.getElementLength(); - const BMultipoleField &field = mult.getField(); - double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP(); - - if(length) { - // Drift through first half of the length. - applyDrift(length / 2.0); - - // Apply thin multipole kick, field is per unit length. - scale *= length; - applyThinMultipole(field, scale); - - // Drift through second half of the length. - applyDrift(length / 2.0); - } else { - // Thin multipole, field is integral(K*dl). - scale *= flip_s; - applyThinMultipole(field, scale); - } -} - -void ThinMapper::visitProbe(const Probe &) { - // Do nothing. -} - - -void ThinMapper::visitRBend(const RBend &bend) { - // Geometry. - const RBendGeometry &geometry = bend.getGeometry(); - double length = flip_s * geometry.getElementLength(); - double angle = flip_s * geometry.getBendAngle(); - - // Magnetic field. - const BMultipoleField &field = bend.getField(); - - // Drift to mid-plane. - applyDrift(length / 2.0); - - // Apply multipole kick and linear approximation to geometric bend. - double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP(); - if(length) scale *= length; - int order = field.order(); - - if(order > 0) { - Series x = itsMap[X]; - Series y = itsMap[Y]; - Series kx = + field.normal(order); - Series ky = - field.skew(order); - - while(--order > 0) { - Series kxt = x * kx - y * ky; - Series kyt = x * ky + y * kx; - kx = kxt + field.normal(order); - ky = kyt - field.skew(order); - } - - itsMap[PX] -= kx * scale - angle * (1.0 + itsMap[PT]); - itsMap[PY] += ky * scale; - itsMap[T] -= angle * x; - } - - // Drift to out-plane. - applyDrift(length / 2.0); -} - - -void ThinMapper::visitRFCavity(const RFCavity &as) { - // Drift through half length. - double length = flip_s * as.getElementLength(); - if(length) applyDrift(length / 2.0); - - // Apply accelerating voltage. - double kin = itsReference.getM() / itsReference.getP(); - double freq = as.getFrequency(); - double peak = flip_s * as.getAmplitude() / itsReference.getP(); - - Series pt = itsMap[PT] + 1.0; - Series speed = (Physics::c * pt) / sqrt(pt * pt + kin * kin); - Series phase = as.getPhase() + freq * itsMap[T] / speed; - itsMap[PT] += peak * sin(phase) / pt; - - // Drift through half length. - if(length) applyDrift(length / 2.0); -} - - -void ThinMapper::visitRFQuadrupole(const RFQuadrupole &rfq) { - // *** MISSING *** Map algorithm on RF Quadrupole. - applyDrift(flip_s * rfq.getElementLength()); -} - - -void ThinMapper::visitSBend(const SBend &bend) { - const PlanarArcGeometry &geometry = bend.getGeometry(); - double length = flip_s * geometry.getElementLength(); - double angle = flip_s * geometry.getBendAngle(); - - // Magnetic field. - const BMultipoleField &field = bend.getField(); - - // Drift to mid-plane. - applyDrift(length / 2.0); - - // Apply multipole kick and linear approximation to geometric bend. - double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP(); - if(length) scale *= length; - int order = field.order(); - - if(order > 0) { - Series x = itsMap[X]; - Series y = itsMap[Y]; - Series kx = + field.normal(order); - Series ky = - field.skew(order); - - while(--order > 0) { - Series kxt = x * kx - y * ky; - Series kyt = x * ky + y * kx; - kx = kxt + field.normal(order); - ky = kyt - field.skew(order); - } - - itsMap[PX] -= kx * scale - angle * (1.0 + itsMap[PT]); - itsMap[PY] += ky * scale; - itsMap[T] -= angle * x; - } - - // Drift to out-plane. - applyDrift(length / 2.0); -} - - -void ThinMapper::visitSeparator(const Separator &sep) { - // Drift through first half of length. - double length = flip_s * sep.getElementLength(); - - if(length) { - applyDrift(length / 2.0); - - double scale = (length * itsReference.getQ()) / itsReference.getP(); - double Ex = scale * sep.getEx(); - double Ey = scale * sep.getEy(); - Series pt = 1.0 + itsMap[PT]; - itsMap[PX] += Ex / pt; - itsMap[PY] += Ey / pt; - - applyDrift(length / 2.0); - } -} - - -void ThinMapper::visitSeptum(const Septum &sept) { - // Assume that the reference orbit is in the magnet's window. - applyDrift(flip_s * sept.getElementLength()); -} - - -void ThinMapper::visitSolenoid(const Solenoid &solenoid) { - double length = flip_s * solenoid.getElementLength(); - - if(length) { - double ks = (flip_B * itsReference.getQ() * solenoid.getBz() * Physics::c) / - (2.0 * itsReference.getP()); - - if(ks) { - Series pt = itsMap[PT] + 1.0; - Series px = itsMap[PX] + ks * itsMap[Y]; - Series py = itsMap[PY] - ks * itsMap[X]; - Series pz = sqrt(pt * pt - px * px - py * py); - Series k = ks / pz; - Series C = cos(k * length); - Series S = sin(k * length); - - Series xt = C * itsMap[X] + S * itsMap[Y]; - Series yt = C * itsMap[Y] - S * itsMap[X]; - Series pxt = C * itsMap[PX] + S * itsMap[PY]; - Series pyt = C * itsMap[PY] - S * itsMap[PX]; - - itsMap[X] = C * xt + (S / k) * pxt; - itsMap[Y] = C * yt + (S / k) * pyt; - itsMap[PX] = C * pxt - (S * k) * xt; - itsMap[PY] = C * pyt - (S * k) * yt; - - double kin = itsReference.getM() / itsReference.getP(); - double ref = kin * kin; - itsMap[T] += length * (pt * ref - (px * px + py * py + 3.0 * pt * pt * ref) / 2.0); - } else { - applyDrift(length); - } - } -} - - -void ThinMapper::visitParallelPlate(const ParallelPlate &) { - // Do nothing. -} - -void ThinMapper::applyDrift(double length) { - double kin = itsReference.getM() / itsReference.getP(); - double ref = kin * kin; - Series px = itsMap[PX]; - Series py = itsMap[PY]; - Series pt = itsMap[PT]; - Series lByPz = length / (1.0 + pt); - itsMap[X] += px * lByPz; - itsMap[Y] += py * lByPz; - itsMap[T] += length * (pt * ref - (px * px + py * py + 3.0 * pt * pt * ref) / 2.0); -} diff --git a/src/Classic/Algorithms/ThinMapper.h b/src/Classic/Algorithms/ThinMapper.h deleted file mode 100644 index c1930dcd6d27054423d4ffeebb0207c50f777889..0000000000000000000000000000000000000000 --- a/src/Classic/Algorithms/ThinMapper.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef CLASSIC_ThinMapper_HH -#define CLASSIC_ThinMapper_HH 1 - -// ------------------------------------------------------------------------ -// $RCSfile: ThinMapper.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ThinMapper -// -// ------------------------------------------------------------------------ -// Class category: Algorithms -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "Algorithms/Mapper.h" - -class BMultipoleField; - - -// Class ThinMapper -// ------------------------------------------------------------------------ -/// Construct thin lens map. -// The visitor class for building a FVps<double,6> for a beamline -// using a thin-lens approximation for all elements. -// [P] -// Approximations used: -// [UL] -// [LI]All active elements are represented as thin lenses, sandwiched -// between two drifts, each half of the element length. -// [LI]Drifts are handled with a second-order approximation. -// [LI]Geometric transformations ignore rotations about transverse axes -// and translations along the design orbit and truncate after second order. -// [/UL] - -class ThinMapper: public Mapper { - -public: - - /// Constructor. - // The beam line to be tracked is [b]bl[/b]. - // The particle reference data are taken from [b]data[/b]. - // If [b]revBeam[/b] is true, the beam runs from s = C to s = 0. - // If [b]revTracl[/b] is true, we track against the beam. - ThinMapper(const Beamline &bl, const PartData &data, - bool revBeam, bool revTrack); - - virtual ~ThinMapper(); - - - /// Apply the algorithm to a beam-beam. - virtual void visitBeamBeam(const BeamBeam &); - - /// Apply the algorithm to a beam stripping. - virtual void visitBeamStripping(const BeamStripping &); - - /// Apply the algorithm to a collimator. - virtual void visitCCollimator(const CCollimator &); - - /// Apply the algorithm to a corrector. - virtual void visitCorrector(const Corrector &); - - /// Apply the algorithm to a drift. - virtual void visitDegrader(const Degrader &); - - /// Apply the algorithm to a diagnostic. - virtual void visitDiagnostic(const Diagnostic &); - - /// Apply the algorithm to a drift. - virtual void visitDrift(const Drift &); - - /// Apply the algorithm to a flexible collimator - virtual void visitFlexibleCollimator(const FlexibleCollimator &); - - /// Apply the algorithm to a Lambertson. - virtual void visitLambertson(const Lambertson &); - - /// Apply the algorithm to a marker. - virtual void visitMarker(const Marker &); - - /// Apply the algorithm to a monitor. - virtual void visitMonitor(const Monitor &); - - /// Apply the algorithm to a multipole. - virtual void visitMultipole(const Multipole &); - - /// Apply the algorithm to a probe. - virtual void visitProbe(const Probe &); - - /// Apply the algorithm to a rectangular bend. - virtual void visitRBend(const RBend &); - - /// Apply the algorithm to a RF cavity. - virtual void visitRFCavity(const RFCavity &); - - /// Apply the algorithm to a RF quadrupole. - virtual void visitRFQuadrupole(const RFQuadrupole &); - - /// Apply the algorithm to a sector bend. - virtual void visitSBend(const SBend &); - - /// Apply the algorithm to a separator. - virtual void visitSeparator(const Separator &); - - /// Apply the algorithm to a septum. - virtual void visitSeptum(const Septum &); - - /// Apply the algorithm to a solenoid. - virtual void visitSolenoid(const Solenoid &); - - /// Apply the algorithm to a ParallelPlate. - virtual void visitParallelPlate(const ParallelPlate &); - -protected: - - // Apply a drift length. - // Approximate method to gain speed. - void applyDrift(double length); - -private: - - // Not implemented. - ThinMapper(); - ThinMapper(const ThinMapper &); - void operator=(const ThinMapper &); -}; - -#endif // CLASSIC_ThinMapper_HH \ No newline at end of file diff --git a/src/Classic/Algorithms/ThinTracker.cpp b/src/Classic/Algorithms/ThinTracker.cpp deleted file mode 100644 index 0aad96940502e6d60e023dafbfe420761f37b6b4..0000000000000000000000000000000000000000 --- a/src/Classic/Algorithms/ThinTracker.cpp +++ /dev/null @@ -1,465 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: ThinTracker.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ThinTracker -// The visitor class for tracking a bunch of particles through a beamline -// using a thin-lens approximation for all elements. -// -// ------------------------------------------------------------------------ -// Class category: Algorithms -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "Algorithms/ThinTracker.h" -#include "AbsBeamline/BeamBeam.h" -#include "AbsBeamline/BeamStripping.h" -#include "AbsBeamline/CCollimator.h" -#include "AbsBeamline/Corrector.h" -#include "AbsBeamline/Diagnostic.h" -#include "AbsBeamline/Drift.h" -#include "AbsBeamline/Degrader.h" -#include "AbsBeamline/ElementBase.h" -#include "AbsBeamline/FlexibleCollimator.h" -#include "AbsBeamline/Lambertson.h" -#include "AbsBeamline/Marker.h" -#include "AbsBeamline/Monitor.h" -#include "AbsBeamline/Multipole.h" -#include "AbsBeamline/Probe.h" -#include "AbsBeamline/RBend.h" -#include "AbsBeamline/RFCavity.h" -#include "AbsBeamline/RFQuadrupole.h" -#include "AbsBeamline/SBend.h" -#include "AbsBeamline/Separator.h" -#include "AbsBeamline/Septum.h" -#include "AbsBeamline/Solenoid.h" -#include "AbsBeamline/ParallelPlate.h" - -#include "Algorithms/PartBunchBase.h" -#include "Algorithms/PartData.h" -#include "Algorithms/OpalParticle.h" -#include "BeamlineGeometry/Euclid3D.h" -#include "BeamlineGeometry/Geometry.h" -#include "Beamlines/Beamline.h" -#include "Fields/BMultipoleField.h" -#include "Physics/Physics.h" -#include "Utilities/ComplexErrorFun.h" -#include <cmath> -#include <complex> - - -// Class ThinTracker -// ------------------------------------------------------------------------ - -ThinTracker::ThinTracker(const Beamline &beamline, const PartData &reference, - bool revBeam, bool revTrack): - Tracker(beamline, reference, revBeam, revTrack) -{} - - -ThinTracker::ThinTracker(const Beamline &beamline, - PartBunchBase<double, 3> *bunch, - const PartData &reference, - bool revBeam, bool revTrack): - Tracker(beamline, bunch, reference, revBeam, revTrack) -{} - - -ThinTracker::~ThinTracker() -{} - - -void ThinTracker::visitBeamBeam(const BeamBeam &bb) { - // If x > explim, exp(-x) is outside machine limits. - static const double explim = 150.0; - - // Parameters of the opposite bunch. - const double NN = itsReference.getQ() * bb.getBunchCharge(); - const Vector3D &displacement = bb.getBunchDisplacement(); - const Matrix3D &sigma = bb.getBunchMoment(); - - if(NN != 0.0) { - // - // N1 N2 mu_0 c^2 q_e^2 N1 N2 - // fk = 2 r_e * ------- = ---------------- * ------- = - // gamma 2 pi m_0 gamma - // - // mu_0 c^2 q_e N1 N2 q_e N1 N2 - // = -------------------- = -------------------- . - // 2 pi p_r 2 pi epsilon_0 p_r - // - // where m_0 is the particle rest mass in Joule. - // - // and p_r = (gamma m_0) / q_e is the momentum in eV. - // - const double fk = Physics::q_e * NN / - (Physics::epsilon_0 * Physics::two_pi * itsReference.getP()); - const double dx = displacement(0); - const double dy = displacement(1); - const double sx2 = std::abs(sigma(0, 0)); - const double sy2 = std::abs(sigma(1, 1)); - const double sx = std::sqrt(sx2); - const double sy = std::sqrt(sy2); - - if(sx2 == sy2) { - // Limit for sigma(x)^2 = sigma(y)^2. - - for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); i++) { - OpalParticle part = itsBunch_m->get_part(i); - - double xs = part.x() - dx; - double ys = part.y() - dy; - double rho2 = xs * xs + ys * ys; - double tk = rho2 / (2.0 * sx2); - double phi = 0.0; - - if(tk > explim) { - phi = fk / rho2; - } else if(tk != 0.0) { - phi = fk * (1.0 - std::exp(- tk)) / rho2; - } - - part.px() += xs * phi; - part.py() += ys * phi; - - itsBunch_m->set_part(part, i); - } - } else { - // Case sigma(x)^2 != sigma(y)^2. - const double r = std::sqrt(2.0 * std::abs(sx2 - sy2)); - double rk = flip_s * flip_B * fk * std::sqrt(Physics::pi) / r; - - for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); i++) { - OpalParticle part = itsBunch_m->get_part(i); - - double xs = part.x() - dx; - double ys = part.y() - dy; - double xr = std::abs(xs) / r; - double yr = std::abs(ys) / r; - std::complex<double> W = Werrf(std::complex<double>(xr, yr)); - - double tk = (xs * xs / sx2 + ys * ys / sy2) / 2.0; - if(tk <= explim) { - W -= std::exp(- tk) * Werrf(std::complex<double>(xr * sy / sx, yr * sx / sy)); - } - - part.px() += rk * ((xs > 0.0) ? std::imag(W) : - std::imag(W)); - part.py() += rk * ((ys > 0.0) ? std::real(W) : - std::real(W)); - - itsBunch_m->set_part(part, i); - } - } - } -} - - -void ThinTracker::visitBeamStripping(const BeamStripping &/*bstp*/) { -// applyDrift(flip_s * bstp.getElementLength()); -} - -void ThinTracker::visitCCollimator(const CCollimator &coll) { - applyDrift(flip_s * coll.getElementLength()); -} - -void ThinTracker::visitDegrader(const Degrader °) { - applyDrift(flip_s * deg.getElementLength()); -} - -void ThinTracker::visitParallelPlate(const ParallelPlate &/*pplate*/) { - //do nothing -} - -void ThinTracker::visitCorrector(const Corrector &corr) { - // Drift through first half of length. - double length = flip_s * corr.getElementLength(); - if(length) applyDrift(length / 2.0); - - // Apply kick. - double scale = (flip_s * flip_B * corr.getElementLength() * - itsReference.getQ() * Physics::c) / itsReference.getP(); - const BDipoleField &field = corr.getField(); - - for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); i++) { - OpalParticle part = itsBunch_m->get_part(i); - part.px() -= field.getBy() * scale; - part.py() += field.getBx() * scale; - itsBunch_m->set_part(part, i); - } - - // Drift through second half of length. - if(length) applyDrift(length / 2.0); -} - - -void ThinTracker::visitDiagnostic(const Diagnostic &diag) { - // The diagnostic has no effect on particle tracking. - applyDrift(flip_s * diag.getElementLength()); -} - - -void ThinTracker::visitDrift(const Drift &drift) { - applyDrift(flip_s * drift.getElementLength()); -} - -void ThinTracker::visitFlexibleCollimator(const FlexibleCollimator &coll) { - applyDrift(flip_s * coll.getElementLength()); -} - -void ThinTracker::visitLambertson(const Lambertson &lamb) { - // Assume the particle go through the magnet's window. - applyDrift(flip_s * lamb.getElementLength()); -} - - -void ThinTracker::visitMarker(const Marker &) { - // Do nothing. -} - - -void ThinTracker::visitMonitor(const Monitor &corr) { - applyDrift(flip_s * corr.getElementLength()); -} - - -void ThinTracker::visitMultipole(const Multipole &mult) { - double length = flip_s * mult.getElementLength(); - const BMultipoleField &field = mult.getField(); - double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP(); - - if(length) { - // Drift through first half of the length. - applyDrift(length / 2.0); - - // Apply multipole kick, field is per unit length. - scale *= length; - applyThinMultipole(field, scale); - - // Drift through second half of the length, field is per unit length. - applyDrift(length / 2.0); - } else { - // Thin multipole, field is integral(K*dl). - scale *= flip_s; - applyThinMultipole(field, scale); - } -} - - -void ThinTracker::visitProbe(const Probe &) { - // Do nothing. -} - - -void ThinTracker::visitRBend(const RBend &bend) { - // Geometry. - const RBendGeometry &geometry = bend.getGeometry(); - double length = flip_s * geometry.getElementLength(); - double angle = flip_s * geometry.getBendAngle(); - - // Magnetic field. - const BMultipoleField &field = bend.getField(); - - // Drift to mid-plane. - applyDrift(length / 2.0); - - // Apply multipole kick and linear approximation to geometric bend. - double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP(); - if(length) scale *= length; - - for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); i++) { - OpalParticle part = itsBunch_m->get_part(i); - int order = field.order(); - - if(order > 0) { - double x = part.x(); - double y = part.y(); - double kx = + field.normal(order); - double ky = - field.skew(order); - - while(--order > 0) { - double kxt = x * kx - y * ky; - double kyt = x * ky + y * kx; - kx = kxt + field.normal(order); - ky = kyt - field.skew(order); - } - - part.px() -= kx * scale - angle * (1.0 + part.pt()); - part.py() += ky * scale; - part.t() -= angle * x; - } - itsBunch_m->set_part(part, i); - } - - // Drift to out-plane. - applyDrift(length / 2.0); -} - - -void ThinTracker::visitRFCavity(const RFCavity &as) { - // Drift through half length. - double length = flip_s * as.getElementLength(); - if(length) applyDrift(length / 2.0); - - // Apply accelerating voltage. - double freq = as.getFrequency(); - double peak = flip_s * as.getAmplitude() / itsReference.getP(); - double kin = itsReference.getM() / itsReference.getP(); - - for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); i++) { - OpalParticle part = itsBunch_m->get_part(i); - double pt = (part.pt() + 1.0); - double speed = (Physics::c * pt) / std::sqrt(pt * pt + kin * kin); - double phase = as.getPhase() + (freq * part.t()) / speed; - part.pt() += peak * std::sin(phase) / pt; - itsBunch_m->set_part(part, i); - } - - if(length) applyDrift(length / 2.0); -} - - -void ThinTracker::visitRFQuadrupole(const RFQuadrupole &rfq) { - // *** MISSING *** Tracking for RF Quadrupole. - applyDrift(flip_s * rfq.getElementLength()); -} - - -void ThinTracker::visitSBend(const SBend &bend) { - const PlanarArcGeometry &geometry = bend.getGeometry(); - double length = flip_s * geometry.getElementLength(); - double angle = flip_s * geometry.getBendAngle(); - - // Magnetic field. - const BMultipoleField &field = bend.getField(); - - // Drift to mid-plane. - applyDrift(length / 2.0); - - // Apply multipole kick and linear approximation to geometric bend. - double scale = (flip_B * itsReference.getQ() * Physics::c) / itsReference.getP(); - if(length) scale *= length; - - for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); i++) { - OpalParticle part = itsBunch_m->get_part(i); - int order = field.order(); - - if(order > 0) { - double x = part.x(); - double y = part.y(); - double kx = + field.normal(order); - double ky = - field.skew(order); - - while(--order > 0) { - double kxt = x * kx - y * ky; - double kyt = x * ky + y * kx; - kx = kxt + field.normal(order); - ky = kyt - field.skew(order); - } - - part.px() -= kx * scale - angle * (1.0 + part.pt()); - part.py() += ky * scale; - part.t() -= angle * x; - } - itsBunch_m->set_part(part, i); - } - - // Drift to out-plane. - applyDrift(length / 2.0); -} - - -void ThinTracker::visitSeparator(const Separator &sep) { - // Drift through first half of length. - double length = flip_s * sep.getElementLength(); - if(length) { - applyDrift(length / 2.0); - - double scale = (length * itsReference.getQ()) / itsReference.getP(); - double Ex = scale * sep.getEx(); - double Ey = scale * sep.getEy(); - - for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); i++) { - OpalParticle part = itsBunch_m->get_part(i); - double pt = 1.0 + part.pt(); - part.px() += Ex / pt; - part.py() += Ey / pt; - itsBunch_m->set_part(part, i); - } - - applyDrift(length / 2.0); - } -} - - -void ThinTracker::visitSeptum(const Septum &sept) { - // Assume the particles go through the magnet's window. - applyDrift(flip_s * sept.getElementLength()); -} - - -void ThinTracker::visitSolenoid(const Solenoid &solenoid) { - double length = flip_s * solenoid.getElementLength(); - - if(length) { - double ks = (flip_B * itsReference.getQ() * solenoid.getBz() * Physics::c) / - (2.0 * itsReference.getP()); - - if(ks) { - double kin = itsReference.getM() / itsReference.getP(); - double ref = kin * kin; - - for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); i++) { - OpalParticle part = itsBunch_m->get_part(i); - - double pt = part.pt() + 1.0; - double px = part.px() + ks * part.y(); - double py = part.py() - ks * part.x(); - double pz = std::sqrt(pt * pt - px * px - py * py); - - double k = ks / pz; - double C = std::cos(k * length); - double S = std::sin(k * length); - - double xt = C * part.x() + S * part.y(); - double yt = C * part.y() - S * part.x(); - double pxt = C * part.px() + S * part.py(); - double pyt = C * part.py() - S * part.px(); - - part.x() = C * xt + (S / k) * pxt; - part.y() = C * yt + (S / k) * pyt; - part.px() = C * pxt - (S * k) * xt; - part.py() = C * pyt - (S * k) * yt; - part.t() += length * (pt * ref - (px * px + py * py + 3.0 * pt * pt * ref) / 2.0); - itsBunch_m->set_part(part, i); - } - } else { - applyDrift(length); - } - } -} - - -void ThinTracker::applyDrift(double length) { - double kin = itsReference.getM() / itsReference.getP(); - double ref = kin * kin; - - for(unsigned int i = 0; i < itsBunch_m->getLocalNum(); i++) { - OpalParticle part = itsBunch_m->get_part(i); - - double px = part.px(); - double py = part.py(); - double pt = part.pt(); - double lByPz = length / (1.0 + pt); - part.x() += px * lByPz; - part.y() += py * lByPz; - part.t() += length * (pt * ref - (px * px + py * py + 3.0 * pt * pt * ref) / 2.0); - itsBunch_m->set_part(part, i); - } -} diff --git a/src/Classic/Algorithms/ThinTracker.h b/src/Classic/Algorithms/ThinTracker.h deleted file mode 100644 index 26004f3fc152e4bdb7a66b4b740c3888e8c6401a..0000000000000000000000000000000000000000 --- a/src/Classic/Algorithms/ThinTracker.h +++ /dev/null @@ -1,146 +0,0 @@ -#ifndef CLASSIC_ThinTracker_HH -#define CLASSIC_ThinTracker_HH - -// ------------------------------------------------------------------------ -// $RCSfile: ThinTracker.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ThinTracker -// -// ------------------------------------------------------------------------ -// Class category: Algorithms -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "Algorithms/Tracker.h" - -class BMultipoleField; - -template <class T, unsigned Dim> -class PartBunchBase; -class PlanarArcGeometry; - - -// Class ThinTracker -// ------------------------------------------------------------------------ -/// Track with thin lens algorithm. -// The visitor class for tracking a bunch of particles through a beamline -// using a thin-lens approximation for all elements. -// [P] -// Approximations used: -// [UL] -// [LI]All active elements are represented as thin lenses, sandwiched -// between two drifts, each half of the element length. -// [LI]Drifts are handled with a second-order approximation. -// [LI]Geometric transformations ignore rotations about transverse axes -// and translations along the design orbit and truncate after second order. -// [/UL] - -class ThinTracker: public Tracker { - -public: - - /// Constructor. - // The beam line to be tracked is [b]bl[/b]. - // The particle reference data are taken from [b]data[/b]. - // The particle bunch tracked is initially empty. - // If [b]revBeam[/b] is true, the beam runs from s = C to s = 0. - // If [b]revTrack[/b] is true, we track against the beam. - ThinTracker(const Beamline &bl, const PartData &data, - bool revBeam, bool revTrack); - - /// Constructor. - // The beam line to be tracked is [b]bl[/b]. - // The particle reference data are taken from [b]data[/b]. - // The particle bunch tracked is taken from [b]bunch[/b]. - // If [b]revBeam[/b] is true, the beam runs from s = C to s = 0. - // If [b]revTrack[/b] is true, we track against the beam. - ThinTracker(const Beamline &bl, PartBunchBase<double, 3> *bunch, - const PartData &data, bool revBeam, bool revTrack); - - virtual ~ThinTracker(); - - /// Apply algorithm to BeamBeam. - virtual void visitBeamBeam(const BeamBeam &); - - /// Apply the algorithm to a beam stripping. - virtual void visitBeamStripping(const BeamStripping &); - - /// Apply algorithm to Collimator. - virtual void visitCCollimator(const CCollimator &); - - /// Apply algorithm to Corrector. - virtual void visitCorrector(const Corrector &); - - /// Apply the algorithm to a drift. - virtual void visitDegrader(const Degrader &); - - /// Apply algorithm to Diagnostic. - virtual void visitDiagnostic(const Diagnostic &); - - /// Apply algorithm to Drift. - virtual void visitDrift(const Drift &); - - /// Apply the algorithm to a flexible collimator - virtual void visitFlexibleCollimator(const FlexibleCollimator &); - - /// Apply algorithm to Lambertson. - virtual void visitLambertson(const Lambertson &); - - /// Apply algorithm to Marker. - virtual void visitMarker(const Marker &); - - /// Apply algorithm to Monitor. - virtual void visitMonitor(const Monitor &); - - /// Apply algorithm to Multipole. - virtual void visitMultipole(const Multipole &); - - /// Apply algorithm to Probe. - virtual void visitProbe(const Probe &); - - /// Apply algorithm to RBend. - virtual void visitRBend(const RBend &); - - /// Apply algorithm to RFCavity. - virtual void visitRFCavity(const RFCavity &); - - /// Apply algorithm to RFQuadrupole. - virtual void visitRFQuadrupole(const RFQuadrupole &); - - /// Apply algorithm to SBend. - virtual void visitSBend(const SBend &); - - /// Apply algorithm to Separator. - virtual void visitSeparator(const Separator &); - - /// Apply algorithm to Septum. - virtual void visitSeptum(const Septum &); - - /// Apply algorithm to Solenoid. - virtual void visitSolenoid(const Solenoid &); - - /// Apply algorithm to Solenoid. - virtual void visitParallelPlate(const ParallelPlate &); - -private: - - // Not implemented. - ThinTracker(); - ThinTracker(const ThinTracker &); - void operator=(const ThinTracker &); - - // Apply a drift length. - // Approximate method to gain speed. - void applyDrift(double length); -}; - -#endif // CLASSIC_ThinTracker_HH \ No newline at end of file diff --git a/src/Classic/Algorithms/Tracker.cpp b/src/Classic/Algorithms/Tracker.cpp index c151117a62cfb23a5804b2b7221a83bb88f95656..2e90c97a521fdd317fe0ce80e320f671864a323d 100644 --- a/src/Classic/Algorithms/Tracker.cpp +++ b/src/Classic/Algorithms/Tracker.cpp @@ -60,7 +60,6 @@ // along with OPAL. If not, see <https://www.gnu.org/licenses/>. // #include "Algorithms/Tracker.h" -#include "AbsBeamline/Patch.h" #include "Fields/BMultipoleField.h" //FIXME Remove headers and dynamic_cast in readOneBunchFromFile @@ -122,13 +121,6 @@ void Tracker::visitComponent(const Component &comp) { } -void Tracker::visitPatch(const Patch &patch) { - Euclid3D transform = patch.getPatch(); - if(back_path) transform = Inverse(transform); - applyTransform(transform); -} - - void Tracker::applyDrift(double length) { double kin = itsReference.getM() / itsReference.getP(); double refTime = length / itsReference.getBeta(); diff --git a/src/Classic/Algorithms/Tracker.h b/src/Classic/Algorithms/Tracker.h index a00f7a40ea95cbb128412a0fdd9fc135fb323057..c2d9408f25a425802884c297b2c73fe394057323 100644 --- a/src/Classic/Algorithms/Tracker.h +++ b/src/Classic/Algorithms/Tracker.h @@ -110,9 +110,6 @@ public: // This override calls the component to track the bunch. virtual void visitComponent(const Component &); - /// Apply the algorithm to a patch. - virtual void visitPatch(const Patch &pat); - /// set total number of tracked bunches virtual void setNumBunch(short) {}; diff --git a/src/Classic/Algorithms/rbendmap.h b/src/Classic/Algorithms/rbendmap.h deleted file mode 100644 index ef5ef7afb32073a943e0908603d86b2d93bcd604..0000000000000000000000000000000000000000 --- a/src/Classic/Algorithms/rbendmap.h +++ /dev/null @@ -1,199 +0,0 @@ -#include "Fields/BMultipoleField.h" - -#include "FixedAlgebra/FTps.h" -#include "FixedAlgebra/FVps.h" -#include "FixedAlgebra/FTpsMath.h" - - -enum { X, PX, Y, PY, T, PT }; // !!!!! used by sbendmap.hh and quadmap.h - -typedef FTps<double, 6> Series_t; - -class RbendMap { - - -public: - RbendMap() { }; - - FVps<double, 6> getBodyMap(const BMultipoleField &field, double length, double beta, - double scale, double p, double mass, - FVps<double, 6> map); - - Series_t getHamiltonian(const BMultipoleField &field, double beta, - double scale, double p, double mass); - - FVps<double, 6> getEntranceFringeMap(double angle, double curve, - const BMultipoleField &field, - double scale, FVps<double, 6> map); - - FVps<double, 6> getExitFringeMap(double angle, double curve, - const BMultipoleField &field, - double scale, FVps<double, 6> map); - - FVps<double, 6> getTransformMap(const Euclid3D &euclid, double refLength, - double beta, double scale, double p, - double mass, FVps<double, 6> map); - - /// Construct the vector potential for a Rbend. - Series_t getMultipoleMap(const BMultipoleField &); - FVps<double, 6> getThinMultipoleMap(const BMultipoleField &field, double scale, FVps<double, 6> &m); - -}; - -FVps<double, 6> RbendMap::getEntranceFringeMap(double angle, double /*curve*/, - const BMultipoleField &field, - double scale, FVps<double, 6> map) { - // *** MISSING *** Higher order terms for entrance fringe. - double hx = scale * field.normal(1); - double ex = hx * tan(angle); - double ey = hx * tan(angle + map[PX][0]); - map[PX] += ex * map[X]; - map[PY] -= ey * map[Y]; - return map; -} - -FVps<double, 6> RbendMap::getExitFringeMap(double angle, double /*curve*/, - const BMultipoleField &field, - double scale, FVps<double, 6> map) { - // *** MISSING *** Higher order terms for exit fringe. - double hx = scale * field.normal(1); - double ex = hx * tan(angle); - double ey = hx * tan(angle - map[PX][0]); - map[PX] += ex * map[X]; - map[PY] -= ey * map[Y]; - return map; -} - -FVps<double, 6> RbendMap::getBodyMap(const BMultipoleField &field, double length, double beta, - double scale, double p, double mass, - FVps<double, 6> map) { - // Build Hamiltonian in local coordinates; substitution done later. - // Step 1: Define variables. - Series_t px = Series_t::makeVariable(PX); - Series_t py = Series_t::makeVariable(PY); - Series_t pt = Series_t::makeVariable(PT) + 1.0; - - // Step 2: Kinematic terms. - Series_t x = Series_t::makeVariable(X); - Series_t pz = sqrt(pt * pt - px * px - py * py); - double kin = mass / p; - Series_t E = sqrt(pt * pt + kin * kin) / beta; - - // Step 3: Vector potential (1 + h*x) * As in curved reference. - Series_t As = getMultipoleMap(field) * scale; - - //cout << "As= " << As << endl; - - // Step 4: Finish Hamiltonian, substitute previous map, - // and apply result to the previous map. - Series_t H = As + E - pz; - - // cout << "H= " << H << endl; - map = ExpMap(- H * length).substitute(map); - return map; -} - -Series_t RbendMap::getHamiltonian(const BMultipoleField &field, double beta, - double scale, double p, double mass) { - // Build Hamiltonian in local coordinates; substitution done later. - // Step 1: Define variables. - Series_t px = Series_t::makeVariable(PX); - Series_t py = Series_t::makeVariable(PY); - Series_t pt = Series_t::makeVariable(PT) + 1.0; - - // Step 2: Kinematic terms. - Series_t x = Series_t::makeVariable(X); - Series_t pz = sqrt(pt * pt - px * px - py * py); - double kin = mass / p; - Series_t E = sqrt(pt * pt + kin * kin) / beta; - - // Step 3: Vector potential (1 + h*x) * As in curved reference. - Series_t As = getMultipoleMap(field) * scale; - - // Step 4: Finish Hamiltonian - Series_t H = As + E - pz; - return H; -} - -Series_t RbendMap::getMultipoleMap(const BMultipoleField &field) { - int order = field.order(); - - if(order > 0) { - static const Series_t x = Series_t::makeVariable(X); - static const Series_t y = Series_t::makeVariable(Y); - Series_t kx = + field.normal(order) / double(order); - Series_t ky = - field.skew(order) / double(order); - - while(order > 1) { - Series_t kxt = x * kx - y * ky; - Series_t kyt = x * ky + y * kx; - order--; - kx = kxt + field.normal(order) / double(order); - ky = kyt - field.skew(order) / double(order); - } - - return (x * kx - y * ky); - } else { - return Series_t(0.0); - } - - - -} - -FVps<double, 6> RbendMap::getThinMultipoleMap(const BMultipoleField &field, double scale, FVps<double, 6> &m) { - int order = field.order(); - - if(order > 0) { - static const Series_t x = Series_t::makeVariable(X); - static const Series_t y = Series_t::makeVariable(Y); - Series_t kx = + field.normal(order) / double(order); - Series_t ky = - field.skew(order) / double(order); - - while(order > 1) { - Series_t kxt = x * kx - y * ky; - Series_t kyt = x * ky + y * kx; - order--; - kx = kxt + field.normal(order) / double(order); - ky = kyt - field.skew(order) / double(order); - } - m[PX] -= kx * scale; - m[PY] += ky * scale; - } - return m; -} - - -FVps<double, 6> RbendMap::getTransformMap(const Euclid3D &euclid, double refLength, - double beta, double /*scale*/, double p, - double mass, FVps<double, 6> map) { - if(! euclid.isIdentity()) { - double kin = mass / p; - double refTime = refLength / beta; - Series_t px = map[PX]; - Series_t py = map[PY]; - Series_t pt = map[PT] + 1.0; - Series_t pz = sqrt(pt * pt - px * px - py * py); - - map[PX] = euclid.M(0, 0) * px + euclid.M(1, 0) * py + euclid.M(2, 0) * pz; - map[PY] = euclid.M(0, 1) * px + euclid.M(1, 1) * py + euclid.M(2, 1) * pz; - pz = euclid.M(0, 2) * px + euclid.M(1, 2) * py + euclid.M(2, 2) * pz; - - Series_t x = map[X] - euclid.getX(); - Series_t y = map[Y] - euclid.getY(); - Series_t x2 = - euclid.M(0, 0) * x + euclid.M(1, 0) * y - euclid.M(2, 0) * euclid.getZ(); - Series_t y2 = - euclid.M(0, 1) * x + euclid.M(1, 1) * y - euclid.M(2, 1) * euclid.getZ(); - Series_t s2 = - euclid.M(0, 2) * x + euclid.M(1, 2) * y - euclid.M(2, 2) * euclid.getZ(); - Series_t sByPz = s2 / pz; - - Series_t E = sqrt(pt * pt + kin * kin); - map[X] = x2 - sByPz * map[PX]; - map[Y] = y2 - sByPz * map[PY]; - map[T] += pt * (refTime / E + sByPz); - return map; - } else - return map; -} diff --git a/src/Classic/BeamlineCore/BeamBeamRep.cpp b/src/Classic/BeamlineCore/BeamBeamRep.cpp deleted file mode 100644 index 4d016f0de60413a37b52625274ab23262d55fbbd..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineCore/BeamBeamRep.cpp +++ /dev/null @@ -1,198 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: BeamBeamRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: BeamBeamRep -// Defines a concrete beam-beam interaction. -// -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "BeamlineCore/BeamBeamRep.h" -#include "AbsBeamline/ElementImage.h" -#include "BeamlineGeometry/Matrix3D.h" -#include "BeamlineGeometry/Vector3D.h" -#include "Channels/IndexedChannel.h" -#include "Channels/IndirectChannel.h" - - -// Attribute access table. -// ------------------------------------------------------------------------ - -namespace { - struct Entry { - const char *name; - double(BeamBeamRep::*get)() const; - void (BeamBeamRep::*set)(double); - }; - - const Entry entries[] = { - { - "L", - &BeamBeamRep::getElementLength, - 0 - }, - { - "CHARGE", - &BeamBeamRep::getBunchCharge, - &BeamBeamRep::setBunchCharge - }, - { 0, 0, 0 } - }; -} - - -// Class BeamBeamRep -// ------------------------------------------------------------------------ - -BeamBeamRep::BeamBeamRep(): - BeamBeam(), geometry() -{} - - -BeamBeamRep::BeamBeamRep(const BeamBeamRep &right): - BeamBeam(right), geometry() -{} - - -BeamBeamRep::BeamBeamRep(const std::string &name): - BeamBeam(name), geometry() -{} - - -BeamBeamRep::~BeamBeamRep() -{} - - -ElementBase *BeamBeamRep::clone() const { - return new BeamBeamRep(*this); -} - - -Channel *BeamBeamRep::getChannel(const std::string &aKey, bool create) { - static char plane[] = "XYS"; - if(aKey[0] == 'D') { - for(int i = 0; i < 3; i++) { - if(aKey[1] == plane[i]) { - return new IndexedChannel<BeamBeamRep> - (*this, &BeamBeamRep::getDisplacement, - &BeamBeamRep::setDisplacement, i); - } - } - } else if(aKey[0] == 'R') { - for(int i = 0; i < 3; i++) { - if(aKey[1] == plane[i]) { - for(int j = 0; j < 3; j++) { - if(aKey[2] == plane[j]) { - int index = 3 * i + j; - return new IndexedChannel<BeamBeamRep> - (*this, &BeamBeamRep::getMoment, - &BeamBeamRep::setMoment, index); - } - } - } - } - } - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - if(aKey == entry->name) { - return new IndirectChannel<BeamBeamRep>(*this, entry->get, entry->set); - } - } - - return ElementBase::getChannel(aKey, create); -} - - -double BeamBeamRep::getBunchCharge() const { - return Q; -} - - -const Matrix3D &BeamBeamRep::getBunchMoment() const { - return sigma; -} - - -const Vector3D &BeamBeamRep::getBunchDisplacement() const { - return delta; -} - - -NullField &BeamBeamRep::getField() { - return field; -} - - -const NullField &BeamBeamRep::getField() const { - return field; -} - - -NullGeometry &BeamBeamRep::getGeometry() { - return geometry; -} - -const NullGeometry &BeamBeamRep::getGeometry() const { - return geometry; -} - - -ElementImage *BeamBeamRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - - -void BeamBeamRep::setBunchCharge(double charge) { - Q = charge; -} - - -void BeamBeamRep::setBunchMoment(const Matrix3D &moments) { - sigma = moments; -} - - -void BeamBeamRep::setBunchDisplacement(const Vector3D &disp) { - delta = disp; -} - - -double BeamBeamRep::getMoment(int index) const { - int i1 = index / 3; - int i2 = index % 3; - return sigma(i1, i2); -} - - -double BeamBeamRep::getDisplacement(int index) const { - return delta(index); -} - - -void BeamBeamRep::setMoment(int index, double moment) { - int i1 = index / 3; - int i2 = index % 3; - sigma(i1, i2) = sigma(i2, i1) = moment; -} - - -void BeamBeamRep::setDisplacement(int index, double disp) { - delta(index) = disp; -} diff --git a/src/Classic/BeamlineCore/BeamBeamRep.h b/src/Classic/BeamlineCore/BeamBeamRep.h deleted file mode 100644 index b026a45e3c623cc7590ce27b64ec88ea6a4f90c0..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineCore/BeamBeamRep.h +++ /dev/null @@ -1,152 +0,0 @@ -#ifndef CLASSIC_BeamBeamRep_HH -#define CLASSIC_BeamBeamRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: BeamBeamRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: BeamBeamRep -// -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/BeamBeam.h" -#include "BeamlineGeometry/NullGeometry.h" -#include "Fields/NullField.h" - - -// Class BeamBeamRep -// ------------------------------------------------------------------------ -/// Representation of beam-beam interaction. -// A concrete representation for a beam-beam interaction. -// The opposite bunch has a Gaussian distribution of the form -// [P] -// N(x,y,s) = c * exp(- transpose(z - delta) sigma**(-1) (z - delta)), -// [P] -// with the definitions -// [DL] -// [DT]z[DD] position vector in space, -// [DT]delta[DD] centroid of opposite bunch in global reference system, -// [DT]sigma[DD] beam matrix in the TRANSPORT sense, -// [DT]c[DD] a normalising factor, such that the total charge is Q, -// [DT]sigma(i,i)[DD] standard deviation sigma(i) in direction i, -// [DT]r(i,j)[DD] = sigma(i,j)/sqrt(sigma(i,i)*sigma(i,j)), -// correlations between phase space coordinates i and j. -// [/DL] - -class BeamBeamRep: public BeamBeam { - -public: - - /// Constructor with given name. - explicit BeamBeamRep(const std::string &name); - - BeamBeamRep(); - BeamBeamRep(const BeamBeamRep &); - virtual ~BeamBeamRep(); - - /// Return clone. - // Return an identical deep copy of the element. - virtual ElementBase *clone() const; - - /// Construct a read/write channel. - // This method constructs a Channel permitting read/write access to - // the attribute[b]aKey[/b] and returns it. - // If the attribute does not exist, it returns NULL. - virtual Channel *getChannel(const std::string &aKey, bool = false); - - /// Get bunch charge. - // Return the number of particles times the particle charge in the - // opposite bunch. Units are proton charges. - virtual double getBunchCharge() const; - - /// Get moments. - // Return the moment matrix for the opposite bunch (the matrix of - // second momenta). Units are square metres. - virtual const Matrix3D &getBunchMoment() const; - - /// Get displacement. - // Return the displacement vector for position of opposite bunch. - // Units are metres. - virtual const Vector3D &getBunchDisplacement() const; - - /// Get field. - // Version for non-constant object. - virtual NullField &getField(); - - /// Get field. - // Version for constant object. - virtual const NullField &getField() const; - - /// Get geometry. - // Version for non-constant object. - virtual NullGeometry &getGeometry(); - - /// Get geometry. - // Version for constant object. - virtual const NullGeometry &getGeometry() const; - - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - - /// Set the bunch charge. - // Units are proton charges. - void setBunchCharge(double); - - /// Set moments. - // Assign the moment matrix for the opposite bunch - // (the matrix of second momenta). Units are square metres. - void setBunchMoment(const Matrix3D &); - - /// Set displacement. - // Assign the displacement vector for the opposite bunch. - // Units are metres. - void setBunchDisplacement(const Vector3D &); - -private: - - // Not implemented. - void operator=(const BeamBeamRep &); - - // Get a moment for the opposite bunch. - double getMoment(int index) const; - - // Get the displacement vector for the opposite bunch. - double getDisplacement(int index) const; - - // Set a moment for the opposite bunch. - void setMoment(int index, double); - - // Set a displacement for the opposite bunch. - void setDisplacement(int index, double); - - // The zero magnetic field. - NullField field; - - // The geometry (a straight geometry with zero length). - NullGeometry geometry; - - // Total charge of the opposite bunch in proton charges. - double Q; - - // Displacement of the centre of gravity of the opposite bunch - // with respect to the local frame for the affected bunch. - Vector3D delta; - - // Second moments of the opposite bunch. - Matrix3D sigma; -}; - -#endif // CLASSIC_BeamBeamRep_HH diff --git a/src/Classic/BeamlineCore/BeamStrippingRep.cpp b/src/Classic/BeamlineCore/BeamStrippingRep.cpp index 6cae70cb112a61ea045767d33e8c13d5db65d715..977f8e3b736397b510c728fb903d7d748366b45b 100644 --- a/src/Classic/BeamlineCore/BeamStrippingRep.cpp +++ b/src/Classic/BeamlineCore/BeamStrippingRep.cpp @@ -20,7 +20,6 @@ // along with OPAL. If not, see <https://www.gnu.org/licenses/>. // -#include "AbsBeamline/ElementImage.h" #include "BeamlineCore/BeamStrippingRep.h" #include "Channels/IndirectChannel.h" @@ -97,14 +96,3 @@ PlanarArcGeometry &BeamStrippingRep::getGeometry() { const PlanarArcGeometry &BeamStrippingRep::getGeometry() const { return geometry; } - - -ElementImage *BeamStrippingRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} \ No newline at end of file diff --git a/src/Classic/BeamlineCore/BeamStrippingRep.h b/src/Classic/BeamlineCore/BeamStrippingRep.h index 4d3ba87005d8bd3246eb8972a1dfed2aa4036ea7..7a3471d3bdfcc874ef3ee3b8f56c04b8e08e2673 100644 --- a/src/Classic/BeamlineCore/BeamStrippingRep.h +++ b/src/Classic/BeamlineCore/BeamStrippingRep.h @@ -66,12 +66,6 @@ public: // Version for constant object. virtual const PlanarArcGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - - private: // Not implemented. diff --git a/src/Classic/BeamlineCore/CCollimatorRep.cpp b/src/Classic/BeamlineCore/CCollimatorRep.cpp index c3210155f76021ff370f2f2d599dadb492ccd2f2..3508c95917404f3aa8d64725ff322c61cb0834a8 100644 --- a/src/Classic/BeamlineCore/CCollimatorRep.cpp +++ b/src/Classic/BeamlineCore/CCollimatorRep.cpp @@ -1,31 +1,24 @@ -// ------------------------------------------------------------------------ -// $RCSfile: CCollimatorRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: CCollimatorRep -// Defines a concrete collimator representation. +// Class CCollimatorRep +// Representation for a collimator. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ +// 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 "BeamlineCore/CCollimatorRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" -// Attribute access table. -// ------------------------------------------------------------------------ - namespace { struct Entry { const char *name; @@ -44,9 +37,6 @@ namespace { } -// Class CCollimatorRep -// ------------------------------------------------------------------------ - CCollimatorRep::CCollimatorRep(): CCollimator(), geometry(0.0) @@ -103,16 +93,6 @@ const StraightGeometry &CCollimatorRep::getGeometry() const { } -ElementImage *CCollimatorRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - /* double CCollimatorRep::getXsize() const diff --git a/src/Classic/BeamlineCore/CCollimatorRep.h b/src/Classic/BeamlineCore/CCollimatorRep.h index 6b0367e7fb5610bc17ecebd93a802730ebc4b036..916ec0115d689f4253c78d41c885809d8b025a3c 100644 --- a/src/Classic/BeamlineCore/CCollimatorRep.h +++ b/src/Classic/BeamlineCore/CCollimatorRep.h @@ -1,34 +1,28 @@ -#ifndef CLASSIC_CCollimatorRep_HH -#define CLASSIC_CCollimatorRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: CCollimatorRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: CCollimatorRep +// Class CCollimatorRep +// Representation for a collimator. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// 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. // -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // -// ------------------------------------------------------------------------ +#ifndef CLASSIC_CCollimatorRep_HH +#define CLASSIC_CCollimatorRep_HH #include "AbsBeamline/CCollimator.h" #include "BeamlineGeometry/StraightGeometry.h" #include "Fields/NullField.h" -// Class CCollimatorRep -// ------------------------------------------------------------------------ -/// Representation for a collimator. - class CCollimatorRep: public CCollimator { public: @@ -66,11 +60,6 @@ public: // Version for constant object. virtual const StraightGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /* /// Return the horizontal half-aperture. virtual double getXsize() = 0;//const; diff --git a/src/Classic/BeamlineCore/CMakeLists.txt b/src/Classic/BeamlineCore/CMakeLists.txt index 87f9c415f1a03ec98f811911bba779f5c2e9155c..8a801ee19948e2a3936813356e885c83acfac185 100644 --- a/src/Classic/BeamlineCore/CMakeLists.txt +++ b/src/Classic/BeamlineCore/CMakeLists.txt @@ -1,5 +1,4 @@ set (_SRCS - BeamBeamRep.cpp BeamStrippingRep.cpp CCollimatorRep.cpp CorrectorRep.cpp @@ -11,14 +10,11 @@ set (_SRCS MonitorRep.cpp MultipoleRep.cpp Octupole.cpp - ParallelPlateRep.cpp - PatchRep.cpp ProbeRep.cpp Quadrupole.cpp RBendRep.cpp RFCavityRep.cpp SBendRep.cpp - SeparatorRep.cpp SeptumRep.cpp Sextupole.cpp SkewOctupole.cpp @@ -29,9 +25,7 @@ set (_SRCS StripperRep.cpp TravelingWaveRep.cpp XCorrectorRep.cpp - XMonitorRep.cpp YCorrectorRep.cpp - YMonitorRep.cpp ) include_directories ( @@ -41,7 +35,6 @@ include_directories ( add_opal_sources (${_SRCS}) set (HDRS - BeamBeamRep.h BeamStrippingRep.h CCollimatorRep.h CorrectorRep.h @@ -53,14 +46,11 @@ set (HDRS MonitorRep.h MultipoleRep.h Octupole.h - ParallelPlateRep.h - PatchRep.h ProbeRep.h Quadrupole.h RBendRep.h RFCavityRep.h SBendRep.h - SeparatorRep.h SeptumRep.h Sextupole.h SingleMultipole.h @@ -72,9 +62,7 @@ set (HDRS StripperRep.h TravelingWaveRep.h XCorrectorRep.h - XMonitorRep.h YCorrectorRep.h - YMonitorRep.h ) install (FILES ${HDRS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/BeamlineCore") diff --git a/src/Classic/BeamlineCore/CorrectorRep.cpp b/src/Classic/BeamlineCore/CorrectorRep.cpp index 26978d154ccaf2e7bbf659ffa0519237ee3a10fd..85c60ab2404ab18e8e6a4988d54e8357a3a4861c 100644 --- a/src/Classic/BeamlineCore/CorrectorRep.cpp +++ b/src/Classic/BeamlineCore/CorrectorRep.cpp @@ -17,7 +17,6 @@ // along with OPAL. If not, see <https://www.gnu.org/licenses/>. // #include "BeamlineCore/CorrectorRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" @@ -97,17 +96,6 @@ const StraightGeometry &CorrectorRep::getGeometry() const { } -ElementImage *CorrectorRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *table = entries; table->name != 0; ++table) { - image->setAttribute(table->name, (this->*(table->get))()); - } - - return image; -} - - Corrector::Plane CorrectorRep::getPlane() const { return active ? XY : OFF; } diff --git a/src/Classic/BeamlineCore/CorrectorRep.h b/src/Classic/BeamlineCore/CorrectorRep.h index 9955dd7e29cb36cda416265602442943e7f541be..820fb7314c2a50964552c36f99a463bc4c4e2cde 100644 --- a/src/Classic/BeamlineCore/CorrectorRep.h +++ b/src/Classic/BeamlineCore/CorrectorRep.h @@ -54,11 +54,6 @@ public: // Version for constant object. virtual const StraightGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /// Get plane(s) of action. virtual Plane getPlane() const; diff --git a/src/Classic/BeamlineCore/CyclotronRep.cpp b/src/Classic/BeamlineCore/CyclotronRep.cpp index 1d5505fa6043c3d0326937e062c9965e1ebcb437..2269abc2b0130b5b146083d6ba6fa697a0c1bb7b 100644 --- a/src/Classic/BeamlineCore/CyclotronRep.cpp +++ b/src/Classic/BeamlineCore/CyclotronRep.cpp @@ -16,7 +16,6 @@ // along with OPAL. If not, see <https://www.gnu.org/licenses/>. // #include "BeamlineCore/CyclotronRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" // Attribute access table. diff --git a/src/Classic/BeamlineCore/DegraderRep.cpp b/src/Classic/BeamlineCore/DegraderRep.cpp index 160d2568af5a72898208f0f336074d63c93c63ec..d3d90d0d67ab70cca156f3d820495d42a3e1a489 100644 --- a/src/Classic/BeamlineCore/DegraderRep.cpp +++ b/src/Classic/BeamlineCore/DegraderRep.cpp @@ -1,31 +1,24 @@ -// ------------------------------------------------------------------------ -// $RCSfile: DegraderRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: DegraderRep -// Defines a concrete collimator representation. +// Class DegraderRep +// Representation for a degrader. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ +// 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 "BeamlineCore/DegraderRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" -// Attribute access table. -// ------------------------------------------------------------------------ - namespace { struct Entry { const char *name; @@ -44,9 +37,6 @@ namespace { } -// Class DegraderRep -// ------------------------------------------------------------------------ - DegraderRep::DegraderRep(): Degrader(), geometry(0.0) @@ -100,15 +90,4 @@ StraightGeometry &DegraderRep::getGeometry() { const StraightGeometry &DegraderRep::getGeometry() const { return geometry; -} - - -ElementImage *DegraderRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; } \ No newline at end of file diff --git a/src/Classic/BeamlineCore/DegraderRep.h b/src/Classic/BeamlineCore/DegraderRep.h index e5545f1e0ee262cc9019633d7346ef428455fb83..a54de4ef3d847bf6b39b036b3a8f7194e640d127 100644 --- a/src/Classic/BeamlineCore/DegraderRep.h +++ b/src/Classic/BeamlineCore/DegraderRep.h @@ -1,34 +1,28 @@ -#ifndef CLASSIC_DegraderRep_HH -#define CLASSIC_DegraderRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: DegraderRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: DegraderRep +// Class DegraderRep +// Representation for a degrader. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// 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. // -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // -// ------------------------------------------------------------------------ +#ifndef CLASSIC_DegraderRep_HH +#define CLASSIC_DegraderRep_HH #include "AbsBeamline/Degrader.h" #include "BeamlineGeometry/StraightGeometry.h" #include "Fields/NullField.h" -// Class DegraderRep -// ------------------------------------------------------------------------ -/// Representation for a collimator. - class DegraderRep: public Degrader { public: @@ -66,11 +60,6 @@ public: // Version for constant object. virtual const StraightGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /* /// Return the horizontal half-aperture. virtual double getXsize() = 0;//const; diff --git a/src/Classic/BeamlineCore/DriftRep.cpp b/src/Classic/BeamlineCore/DriftRep.cpp index c01cd5fe9152b78ac68aa9cc6f90617f7a981403..4ae64bb3d18431615d52b8d6dd1611eebf6b52ee 100644 --- a/src/Classic/BeamlineCore/DriftRep.cpp +++ b/src/Classic/BeamlineCore/DriftRep.cpp @@ -1,31 +1,24 @@ -// ------------------------------------------------------------------------ -// $RCSfile: DriftRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: DriftRep -// Defines a concrete drift space representation. +// Class DriftRep +// Representation for a drift space. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ +// 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 "BeamlineCore/DriftRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" -// Attribute access table. -// ------------------------------------------------------------------------ - namespace { struct Entry { const char *name; @@ -44,9 +37,6 @@ namespace { } -// Class DriftRep -// ------------------------------------------------------------------------ - DriftRep::DriftRep(): Drift(), geometry(0.0) @@ -100,15 +90,4 @@ StraightGeometry &DriftRep::getGeometry() { const StraightGeometry &DriftRep::getGeometry() const { return geometry; -} - - -ElementImage *DriftRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} +} \ No newline at end of file diff --git a/src/Classic/BeamlineCore/DriftRep.h b/src/Classic/BeamlineCore/DriftRep.h index 0f4825249a74d1b72638007a163770e19418d01e..13e9d774683cf466934e6f3f6736e968a6cc4f3d 100644 --- a/src/Classic/BeamlineCore/DriftRep.h +++ b/src/Classic/BeamlineCore/DriftRep.h @@ -1,34 +1,28 @@ -#ifndef CLASSIC_DriftRep_HH -#define CLASSIC_DriftRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: DriftRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: DriftRep +// Class DriftRep +// Representation for a drift space. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// 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. // -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // -// ------------------------------------------------------------------------ +#ifndef CLASSIC_DriftRep_HH +#define CLASSIC_DriftRep_HH #include "AbsBeamline/Drift.h" #include "BeamlineGeometry/StraightGeometry.h" #include "Fields/NullField.h" -// Class DriftRep -// ------------------------------------------------------------------------ -/// Representation for a drift space. - class DriftRep: public Drift { public: @@ -66,11 +60,6 @@ public: // Version for constant object. virtual const StraightGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - private: // Not implemented. diff --git a/src/Classic/BeamlineCore/FlexibleCollimatorRep.cpp b/src/Classic/BeamlineCore/FlexibleCollimatorRep.cpp index 85b87f89f29b826e7b91f6d8424a0754db3e7205..71305464f19aab12b1e4a319ac55dcd919fa5cf4 100644 --- a/src/Classic/BeamlineCore/FlexibleCollimatorRep.cpp +++ b/src/Classic/BeamlineCore/FlexibleCollimatorRep.cpp @@ -1,31 +1,23 @@ -// ------------------------------------------------------------------------ -// $RCSfile: FlexibleCollimatorRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: FlexibleCollimatorRep -// Defines a concrete collimator representation. +// Class FlexibleCollimatorRep +// Representation for a flexible collimator. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ +// 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 "BeamlineCore/FlexibleCollimatorRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" - -// Attribute access table. -// ------------------------------------------------------------------------ - namespace { struct Entry { const char *name; @@ -44,9 +36,6 @@ namespace { } -// Class FlexibleCollimatorRep -// ------------------------------------------------------------------------ - FlexibleCollimatorRep::FlexibleCollimatorRep(): FlexibleCollimator(), geometry(0.0) @@ -100,15 +89,4 @@ StraightGeometry &FlexibleCollimatorRep::getGeometry() { const StraightGeometry &FlexibleCollimatorRep::getGeometry() const { return geometry; -} - - -ElementImage *FlexibleCollimatorRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; } \ No newline at end of file diff --git a/src/Classic/BeamlineCore/FlexibleCollimatorRep.h b/src/Classic/BeamlineCore/FlexibleCollimatorRep.h index 3b2a19b10e5bb7de97d43bb9976585a435c0a629..eea89ef52e107eeb6f3a8c6bde897a654eeb9f79 100644 --- a/src/Classic/BeamlineCore/FlexibleCollimatorRep.h +++ b/src/Classic/BeamlineCore/FlexibleCollimatorRep.h @@ -1,34 +1,28 @@ -#ifndef CLASSIC_FlexibleCollimatorRep_HH -#define CLASSIC_FlexibleCollimatorRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: FlexibleCollimatorRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: FlexibleCollimatorRep +// Class FlexibleCollimatorRep +// Representation for a flexible collimator. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// 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. // -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // -// ------------------------------------------------------------------------ +#ifndef CLASSIC_FlexibleCollimatorRep_HH +#define CLASSIC_FlexibleCollimatorRep_HH #include "AbsBeamline/FlexibleCollimator.h" #include "BeamlineGeometry/StraightGeometry.h" #include "Fields/NullField.h" -// Class FlexibleCollimatorRep -// ------------------------------------------------------------------------ -/// Representation for a collimator. - class FlexibleCollimatorRep: public FlexibleCollimator { public: @@ -66,11 +60,6 @@ public: // Version for constant object. virtual const StraightGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /* /// Return the horizontal half-aperture. virtual double getXsize() = 0;//const; diff --git a/src/Classic/BeamlineCore/MonitorRep.cpp b/src/Classic/BeamlineCore/MonitorRep.cpp index 2b38fb75b899194295405e28725e5c8eae3ecb42..dfdf6a21d2cfd145fbf01705e79fcab7eb7fa272 100644 --- a/src/Classic/BeamlineCore/MonitorRep.cpp +++ b/src/Classic/BeamlineCore/MonitorRep.cpp @@ -1,32 +1,24 @@ -// ------------------------------------------------------------------------ -// $RCSfile: MonitorRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: MonitorRep -// Defines a concrete representation for an orbit monitor acting on -// both planes. +// Class MonitorRep +// Representation for an orbit position monitor. +// The base class observes both planes. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ +// 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 "BeamlineCore/MonitorRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" - -// Attribute access table. -// ------------------------------------------------------------------------ - namespace { struct Entry { const char *name; @@ -45,9 +37,6 @@ namespace { } -// Class MonitorRep -// ------------------------------------------------------------------------ - MonitorRep::MonitorRep(): Monitor(), field(), geometry(), active(true) {} @@ -101,17 +90,6 @@ const StraightGeometry &MonitorRep::getGeometry() const { } -ElementImage *MonitorRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - - Monitor::Plane MonitorRep::getPlane() const { return active ? XY : OFF; } diff --git a/src/Classic/BeamlineCore/MonitorRep.h b/src/Classic/BeamlineCore/MonitorRep.h index c8f71ad7602ad9f78e34cae1c8c86d43648ee57b..45cc27f0642471818166e9471da5fd6934dc51a4 100644 --- a/src/Classic/BeamlineCore/MonitorRep.h +++ b/src/Classic/BeamlineCore/MonitorRep.h @@ -1,34 +1,28 @@ -#ifndef CLASSIC_MonitorRep_HH -#define CLASSIC_MonitorRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: MonitorRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: MonitorRep +// Class MonitorRep +// Representation for an orbit position monitor. +// The base class observes both planes. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// 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. // -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // -// ------------------------------------------------------------------------ +#ifndef CLASSIC_MonitorRep_HH +#define CLASSIC_MonitorRep_HH #include "AbsBeamline/Monitor.h" #include "BeamlineGeometry/StraightGeometry.h" #include "Fields/NullField.h" -// Class MonitorRep -// ------------------------------------------------------------------------ -/// Representation for an orbit position monitor. -// The base class observes both planes. - class MonitorRep: public Monitor { public: @@ -68,11 +62,6 @@ public: // Version for constant object. virtual const StraightGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /// Get planes. // Return the plane(s) observed by this monitor. virtual Plane getPlane() const; diff --git a/src/Classic/BeamlineCore/MultipoleRep.cpp b/src/Classic/BeamlineCore/MultipoleRep.cpp index f829af6b02e933566e3c6bb2c68fc0747aa751ff..ae1f4e6a2f594307978dfbe660daa037a29836c8 100644 --- a/src/Classic/BeamlineCore/MultipoleRep.cpp +++ b/src/Classic/BeamlineCore/MultipoleRep.cpp @@ -16,7 +16,6 @@ // along with OPAL. If not, see <https://www.gnu.org/licenses/>. // #include "BeamlineCore/MultipoleRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndexedChannel.h" #include "Channels/IndirectChannel.h" #include <cctype> @@ -115,43 +114,6 @@ const StraightGeometry &MultipoleRep::getGeometry() const { } -ElementImage *MultipoleRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - for(int n = 1; n <= field.order(); n++) { - char buffer[20]; - char *p = buffer; - int k = n; - - while(k != 0) { - *p++ = k % 10 + '0'; - k /= 10; - } - - std::string name(" "); - while(p > buffer) name += *--p; - - double b = getNormalComponent(n); - if(b != 0.0) { - name[0] = 'b'; - image->setAttribute(name, b); - } - - double a = getSkewComponent(n); - if(a != 0.0) { - name[0] = 'a'; - image->setAttribute(name, a); - } - } - - return image; -} - - BMultipoleField &MultipoleRep::getField() { return field; } diff --git a/src/Classic/BeamlineCore/MultipoleRep.h b/src/Classic/BeamlineCore/MultipoleRep.h index 6c6690219c44bad0c24ba44a4b7f224d1aa09aa5..6eee6a4803186b9ca65792f9c1782ac5078bcfbd 100644 --- a/src/Classic/BeamlineCore/MultipoleRep.h +++ b/src/Classic/BeamlineCore/MultipoleRep.h @@ -60,11 +60,6 @@ public: // Version for constant object. virtual const StraightGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /// Set mulitpole field. virtual void setField(const BMultipoleField &field); diff --git a/src/Classic/BeamlineCore/ParallelPlateRep.cpp b/src/Classic/BeamlineCore/ParallelPlateRep.cpp deleted file mode 100644 index f4c722f0148584a0da3559a44dc88c87a5759a7e..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineCore/ParallelPlateRep.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: ParallelPlateRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ParallelPlateRep -// Defines a representation for a RF cavity. -// -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "BeamlineCore/ParallelPlateRep.h" -#include "AbsBeamline/ElementImage.h" -#include "Channels/IndirectChannel.h" - - -// Attribute access table. -// ------------------------------------------------------------------------ - - -namespace { - struct Entry { - const char *name; - double(ParallelPlateRep::*get)() const; - void (ParallelPlateRep::*set)(double); - }; - - static const Entry entries[] = { - { - "L", - &ParallelPlateRep::getElementLength, - &ParallelPlateRep::setElementLength - }, - { - "AMPLITUDE", - &ParallelPlateRep::getAmplitude, - &ParallelPlateRep::setAmplitude - }, - { - "FREQUENCY", - &ParallelPlateRep::getFrequency, - &ParallelPlateRep::setFrequency - }, - { - "PHASE", - &ParallelPlateRep::getPhase, - &ParallelPlateRep::setPhase - }, - { 0, 0, 0 } - }; -} - - -// Class ParallelPlateRep -// ------------------------------------------------------------------------ - -ParallelPlateRep::ParallelPlateRep(): - ParallelPlate() -{} - - -ParallelPlateRep::ParallelPlateRep(const ParallelPlateRep &right): - ParallelPlate(right) -{} - - -ParallelPlateRep::ParallelPlateRep(const std::string &name): - ParallelPlate(name) -{} - - -ParallelPlateRep::~ParallelPlateRep() -{} - - -ElementBase *ParallelPlateRep::clone() const { - return new ParallelPlateRep(*this); -} - - -Channel *ParallelPlateRep::getChannel(const std::string &aKey, bool create) { - for(const Entry *entry = entries; entry->name != 0; ++entry) { - if(aKey == entry->name) { - return new IndirectChannel<ParallelPlateRep>(*this, entry->get, entry->set); - } - } - - return ElementBase::getChannel(aKey, create); -} - - -AcceleratingField &ParallelPlateRep::getField() { - return field; -} - -const AcceleratingField &ParallelPlateRep::getField() const { - return field; -} - - -StraightGeometry &ParallelPlateRep::getGeometry() { - return geometry; -} - -const StraightGeometry &ParallelPlateRep::getGeometry() const { - return geometry; -} - - -ElementImage *ParallelPlateRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} \ No newline at end of file diff --git a/src/Classic/BeamlineCore/ParallelPlateRep.h b/src/Classic/BeamlineCore/ParallelPlateRep.h deleted file mode 100644 index 8a7df90281f32d454905c4f47ccf3034b83c007b..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineCore/ParallelPlateRep.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef CLASSIC_ParallelPlateRep_HH -#define CLASSIC_ParallelPlateRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: ParallelPlateRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ParallelPlateRep -// -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/ParallelPlate.h" -#include "BeamlineGeometry/StraightGeometry.h" -#include "Fields/AcceleratingField.h" - - -// Class ParallelPlateRep -// ------------------------------------------------------------------------ -/// Representation for a RF cavity. - -class ParallelPlateRep: public ParallelPlate { - -public: - - /// Constructor with given name. - explicit ParallelPlateRep(const std::string &name); - - ParallelPlateRep(); - ParallelPlateRep(const ParallelPlateRep &); - virtual ~ParallelPlateRep(); - - /// Return clone. - // Return an identical deep copy of the element. - virtual ElementBase *clone() const; - - /// Construct a read/write channel. - // This method constructs a Channel permitting read/write access to - // the attribute [b]aKey[/b] and returns it. - // If the attribute does not exist, it returns NULL. - virtual Channel *getChannel(const std::string &aKey, bool = false); - - /// Get field. - // Version for non-constant object. - virtual AcceleratingField &getField(); - - /// Get field. - // Version for constant object. - virtual const AcceleratingField &getField() const; - - /// Get geometry. - // Return the element geometry. - // Version for non-constant object. - virtual StraightGeometry &getGeometry(); - - /// Get geometry. - // Return the element geometry - // Version for constant object. - virtual const StraightGeometry &getGeometry() const; - - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - - - -private: - - // Not implemented. - void operator=(const ParallelPlateRep &); - - /// The cavity's geometry. - StraightGeometry geometry; - - /// The cavity's field. - AcceleratingField field; - - -}; - -#endif // CLASSIC_ParallelPlateRep_HH diff --git a/src/Classic/BeamlineCore/PatchRep.cpp b/src/Classic/BeamlineCore/PatchRep.cpp deleted file mode 100644 index cbbbd6a9ba1695351872ee207098476f56d323dc..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineCore/PatchRep.cpp +++ /dev/null @@ -1,228 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: PatchRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: PatchRep -// Defines a concrete representation for a geometry patch. -// -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:33 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "BeamlineCore/PatchRep.h" -#include "AbsBeamline/ElementImage.h" -#include "Channels/IndirectChannel.h" - - -// Attribute access table. -// ------------------------------------------------------------------------ - -namespace { - struct Entry { - const char *name; - double(PatchRep::*get)() const; - void (PatchRep::*set)(double); - }; - - const Entry entries[] = { - { - "X", - &PatchRep::getX, - &PatchRep::setX - }, - { - "Y", - &PatchRep::getY, - &PatchRep::setY - }, - { - "Z", - &PatchRep::getZ, - &PatchRep::setZ - }, - { - "VX", - &PatchRep::getVX, - &PatchRep::setVX - }, - { - "VY", - &PatchRep::getVY, - &PatchRep::setVY - }, - { - "VZ", - &PatchRep::getVZ, - &PatchRep::setVZ - }, - { 0, 0, 0 } - }; -} - - -// Class PatchRep -// ------------------------------------------------------------------------ - -PatchRep::PatchRep(): - Patch(), geometry(), patch() -{} - - -PatchRep::PatchRep(const PatchRep &rhs): - Patch(rhs), geometry(), patch(rhs.patch) -{} - - -PatchRep::PatchRep(const std::string &name): - Patch(name), geometry(), patch() -{} - - -PatchRep::~PatchRep() -{} - - -ElementBase *PatchRep::clone() const { - return new PatchRep(*this); -} - - -Channel *PatchRep::getChannel(const std::string &aKey, bool create) { - for(const Entry *entry = entries; entry->name != 0; ++entry) { - if(aKey == entry->name) { - return new IndirectChannel<PatchRep>(*this, entry->get, entry->set); - } - } - - return ElementBase::getChannel(aKey, create); -} - - -NullField &PatchRep::getField() { - return field; -} - -const NullField &PatchRep::getField() const { - return field; -} - - -NullGeometry &PatchRep::getGeometry() { - return geometry; -} - - -const NullGeometry &PatchRep::getGeometry() const { - return geometry; -} - - -const Euclid3D &PatchRep::getPatch() const { - return patch; -} - - -void PatchRep::setPatch(const Euclid3D &p) { - patch = p; -} - - -void PatchRep::setPatch(double x, double y, double z, - double vx, double vy, double vz) { - patch = Euclid3D(x, y, z, vx, vy, vz); -} - - -ElementImage *PatchRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - - -double PatchRep::getX() const { - return patch.getX(); -} - - -double PatchRep::getY() const { - return patch.getY(); -} - - -double PatchRep::getZ() const { - return patch.getZ(); -} - - -double PatchRep::getVX() const { - double vx, vy, vz; - patch.getRotation().getAxis(vx, vy, vz); - return vx; -} - - -double PatchRep::getVY() const { - double vx, vy, vz; - patch.getRotation().getAxis(vx, vy, vz); - return vy; -} - - -double PatchRep::getVZ() const { - double vx, vy, vz; - patch.getRotation().getAxis(vx, vy, vz); - return vz; -} - - -void PatchRep::setX(double x) { - patch.setX(x); -} - - -void PatchRep::setY(double y) { - patch.setY(y); -} - - -void PatchRep::setZ(double z) { - patch.setZ(z); -} - - -void PatchRep::setVX(double v) { - double vx, vy, vz; - patch.getRotation().getAxis(vx, vy, vz); - vx = v; - patch.setRotation(Rotation3D(vx, vy, vz)); -} - - -void PatchRep::setVY(double v) { - double vx, vy, vz; - patch.getRotation().getAxis(vx, vy, vz); - vy = v; - patch.setRotation(Rotation3D(vx, vy, vz)); -} - - -void PatchRep::setVZ(double v) { - double vx, vy, vz; - patch.getRotation().getAxis(vx, vy, vz); - vz = v; - patch.setRotation(Rotation3D(vx, vy, vz)); -} diff --git a/src/Classic/BeamlineCore/PatchRep.h b/src/Classic/BeamlineCore/PatchRep.h deleted file mode 100644 index 2e68bc6640b288e13c922c9e09c54db74dbff492..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineCore/PatchRep.h +++ /dev/null @@ -1,152 +0,0 @@ -#ifndef CLASSIC_PatchRep_HH -#define CLASSIC_PatchRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: PatchRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: PatchRep -// -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/Patch.h" -#include "BeamlineGeometry/Euclid3D.h" -#include "BeamlineGeometry/NullGeometry.h" -#include "Fields/NullField.h" - - -// Class PatchRep -// ------------------------------------------------------------------------ -/// Representation for a geometry patch. - -class PatchRep: public Patch { - -public: - - /// Constructor with given name. - explicit PatchRep(const std::string &name); - - PatchRep(); - PatchRep(const PatchRep &); - virtual ~PatchRep(); - - /// Return clone. - // Return an identical deep copy of the element. - virtual ElementBase *clone() const; - - /// Construct a read/write channel. - // This method constructs a Channel permitting read/write access to - // the attribute [b]aKey[/b] and returns it. - // If the attribute does not exist, it returns NULL. - virtual Channel *getChannel(const std::string &aKey, bool = false); - - /// Get field. - // Version for non-constant object. - virtual NullField &getField(); - - /// Get field. - // Version for constant object. - virtual const NullField &getField() const; - - /// Get geometry. - // Version for non-constant object. - virtual NullGeometry &getGeometry(); - - /// Get geometry. - // Version for constant object. - virtual const NullGeometry &getGeometry() const; - - /// Get patch. - // Return the geometric patch to transform from input to output. - virtual const Euclid3D &getPatch() const; - - /// Set patch. - // Assign the geometric patch to transform from input to output. - void setPatch(const Euclid3D &euclid); - - /// Set patch. - // Assign the geometric patch to transform from input to output, - // using the displacement (x,y,z) and the rotation vector (vx,vy,vz). - void setPatch(double x, double y, double z, - double vx, double vy, double vz); - - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - - /// Get displacement. - // Return the x-displacement. - double getX() const; - - /// Get displacement. - // Return the y-displacement. - double getY() const; - - /// Get displacement. - // Return the z-displacement. - double getZ() const; - - /// Get rotation. - // Return the rotation around the x-axis - double getVX() const; - - /// Get rotation. - // Return the rotation around the y-axis - double getVY() const; - - /// Get rotation. - // Return the rotation around the z-axis - double getVZ() const; - - /// Set displacement. - // Assign the x-displacement. - void setX(double); - - /// Set displacement. - // Assign the y-displacement. - void setY(double); - - /// Set displacement. - // Assign the z-displacement. - void setZ(double); - - /// Set rotation. - // Assign the rotation around the x-axis - void setVX(double); - - /// Set rotation. - // Assign the rotation around the y-axis - void setVY(double); - - /// Set rotation. - // Assign the rotation around the z-axis - void setVZ(double); - -private: - - // Not implemented. - void operator=(const PatchRep &); - - /// The zero magnetic field. - NullField field; - - /// The geometry. - NullGeometry geometry; - - /// The geometry patch. - Euclid3D patch; -}; - -#endif // CLASSIC_PatchRep_HH diff --git a/src/Classic/BeamlineCore/ProbeRep.cpp b/src/Classic/BeamlineCore/ProbeRep.cpp index db661fcddcf12c4163a9048176b562c87ba1d35c..054fd6fe895f8264eb744141beb812c61b21f997 100644 --- a/src/Classic/BeamlineCore/ProbeRep.cpp +++ b/src/Classic/BeamlineCore/ProbeRep.cpp @@ -1,31 +1,24 @@ -// ------------------------------------------------------------------------ -// $RCSfile: ProbeRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: ProbeRep -// Defines a representation for a septa. +// Class ProbeRep +// Representation for Probe. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2009/10/07 10:26:06 $ -// $Author: bi $ +// 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 "BeamlineCore/ProbeRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" -// Attribute access table. -// ------------------------------------------------------------------------ - namespace { struct Entry { const char *name; @@ -44,9 +37,6 @@ namespace { } -// Class ProbeRep -// ------------------------------------------------------------------------ - ProbeRep::ProbeRep(): Probe(), field(), geometry(), active(true) {} @@ -98,16 +88,6 @@ const StraightGeometry &ProbeRep::getGeometry() const { } -ElementImage *ProbeRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - void ProbeRep::setActive(bool flag) { active = flag; } diff --git a/src/Classic/BeamlineCore/ProbeRep.h b/src/Classic/BeamlineCore/ProbeRep.h index cf4a4719acf11dfc1826da7ee1003be352b12014..47a584001cce93ad624394007518588f0758d3ed 100644 --- a/src/Classic/BeamlineCore/ProbeRep.h +++ b/src/Classic/BeamlineCore/ProbeRep.h @@ -1,33 +1,27 @@ -#ifndef CLASSIC_ProbeRep_HH -#define CLASSIC_ProbeRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: ProbeRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: ProbeRep +// Class ProbeRep +// Representation for Probe. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// 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. // -// $Date: 2009/10/07 10:21:06 $ -// $Author: bi $ +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // -// ------------------------------------------------------------------------ +#ifndef CLASSIC_ProbeRep_HH +#define CLASSIC_ProbeRep_HH #include "AbsBeamline/Probe.h" #include "BeamlineGeometry/StraightGeometry.h" #include "Fields/NullField.h" -// Class ProbeRep -// ------------------------------------------------------------------------ -/// Representation for Probe. - class ProbeRep: public Probe { public: @@ -70,11 +64,6 @@ public: // Version for constant object. virtual const StraightGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /// Set active flag. virtual void setActive(bool = true); diff --git a/src/Classic/BeamlineCore/RBendRep.cpp b/src/Classic/BeamlineCore/RBendRep.cpp index 8096f02c7a7b732ee5997d466fe2561bf8f82f87..7b43f9af9bc8b6549c075801ab00158b47dde504 100644 --- a/src/Classic/BeamlineCore/RBendRep.cpp +++ b/src/Classic/BeamlineCore/RBendRep.cpp @@ -18,7 +18,6 @@ // along with OPAL. If not, see <https://www.gnu.org/licenses/>. // #include "BeamlineCore/RBendRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndexedChannel.h" #include "Channels/IndirectChannel.h" #include <cctype> @@ -103,17 +102,6 @@ const RBendGeometry &RBendRep::getGeometry() const { } -ElementImage *RBendRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - - double RBendRep::getB() const { return field.getNormalComponent(1); } diff --git a/src/Classic/BeamlineCore/RBendRep.h b/src/Classic/BeamlineCore/RBendRep.h index 48d128ce6791329cffb16c666caaca3b6b54e62a..f1f85b6efac0c5f70deb546c7f725d1e5834a1cf 100644 --- a/src/Classic/BeamlineCore/RBendRep.h +++ b/src/Classic/BeamlineCore/RBendRep.h @@ -62,11 +62,6 @@ public: // Version for constant object. virtual const RBendGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /// Get field. // Return the vertical component of the field in Teslas. virtual double getB() const; diff --git a/src/Classic/BeamlineCore/RFCavityRep.cpp b/src/Classic/BeamlineCore/RFCavityRep.cpp index 5e67daecdf8e2d8455bf906865f0349122d69c48..ceef4b703492e805ef4e5c0f711e288316ae30ce 100644 --- a/src/Classic/BeamlineCore/RFCavityRep.cpp +++ b/src/Classic/BeamlineCore/RFCavityRep.cpp @@ -1,31 +1,24 @@ -// ------------------------------------------------------------------------ -// $RCSfile: RFCavityRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: RFCavityRep -// Defines a representation for a RF cavity. +// Class RFCavityRep +// Representation for a RF cavity. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ +// 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 "BeamlineCore/RFCavityRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" -// Attribute access table. -// ------------------------------------------------------------------------ - bool RFCavityRep::ignoreCavities = false; namespace { @@ -61,9 +54,6 @@ namespace { } -// Class RFCavityRep -// ------------------------------------------------------------------------ - RFCavityRep::RFCavityRep(): RFCavity() {} @@ -118,17 +108,6 @@ const StraightGeometry &RFCavityRep::getGeometry() const { } -ElementImage *RFCavityRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - - double RFCavityRep::getAmplitude() const { return ignoreCavities ? 0.0 : field.getEz(); } diff --git a/src/Classic/BeamlineCore/RFCavityRep.h b/src/Classic/BeamlineCore/RFCavityRep.h index 94572ae5aadea909a90d2a93384e5a297e309f3f..acbd9ac46b4df08fb71003ab694b4af6c7632d96 100644 --- a/src/Classic/BeamlineCore/RFCavityRep.h +++ b/src/Classic/BeamlineCore/RFCavityRep.h @@ -1,34 +1,28 @@ -#ifndef CLASSIC_RFCavityRep_HH -#define CLASSIC_RFCavityRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: RFCavityRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: RFCavityRep +// Class RFCavityRep +// Representation for a RF cavity. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// 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. // -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // -// ------------------------------------------------------------------------ +#ifndef CLASSIC_RFCavityRep_HH +#define CLASSIC_RFCavityRep_HH #include "AbsBeamline/RFCavity.h" #include "BeamlineGeometry/StraightGeometry.h" #include "Fields/AcceleratingField.h" -// Class RFCavityRep -// ------------------------------------------------------------------------ -/// Representation for a RF cavity. - class RFCavityRep: public RFCavity { public: @@ -68,11 +62,6 @@ public: // Version for constant object. virtual const StraightGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /// Get amplitude. // Return the RF amplitude in Volts. virtual double getAmplitude() const; diff --git a/src/Classic/BeamlineCore/SBendRep.cpp b/src/Classic/BeamlineCore/SBendRep.cpp index f18e1954719f2dd4da22c7cbf54bf967f7514515..c1e44497218c444d26bf427c6950c9052c3a877b 100644 --- a/src/Classic/BeamlineCore/SBendRep.cpp +++ b/src/Classic/BeamlineCore/SBendRep.cpp @@ -18,7 +18,6 @@ // along with OPAL. If not, see <https://www.gnu.org/licenses/>. // #include "BeamlineCore/SBendRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndexedChannel.h" #include "Channels/IndirectChannel.h" #include <cctype> @@ -153,43 +152,6 @@ const PlanarArcGeometry &SBendRep::getGeometry() const { } -ElementImage *SBendRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *table = entries; table->name != 0; ++table) { - image->setAttribute(table->name, (this->*(table->get))()); - } - - for(int n = 1; n <= field.order(); n++) { - char buffer[20]; - char *p = buffer; - int k = n; - - while(k != 0) { - *p++ = k % 10 + '0'; - k /= 10; - } - - std::string name(" "); - while(p > buffer) name += *--p; - - double b = field.getNormalComponent(n); - if(b != 0.0) { - name[0] = 'b'; - image->setAttribute(name, b); - } - - double a = field.getSkewComponent(n); - if(a != 0.0) { - name[0] = 'a'; - image->setAttribute(name, a); - } - } - - return image; -} - - double SBendRep::getB() const { return field.getNormalComponent(1); } diff --git a/src/Classic/BeamlineCore/SBendRep.h b/src/Classic/BeamlineCore/SBendRep.h index 575f758fef70b645833d401bcf24b003523a1594..fcdb108cc00a13bd9f9060fd02354015fd07bde9 100644 --- a/src/Classic/BeamlineCore/SBendRep.h +++ b/src/Classic/BeamlineCore/SBendRep.h @@ -62,11 +62,6 @@ public: // Version for constant object. virtual const PlanarArcGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /// Get field. // Return the vertical component of the field in Teslas. virtual double getB() const; diff --git a/src/Classic/BeamlineCore/SeparatorRep.cpp b/src/Classic/BeamlineCore/SeparatorRep.cpp deleted file mode 100644 index fbdfa71a1bc6769cefb8de1ad2f191d3d3dcd863..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineCore/SeparatorRep.cpp +++ /dev/null @@ -1,147 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: SeparatorRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: SeparatorRep -// Defines the abstract interface for an electrostatic separator. -// -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "BeamlineCore/SeparatorRep.h" -#include "AbsBeamline/ElementImage.h" -#include "Channels/IndirectChannel.h" - - -// Attribute access table. -// ------------------------------------------------------------------------ - -namespace { - struct Entry { - const char *name; - double(SeparatorRep::*get)() const; - void (SeparatorRep::*set)(double); - }; - - const Entry entries[] = { - { - "L", - &SeparatorRep::getElementLength, - &SeparatorRep::setElementLength - }, - { - "EX", - &SeparatorRep::getEx, - &SeparatorRep::setEx - }, - { - "EY", - &SeparatorRep::getEy, - &SeparatorRep::setEy - }, - { 0, 0, 0 } - }; -} - - -// Class SeparatorRep -// ------------------------------------------------------------------------ - -SeparatorRep::SeparatorRep(): - Separator(), - geometry(), - field() -{} - - -SeparatorRep::SeparatorRep(const SeparatorRep &right): - Separator(right), - geometry(right.geometry), - field(right.field) -{} - - -SeparatorRep::SeparatorRep(const std::string &name): - Separator(name), - geometry(), - field() -{} - - -SeparatorRep::~SeparatorRep() -{} - - -ElementBase *SeparatorRep::clone() const { - return new SeparatorRep(*this); -} - - -Channel *SeparatorRep::getChannel(const std::string &aKey, bool create) { - for(const Entry *table = entries; table->name != 0; ++table) { - if(aKey == table->name) { - return new IndirectChannel<SeparatorRep>(*this, table->get, table->set); - } - } - - return ElementBase::getChannel(aKey, create); -} - - -EDipoleField &SeparatorRep::getField() { - return field; -} - -const EDipoleField &SeparatorRep::getField() const { - return field; -} - - -StraightGeometry &SeparatorRep::getGeometry() { - return geometry; -} - -const StraightGeometry &SeparatorRep::getGeometry() const { - return geometry; -} - - -ElementImage *SeparatorRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *table = entries; table->name != 0; ++table) { - image->setAttribute(table->name, (this->*(table->get))()); - } - - return image; -} - - -double SeparatorRep::getEx() const { - return field.getEx(); -} - - -double SeparatorRep::getEy() const { - return field.getEy(); -} - - -void SeparatorRep::setEx(double value) { - field.setEx(value); -} - - -void SeparatorRep::setEy(double value) { - field.setEy(value); -} diff --git a/src/Classic/BeamlineCore/SeparatorRep.h b/src/Classic/BeamlineCore/SeparatorRep.h deleted file mode 100644 index ca132aa2acd10aa46720d064a83d258d85798430..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineCore/SeparatorRep.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef CLASSIC_SeparatorRep_HH -#define CLASSIC_SeparatorRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: SeparatorRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: SeparatorRep -// -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "AbsBeamline/Separator.h" -#include "BeamlineGeometry/StraightGeometry.h" -#include "Fields/EDipoleField.h" - - -// Class SeparatorRep -// ------------------------------------------------------------------------ -/// Representation for an electrostatic separator. - -class SeparatorRep: public Separator { - -public: - - /// Constructor with given name. - explicit SeparatorRep(const std::string &name); - - SeparatorRep(); - SeparatorRep(const SeparatorRep &); - virtual ~SeparatorRep(); - - /// Return clone. - // Return an identical deep copy of the element. - virtual ElementBase *clone() const; - - /// Construct a read/write channel. - // This method constructs a Channel permitting read/write access to - // the attribute [b]aKey[/b] and returns it. - // If the attribute does not exist, it returns NULL. - virtual Channel *getChannel(const std::string &aKey, bool = false); - - /// Get field. - // Version for non-constant object. - virtual EDipoleField &getField(); - - /// Get field. - // Version for constant object. - virtual const EDipoleField &getField() const; - - /// Get geometry. - // Version for non-constant object. - virtual StraightGeometry &getGeometry(); - - /// Get geometry. - // Version for constant object. - virtual const StraightGeometry &getGeometry() const; - - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - - /// Get component. - // Return the x-component of the electric field in A/m. - virtual double getEx() const; - - /// Get component. - // Return the y-component of the electric field in A/m. - virtual double getEy() const; - - /// Set component. - // Assign the x-component of the electric field in A/m. - virtual void setEx(double Ex); - - /// Set component. - // Assign the y-component of the electric field in A/m. - virtual void setEy(double Ey); - -private: - - // Not implemented. - void operator=(const SeparatorRep &); - - /// The separator geometry. - StraightGeometry geometry; - - /// The separator field. - EDipoleField field; -}; - -#endif // CLASSIC_SeparatorRep_HH diff --git a/src/Classic/BeamlineCore/SeptumRep.cpp b/src/Classic/BeamlineCore/SeptumRep.cpp index e6d77a0016f56f409679d8a5a58211fd28d01e3b..08cf73927555693cc5e93c172bd82c83c6df362f 100644 --- a/src/Classic/BeamlineCore/SeptumRep.cpp +++ b/src/Classic/BeamlineCore/SeptumRep.cpp @@ -1,31 +1,23 @@ -// ------------------------------------------------------------------------ -// $RCSfile: SeptumRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: SeptumRep -// Defines a representation for a septa. +// Class SeptumRep +// Representation for Septum. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2009/09/21 10:26:06 $ -// $Author: bi $ +// 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 "BeamlineCore/SeptumRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" - -// Attribute access table. -// ------------------------------------------------------------------------ - namespace { struct Entry { const char *name; @@ -44,9 +36,6 @@ namespace { } -// Class SeptumRep -// ------------------------------------------------------------------------ - SeptumRep::SeptumRep(): Septum(), field(), geometry(), active(true) {} @@ -98,16 +87,6 @@ const StraightGeometry &SeptumRep::getGeometry() const { } -ElementImage *SeptumRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - void SeptumRep::setActive(bool flag) { active = flag; } diff --git a/src/Classic/BeamlineCore/SeptumRep.h b/src/Classic/BeamlineCore/SeptumRep.h index f44ba4ca9c4ec4289e533216ede8e04117e55775..18a586367daf882a82783ae4eb95e281d78e22c1 100644 --- a/src/Classic/BeamlineCore/SeptumRep.h +++ b/src/Classic/BeamlineCore/SeptumRep.h @@ -1,33 +1,27 @@ -#ifndef CLASSIC_SeptumRep_HH -#define CLASSIC_SeptumRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: SeptumRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: SeptumRep +// Class SeptumRep +// Representation for Septum. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// 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. // -// $Date: 2009/09/21 10:21:06 $ -// $Author: bi $ +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // -// ------------------------------------------------------------------------ +#ifndef CLASSIC_SeptumRep_HH +#define CLASSIC_SeptumRep_HH #include "AbsBeamline/Septum.h" #include "BeamlineGeometry/StraightGeometry.h" #include "Fields/NullField.h" -// Class SeptumRep -// ------------------------------------------------------------------------ -/// Representation for Septum. - class SeptumRep: public Septum { public: @@ -70,11 +64,6 @@ public: // Version for constant object. virtual const StraightGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /// Set active flag. virtual void setActive(bool = true); diff --git a/src/Classic/BeamlineCore/SingleMultipole.h b/src/Classic/BeamlineCore/SingleMultipole.h index 5117d8d3d102808b5fac79ad63e7fc9468588ad9..c85e27ec5d88b12eb243ca9eb8c0d8f6c854aef9 100644 --- a/src/Classic/BeamlineCore/SingleMultipole.h +++ b/src/Classic/BeamlineCore/SingleMultipole.h @@ -38,7 +38,6 @@ #define CLASSIC_SingleMultipole_HH #include "AbsBeamline/Multipole.h" -#include "AbsBeamline/ElementImage.h" #include "BeamlineGeometry/StraightGeometry.h" #include "Channels/IndirectChannel.h" #include "Fields/BSingleMultipoleField.h" @@ -90,11 +89,6 @@ public: // If the attribute does not exist, it returns NULL. virtual Channel *getChannel(const std::string &aKey, bool = false); - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - ElementImage *getImage() const; - private: // Not implemented. @@ -211,17 +205,4 @@ Channel *SingleMultipole<order>::getChannel(const std::string &aKey, bool) { return ElementBase::getChannel(aKey); } - -template <int order> inline -ElementImage *SingleMultipole<order>::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - - #endif // __SingleMultipole_HH diff --git a/src/Classic/BeamlineCore/SolenoidRep.cpp b/src/Classic/BeamlineCore/SolenoidRep.cpp index b0b3caf0817cf8739d08a6adb893e61f8ccbd850..ea163238cb8f871e3b4a6222055bda52c8451fd3 100644 --- a/src/Classic/BeamlineCore/SolenoidRep.cpp +++ b/src/Classic/BeamlineCore/SolenoidRep.cpp @@ -1,31 +1,23 @@ -// ------------------------------------------------------------------------ -// $RCSfile: SolenoidRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: SolenoidRep -// Defines a concrete representation for a solenoid. +// Class SolenoidRep +// Representation for a solenoid magnet. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ +// 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 "BeamlineCore/SolenoidRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" - -// Attribute access table. -// ------------------------------------------------------------------------ - namespace { struct Entry { const char *name; @@ -49,9 +41,6 @@ namespace { } -// Class SolenoidRep -// ------------------------------------------------------------------------ - SolenoidRep::SolenoidRep(): Solenoid(), geometry(), @@ -109,17 +98,6 @@ const StraightGeometry &SolenoidRep::getGeometry() const { } -ElementImage *SolenoidRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - - double SolenoidRep::getBz() const { return field.getBz(); } diff --git a/src/Classic/BeamlineCore/SolenoidRep.h b/src/Classic/BeamlineCore/SolenoidRep.h index 280fd76d6860c70feb053a5b3333cea7d9da5ffb..25853247b2f31b0b6e9be0a17d8d8595f93735c7 100644 --- a/src/Classic/BeamlineCore/SolenoidRep.h +++ b/src/Classic/BeamlineCore/SolenoidRep.h @@ -1,34 +1,28 @@ -#ifndef CLASSIC_SolenoidRep_HH -#define CLASSIC_SolenoidRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: SolenoidRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: SolenoidRep +// Class SolenoidRep +// Representation for a solenoid magnet. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// 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. // -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // -// ------------------------------------------------------------------------ +#ifndef CLASSIC_SolenoidRep_HH +#define CLASSIC_SolenoidRep_HH #include "AbsBeamline/Solenoid.h" #include "BeamlineGeometry/StraightGeometry.h" #include "Fields/ConstBzField.h" -// Class SolenoidRep -// ------------------------------------------------------------------------ -/// Tepresentation for a solenoid magnet. - class SolenoidRep: public Solenoid { public: @@ -66,11 +60,6 @@ public: // Version for constant object. virtual const StraightGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /// Get field. // Return the solenoid field in Teslas. virtual double getBz() const; diff --git a/src/Classic/BeamlineCore/SourceRep.cpp b/src/Classic/BeamlineCore/SourceRep.cpp index f2d74808582143ac028e3ff7c34e95ac82965e6f..dc39c8dc90fc9527b8631de53ad312630106b28a 100644 --- a/src/Classic/BeamlineCore/SourceRep.cpp +++ b/src/Classic/BeamlineCore/SourceRep.cpp @@ -1,11 +1,23 @@ +// +// Class SourceRep +// Representation for a source. +// +// Copyright (c) 200x - 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 "BeamlineCore/SourceRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" - -// Attribute access table. -// ------------------------------------------------------------------------ - namespace { struct Entry { const char *name; @@ -24,9 +36,6 @@ namespace { } -// Class SourceRep -// ------------------------------------------------------------------------ - SourceRep::SourceRep(): Source(), geometry() @@ -77,15 +86,4 @@ StraightGeometry &SourceRep::getGeometry() { const StraightGeometry &SourceRep::getGeometry() const { return geometry; -} - - -ElementImage *SourceRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; } \ No newline at end of file diff --git a/src/Classic/BeamlineCore/SourceRep.h b/src/Classic/BeamlineCore/SourceRep.h index f037a8130164a71b33549d41315d78471ab61b06..31290a40d2bf935e428bed44e2b95d86abca1c77 100644 --- a/src/Classic/BeamlineCore/SourceRep.h +++ b/src/Classic/BeamlineCore/SourceRep.h @@ -1,34 +1,28 @@ -#ifndef CLASSIC_SOURCEREP_HH -#define CLASSIC_SOURCEREP_HH - -// ------------------------------------------------------------------------ -// $RCSfile: SourceRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: SourceRep +// Class SourceRep +// Representation for a source. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// 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. // -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // -// ------------------------------------------------------------------------ +#ifndef CLASSIC_SOURCEREP_HH +#define CLASSIC_SOURCEREP_HH #include "AbsBeamline/Source.h" #include "BeamlineGeometry/StraightGeometry.h" #include "Fields/NullField.h" -// Class SourceRep -// ------------------------------------------------------------------------ -/// Tepresentation for a solenoid magnet. - class SourceRep: public Source { public: @@ -66,11 +60,6 @@ public: // Version for constant object. virtual const StraightGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - private: // Not implemented. diff --git a/src/Classic/BeamlineCore/StripperRep.cpp b/src/Classic/BeamlineCore/StripperRep.cpp index abef05bb3d604873ed84c7417b75d220021118ff..9b564f74c70e4a077dea7bffa47107bdde40068b 100644 --- a/src/Classic/BeamlineCore/StripperRep.cpp +++ b/src/Classic/BeamlineCore/StripperRep.cpp @@ -24,7 +24,6 @@ // along with OPAL. If not, see <https://www.gnu.org/licenses/>. // #include "BeamlineCore/StripperRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" @@ -102,17 +101,6 @@ const StraightGeometry &StripperRep::getGeometry() const { return geometry; } - -ElementImage *StripperRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - void StripperRep::setActive(bool flag) { active = flag; } diff --git a/src/Classic/BeamlineCore/StripperRep.h b/src/Classic/BeamlineCore/StripperRep.h index e79de1e80c3e9f01b2fe61fad9660b22a1a7a07b..3341a63acb9d4be2c29c9503d1ada371294c780f 100644 --- a/src/Classic/BeamlineCore/StripperRep.h +++ b/src/Classic/BeamlineCore/StripperRep.h @@ -72,11 +72,6 @@ public: // Version for constant object. virtual const StraightGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /// Set active flag. virtual void setActive(bool = true); diff --git a/src/Classic/BeamlineCore/TravelingWaveRep.cpp b/src/Classic/BeamlineCore/TravelingWaveRep.cpp index dd5d722e093be1795555a1e356fa44a64f47cfdb..b682ddd807cd9ef70b21b2b24a8e00b76e4ac38c 100644 --- a/src/Classic/BeamlineCore/TravelingWaveRep.cpp +++ b/src/Classic/BeamlineCore/TravelingWaveRep.cpp @@ -1,31 +1,23 @@ -// ------------------------------------------------------------------------ -// $RCSfile: RFCavityRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: RFCavityRep -// Defines a representation for a RF cavity. +// Class TravelingWaveRep +// Representation for a traveling wave. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ +// 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 "BeamlineCore/TravelingWaveRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" - -// Attribute access table. -// ------------------------------------------------------------------------ - bool TravelingWaveRep::ignoreCavities = false; namespace { @@ -61,9 +53,6 @@ namespace { } -// Class TravelingWaveRep -// ------------------------------------------------------------------------ - TravelingWaveRep::TravelingWaveRep(): TravelingWave() {} @@ -118,17 +107,6 @@ const StraightGeometry &TravelingWaveRep::getGeometry() const { } -ElementImage *TravelingWaveRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - - double TravelingWaveRep::getAmplitude() const { return ignoreCavities ? 0.0 : field.getEz(); } diff --git a/src/Classic/BeamlineCore/TravelingWaveRep.h b/src/Classic/BeamlineCore/TravelingWaveRep.h index 2127bc3ddd1c0a94bb344a4cfd0f28684ff6e928..b8cfe86004013aac745565b599e675a6052e7cc0 100644 --- a/src/Classic/BeamlineCore/TravelingWaveRep.h +++ b/src/Classic/BeamlineCore/TravelingWaveRep.h @@ -1,34 +1,28 @@ -#ifndef CLASSIC_TravelingWaveRep_HH -#define CLASSIC_TravelingWaveRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: TravelingWaveRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: TravelingWaveRep +// Class TravelingWaveRep +// Representation for a traveling wave. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// 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. // -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // -// ------------------------------------------------------------------------ +#ifndef CLASSIC_TravelingWaveRep_HH +#define CLASSIC_TravelingWaveRep_HH #include "AbsBeamline/TravelingWave.h" #include "BeamlineGeometry/StraightGeometry.h" #include "Fields/AcceleratingField.h" -// Class TravelingWaveRep -// ------------------------------------------------------------------------ -/// Representation for a RF cavity. - class TravelingWaveRep: public TravelingWave { public: @@ -68,11 +62,6 @@ public: // Version for constant object. virtual const StraightGeometry &getGeometry() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /// Get amplitude. // Return the RF amplitude in Volts. virtual double getAmplitude() const; diff --git a/src/Classic/BeamlineCore/XCorrectorRep.cpp b/src/Classic/BeamlineCore/XCorrectorRep.cpp index 02d23d6d9f1a67e324b7c2f5ff0d179cf1613304..72b20c501a3e43d68f8bf5508f2439c52346c9d4 100644 --- a/src/Classic/BeamlineCore/XCorrectorRep.cpp +++ b/src/Classic/BeamlineCore/XCorrectorRep.cpp @@ -1,34 +1,24 @@ -// ------------------------------------------------------------------------ -// $RCSfile: XCorrectorRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: XCorrectorRep -// Defines a concrete representation for a horizontal orbit corrector. +// Class XCorrectorRep +// Representation for an orbit corrector. +// This derived class acts on the horizontal plane. // -// ------------------------------------------------------------------------ -// 02-Nov-98, Chris Iselin, CERN -// Original release. -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// Revision History: -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ +// 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 "BeamlineCore/XCorrectorRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" - -// Attribute access table. -// ------------------------------------------------------------------------ - namespace { struct Entry { const char *name; @@ -52,9 +42,6 @@ namespace { } -// Class XCorrectorRep -// ------------------------------------------------------------------------ - XCorrectorRep::XCorrectorRep(): CorrectorRep() {} @@ -89,18 +76,6 @@ Channel *XCorrectorRep::getChannel(const std::string &aKey, bool create) { return ElementBase::getChannel(aKey, create); } - -ElementImage *XCorrectorRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - - Corrector::Plane XCorrectorRep::getPlane() const { return active ? X : OFF; } diff --git a/src/Classic/BeamlineCore/XCorrectorRep.h b/src/Classic/BeamlineCore/XCorrectorRep.h index 523cba92b4d3a527c3d1415b6df8e9c51c6df50d..d99c5aafd30e8930fd81653078bfa70cec15299b 100644 --- a/src/Classic/BeamlineCore/XCorrectorRep.h +++ b/src/Classic/BeamlineCore/XCorrectorRep.h @@ -1,33 +1,27 @@ -#ifndef CLASSIC_XCorrectorRep_HH -#define CLASSIC_XCorrectorRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: XCorrectorRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: XCorrectorRep +// Class XCorrectorRep +// Representation for an orbit corrector. +// This derived class acts on the horizontal plane. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// 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. // -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // -// ------------------------------------------------------------------------ +#ifndef CLASSIC_XCorrectorRep_HH +#define CLASSIC_XCorrectorRep_HH #include "BeamlineCore/CorrectorRep.h" -// Class XCorrectorRep -// ------------------------------------------------------------------------ -/// Representation for an orbit corrector. -// This derived class acts on the horizontal plane. - class XCorrectorRep: public CorrectorRep { public: @@ -49,11 +43,6 @@ public: // If the attribute does not exist, it returns NULL. virtual Channel *getChannel(const std::string &aKey, bool = false); - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /// Get plane of action. // Return the x-plane for this class. virtual Plane getPlane() const; diff --git a/src/Classic/BeamlineCore/XMonitorRep.cpp b/src/Classic/BeamlineCore/XMonitorRep.cpp deleted file mode 100644 index f56f7620c369b4c7175d5c42d1fc0ec59ad87e1e..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineCore/XMonitorRep.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: XMonitorRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: XMonitorRep -// Defines a concrete representation for a horizontal orbit monitor. -// -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "BeamlineCore/XMonitorRep.h" -#include "AbsBeamline/ElementImage.h" -#include "Channels/IndirectChannel.h" - - -// Attribute access table. -// ------------------------------------------------------------------------ - -namespace { - struct Entry { - const char *name; - double(XMonitorRep::*get)() const; - void (XMonitorRep::*set)(double); - }; - - const Entry entries[] = { - { - "L", - &XMonitorRep::getElementLength, - &XMonitorRep::setElementLength - }, - { 0, 0, 0 } - }; -} - - -// Class XMonitorRep -// ------------------------------------------------------------------------ - -XMonitorRep::XMonitorRep(): - MonitorRep() -{} - - -XMonitorRep::XMonitorRep(const XMonitorRep &rhs): - MonitorRep(rhs) -{} - - -XMonitorRep::XMonitorRep(const std::string &name): - MonitorRep(name) -{} - - -XMonitorRep::~XMonitorRep() -{} - - -ElementBase *XMonitorRep::clone() const { - return new XMonitorRep(*this); -} - - -Channel *XMonitorRep::getChannel(const std::string &aKey, bool create) { - for(const Entry *entry = entries; entry->name != 0; ++entry) { - if(aKey == entry->name) { - return new IndirectChannel<XMonitorRep>(*this, entry->get, entry->set); - } - } - - return ElementBase::getChannel(aKey, create); -} - - -ElementImage *XMonitorRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - - -Monitor::Plane XMonitorRep::getPlane() const { - return active ? X : OFF; -} diff --git a/src/Classic/BeamlineCore/XMonitorRep.h b/src/Classic/BeamlineCore/XMonitorRep.h deleted file mode 100644 index f73f9fd9274e95d686d13d3cf5f1b8fdbc7aafdb..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineCore/XMonitorRep.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef CLASSIC_XMonitorRep_HH -#define CLASSIC_XMonitorRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: XMonitorRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: XMonitorRep -// -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "BeamlineCore/MonitorRep.h" - - -// Class XMonitorRep -// ------------------------------------------------------------------------ -/// Representation for a orbit position monitor. -// Acts on the horizontal plane. - -class XMonitorRep: public MonitorRep { - -public: - - /// Constructor with given name. - explicit XMonitorRep(const std::string &name); - - XMonitorRep(); - XMonitorRep(const XMonitorRep &); - virtual ~XMonitorRep(); - - /// Return clone. - // Return an identical deep copy of the element. - virtual ElementBase *clone() const; - - /// Construct a read/write channel. - // This method constructs a Channel permitting read/write access to - // the attribute [b]aKey[/b] and returns it. - // If the attribute does not exist, it returns NULL. - virtual Channel *getChannel(const std::string &aKey, bool = false); - - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - - /// Get plane. - // Return the x-plane for this class. - virtual Plane getPlane() const; - -private: - - // Not implemented. - void operator=(const XMonitorRep &); -}; - -#endif // CLASSIC_XMonitorRep_HH diff --git a/src/Classic/BeamlineCore/YCorrectorRep.cpp b/src/Classic/BeamlineCore/YCorrectorRep.cpp index 74bb8c9a72b092298e3b08782c76aa892464528b..e4bce750076d96f054b629e83403d9f8fd2f6c7f 100644 --- a/src/Classic/BeamlineCore/YCorrectorRep.cpp +++ b/src/Classic/BeamlineCore/YCorrectorRep.cpp @@ -1,31 +1,24 @@ -// ------------------------------------------------------------------------ -// $RCSfile: YCorrectorRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: YCorrectorRep -// Defines a concrete representation for a vertical orbit corrector. +// Class YCorrectorRep +// Representation for an orbit corrector. +// Acts on the vertical plane. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ +// 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 "BeamlineCore/YCorrectorRep.h" -#include "AbsBeamline/ElementImage.h" #include "Channels/IndirectChannel.h" - -// Attribute access table. -// ------------------------------------------------------------------------ - namespace { struct Entry { const char *name; @@ -49,9 +42,6 @@ namespace { } -// Class YCorrectorRep -// ------------------------------------------------------------------------ - YCorrectorRep::YCorrectorRep(): CorrectorRep() {} @@ -87,17 +77,6 @@ Channel *YCorrectorRep::getChannel(const std::string &aKey, bool create) { } -ElementImage *YCorrectorRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - - Corrector::Plane YCorrectorRep::getPlane() const { return Y; } diff --git a/src/Classic/BeamlineCore/YCorrectorRep.h b/src/Classic/BeamlineCore/YCorrectorRep.h index a5d389304a0b2df09e4f0415f520536081dd5824..71df24eb29d9dce128b2868e4b6874c6bd21cec8 100644 --- a/src/Classic/BeamlineCore/YCorrectorRep.h +++ b/src/Classic/BeamlineCore/YCorrectorRep.h @@ -1,33 +1,27 @@ -#ifndef CLASSIC_YCorrectorRep_HH -#define CLASSIC_YCorrectorRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: YCorrectorRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: YCorrectorRep +// Class YCorrectorRep +// Representation for an orbit corrector. +// Acts on the vertical plane. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved +// +// This file is part of OPAL. // -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ +// 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. // -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ +// You should have received a copy of the GNU General Public License +// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // -// ------------------------------------------------------------------------ +#ifndef CLASSIC_YCorrectorRep_HH +#define CLASSIC_YCorrectorRep_HH #include "BeamlineCore/CorrectorRep.h" -// Class YCorrectorRep -// ------------------------------------------------------------------------ -/// Representation for an orbit corrector. -// Acts on the vertical plane. - class YCorrectorRep: public CorrectorRep { public: @@ -49,11 +43,6 @@ public: // If the attribute does not exist, it returns NULL. virtual Channel *getChannel(const std::string &aKey, bool = false); - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /// Get plane. // Return the y-plane for this class. virtual Plane getPlane() const; diff --git a/src/Classic/BeamlineCore/YMonitorRep.cpp b/src/Classic/BeamlineCore/YMonitorRep.cpp deleted file mode 100644 index 4dc9efc49f2fa74b08aec399ddc204f1d9348de7..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineCore/YMonitorRep.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: YMonitorRep.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: YMonitorRep -// Defines a concrete representation for a vertical orbit monitor. -// -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "BeamlineCore/YMonitorRep.h" -#include "AbsBeamline/ElementImage.h" -#include "Channels/IndirectChannel.h" - - -// Attribute access table. -// ------------------------------------------------------------------------ - -namespace { - struct Entry { - const char *name; - double(YMonitorRep::*get)() const; - void (YMonitorRep::*set)(double); - }; - - const Entry entries[] = { - { - "L", - &YMonitorRep::getElementLength, - &YMonitorRep::setElementLength - }, - { 0, 0, 0 } - }; -} - - -// Class YMonitorRep -// ------------------------------------------------------------------------ - -YMonitorRep::YMonitorRep(): - MonitorRep() -{} - - -YMonitorRep::YMonitorRep(const YMonitorRep &right): - MonitorRep(right) -{} - - -YMonitorRep::YMonitorRep(const std::string &name): - MonitorRep(name) -{} - - -YMonitorRep::~YMonitorRep() -{} - - -ElementBase *YMonitorRep::clone() const { - return new YMonitorRep(*this); -} - - -Channel *YMonitorRep::getChannel(const std::string &aKey, bool create) { - for(const Entry *entry = entries; entry->name != 0; ++entry) { - if(aKey == entry->name) { - return new IndirectChannel<YMonitorRep>(*this, entry->get, entry->set); - } - } - - return ElementBase::getChannel(aKey, create); -} - - -ElementImage *YMonitorRep::getImage() const { - ElementImage *image = ElementBase::getImage(); - - for(const Entry *entry = entries; entry->name != 0; ++entry) { - image->setAttribute(entry->name, (this->*(entry->get))()); - } - - return image; -} - - -Monitor::Plane YMonitorRep::getPlane() const { - return active ? Y : OFF; -} diff --git a/src/Classic/BeamlineCore/YMonitorRep.h b/src/Classic/BeamlineCore/YMonitorRep.h deleted file mode 100644 index 74c6f4ceaf5a3af1a694965879bec8d07a75b899..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineCore/YMonitorRep.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef CLASSIC_YMonitorRep_HH -#define CLASSIC_YMonitorRep_HH - -// ------------------------------------------------------------------------ -// $RCSfile: YMonitorRep.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: YMonitorRep -// -// ------------------------------------------------------------------------ -// Class category: BeamlineCore -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "BeamlineCore/MonitorRep.h" - - -// Class YMonitorRep -// ------------------------------------------------------------------------ -/// Representation for a orbit position monitor. -// Acts on the vertical plane. - -class YMonitorRep: public MonitorRep { - -public: - - /// Constructor with given name. - explicit YMonitorRep(const std::string &name); - - YMonitorRep(); - YMonitorRep(const YMonitorRep &); - virtual ~YMonitorRep(); - - /// Return clone. - // Return an identical deep copy of the element. - virtual ElementBase *clone() const; - - /// Construct a read/write channel. - // This method constructs a Channel permitting read/write access to - // the attribute [b]aKey[/b] and returns it. - // If the attribute does not exist, it returns NULL. - virtual Channel *getChannel(const std::string &aKey, bool = false); - - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - - /// Get plane. - // Return y-plane for this class. - virtual Plane getPlane() const; - -private: - - // Not implemented. - void operator=(const YMonitorRep &); -}; - -#endif // CLASSIC_YMonitorRep_HH diff --git a/src/Classic/BeamlineGeometry/CMakeLists.txt b/src/Classic/BeamlineGeometry/CMakeLists.txt index 198080a94ea7cbfce2b761e5cd04767d616f8048..4b6adc428c77ee18b86b1af60edc2862cc2cc766 100644 --- a/src/Classic/BeamlineGeometry/CMakeLists.txt +++ b/src/Classic/BeamlineGeometry/CMakeLists.txt @@ -4,12 +4,10 @@ set (_SRCS Matrix3D.cpp Euclid3DGeometry.cpp NullGeometry.cpp - OffsetGeometry.cpp PlanarArcGeometry.cpp VarRadiusGeometry.cpp RBendGeometry.cpp Rotation3D.cpp - SRotatedGeometry.cpp StraightGeometry.cpp Vector3D.cpp ) @@ -26,12 +24,10 @@ set (HDRS Geometry.h Matrix3D.h NullGeometry.h - OffsetGeometry.h PlanarArcGeometry.h VarRadiusGeometry.h RBendGeometry.h Rotation3D.h - SRotatedGeometry.h StraightGeometry.h Vector3D.h ) diff --git a/src/Classic/BeamlineGeometry/OffsetGeometry.cpp b/src/Classic/BeamlineGeometry/OffsetGeometry.cpp deleted file mode 100644 index ca5569a20161d36002558abbf167cdae008b9894..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineGeometry/OffsetGeometry.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: OffsetGeometry.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: OffsetGeometry -// Represents a geometry which is offset with respect to some global -// (super) geometry. -// -// ------------------------------------------------------------------------ -// Class category: BeamlineGeometry -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "BeamlineGeometry/OffsetGeometry.h" - - -// Class OffsetGeometry. -// ------------------------------------------------------------------------ - -OffsetGeometry::OffsetGeometry(const BGeometryBase &g, const BGeometryBase &l, - const Euclid3D &t): - global(g), local(l), g2l(t) -{} - - -OffsetGeometry::OffsetGeometry(const BGeometryBase &g, const Euclid3D &t): - global(g), local(g), g2l(t) -{} - - -OffsetGeometry::OffsetGeometry(const OffsetGeometry &og): - BGeometryBase(og), - global(og.global), local(og.local), g2l(og.g2l) -{} - - -OffsetGeometry::~OffsetGeometry() -{} - - -double OffsetGeometry::getArcLength() const { - return global.getArcLength(); -} - - -double OffsetGeometry::getElementLength() const { - return global.getElementLength(); -} - - -Euclid3D OffsetGeometry::getGtoL() const { - return g2l; -} - - -void OffsetGeometry::setGtoL(const Euclid3D &t) { - g2l = t; -} - - -double OffsetGeometry::getOrigin() const { - return global.getOrigin(); -} - - -double OffsetGeometry::getEntrance() const { - return global.getEntrance(); -} - - -double OffsetGeometry::getExit() const { - return global.getExit(); -} - - -Euclid3D OffsetGeometry::getTransform(double fromS, double toS) const { - return global.getTransform(fromS, toS); -} - - -Euclid3D OffsetGeometry::getTotalTransform() const { - return global.getTotalTransform(); -} - - -Euclid3D OffsetGeometry::getTransform(double s) const { - return global.getTransform(s); -} - - -Euclid3D OffsetGeometry::getEntranceFrame() const { - return global.getEntranceFrame(); -} - - -Euclid3D OffsetGeometry::getExitFrame() const { - return global.getExitFrame(); -} - - -Euclid3D OffsetGeometry::getEntrancePatch() const { - return getGlobalToLocalTransform(global.getEntrance(), local.getEntrance()); -} - - -Euclid3D OffsetGeometry::getExitPatch() const { - return Inverse(getGlobalToLocalTransform(global.getExit(), local.getExit())); -} - - -Euclid3D OffsetGeometry::getGlobalToLocalTransform -(double gs, double ls) const { - Euclid3D tl = local.getTransform(ls); - Euclid3D tgi = Inverse(local.getTransform(gs)); - - return tl * g2l * tgi; -} - diff --git a/src/Classic/BeamlineGeometry/OffsetGeometry.h b/src/Classic/BeamlineGeometry/OffsetGeometry.h deleted file mode 100644 index 82ced4a7281b53b946f2786014042146166a6632..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineGeometry/OffsetGeometry.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef CLASSIC_OffsetGeometry_HH -#define CLASSIC_OffsetGeometry_HH - -// ------------------------------------------------------------------------ -// $RCSfile: OffsetGeometry.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: OffsetGeometry -// -// ------------------------------------------------------------------------ -// Class category: BeamlineGeometry -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "BeamlineGeometry/Geometry.h" -#include "BeamlineGeometry/Euclid3D.h" - -// Class OffsetGeometry -// ------------------------------------------------------------------------ -/// A geometry which offset with respect to some global geometry. -// OffsetGeometry effectively acts as a bridge between two geometries, -// designated as the global geometry and the local geometry. The global -// geometry is used to define a segment of the true global geometry, and -// so most functions are delegated to the global geometry. The local and -// global geometries are ``offset'' with respect to each other by a single -// transformation (Euclid3D object), which defines the transformation from -// the global geometry's Local Frame to the local geometry's Local Frame. -// The two patch functions return the necessary transformations to/from the -// global/local geometries. OffsetGeometry primary task is to calculate -// these two patches. Note that when OffsetGeometry is being used to model -// an alignment error, the local and global geometries can both refer to -// the same geometry. - -class OffsetGeometry : public BGeometryBase { -public: - - /// Constructor. - // Assign the [b]global[/b] and [b]local[/b] geometries, - // and the displacement [b]euclid[/b] between their origins. - OffsetGeometry - (const BGeometryBase &global, const BGeometryBase &local, const Euclid3D &euclid); - - /// Constructor. - // Both global and local geometries are set to [b]geom[/b], - // and the displacement is [b]euclid[/b]. - OffsetGeometry(const BGeometryBase &geom, const Euclid3D &euclid); - - OffsetGeometry(const OffsetGeometry &); - virtual ~OffsetGeometry(); - const OffsetGeometry &operator=(const OffsetGeometry &); - - /// Get displacement. - // Return the displacement from the global to the local origin. - Euclid3D getGtoL() const; - - /// Set displacement. - // Assign the displacement from the global to the local origin. - void setGtoL(const Euclid3D &); - - /// Get arc length. - // Return the length of the global geometry, - // measured along its design arc. - virtual double getArcLength() const; - - /// Get design length. - // Return the design length of the global geometry, - // measured along its design polygone. - virtual double getElementLength() const; - - /// Get origin. - // Return the arc length from the entrance to the origin of the - // global geometry (non-negative). - virtual double getOrigin() const; - - /// Get entrance position. - // Return the arc length from the origin to the entrance of the - // global geometry (non-positive). - virtual double getEntrance() const; - - /// Get exit position. - // Return the arc length from the origin to the exit of the - // global geometry (non-negative). - virtual double getExit() const; - - /// Get transform. - // Return the transform of the global coordinate system from the - // position [b]fromS[/b] to the position [b]toS[/b]. - virtual Euclid3D getTransform(double fromS, double toS) const; - - /// Get transform. - // Equivalent to getTransform(0.0, s). - // Return the transform of the local coordinate system from the - // global origin at [b]s[/b]. - virtual Euclid3D getTransform(double s) const; - - /// Get transform. - // Equivalent to getTransform(getEntrance(), getExit()). - // Return the transform of the global coordinate system from the - // entrance to the exit of the element. - virtual Euclid3D getTotalTransform() const; - - - /// Get transform. - // Equivalent to getTransform(0.0, getEntrance()). - // Return the transform of the local coordinate system from the - // global origin to the entrance of the element. - virtual Euclid3D getEntranceFrame() const; - - /// Get transform. - // Equivalent to getTransform(0.0, getExit()). - // Return the transform of the local coordinate system from the - // global origin to the exit of the element. - virtual Euclid3D getExitFrame() const; - - /// Get patch. - // Return the entrance patch (transformation) which is used to transform - // the global geometry to the local geometry at entrance. - virtual Euclid3D getEntrancePatch() const; - - /// Get patch. - // Returns the entrance patch (transformation) which is used to transform - // the local geometry to the global geometry at exit. - virtual Euclid3D getExitPatch() const; - - /// Transform global to local. - // Special OffsetGeometry function which calculates the transformation - // from position [b]globalS[/b] on the global geometry to position - // [b]localS[/b] on the local geometry. - Euclid3D getGlobalToLocalTransform(double globalS, double localS) const; - -private: - - const BGeometryBase &global; - const BGeometryBase &local; - Euclid3D g2l; -}; - -#endif // CLASSIC_OffsetGeometry_HH - diff --git a/src/Classic/BeamlineGeometry/SRotatedGeometry.cpp b/src/Classic/BeamlineGeometry/SRotatedGeometry.cpp deleted file mode 100644 index 9755171a096101ab9586c76115fe17d541667f3c..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineGeometry/SRotatedGeometry.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: SRotatedGeometry.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: SRotatedGeometry -// A Geometry which wraps another arbitrary geometry in two s-rotations. -// -// ------------------------------------------------------------------------ -// Class category: BeamlineGeometry -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "BeamlineGeometry/SRotatedGeometry.h" -#include "BeamlineGeometry/Euclid3D.h" - - -// Class SRotatedGeometry. -// ------------------------------------------------------------------------ - -SRotatedGeometry::SRotatedGeometry(const BGeometryBase &g, - double sin, double sout): - srotIn(sin), srotOut(sout), geom(g) -{} - - -SRotatedGeometry::SRotatedGeometry(const BGeometryBase &g, - double srot, BalanceMode mode): - srotIn(srot), srotOut(0), geom(g) { - balanceSrots(mode); -} - -SRotatedGeometry::SRotatedGeometry(const SRotatedGeometry &rhs): - BGeometryBase(rhs), - srotIn(rhs.srotIn), srotOut(rhs.srotOut), geom(rhs.geom) -{} - - -SRotatedGeometry::~SRotatedGeometry() -{} - - -double SRotatedGeometry::getArcLength() const { - return geom.getArcLength(); -} - - -double SRotatedGeometry::getElementLength() const { - return geom.getElementLength(); -} - - -double SRotatedGeometry::getSrotIn() const { - return srotIn; -} - - -double SRotatedGeometry::getSrotOut() const { - return srotOut; -} - - -void SRotatedGeometry::setSrotIn(double phi) { - srotIn = phi; -} - - -void SRotatedGeometry::setSrotOut(double phi) { - srotOut = phi; -} - -void SRotatedGeometry::balanceSrots(BalanceMode mode) { - // switch(mode) { - // tilt: - // srotOut = -srotIn; - // break; - // balanceX: - // // to be implemented - // break; - // } - if(mode == tilt) - srotOut = -srotIn; - else { - // balanceX to be implemented - } -} - - -double SRotatedGeometry::getOrigin() const { - return geom.getOrigin(); -} - - -double SRotatedGeometry::getEntrance() const { - return geom.getEntrance(); -} - - -double SRotatedGeometry::getExit() const { - return geom.getExit(); -} - - -Euclid3D SRotatedGeometry::getTransform(double fromS, double toS) const { - Euclid3D t = geom.getTransform(fromS, toS); - - if(fromS == geom.getEntrance()) - t = t * Euclid3D::ZRotation(srotIn); - else if(fromS == geom.getExit()) - t = t * Euclid3D::ZRotation(-srotOut); - - if(toS == geom.getEntrance()) - t *= Euclid3D::ZRotation(-srotIn); - else if(toS == geom.getExit()) - t *= Euclid3D::ZRotation(srotOut); - - return t; -} - - -Euclid3D SRotatedGeometry::getTotalTransform() const { - Euclid3D tin = Euclid3D::ZRotation(srotIn); - Euclid3D tout = Euclid3D::ZRotation(srotOut); - Euclid3D t = geom.getTotalTransform(); - - return tout * t * tin; -} - - -Euclid3D SRotatedGeometry::getTransform(double s) const { - return getTransform(0, s); -} - - -Euclid3D SRotatedGeometry::getExitFrame() const { - Euclid3D t = geom.getExitFrame(); - return Euclid3D::ZRotation(srotOut) * t; -} - - -Euclid3D SRotatedGeometry::getEntranceFrame() const { - Euclid3D t = geom.getEntranceFrame(); - return t * Euclid3D::ZRotation(srotIn); -} - - -Euclid3D SRotatedGeometry::getEntrancePatch() const { - return Euclid3D::ZRotation(srotIn); -} - - -Euclid3D SRotatedGeometry::getExitPatch() const { - return Euclid3D::ZRotation(srotOut); -} diff --git a/src/Classic/BeamlineGeometry/SRotatedGeometry.h b/src/Classic/BeamlineGeometry/SRotatedGeometry.h deleted file mode 100644 index 6683bf390022dddb6baa49e6fd69c58d31f6be93..0000000000000000000000000000000000000000 --- a/src/Classic/BeamlineGeometry/SRotatedGeometry.h +++ /dev/null @@ -1,169 +0,0 @@ -#ifndef CLASSIC_SRotatedGeometry_HH -#define CLASSIC_SRotatedGeometry_HH - -// ------------------------------------------------------------------------ -// $RCSfile: SRotatedGeometry.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: SRotatedGeometry -// -// ------------------------------------------------------------------------ -// Class category: BeamlineGeometry -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:34 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "BeamlineGeometry/Geometry.h" - -// Class SRotatedGeometry -// ------------------------------------------------------------------------ -/// A Geometry which wraps an arbitrary geometry in two s-rotations. -// An SRotatedGeometry object is a Geometry wrapper which adds two -// arbitrary s-rotations (local z-axis rotations) to the entrance and -// exit planes of an arbitrary geometry. Any Geometry object can be -// wrapped, including another SRotatedGeometry. The s-rotations become -// part of the global geometry definition. Functions for setting the -// two in- and out-rotations using certain constraints are provided. -// [P] -// NOTE: in general the transformations returned include the effects of -// the s-rotations when the required distance parameter specified is -// either the entrance or exit point. Requests for transformations -// within the geometry (i.e. from s1 to s2, where s1 and/or s2 are not -// the entrance or exit planes) do not contain the s-rotations. - -class SRotatedGeometry : public BGeometryBase { -public: - - /// Balance mode. - enum BalanceMode { - - /// srotOut is set to -srotIn. - tilt, - - /// srotOut calculated. - // srotOut is calculated to be the vlaue which returns the local - // x-axis after rotation to be in a plane parallel with the local - // x-axis before application of srotIn. - balanceX - - }; - - /// Constructor. - // Use the wrapped geometry [b]geom[/b], - // and the two angles [b]srotIn[/b] and [b]srotOut[/b]. - SRotatedGeometry(const BGeometryBase &geom, double srotIn, double srotOut); - - /// Constructor. - // Use the wrapped geometry [b]geom[/b], - // the entrance rotation [b]srotIn[/b], - // and the balanc mode [b]mode[/b]. - SRotatedGeometry(const BGeometryBase &geom, double srotIn, BalanceMode mode = tilt); - - SRotatedGeometry(const SRotatedGeometry &); - virtual ~SRotatedGeometry(); - const SRotatedGeometry &operator=(const SRotatedGeometry &); - - /// Get arc length. - // Return or the design length of the embedded geometry. - // This is the length of the straight line connecting entrance and exit. - virtual double getArcLength() const; - - /// Get design length. - // Return or the design length of the embedded geometry. - // Depending on the element this may be the arc length or the straight - // length. - virtual double getElementLength() const; - - /// Get entrance rotation. - double getSrotIn() const; - - /// Get exit rotation. - double getSrotOut() const; - - /// Set entrance rotation. - void setSrotIn(double); - - /// Set exit rotation. - void setSrotOut(double); - - /// Balance rotations. - // Set the exit rotation in one of two modes: - // [UL] - // [LI]if [tt]mode==tilt[/tt], then srotOut is set to -srotIn. - // [LI]if [tt]mode==balanceX[/tt], then srotOut is calculated to be - // the value which returns the local x-axis after rotation to be in - // a parallel plane with the local x-axis before the application of - // [tt]srotIn[/tt]. - // [/UL] - void balanceSrots(BalanceMode mode = tilt); - - /// Get origin. - // Return the arc length from the entrance to the origin of the - // geometry (non-negative). - double getOrigin() const; - - /// Get entrance. - // Return the arc length from the origin to the entrance of the - // geometry (non-positive) - double getEntrance() const; - - /// Get exit. - // Return the arc length from the origin to the exit of the - // geometry (non-negative) - double getExit() const; - - /// Get transform. - // Return the transform of the local coordinate system from the - // position [b]fromS[/b] to the position [b]toS[/b]. - Euclid3D getTransform(double fromS, double toS) const; - - /// Get transform. - // Equivalent to getTransform(0.0, s). - // Return the transform of the local coordinate system from the - // origin and [b]s[/b]. - Euclid3D getTransform(double s) const; - - /// Get transform. - // Equivalent to getTransform(getEntrance(), getExit()). - // Return the transform of the local coordinate system from the - // entrance to the exit of the element. - Euclid3D getTotalTransform() const; - - /// Get transform. - // Equivalent to getTransform(0.0, getEntrance()). - // Return the transform of the local coordinate system from the - // origin to the entrance of the element. - Euclid3D getEntranceFrame() const; - - /// Get transform. - // Equivalent to getTransform(0.0, getExit()). - // Return the transform of the local coordinate system from the - // origin to the exit of the element. - Euclid3D getExitFrame() const; - - /// Get patch. - // Returns the entrance patch (transformation) which is used to - // transform the global geometry to the local geometry at entrance. - Euclid3D getEntrancePatch() const; - - /// Get patch. - // Returns the entrance patch (transformation) which is used to - // transform the local geometry to the global geometry at exit. - Euclid3D getExitPatch() const; - -private: - - double srotIn; - double srotOut; - const BGeometryBase &geom; -}; - -#endif // CLASSIC_SRotatedGeometry_HH - diff --git a/src/Classic/Beamlines/TBeamline.h b/src/Classic/Beamlines/TBeamline.h index c536698f0b9aec895b793e325164eea53603bad3..2e20b65223f0a23a619bc9d0eb7b5d19d73b6031 100644 --- a/src/Classic/Beamlines/TBeamline.h +++ b/src/Classic/Beamlines/TBeamline.h @@ -1,24 +1,24 @@ -#ifndef CLASSIC_TBeamline_HH -#define CLASSIC_TBeamline_HH - -// ------------------------------------------------------------------------ -// $RCSfile: TBeamline.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.3.2.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Template class: TBeamline<class T> +// Class TBeamline +// Template class for beam lines. +// Instantiation with different T types allows attachment of additional +// data to each position in the line. // -// ------------------------------------------------------------------------ -// Class category: Beamlines -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2004/11/18 22:18:06 $ -// $Author: jsberg $ +// 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 CLASSIC_TBeamline_HH +#define CLASSIC_TBeamline_HH #include "Beamlines/Beamline.h" #include "AbsBeamline/BeamlineVisitor.h" @@ -29,13 +29,6 @@ #include <algorithm> #include <list> - -// Template class TBeamline -// ------------------------------------------------------------------------ -/// Template class for beam lines. -// Instantiation with different T types allows attachment of additional -// data to each position in the line. - template <class T> class TBeamline: public Beamline, public std::list<T> { @@ -131,11 +124,6 @@ public: // origin to the exit of the element. virtual Euclid3D getExitFrame() const; - /// Construct an image. - // Return the image of the element, containing the name and type string - // of the element, and a copy of the user-defined attributes. - virtual ElementImage *getImage() const; - /// Get beamline type virtual ElementBase::ElementType getType() const; @@ -417,13 +405,6 @@ Euclid3D TBeamline<T>::getExitFrame() const { } -template <class T> inline -ElementImage *TBeamline<T>::getImage() const { - // this code needs revision when the class ElementImage is defined - return NULL; -} - - template <class T> inline ElementBase::ElementType TBeamline<T>::getType() const { return BEAMLINE; diff --git a/src/Classic/CMakeLists.txt b/src/Classic/CMakeLists.txt index 954849b84549d5dd7385a7c9a3f603d68e145e01..aaeb5f611136c0318fd1c2208c5032ef62318716 100644 --- a/src/Classic/CMakeLists.txt +++ b/src/Classic/CMakeLists.txt @@ -7,7 +7,6 @@ add_subdirectory(BeamlineCore) add_subdirectory(BeamlineGeometry) add_subdirectory(Beamlines) add_subdirectory(Channels) -add_subdirectory(Construction) add_subdirectory(Fields) add_subdirectory(Filters) add_subdirectory(FixedAlgebra) diff --git a/src/Classic/Construction/CMakeLists.txt b/src/Classic/Construction/CMakeLists.txt deleted file mode 100644 index dae28a19a862c96b295a0be0d49c149360d602dd..0000000000000000000000000000000000000000 --- a/src/Classic/Construction/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -set (_SRCS - ElementFactory.cpp - Factory.cpp - ) - -include_directories ( - ${CMAKE_CURRENT_SOURCE_DIR} - ) - -add_opal_sources (${_SRCS}) - -set (HDRS - ElementFactory.h - Factory.h - ) - -install (FILES ${HDRS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/Construction") - -# vi: set et ts=4 sw=4 sts=4: - -# Local Variables: -# mode: cmake -# cmake-tab-width: 4 -# indent-tabs-mode: nil -# require-final-newline: nil -# End: diff --git a/src/Classic/Construction/ElementFactory.cpp b/src/Classic/Construction/ElementFactory.cpp deleted file mode 100644 index 0af5eba9f2cc4c3999433382fc762615b37c09c7..0000000000000000000000000000000000000000 --- a/src/Classic/Construction/ElementFactory.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: ElementFactory.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ElementFactory -// This class is the main CLASSIC element factory. -// -// ------------------------------------------------------------------------ -// Class category: Construction -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:35 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "Construction/ElementFactory.h" -#include "AbsBeamline/AttributeSet.h" -#include "AbsBeamline/ElementBase.h" - - -// Class ElementFactory -// ------------------------------------------------------------------------ - -ElementFactory::ElementFactory(): - inventory() -{} - - -ElementFactory::~ElementFactory() -{} - - -bool ElementFactory::define(ElementBase *newElement) { - std::string name = newElement->getName(); - MapType::value_type value(name, newElement); - std::pair<MapType::iterator, bool> index = inventory.insert(value); - - if(index.second) { - // Insertion took place (no duplicate). - return true; - } else { - // Insertion rejected. - delete newElement; - return false; - } -} - - -void ElementFactory::erase(const std::string &name) { - inventory.erase(name); -} - - -ElementBase *ElementFactory::find(const std::string &name) const { - MapType::const_iterator index = inventory.find(name); - - if(index == inventory.end()) { - return 0; - } else { - return (*index).second; - } -} - - -ElementBase *ElementFactory::makeElement(const std::string &type, - const std::string &name, - const AttributeSet &set) { - ElementBase *model = find(type); - ElementBase *copy = 0; - - try { - if(model != 0) { - ElementBase *copy = model->clone(); - copy->setName(name); - copy->update(set); - storeElement(copy); - return copy; - } - } catch(...) { - delete copy; - } - - return 0; -} - - -bool ElementFactory::storeElement(ElementBase *newElement) { - std::string name = newElement->getName(); - MapType::value_type value(name, newElement); - std::pair<MapType::iterator, bool> index = inventory.insert(value); - - if(index.second) { - // Insertion took place (no duplicate). - return true; - } else { - // Insertion was a replacement. - (*index.first).second = newElement; - return false; - } -} diff --git a/src/Classic/Construction/ElementFactory.h b/src/Classic/Construction/ElementFactory.h deleted file mode 100644 index 2e5dcc89135c3a144be0b5cf97f73717f7d2df3a..0000000000000000000000000000000000000000 --- a/src/Classic/Construction/ElementFactory.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef CLASSIC_ElementFactory_HH -#define CLASSIC_ElementFactory_HH - -// ------------------------------------------------------------------------ -// $RCSfile: ElementFactory.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ElementFactory -// -// ------------------------------------------------------------------------ -// Class category: Construction -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:35 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "Construction/Factory.h" -#include <map> - - -// Class ElementFactory -// ------------------------------------------------------------------------ -/// Concrete factory class for CLASSIC elements. -// Defines the beamline element creation via the factory pattern. -// When the factory is constructed, empty elements are first created and -// stored. -// {p} -// With the makeElement() method, these elements can be cloned and then -// filled in with from an ElementImage. The factory also implements an -// element repository which can store beam lines. - - -class ElementFactory: public Factory { - -public: - - /// Default constructor. - // Fills the repository with all standard element definitions. - ElementFactory(); - - virtual ~ElementFactory(); - - /// Define a new element. - // The element [b]newElement[/b] is linked to the repository. - // If an element with the same name exists already, replacement is - // rejected, and [b]newElement[/b] is deleted. - virtual bool define(ElementBase *newElement); - - /// Erase element by name. - // If there is no element with the given [b]name[/b], - // the request is ignored. - virtual void erase(const std::string &name); - - /// Find element by name. - // If an element with the name [b]name[/b] exists, - // return a pointer to this element, otherwise return NULL. - virtual ElementBase *find(const std::string &name) const; - - /// Make new element. - // Create a new element with the type [b]type[/b], the name [b]name[/b] - // and the attributes in [b]set[/b]. - // If an element with the name [b]name[/b] already exists, it is replaced. - virtual ElementBase *makeElement(const std::string &type, - const std::string &name, - const AttributeSet &set); - - /// Define a new element. - // The element [b]newElement[/b] is linked to the repository. - // If an element with the same name exists already, it is replaced. - virtual bool storeElement(ElementBase *newElement); - -private: - - // Not implemented. - ElementFactory(const ElementFactory &); - void operator=(const ElementFactory &); - - // The beamline elements are stored in this map. - typedef std::map<std::string, ElementBase *, std::less<std::string> > MapType; - MapType inventory; -}; - -#endif // CLASSIC_ElementFactory_HH diff --git a/src/Classic/Construction/Factory.cpp b/src/Classic/Construction/Factory.cpp deleted file mode 100644 index 5b849439149d008fb10ab323d0cef5b1d36a6375..0000000000000000000000000000000000000000 --- a/src/Classic/Construction/Factory.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Factory.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Factory -// The abstract interface for the CLASSIC element factory. -// -// ------------------------------------------------------------------------ -// Class category: Construction -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:35 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "Construction/Factory.h" - - -// Class Factory -// ------------------------------------------------------------------------ - -Factory::Factory() -{} - - -Factory::~Factory() -{} diff --git a/src/Classic/Construction/Factory.h b/src/Classic/Construction/Factory.h deleted file mode 100644 index 0017f9f92c24aa9859f2e8e94bcd3650c67d2f69..0000000000000000000000000000000000000000 --- a/src/Classic/Construction/Factory.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef CLASSIC_Factory_HH -#define CLASSIC_Factory_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Factory.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Factory -// -// ------------------------------------------------------------------------ -// Class category: Construction -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:35 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include <string> - -class ElementBase; -class AttributeSet; - - -// Class Factory -// ------------------------------------------------------------------------ -/// Abstract interface for an element factory. - -class Factory { - -public: - - Factory(); - virtual ~Factory(); - - /// Define a new element. - // The element [b]newElement[/b] is linked to the repository. - // If an element with the same name exists already, replacement is - // rejected, and [b]newElement[/b] is deleted. - virtual bool define(ElementBase *newElement) = 0; - - /// Erase element by name. - // If there is no element with the given [b]name[/b], - // the request is ignored. - virtual void erase(const std::string &name) = 0; - - /// Find element by name. - // If an element with the name [b]name[/b] exists, - // return a pointer to this element, otherwise return NULL. - virtual ElementBase *find(const std::string &name) const = 0; - - /// Make new element. - // Create a new element with the type [b]type[/b], the name [b]name[/b] - // and the attributes in [b]set[/b]. If an element with the name - // [b]name[/b] already exists, it is replaced. - virtual ElementBase *makeElement(const std::string &type, const std::string &name, - const AttributeSet &set) = 0; - - /// Define a new element. - // The element [b]newElement[/b] is linked to the repository. - // If an element with the same name exists already, it is replaced. - virtual bool storeElement(ElementBase *newElement) = 0; -}; - -#endif // CLASSIC_Factory_HH diff --git a/src/Classic/Fields/CMakeLists.txt b/src/Classic/Fields/CMakeLists.txt index 9ad324840c3092442beafce6406ffc841285aae3..4a5c5f5066f41f70862d0259105096102b3fea66 100644 --- a/src/Classic/Fields/CMakeLists.txt +++ b/src/Classic/Fields/CMakeLists.txt @@ -3,9 +3,7 @@ set (_SRCS BMultipoleField.cpp ConstBField.cpp ConstBzField.cpp - ConstEField.cpp ConstEzField.cpp - EDipoleField.cpp EMField.cpp NullField.cpp StaticElectricField.cpp @@ -64,9 +62,7 @@ set (HDRS BSingleMultipoleField.h ConstBField.h ConstBzField.h - ConstEField.h ConstEzField.h - EDipoleField.h EMField.h Fieldmap.h Fieldmap.hpp diff --git a/src/Classic/Fields/ConstEField.cpp b/src/Classic/Fields/ConstEField.cpp deleted file mode 100644 index fd85d79fd25d0d69a734a25fa313cd749dfa2578..0000000000000000000000000000000000000000 --- a/src/Classic/Fields/ConstEField.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: ConstEField.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ConstEField -// A static electric field independent of (x,y,z). -// -// ------------------------------------------------------------------------ -// Class category: Fields -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:35 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "Fields/ConstEField.h" - - -// Class ConstEField -// ------------------------------------------------------------------------ - -ConstEField::ConstEField() -{} - - -ConstEField::~ConstEField() -{} - - -double ConstEField::getEx() const { - return 0.0; -} - - -double ConstEField::getEy() const { - return 0.0; -} - - -double ConstEField::getEz() const { - return 0.0; -} - - -void ConstEField::setEx(double /*E*/) -{} - - -void ConstEField::setEy(double /*E*/) -{} - - -void ConstEField::setEz(double /*E*/) -{} diff --git a/src/Classic/Fields/ConstEField.h b/src/Classic/Fields/ConstEField.h deleted file mode 100644 index c896e2988d5b4ae58b62414f17cc1d46d2ca91d0..0000000000000000000000000000000000000000 --- a/src/Classic/Fields/ConstEField.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef CLASSIC_ConstEField_HH -#define CLASSIC_ConstEField_HH - -// ------------------------------------------------------------------------ -// $RCSfile: ConstEField.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: ConstEField -// -// ------------------------------------------------------------------------ -// Class category: Fields -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:35 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "Fields/StaticElectricField.h" - - -// Class ConstEField -// ------------------------------------------------------------------------ -/// A homogeneous electricstatic field. - -class ConstEField: public StaticElectricField { - -public: - - /// Default constructor. - // Constructs null field. - ConstEField(); - - virtual ~ConstEField(); - - /// Get component. - // Return the x-component of the electric field in A/m. - virtual double getEx() const; - - /// Get component. - // Return the y-component of the electric field in A/m. - virtual double getEy() const; - - /// Get component. - // Return the z-component of the electric field in A/m. - virtual double getEz() const; - - /// Set component. - // Assign the x-component of the electric field in A/m. - virtual void setEx(double); - - /// Set component. - // Assign the y-component of the electric field in A/m. - virtual void setEy(double); - - /// Set component. - // Assign the z-component of the electric field in A/m. - virtual void setEz(double); -}; - -#endif // CLASSIC_ConstEField_HH diff --git a/src/Classic/Fields/ConstEzField.cpp b/src/Classic/Fields/ConstEzField.cpp index 1f7bbcc23df1f310ae728776a7aa7c3fb924d4c8..d187a9774c8d0c3cec474a5804408808d878dc2d 100644 --- a/src/Classic/Fields/ConstEzField.cpp +++ b/src/Classic/Fields/ConstEzField.cpp @@ -1,29 +1,23 @@ -// ------------------------------------------------------------------------ -// $RCSfile: ConstEzField.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: ConstEzField -// A static electric field of constant value in z-direction. +// Class ConstEzField +// A homogeneous electrostatic field in z-direction. // -// ------------------------------------------------------------------------ -// Class category: Fields -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:32:35 $ -// $Author: fci $ +// 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 "Fields/ConstEzField.h" -// Class ConstEzField -// ------------------------------------------------------------------------ - ConstEzField::ConstEzField() {} diff --git a/src/Classic/Fields/ConstEzField.h b/src/Classic/Fields/ConstEzField.h index c79c2767303050bee98bc5be70b522cbf253ce20..5609097bc7377e0d01eb11c0653360ec2a5b37af 100644 --- a/src/Classic/Fields/ConstEzField.h +++ b/src/Classic/Fields/ConstEzField.h @@ -1,31 +1,24 @@ -#ifndef CLASSIC_ConstEzField_HH -#define CLASSIC_ConstEzField_HH - -// ------------------------------------------------------------------------ -// $RCSfile: ConstEzField.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: ConstEzField +// Class ConstEzField +// A homogeneous electrostatic field in z-direction. // -// ------------------------------------------------------------------------ -// Class category: Fields -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:32:35 $ -// $Author: fci $ +// This file is part of OPAL. // -// ------------------------------------------------------------------------ - -#include "Fields/ConstEField.h" - +// 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 CLASSIC_ConstEzField_HH +#define CLASSIC_ConstEzField_HH -// Class ConstEzField -// ------------------------------------------------------------------------ -/// A homogeneous electrostatic field in z-direction. +#include "Fields/StaticElectricField.h" class ConstEzField: public StaticElectricField { diff --git a/src/Classic/Fields/EDipoleField.cpp b/src/Classic/Fields/EDipoleField.cpp deleted file mode 100644 index ecb1a0d54132feaa263c30aa5d5a30c449a47ce7..0000000000000000000000000000000000000000 --- a/src/Classic/Fields/EDipoleField.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: EDipoleField.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: EDipoleField -// An electrostatic dipole field in the (x,y)-plane. -// -// ------------------------------------------------------------------------ -// Class category: Fields -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:35 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "Fields/EDipoleField.h" - - -// Class EDipoleField -// ------------------------------------------------------------------------ - -EDipoleField::EDipoleField() -{} - - -EDipoleField::~EDipoleField() -{} - - -EVector EDipoleField::Efield(const Point3D &) const { - return EVector(Ex, Ey, 0.0); -} - - -EVector EDipoleField::Efield(const Point3D &/*P*/, double) const { - return EVector(Ex, Ey, 0.0); -} - - -double EDipoleField::getEx() const { - return Ex; -} - -double EDipoleField::getEy() const { - return Ey; -} - - -void EDipoleField::setEx(double value) { - Ex = value; -} - - -void EDipoleField::setEy(double value) { - Ey = value; -} - - -void EDipoleField::scale(double scalar) { - Ex *= scalar; - Ey *= scalar; -} diff --git a/src/Classic/Fields/EDipoleField.h b/src/Classic/Fields/EDipoleField.h deleted file mode 100644 index 9f63f13ecf4e5c8795b449ba8ff1252280949b70..0000000000000000000000000000000000000000 --- a/src/Classic/Fields/EDipoleField.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef CLASSIC_EDipoleField_HH -#define CLASSIC_EDipoleField_HH - -// ------------------------------------------------------------------------ -// $RCSfile: EDipoleField.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: EDipoleField -// -// ------------------------------------------------------------------------ -// Class category: Fields -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:32:35 $ -// $Author: fci $ -// -// ------------------------------------------------------------------------ - -#include "Fields/ConstEField.h" - - -// Class EDipoleField -// ------------------------------------------------------------------------ -/// A static homogeneous electrostatic field in the (x,y)-plane. - -class EDipoleField: public ConstEField { - -public: - - /// Default constructor. - // Constructs a null field. - EDipoleField(); - - virtual ~EDipoleField(); - - /// Get field. - // Return the time-independent part of the electric field in point [b]P[/b]. - virtual EVector Efield(const Point3D &P) const; - - /// Get field. - // Return the electric field at time [b]t[/b] in point [b]P[/b]. - virtual EVector Efield(const Point3D &P, double t) const; - - /// Get component. - // Return the x-component of the electric field in A/m. - virtual double getEx() const; - - /// Get component. - // Return the y-component of the electric field in A/m. - virtual double getEy() const; - - /// Set component. - // Assign the x-component of the electric field in A/m. - virtual void setEx(double); - - /// Set component. - // Assign the y-component of the electric field in A/m. - virtual void setEy(double); - - /// Scale the field. - // Multiply the field by [b]scalar[/b]. - virtual void scale(double scalar); - -private: - - // The field components. - double Ex, Ey; -}; - -#endif // CLASSIC_EDipoleField_HH diff --git a/src/Classic/FixedAlgebra/CMakeLists.txt b/src/Classic/FixedAlgebra/CMakeLists.txt index 779cef8415336e2c758337871d821e86e3944c2e..d8752d66ce76fb3dc90811cc1f4f183103cb7392 100644 --- a/src/Classic/FixedAlgebra/CMakeLists.txt +++ b/src/Classic/FixedAlgebra/CMakeLists.txt @@ -16,9 +16,7 @@ set (HDRS FLUMatrix.h FMatrix.h FMonomial.h - FNormalForm.h FSlice.h - FStaticFP.h FTpsData.h FTps.h FTps.hpp @@ -30,14 +28,12 @@ set (HDRS LinearFun.hpp LinearMap.h LinearMap.hpp - LinearMath.h Taylor.h Taylor.hpp TransportFun.h TransportFun.hpp TransportMap.h TransportMap.hpp - TransportMath.h ) install (FILES ${HDRS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/FixedAlgebra") diff --git a/src/Classic/FixedAlgebra/FNormalForm.h b/src/Classic/FixedAlgebra/FNormalForm.h deleted file mode 100644 index 8c0bfab0530fcf01656f5af393e0b1c3f0d399ad..0000000000000000000000000000000000000000 --- a/src/Classic/FixedAlgebra/FNormalForm.h +++ /dev/null @@ -1,526 +0,0 @@ -#ifndef MAD_FNormalForm_HH -#define MAD_FNormalForm_HH - -// ------------------------------------------------------------------------ -// $RCSfile: FNormalForm.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1.2.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: FNormalForm -// -// ------------------------------------------------------------------------ -// Class category: FixedAlgebra -// ------------------------------------------------------------------------ -// -// $Date: 2002/03/25 20:44:17 $ -// $Author: dbruhwil $ -// -// ------------------------------------------------------------------------ - -#include "FixedAlgebra/FMatrix.h" -#include "FixedAlgebra/FVector.h" -#include <algorithm> -#include <complex> - -template <class T, int, int> class FMatrix; -template <class T, int> class FTps; -template <class T, int> class FVps; - - -// Tolerance for accepting an eigenvalue. -namespace { - const double tol = 1.0e-8; -} - - -// Class FNormalForm -// ------------------------------------------------------------------------ -/// Normal form of a truncated Taylor series map. -// Compute from representation of a map which can be a nil-potent, -// static or dynamic symplectic map. Implementation of an algorithm -// described in -// [center] -// M. Berz, E. Forest and J. Irwin,[br] -// Particle Accelerators, 1989, Vol. 24, pp. 91-107. -// [/center] - -template <int N> -class FNormalForm { - -public: - - /// Constructor. - // Perform normal-form analysis of [b]map[/b]. - explicit FNormalForm(const FVps<double, N> &map); - - FNormalForm(); - FNormalForm(const FNormalForm &); - ~FNormalForm(); - - /// Get number of stable degrees of freedom. - int degreesOfFreedom() const; - - /// Get normal-form map as a Lie transform. - const FTps<double, N> &normalForm() const; - - /// Get normalising map as a Lie transform. - const FTps<double, N> &normalisingMap() const; - - /// Get eigenvalues of the linear part as a complex vector. - const FVector<std::complex<double>, N> &eigenValues() const; - - /// Get eigenvectors of the linear part in packed form. - const FMatrix<double, N, N> &eigenVectors() const; - - /// Get anharmonicities as a matrix. - FMatrix < double, N / 2, N / 2 > anharmonicity() const; - - /// Get invariant polynomial for mode i. - FTps<double, N> invariant(int i) const; - -protected: - - // Order the modes of the map and associate them to the planes. - void orderModes(FVector<std::complex<double>, N>, FMatrix<double, N, N>); - -private: - - // Not implemented. - void operator=(const FNormalForm &); - - // Representation of the normal form analysis results. - // ---------------------------------------------------------------------- - // Number of degrees of freedom. - int freedom; - - // The factorised normalising map. - FTps<double, N> A_Lie; - - // The factorised normal form map/ - FTps<double, N> N_Lie; - - // The vector of eigenvalues. - FVector<std::complex<double>, N> lambda; - - // The matrix of eigenvectors. - FMatrix<double, N, N> V; -}; - - -#include "FixedAlgebra/FDoubleEigen.h" -#include "FixedAlgebra/FMatrix.h" -#include "FixedAlgebra/FLUMatrix.h" -#include "FixedAlgebra/FMonomial.h" -#include "FixedAlgebra/FVps.h" -#include "Physics/Physics.h" -#include "Utilities/LogicalError.h" -#include <functional> - - - - -// Class FNormalForm -// ------------------------------------------------------------------------ - -template <int N> -FNormalForm<N>::FNormalForm(): - freedom(0), A_Lie(), N_Lie(), lambda(), V() -{} - - -template <int N> -FNormalForm<N>::FNormalForm(const FNormalForm &form): - freedom(form.freedom), A_Lie(form.A_Lie), N_Lie(form.N_Lie), - lambda(form.lambda), V(form.V) -{} - - -template <int N> -FNormalForm<N>::FNormalForm(const FVps<double, N> &M_scr): - freedom(N / 2), A_Lie(0.0), - N_Lie(0, 2, M_scr.getTopOrder() + 1), // Reserve space for second-order. - lambda(), V() { - if(N % 2 != 0) { - throw LogicalError("FNormalForm::FNormalForm()", "Map dimension is odd."); - } - - // Establish Jacobian matrix of map, - // and find its eigenvalues and eigenvectors. - // Order eigenvectors, attach modes to planes and find inverse of V. - FMatrix<double, N, N> V_inv; - { - FMatrix<double, N, N> M = M_scr.linearTerms(); - FDoubleEigen<N> eigen(M, true); - orderModes(eigen.eigenValues(), eigen.packedEigenVectors()); - FLUMatrix<double, N> lu(V); - V_inv = lu.inverse(); - } - - // Initialise. - FMatrix<double, N, N> Rot, R_dir, I_dir, R_inv; - - for(int i = 0; i < N; ++i) { - Rot(i, i) = R_dir(i, i) = I_dir(i, i) = R_inv(i, i) = 1.0; - } - - FMonomial<N> pows; - - for(int i = 0; i < 2 * freedom; i += 2) { - // Store linear part of normal form. - double c1, c2; - - if(std::abs(std::imag(lambda[i])) > tol) { - c1 = c2 = std::arg(lambda[i]) / 2.0; - } else { - c1 = log(std::abs(lambda[i])) / 2.0; - c2 = - c1; - } - - pows[i] = 2; - N_Lie.setCoefficient(pows, c1); - pows[i] = 0; - - pows[i+1] = 2; - N_Lie.setCoefficient(pows, c2); - pows[i+1] = 0; - - // Set up the auxiliary matrices. - R_dir(i, i) = R_dir(i, i + 1) = R_dir(i + 1, i) = 0.5; - R_dir(i + 1, i + 1) = -0.5; - R_inv(i, i) = R_inv(i, i + 1) = R_inv(i + 1, i) = 1.0; - R_inv(i + 1, i + 1) = -1.0; - - if(std::abs(std::imag(lambda[i])) > tol) { - // Complex eigenvalue pair. - Rot(i, i) = Rot(i + 1, i + 1) = std::real(lambda[i]); - Rot(i, i + 1) = std::imag(lambda[i]); - Rot(i + 1, i) = - std::imag(lambda[i]); - - I_dir(i, i) = I_dir(i + 1, i + 1) = 0.0; - I_dir(i, i + 1) = I_dir(i + 1, i) = 1.0; - } else { - // Real eigenvalue pair. - Rot(i, i) = Rot(i + 1, i + 1) = std::real(lambda[i] + lambda[i+1]) * 0.5; - Rot(i, i + 1) = Rot(i + 1, i) = std::real(lambda[i] - lambda[i+1]) * 0.5; - } - } - - // Fill in the values for the coasting modes. - // Note that the matrices already have ones on the main diagonal. - for(int i = 2 * freedom; i < N; i += 2) { - // Store linear part of normal form. - pows[i+1] = 2; - N_Lie.setCoefficient(pows, 0.5); - pows[i+1] = 0; - } - - // Initialise the factored map. - FVps<double, N> N_scr = V_inv * M_scr.substitute(V * Rot); - FVps<double, N> N_acc; - - // Remove non-resonant terms order by order. - int maxOrder = M_scr.getTopOrder(); - - for(int omega = 2; omega < maxOrder; omega++) { - // Compute the terms to be removed and store in f. - FVps<double, N> temp = N_scr.substitute(N_acc).filter(omega, omega); - FTps<double, N> f(0, omega + 1, omega + 1); - - for(int i = 0; i < N; i += 2) { - f += temp[i+1].multiplyVariable(i) - temp[i].multiplyVariable(i + 1); - } - - f /= double(omega + 1); - - // Set up the "phi" transformations. - FTps<double, N> a(0, omega + 1, omega + 1); - FTps<double, N> b(0, omega + 1, omega + 1); - FTps<double, N> pi(0, omega + 1, omega + 1); - FTps<double, N> t(0, omega + 1, omega + 1); - - for(int m = FTps<double, N>::getSize(omega); - m < FTps<double, N>::getSize(omega + 1); m++) { - const FMonomial<N> &index = FTpsData<N>::getExponents(m); - std::complex<double> factor = 1.0; - int count = 0; - - for(int j = 0; j < 2 * freedom; j += 2) { - if(std::abs(std::imag(lambda[j])) > tol) count += index[j+1]; - factor *= (std::pow(lambda[j], index[j]) * std::pow(lambda[j+1], index[j+1])); - } - - if(std::abs(1.0 - factor) < tol) { - // Term cannot be removed. - t.setCoefficient(m, 0.5); - } else { - // Term can be removed. - factor = 1.0 / (1.0 - factor); - a.setCoefficient(m, std::real(factor)); - b.setCoefficient(m, std::imag(factor)); - } - - pi.setCoefficient(m, std::pow(-1.0, int(count + 1) / 2)); - } - - // Compute cal_T^(-1) * f and T_omega. - FTps<double, N> f1 = pi.scaleMonomials(f).substitute(R_dir); - FTps<double, N> f2 = f1.substitute(I_dir); - - // Remove terms of order "omega" and accumulate map script(A). - FTps<double, N> F_omega = - (a.scaleMonomials(f1) + b.scaleMonomials(f2)). - substitute(R_inv).scaleMonomials(pi); - - if(F_omega != 0.0) { - FVps<double, N> A_omega = ExpMap(F_omega.substitute(Rot)); - FVps<double, N> A_invert = ExpMap(- F_omega); - N_scr = A_invert.substitute(N_scr).substitute(A_omega); - A_Lie -= F_omega; - } - - // Accumulate map script(N). - FTps<double, N> T_omega = t.scaleMonomials(f1 + f2). - substitute(R_inv).scaleMonomials(pi); - - if(T_omega != 0.0) { - N_acc = ExpMap(- T_omega, N_acc); - N_Lie -= T_omega; - } - } -} - - -template <int N> -FNormalForm<N>::~FNormalForm() -{} - - -template <int N> -int FNormalForm<N>::degreesOfFreedom() const { - return freedom; -} - - -template <int N> -FMatrix < double, N / 2, N / 2 > FNormalForm<N>::anharmonicity() const { - FMatrix < double, N / 2, N / 2 > QQ; - - for(int mode1 = 0; mode1 < freedom; mode1++) { - { - FMonomial<N> power1, power2, power3; - power1[2*mode1] = power3[2*mode1+1] = 4; - power2[2*mode1] = power2[2*mode1+1] = 2; - QQ(mode1, mode1) = - - (3.0 * (N_Lie.getCoefficient(power1) + - N_Lie.getCoefficient(power3)) + - N_Lie.getCoefficient(power2)) / (4.0 * Physics::pi); - } - - for(int mode2 = mode1 + 1; mode2 < freedom; mode2++) { - FMonomial<N> power1, power2, power3, power4; - power1[2*mode1] = power1[2*mode2] = 2; - power2[2*mode1+1] = power2[2*mode2] = 2; - power3[2*mode1] = power3[2*mode2+1] = 2; - power4[2*mode1+1] = power4[2*mode2+1] = 2; - QQ(mode1, mode2) = QQ(mode2, mode1) = - - (N_Lie.getCoefficient(power1) + - N_Lie.getCoefficient(power2) + - N_Lie.getCoefficient(power3) + - N_Lie.getCoefficient(power4)) / (4.0 * Physics::pi); - } - } - - return QQ; -} - - -template <int N> -FTps<double, N> FNormalForm<N>::invariant(int mode) const { - FTps<double, N> a(1, 1); - FTps<double, N> b(1, 1); - - for(int j = 0; j < N; j += 2) { - a.setCoefficient(j + 1, - V(j + 1, 2 * mode)); - a.setCoefficient(j + 2, V(j, 2 * mode)); - b.setCoefficient(j + 1, - V(j + 1, 2 * mode + 1)); - b.setCoefficient(j + 2, V(j, 2 * mode + 1)); - } - - if(std::abs(std::imag(lambda[2*mode])) > tol) { - return (a * a + b * b); - } else { - return (a * a - b * b); - } -} - - -template <int N> -const FTps<double, N> &FNormalForm<N>::normalForm() const { - return N_Lie; -} - - -template <int N> -const FTps<double, N> &FNormalForm<N>::normalisingMap() const { - return A_Lie; -} - - -template <int N> -const FVector<std::complex<double>, N> &FNormalForm<N>::eigenValues() const { - return lambda; -} - - -template <int N> -const FMatrix<double, N, N> &FNormalForm<N>::eigenVectors() const { - return V; -} - - -template <int N> -void FNormalForm<N>::orderModes(FVector<std::complex<double>, N> tlam, - FMatrix<double, N, N> tmat) { - // Static constant. - int nDim = N; - int n_c = 0; - int n_r = 0; - - for(int i = 0; i < N;) { - if(std::abs(tlam[i] - 1.0) < tol) { - // Collect "coasting" modes in upper indices of V. - nDim--; - lambda[nDim] = 1.0; - std::fill(V.col_begin(nDim), V.col_end(nDim), 0.0); - V(nDim, nDim) = 1.0; - i++; - } else if(std::abs(std::imag(tlam[i])) < tol) { - // Collect "unstable" modes in lower indices of tmat. - if(n_r != i) { - tlam[n_r] = tlam[i]; - std::copy(tmat.col_begin(i), tmat.col_end(i), tmat.col_begin(n_r)); - } - n_r++; - i++; - } else { - // Collect "stable" modes in lower indices of V. - double pb = 0.0; - for(int j = 0; j < N; j += 2) { - pb += tmat(j, i) * tmat(j + 1, i + 1) - tmat(j + 1, i) * tmat(j, i + 1); - } - - int i1 = i; - int i2 = i; - if(pb > 0.0) { - ++i2; - } else { - ++i1; - } - - lambda[n_c] = tlam[i1]; - lambda[n_c+1] = tlam[i2]; - - double fact = std::sqrt(std::abs(pb)); - - for(int j = 0; j < N; j++) { - V(j, n_c) = tmat(j, i1) / fact; - V(j, n_c + 1) = tmat(j, i2) / fact; - } - - i += 2; - n_c += 2; - } - } - - // Order and copy "unstable" modes. - for(int i = 0; i < n_r;) { - int m; - for(m = i + 1; m < n_r; ++m) { - if(std::abs(tlam[i] * tlam[m] - 1.0) < tol) break; - } - - if(m >= n_r) { - throw LogicalError("FNormalForm::orderModes()", - "Cannot find pair of real eigenvalues."); - } - - // Swap values to make pair. - if(m != i + 1) { - std::swap(tlam[m], tlam[i+1]); - tmat.swapColumns(m, i + 1); - } - - // Normalise this real pair and convert it to Sinh/Cosh form. - double pb = 0.0; - for(int j = 0; j < N; j += 2) { - pb += tmat(j, i) * tmat(j + 1, i + 1) - tmat(j + 1, i) * tmat(j, i + 1); - } - - int i1 = i; - int i2 = i; - if(pb > 0.0) { - ++i2; - } else { - ++i1; - } - - lambda[n_c] = tlam[i1]; - lambda[n_c+1] = tlam[i2]; - - double fact = std::sqrt(std::abs(2.0 * pb)); - - for(int j = 0; j < N; ++j) { - V(j, n_c) = (tmat(j, i1) + tmat(j, i2)) / fact; - V(j, n_c + 1) = (tmat(j, i1) - tmat(j, i2)) / fact; - } - - n_c += 2; - i += 2; - } - - freedom = nDim / 2; - if(nDim != 2 * freedom) { - throw LogicalError("FNormalForm::orderModes()", "Map dimension is odd."); - } - - // Re-order eigenvector pairs by their main components. - for(int i = 0; i < nDim; i += 2) { - // Find eigenvector pair with larges component in direction i/2. - double big = 0.0; - int k = i; - for(int j = i; j < N; j += 2) { - double c = std::abs(V(i, j) * V(i + 1, j + 1) - V(i, j + 1) * V(i + 1, j)); - - if(c > big) { - big = c; - k = j; - } - } - - if(k != i) { - // Move eigenvector pair to its place. - std::swap(lambda[i], lambda[k]); - std::swap(lambda[i+1], lambda[k+1]); - V.swapColumns(i, k); - V.swapColumns(i + 1, k + 1); - } - - if(std::abs(std::imag(lambda[i])) > tol) { - // Rotate complex eigenvectors to make their main components real. - double re = V(i, i) / std::sqrt(V(i, i) * V(i, i) + V(i, i + 1) * V(i, i + 1)); - double im = V(i, i + 1) / std::sqrt(V(i, i) * V(i, i) + V(i, i + 1) * V(i, i + 1)); - - for(int j = 0; j < N; j++) { - double real_part = re * V(j, i) + im * V(j, i + 1); - double imag_part = re * V(j, i + 1) - im * V(j, i); - V(j, i) = real_part; - V(j, i + 1) = imag_part; - } - } - } -} - -#endif // MAD_FNormalForm_HH diff --git a/src/Classic/FixedAlgebra/FStaticFP.h b/src/Classic/FixedAlgebra/FStaticFP.h deleted file mode 100644 index fe8b206bcbc88c743f30f15e071621f8d498852a..0000000000000000000000000000000000000000 --- a/src/Classic/FixedAlgebra/FStaticFP.h +++ /dev/null @@ -1,209 +0,0 @@ -#ifndef MAD_FStaticFP_HH -#define MAD_FStaticFP_HH - -// ------------------------------------------------------------------------ -// $RCSfile: FStaticFP.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1.2.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: FStaticFP -// -// ------------------------------------------------------------------------ -// Class category: FixedAlgebra -// ------------------------------------------------------------------------ -// -// $Date: 2003/11/07 18:03:01 $ -// $Author: dbruhwil $ -// -// ------------------------------------------------------------------------ - -#include "FixedAlgebra/FVps.h" -#include <cmath> - - -// Class FStaticFP -// ------------------------------------------------------------------------ -/// Static fixed point of a Truncated power series map. - -template <int N> -class FStaticFP { - -public: - - /// Constructor. - // Find fixed point for [b]map[/b]. - FStaticFP(const FVps<double, N> &map); - - FStaticFP(); - FStaticFP(const FStaticFP &rhs); - ~FStaticFP(); - - /// Get the dispersion map. - const FVps<double, N> &getDispersion() const; - - /// Get the transformation to the fixed point. - const FVps<double, N> &getFixedPoint() const; - - /// Get the map around the fixed point. - const FVps<double, N> &getFixedPointMap() const; - -private: - - // Not implemented. - void operator=(const FStaticFP &); - - // Fixed point position. - FVps<double, N> fixedPoint; - - // Map around the fixed point. - FVps<double, N> fixedPointMap; -}; - - -#include "FixedAlgebra/FMatrix.h" -#include "FixedAlgebra/FLUMatrix.h" -#include "FixedAlgebra/FMonomial.h" -#include "FixedAlgebra/FTps.h" -#include "FixedAlgebra/FVector.h" - - -// Class FStaticFP -// ------------------------------------------------------------------------ - -template <int N> -FStaticFP<N>::FStaticFP(): - fixedPoint(), fixedPointMap() -{} - - -template <int N> -FStaticFP<N>::FStaticFP(const FStaticFP &fp): - fixedPoint(fp.fixedPoint), fixedPointMap(fp.fixedPointMap) -{} - - -template <int N> -FStaticFP<N>::FStaticFP(const FVps<double, N> &map): - fixedPoint(), fixedPointMap() { - //std::cerr << "==> In FStaticFP<N>::FStaticFP(const FVps<double,N> &map)..." << std::endl; - const int nFree = 4; - FLUMatrix<double, N> lu; - FVector<double, N> fixPoint; - - // Find fixed point; - // tempMap will become the map around the fixed point. - FVps<double, N> tempMap(map); - - // Determine fixPoint of map T by iterating the contraction map - // z_{n+1} = z_n - (M(z_n) - I)^{-1} . (T(z_n) - z_n) - // Here M(z_n) is the matrix part of T(z_n + z); and the iterating atarts at z_0 = 0. - if(tempMap.getMinOrder() == 0) { - while(true) { - // Get system of equations for fixed point. - FMatrix<double, N, N> A = tempMap.linearTerms(); - FVector<double, N> Error = tempMap.constantTerm(); - double error = 0.0; - - // Form (A - I). - for(int i = 0; i < nFree; i++) { - A(i, i) -= 1.0; - if(std::abs(Error(i)) > error) error = std::abs(Error(i)); - } - for(int i = nFree; i < N; i++) { - for(int j = 0; j < N; j++) A(i, j) = A(j, i) = 0.0; - A(i, i) = 1.0; - Error(i) = 0.0; - } - - // Correct the fixed point. - lu = FLUMatrix<double, N>(A); - lu.backSubstitute(Error); - fixPoint -= Error; - - // Test for convergence. - static const double tol = 1.0e-10; - if(error < tol) break; - - // Build map around fixed point found so far. - // (Note that inside this while loop fixedPoint == Identity.) - tempMap = map.substitute(fixPoint + fixedPoint) - fixPoint; - } - } else { - // Force computation of lu. - FMatrix<double, N, N> A = tempMap.linearTerms(); - for(int i = 0; i < nFree; i++) A(i, i) -= 1.0; - for(int i = nFree; i < N; i++) { - for(int j = 0; j < N; j++) A(i, j) = A(j, i) = 0.0; - A(i, i) = 1.0; - } - lu = FLUMatrix<double, N>(A); - } - - // Fixed point map for orders one and higher in delta (dispersion). - fixedPoint.setTruncOrder(map.getMaxOrder()); - for(int limit = 1; limit <= map.getMaxOrder(); limit++) { - // Remove pure delta terms. - FVps<double, N> Q = tempMap.substitute(fixedPoint) - - fixedPoint.substitute(fixedPointMap); - FMonomial<N> delta; - delta[nFree+1] = limit; - FVector<double, N> Error; - for(int i = 0; i < nFree; i++) { - fixedPointMap[i] += Q[i].filter(limit, limit); - Error(i) = Q[i].getCoefficient(delta); - fixedPointMap[i].setCoefficient(delta, 0.0); - } - - lu.backSubstitute(Error); - - for(int i = 0; i < nFree; i += 2) { - // Effect on orbit. - fixedPoint[i].setCoefficient(delta, - Error(i)); - fixedPoint[i+1].setCoefficient(delta, - Error(i + 1)); - - // Orbit terms acting on path length difference. - FMonomial<N> powers; - powers[nFree+1] = limit - 1; - powers[i] = 1; - fixedPoint[nFree].setCoefficient(powers, double(limit) * Error(i + 1)); - powers[i] = 0; - powers[i+1] = 1; - fixedPoint[nFree].setCoefficient(powers, - double(limit) * Error(i)); - powers[i+1] = 0; - } - - // Path length term in delta^limit. - fixedPoint[nFree].setCoefficient(delta, Q[nFree].getCoefficient(delta)); - } - - // Fill in path length terms and identity for delta(p)/p. - fixedPointMap[nFree+1] = FTps<double, N>::makeVariable(nFree + 1); - fixedPointMap[nFree] = - fixedPoint.inverse()[nFree].substitute(tempMap).substitute(fixedPoint); - - // Combine fixed point and dispersion. - fixedPoint += fixPoint; - //std::cerr << "Leaving FStaticFP<N>::FStaticFP(...)" << std::endl; -} - - -template <int N> -FStaticFP<N>::~FStaticFP() -{} - - -template <int N> -const FVps<double, N> &FStaticFP<N>::getFixedPoint() const { - return fixedPoint; -} - - -template <int N> -const FVps<double, N> &FStaticFP<N>::getFixedPointMap() const { - return fixedPointMap; -} - -#endif // MAD_FStaticFP_HH diff --git a/src/Classic/FixedAlgebra/LinearMath.h b/src/Classic/FixedAlgebra/LinearMath.h deleted file mode 100644 index 4abf3f6a553bbb5e6339c25983a3b8ebff9af948..0000000000000000000000000000000000000000 --- a/src/Classic/FixedAlgebra/LinearMath.h +++ /dev/null @@ -1,193 +0,0 @@ -#ifndef CLASSIC_LinearMath_HH -#define CLASSIC_LinearMath_HH - -// ------------------------------------------------------------------------ -// $RCSfile: LinearMath.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1.2.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// Description: -// -// Declared template functions: -// -// ------------------------------------------------------------------------ -// Class category: FixedAlgebra -// ------------------------------------------------------------------------ -// -// $Date: 2004/11/18 22:18:06 $ -// $Author: jsberg $ -// -// ------------------------------------------------------------------------ - -#include "FixedAlgebra/LinearFun.h" -#include "Utilities/DomainError.h" - - -// Class LinearFun; global functions acting on LinearFun objects. -// These functions all work in the linear approximation. -// ------------------------------------------------------------------------ - -/// Power (int y). -template <class T, int N> -LinearFun<T, N> pow(const LinearFun<T, N> &x, int y); - -/// Square root. -template <class T, int N> -LinearFun<T, N> sqrt(const LinearFun<T, N> &x); - -/// Sine. -template <class T, int N> -LinearFun<T, N> sin(const LinearFun<T, N> &x); - -/// Cosine. -template <class T, int N> -LinearFun<T, N> cos(const LinearFun<T, N> &x); - -/// Tangent. -template <class T, int N> -LinearFun<T, N> tan(const LinearFun<T, N> &x); - -/// Cotangent. -template <class T, int N> -LinearFun<T, N> cot(const LinearFun<T, N> &x); - -/// Secant. -template <class T, int N> -LinearFun<T, N> sec(const LinearFun<T, N> &x); - -/// Cosecant. -template <class T, int N> -LinearFun<T, N> csc(const LinearFun<T, N> &x); - -/// Exponential. -template <class T, int N> -LinearFun<T, N> exp(const LinearFun<T, N> &x); - -/// Natural logarithm. -template <class T, int N> -LinearFun<T, N> log(const LinearFun<T, N> &x); - -/// Hyperbolic sine. -template <class T, int N> -LinearFun<T, N> sinh(const LinearFun<T, N> &x); - -/// Hyperbolic cosine. -template <class T, int N> -LinearFun<T, N> cosh(const LinearFun<T, N> &x); - -/// Hyperbolic tangent. -template <class T, int N> -LinearFun<T, N> tanh(const LinearFun<T, N> &x); - - -// Implementation -// ------------------------------------------------------------------------ - -template <class T, int N> -LinearFun<T, N> pow(const LinearFun<T, N> &x, int y) { - LinearFun<T, N> z; - z[0] = std::pow(x[0], y); - T fac = T(y) * std::pow(x[0], y - 1); - for(int i = 1; i <= N; ++i) z[i] = fac * x[i]; - return z; -} - - -template <class T, int N> -LinearFun<T, N> sqrt(const LinearFun<T, N> &x) { - T aZero = x[0]; - if(aZero <= 0.0) throw DomainError("sqrt(const LinearFun &)"); - T series[2]; - series[0] = sqrt(aZero); - series[1] = series[0] / (2.0 * aZero); - return x.taylor(series); -} - - -template <class T, int N> -LinearFun<T, N> sin(const LinearFun<T, N> &x) { - T aZero = x[0]; - T series[2]; - series[0] = sin(aZero); - series[1] = cos(aZero); - return x.taylor(series); -} - - -template <class T, int N> -LinearFun<T, N> cos(const LinearFun<T, N> &x) { - T aZero = x[0]; - T series[2]; - series[0] = cos(aZero); - series[1] = - sin(aZero); - return x.taylor(series); -} - - -template <class T, int N> -LinearFun<T, N> tan(const LinearFun<T, N> &x) { - return sin(x) / cos(x); -} - - -template <class T, int N> -LinearFun<T, N> sec(const LinearFun<T, N> &x) { - return cos(x).inverse(); -} - - -template <class T, int N> -LinearFun<T, N> csc(const LinearFun<T, N> &x) { - return sin(x).inverse(); -} - - -template <class T, int N> -LinearFun<T, N> exp(const LinearFun<T, N> &x) { - T aZero = x[0]; - T series[2]; - series[0] = series[1] = exp(aZero); - return x.taylor(series); -} - - -template <class T, int N> -LinearFun<T, N> log(const LinearFun<T, N> &x) { - T aZero = x[0]; - if(aZero <= 0) throw DomainError("log(const LinearFun &)"); - - T series[2]; - series[0] = log(aZero); - series[1] = T(1) / aZero; - return x.taylor(series); -} - - -template <class T, int N> -LinearFun<T, N> sinh(const LinearFun<T, N> &x) { - T aZero = x[0]; - T series[2]; - series[0] = sinh(aZero); - series[1] = cosh(aZero); - return x.taylor(series); -} - - -template <class T, int N> -LinearFun<T, N> cosh(const LinearFun<T, N> &x) { - T aZero = x[0]; - T series[2]; - series[0] = cosh(aZero); - series[1] = sinh(aZero); - return x.taylor(series); -} - - -template <class T, int N> -LinearFun<T, N> tanh(const LinearFun<T, N> &x) { - return sinh(x) / cosh(x); -} - -#endif // CLASSIC_LinearMath_HH diff --git a/src/Classic/FixedAlgebra/TransportMath.h b/src/Classic/FixedAlgebra/TransportMath.h deleted file mode 100644 index 5537e1235fc4baad95362bbaa322dcdbbed8051f..0000000000000000000000000000000000000000 --- a/src/Classic/FixedAlgebra/TransportMath.h +++ /dev/null @@ -1,194 +0,0 @@ -#ifndef CLASSIC_TransportMath_HH -#define CLASSIC_TransportMath_HH - -// ------------------------------------------------------------------------ -// $RCSfile: TransportMath.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1.2.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// Description: -// -// Declared template functions: -// Elementary functions acting on TransportFun<T,N> objects. -// -// ------------------------------------------------------------------------ -// Class category: FixedAlgebra -// ------------------------------------------------------------------------ -// -// $Date: 2004/11/18 22:50:59 $ -// $Author: jsberg $ -// -// ------------------------------------------------------------------------ - -#include "FixedAlgebra/TransportFun.h" -#include "Utilities/DomainError.h" - - -// Class TransportFun; global functions acting on TransportFun objects. -// These functions all work in the Transport approximation. -// ------------------------------------------------------------------------ - -/// Power (int y). -template <class T, int N> -TransportFun<T, N> pow(const TransportFun<T, N> &x, int y); - -/// Square root. -template <class T, int N> -TransportFun<T, N> sqrt(const TransportFun<T, N> &x); - -/// Sine. -template <class T, int N> -TransportFun<T, N> sin(const TransportFun<T, N> &x); - -/// Cosine. -template <class T, int N> -TransportFun<T, N> cos(const TransportFun<T, N> &x); - -/// Tangent. -template <class T, int N> -TransportFun<T, N> tan(const TransportFun<T, N> &x); - -/// Cotangent. -template <class T, int N> -TransportFun<T, N> cot(const TransportFun<T, N> &x); - -/// Secant. -template <class T, int N> -TransportFun<T, N> sec(const TransportFun<T, N> &x); - -/// Cosecant. -template <class T, int N> -TransportFun<T, N> csc(const TransportFun<T, N> &x); - -/// Exponential. -template <class T, int N> -TransportFun<T, N> exp(const TransportFun<T, N> &x); - -/// Natural logarithm. -template <class T, int N> -TransportFun<T, N> log(const TransportFun<T, N> &x); - -/// Hyperbolic sine. -template <class T, int N> -TransportFun<T, N> sinh(const TransportFun<T, N> &x); - -/// Hyperbolic cosine. -template <class T, int N> -TransportFun<T, N> cosh(const TransportFun<T, N> &x); - -/// Hyperbolic tangent. -template <class T, int N> -TransportFun<T, N> tanh(const TransportFun<T, N> &x); - - -// Implementation -// ------------------------------------------------------------------------ - -template <class T, int N> -TransportFun<T, N> pow(const TransportFun<T, N> &x, int y) { - TransportFun<T, N> z; - z[0] = std::pow(x[0], y); - T fac = T(y) * std::pow(x[0], y - 1); - for(int i = 1; i <= N; ++i) z[i] = fac * x[i]; - return z; -} - - -template <class T, int N> -TransportFun<T, N> sqrt(const TransportFun<T, N> &x) { - T aZero = x[0]; - if(aZero <= 0.0) throw DomainError("sqrt(const TransportFun &)"); - T series[2]; - series[0] = sqrt(aZero); - series[1] = series[0] / (2.0 * aZero); - return x.taylor(series); -} - - -template <class T, int N> -TransportFun<T, N> sin(const TransportFun<T, N> &x) { - T aZero = x[0]; - T series[2]; - series[0] = sin(aZero); - series[1] = cos(aZero); - return x.taylor(series); -} - - -template <class T, int N> -TransportFun<T, N> cos(const TransportFun<T, N> &x) { - T aZero = x[0]; - T series[2]; - series[0] = cos(aZero); - series[1] = - sin(aZero); - return x.taylor(series); -} - - -template <class T, int N> -TransportFun<T, N> tan(const TransportFun<T, N> &x) { - return sin(x) / cos(x); -} - - -template <class T, int N> -TransportFun<T, N> sec(const TransportFun<T, N> &x) { - return cos(x).inverse(); -} - - -template <class T, int N> -TransportFun<T, N> csc(const TransportFun<T, N> &x) { - return sin(x).inverse(); -} - - -template <class T, int N> -TransportFun<T, N> exp(const TransportFun<T, N> &x) { - T aZero = x[0]; - T series[2]; - series[0] = series[1] = exp(aZero); - return x.taylor(series); -} - - -template <class T, int N> -TransportFun<T, N> log(const TransportFun<T, N> &x) { - T aZero = x[0]; - if(aZero <= 0) throw DomainError("log(const TransportFun &)"); - - T series[2]; - series[0] = log(aZero); - series[1] = T(1) / aZero; - return x.taylor(series); -} - - -template <class T, int N> -TransportFun<T, N> sinh(const TransportFun<T, N> &x) { - T aZero = x[0]; - T series[2]; - series[0] = sinh(aZero); - series[1] = cosh(aZero); - return x.taylor(series); -} - - -template <class T, int N> -TransportFun<T, N> cosh(const TransportFun<T, N> &x) { - T aZero = x[0]; - T series[2]; - series[0] = cosh(aZero); - series[1] = sinh(aZero); - return x.taylor(series); -} - - -template <class T, int N> -TransportFun<T, N> tanh(const TransportFun<T, N> &x) { - return sinh(x) / cosh(x); -} - -#endif // CLASSIC_TransportMath_HH diff --git a/src/Classic/Utilities/Options.cpp b/src/Classic/Utilities/Options.cpp index d58eb9767ae325408cfc7023c0da6f5776d57516..f301cc4c1d18d3eee02c273c4c595adc6e4d86af 100644 --- a/src/Classic/Utilities/Options.cpp +++ b/src/Classic/Utilities/Options.cpp @@ -1,3 +1,21 @@ +// +// Namespace Options +// The global OPAL option flags. +// This namespace contains the global option flags. +// +// Copyright (c) 200x - 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 "OptionTypes.h" #include "Utilities/ClassicRandom.h" #include <string> @@ -10,7 +28,6 @@ namespace Options { bool warn = true; int warnLevel = 1; bool csrDump = false; - bool ppdebug = false; // If true create symmetric distribution bool cZero = false; diff --git a/src/Classic/Utilities/Options.h b/src/Classic/Utilities/Options.h index 50f4f708d9711297eaf81c10be7f6e392eb53aad..2056d08a20ffb66a08def17068947ead3d2fb2e5 100644 --- a/src/Classic/Utilities/Options.h +++ b/src/Classic/Utilities/Options.h @@ -1,28 +1,23 @@ -#ifndef OPTIONS_HH -#define OPTIONS_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Options.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Struct: Options +// Namespace Options +// The global OPAL option flags. +// This namespace contains the global option flags. // -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:33:48 $ -// $Author: Andreas Adelmann $ +// This file is part of OPAL. // -// ------------------------------------------------------------------------ - - -// Namespace Options. -// ------------------------------------------------------------------------ -/// The global OPAL option flags. -// This namespace contains the global option flags. +// 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 OPTIONS_HH +#define OPTIONS_HH #include "OptionTypes.h" #include "Utilities/ClassicRandom.h" @@ -46,10 +41,6 @@ namespace Options { extern bool csrDump; - /// ppdebug flag. - // If true, use special initial velocity distribution for parallel plate and print special debug output . - extern bool ppdebug; - /// if true create symmetric distribution extern bool cZero; diff --git a/src/Elements/AttCell.cpp b/src/Elements/AttCell.cpp deleted file mode 100644 index 5408d7ae13a43605a7bae4fccc701a50c6905ecf..0000000000000000000000000000000000000000 --- a/src/Elements/AttCell.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: AttCell.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.2 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: AttCell -// The representation of a table cell for OPAL ATTLIST commands. -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/28 11:50:57 $ -// $Author: opal $ -// -// ------------------------------------------------------------------------ - -#include "Elements/AttCell.h" -#include <iostream> - - -// Class AttCell. -// ------------------------------------------------------------------------ - -AttCell::AttCell() -{} - - -AttCell::~AttCell() -{} - - -void AttCell::setReal(double) -{} - - -void AttCell::setString(const std::string &) -{} - - -// Class AttString. -// ------------------------------------------------------------------------ - -AttString::AttString(): - itsValue() -{} - - -AttString::~AttString() -{} - - -void AttString::clearValue() { - itsValue.erase(); -} - - -void AttString::printFormat(std::ostream &os) const { - os << "%s"; -} - - -void AttString::printValue(std::ostream &os) const { - if(itsValue.empty()) { - os << "Null"; - } else { - os << itsValue; - } -} - - -void AttString::setString(const std::string &value) { - itsValue = value; -} - - -// Class AttReal. -// ------------------------------------------------------------------------ - -AttReal::AttReal(): - itsValue(0.0) -{} - - -AttReal::~AttReal() -{} - - -void AttReal::clearValue() { - itsValue = 0.0; -} - - -void AttReal::printFormat(std::ostream &os) const { - os << "%le"; -} - - -void AttReal::printValue(std::ostream &os) const { - os << itsValue; -} - - -void AttReal::setReal(double value) { - itsValue = value; -} diff --git a/src/Elements/AttCell.h b/src/Elements/AttCell.h deleted file mode 100644 index f45da770261cb66db71aeb8750045683d5fb67a9..0000000000000000000000000000000000000000 --- a/src/Elements/AttCell.h +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef OPAL_AttCell_HH -#define OPAL_AttCell_HH 1 - -// ------------------------------------------------------------------------ -// $RCSfile: AttCell.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: AttCell -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:40 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include <map> -#include <string> - - -// Class AttCell. -// ------------------------------------------------------------------------ -/// The abstract base class for attribute cells. -// Representation of a table cell for ATTLIST command. - -class AttCell { - -public: - - AttCell(); - virtual ~AttCell(); - - /// Clear the value. - // Reset the value to undefined. - virtual void clearValue() = 0; - - /// Print the attribute format. - // Print the format string in C style. - virtual void printFormat(std::ostream &os) const = 0; - - /// Print the attribute value. - // According to the format string. - virtual void printValue(std::ostream &os) const = 0; - - /// Store the value. - // Set the cell value to the given double. - virtual void setReal(double); - - /// Store the value. - // Set the cell value to the given string. - virtual void setString(const std::string &); - -private: - - // Not implemented. - AttCell(const AttCell &); - void operator=(const AttCell &); -}; - - -// Class AttReal. -// ------------------------------------------------------------------------ -/// The class for attribute cells with a real value. - -class AttReal: public AttCell { - -public: - - AttReal(); - virtual ~AttReal(); - - /// Clear the value. - virtual void clearValue(); - - /// Print the attribute format. - // Prints "%le". - virtual void printFormat(std::ostream &os) const; - - /// Print the attribute value. - virtual void printValue(std::ostream &os) const; - - /// Store the value. - virtual void setReal(double); - -private: - - // Not implemented. - AttReal(const AttReal &); - void operator=(const AttReal &); - - // The attribute value. - double itsValue; -}; - - -// Class AttString. -// ------------------------------------------------------------------------ -/// The class for attribute cells with a string value. - -class AttString: public AttCell { - -public: - - AttString(); - virtual ~AttString(); - - /// Clear the value. - virtual void clearValue(); - - /// Print the attribute format. - // Prints "%s". - virtual void printFormat(std::ostream &os) const; - - /// Print the attribute value. - virtual void printValue(std::ostream &os) const; - - /// Store the value. - virtual void setString(const std::string &); - -private: - - // Not implemented. - AttString(const AttString &); - void operator=(const AttString &); - - // The attribute value. - std::string itsValue; -}; - -#endif // OPAL_AttCell_HH diff --git a/src/Elements/CMakeLists.txt b/src/Elements/CMakeLists.txt index 9b3f90b73c1065c30da11900def91f9c70adb816..4210092fad4b2ad2d3f03b86afb5300119027f16 100644 --- a/src/Elements/CMakeLists.txt +++ b/src/Elements/CMakeLists.txt @@ -1,5 +1,4 @@ set (_SRCS - AttCell.cpp OpalBeamStripping.cpp OpalBend.cpp OpalCavity.cpp @@ -12,8 +11,6 @@ set (_SRCS OpalDegrader.cpp OpalElement.cpp OpalHKicker.cpp - OpalHMonitor.cpp - OpalInstrument.cpp OpalKicker.cpp OpalMarker.cpp OpalMonitor.cpp @@ -27,7 +24,6 @@ set (_SRCS OpalOffset/OpalLocalCartesianOffset.cpp OpalOffset/OpalGlobalCylindricalOffset.cpp OpalOffset/OpalGlobalCartesianOffset.cpp - OpalPatch.cpp OpalProbe.cpp OpalPepperPot.cpp OpalPolynomialTimeDependence.cpp @@ -39,22 +35,17 @@ set (_SRCS OpalSBend.cpp OpalSBend3D.cpp OpalScalingFFAMagnet.cpp - OpalSeparator.cpp OpalSeptum.cpp OpalSextupole.cpp OpalSlit.cpp OpalSolenoid.cpp OpalSource.cpp OpalSplineTimeDependence.cpp - OpalSRot.cpp OpalVariableRFCavity.cpp OpalVariableRFCavityFringeField.cpp OpalVerticalFFAMagnet.cpp OpalVKicker.cpp - OpalVMonitor.cpp - OpalYRot.cpp OpalBeamline.cpp - OpalParallelPlate.cpp OpalStripper.cpp ) @@ -65,7 +56,6 @@ include_directories ( add_opal_sources (${_SRCS}) set (HDRS - AttCell.h OpalBeamline.h OpalBeamStripping.h OpalBend.h @@ -77,8 +67,6 @@ set (HDRS OpalECollimator.h OpalElement.h OpalHKicker.h - OpalHMonitor.h - OpalInstrument.h OpalKicker.h OpalMarker.h OpalMonitor.h @@ -88,8 +76,6 @@ set (HDRS OpalMultipoleTCurvedConstRadius.h OpalMultipoleTCurvedVarRadius.h OpalOctupole.h - OpalParallelPlate.h - OpalPatch.h OpalPepperPot.h OpalPolynomialTimeDependence.h OpalProbe.h @@ -101,22 +87,18 @@ set (HDRS OpalSBend3D.h OpalSBend.h OpalScalingFFAMagnet.h - OpalSeparator.h OpalSeptum.h OpalSextupole.h OpalSlit.h OpalSolenoid.h OpalSource.h OpalSplineTimeDependence.h - OpalSRot.h OpalStripper.h OpalTravelingWave.h OpalVariableRFCavity.h OpalVariableRFCavityFringeField.h OpalVerticalFFAMagnet.h OpalVKicker.h - OpalVMonitor.h - OpalYRot.h OpalOffset/OpalGlobalCartesianOffset.h OpalOffset/OpalGlobalCylindricalOffset.h OpalOffset/OpalLocalCartesianOffset.h diff --git a/src/Elements/OpalBeamStripping.cpp b/src/Elements/OpalBeamStripping.cpp index 59db360f647630422c4b0063801ae7462897b7c6..2cf0ef2eb2d2a98c2191b593ee6dbbcf1518ab78 100644 --- a/src/Elements/OpalBeamStripping.cpp +++ b/src/Elements/OpalBeamStripping.cpp @@ -47,12 +47,6 @@ OpalBeamStripping::OpalBeamStripping(): itsAttr[STOP] = Attributes::makeBool ("STOP", "Option Whether stop tracking after beam stripping. Default: true", true); - registerRealAttribute("PRESSURE"); - registerRealAttribute("TEMPERATURE"); - registerStringAttribute("PMAPFN"); - registerRealAttribute("PSCALE"); - registerStringAttribute("GAS"); - registerOwnership(); setElement(new BeamStrippingRep("BEAMSTRIPPING")); @@ -76,11 +70,6 @@ OpalBeamStripping *OpalBeamStripping::clone(const std::string &name) { } -void OpalBeamStripping::fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - - void OpalBeamStripping::update() { OpalElement::update(); diff --git a/src/Elements/OpalBeamStripping.h b/src/Elements/OpalBeamStripping.h index 7776d216649c75dde81a56c76692c45d1ffaa190..52c8dc02d72241b266f19271dcae2c939c4c3d32 100644 --- a/src/Elements/OpalBeamStripping.h +++ b/src/Elements/OpalBeamStripping.h @@ -52,9 +52,6 @@ public: /// Make clone. virtual OpalBeamStripping *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC beam stripping. virtual void update(); diff --git a/src/Elements/OpalBeamline.cpp b/src/Elements/OpalBeamline.cpp index 0bc448391d950a289928f0ca2e04ee4f019d1472..076e433c16d1eebbc0c639e3fd1a458c69582d35 100644 --- a/src/Elements/OpalBeamline.cpp +++ b/src/Elements/OpalBeamline.cpp @@ -86,8 +86,7 @@ unsigned long OpalBeamline::getFieldAt(const Vector_t &position, ElementBase::ElementType type = (*it)->getType(); if (type == ElementBase::MONITOR || type == ElementBase::MARKER || - type == ElementBase::CCOLLIMATOR || - type == ElementBase::DIAGNOSTIC) continue; + type == ElementBase::CCOLLIMATOR) continue; Vector_t localR = transformToLocalCS(*it, position); Vector_t localP = rotateToLocalCS(*it, momentum); diff --git a/src/Elements/OpalBeamline.h b/src/Elements/OpalBeamline.h index f452faf7267f078248b85d30f98d149aa5f9ec6a..49d8e75fa08ee4ef524c29b7079c2f3fc3efffa3 100644 --- a/src/Elements/OpalBeamline.h +++ b/src/Elements/OpalBeamline.h @@ -22,14 +22,9 @@ #include <string> #include "Beamlines/Beamline.h" -#include "AbsBeamline/BeamBeam.h" #include "AbsBeamline/Corrector.h" #include "AbsBeamline/Degrader.h" -#include "AbsBeamline/Diagnostic.h" -#include "AbsBeamline/Lambertson.h" #include "AbsBeamline/Marker.h" -#include "AbsBeamline/RFQuadrupole.h" -#include "AbsBeamline/Separator.h" #include "AbsBeamline/Septum.h" #include "AbsBeamline/Source.h" @@ -135,35 +130,10 @@ void OpalBeamline::visit<Source>(const Source &element, BeamlineVisitor &, PartB elements_m.push_back(ClassicField(elptr, startField, endField)); } -template<> inline -void OpalBeamline::visit<BeamBeam>(const BeamBeam &element, BeamlineVisitor &, PartBunchBase<double, 3> *) { - WARNMSG(element.getTypeString() << " not implemented yet!" << endl); -} - -template<> inline -void OpalBeamline::visit<Diagnostic>(const Diagnostic &element, BeamlineVisitor &, PartBunchBase<double, 3> *) { - WARNMSG(element.getTypeString() << " not implemented yet!" << endl); -} - -template<> inline -void OpalBeamline::visit<Lambertson>(const Lambertson &element, BeamlineVisitor &, PartBunchBase<double, 3> *) { - WARNMSG(element.getTypeString() << " not implemented yet!" << endl); -} - template<> inline void OpalBeamline::visit<Marker>(const Marker &/*element*/, BeamlineVisitor &, PartBunchBase<double, 3> *) { } -template<> inline -void OpalBeamline::visit<RFQuadrupole>(const RFQuadrupole &element, BeamlineVisitor &, PartBunchBase<double, 3> *) { - WARNMSG(element.getTypeString() << " not implemented yet!" << endl); -} - -template<> inline -void OpalBeamline::visit<Separator>(const Separator &element, BeamlineVisitor &, PartBunchBase<double, 3> *) { - WARNMSG(element.getTypeString() << " not implemented yet!" << endl); -} - template<> inline void OpalBeamline::visit<Septum>(const Septum &element, BeamlineVisitor &, PartBunchBase<double, 3> *) { WARNMSG(element.getTypeString() << " not implemented yet!" << endl); diff --git a/src/Elements/OpalBend.cpp b/src/Elements/OpalBend.cpp index 4e81af52cd5db911c7f904be89efcd3235fdcfba..f18d1acd510a618abbd4dc394dcb3f4ddab812be 100644 --- a/src/Elements/OpalBend.cpp +++ b/src/Elements/OpalBend.cpp @@ -79,30 +79,6 @@ OpalBend::OpalBend(const char *name, const char *help): itsAttr[NSLICES] = Attributes::makeReal ("NSLICES", "The number of slices/ steps for this element in Map Tracking", 1); - - registerRealAttribute("ANGLE"); - registerRealAttribute("K0L"); - registerRealAttribute("K0SL"); - registerRealAttribute("K1L"); - registerRealAttribute("K1SL"); - registerRealAttribute("K2L"); - registerRealAttribute("K2SL"); - registerRealAttribute("K3L"); - registerRealAttribute("K3SL"); - registerRealAttribute("E1"); - registerRealAttribute("E2"); - registerRealAttribute("H1"); - registerRealAttribute("H2"); - registerRealAttribute("HGAP"); - registerRealAttribute("FINT"); - registerRealAttribute("SLICES"); - registerRealAttribute("STEPSIZE"); - registerStringAttribute("FMAPFN"); - registerRealAttribute("GAP"); - registerRealAttribute("HAPERT"); - registerRealAttribute("ROTATION"); - registerRealAttribute("DESIGNENERGY"); - registerRealAttribute("NSLICES"); } diff --git a/src/Elements/OpalCCollimator.cpp b/src/Elements/OpalCCollimator.cpp index 635cfe6a99bc96f7afe887602162088d70188369..a877d1dc25ff3e8c0315de2d492f775d48009211 100644 --- a/src/Elements/OpalCCollimator.cpp +++ b/src/Elements/OpalCCollimator.cpp @@ -46,15 +46,6 @@ OpalCCollimator::OpalCCollimator(): itsAttr[OUTFN] = Attributes::makeString ("OUTFN", "Output filename"); - registerRealAttribute("XSTART"); - registerRealAttribute("XEND"); - registerRealAttribute("YSTART"); - registerRealAttribute("YEND"); - registerRealAttribute("ZSTART"); - registerRealAttribute("ZEND"); - registerRealAttribute("WIDTH"); - registerStringAttribute("OUTFN"); - registerOwnership(); setElement(new CCollimatorRep("CCOLLIMATOR")); @@ -79,11 +70,6 @@ OpalCCollimator *OpalCCollimator::clone(const std::string &name) { } -void OpalCCollimator::fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - - void OpalCCollimator::update() { OpalElement::update(); diff --git a/src/Elements/OpalCCollimator.h b/src/Elements/OpalCCollimator.h index b97263f3160d9f9b7edd4d1dfaee1cb85f5a4b33..b9727484caf56ffb8469ba09c5179e859171219a 100644 --- a/src/Elements/OpalCCollimator.h +++ b/src/Elements/OpalCCollimator.h @@ -47,9 +47,6 @@ public: /// Make clone. virtual OpalCCollimator *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC collimator. virtual void update(); diff --git a/src/Elements/OpalCavity.cpp b/src/Elements/OpalCavity.cpp index d7548d3224e5d52525ff37c4b0d4fa5d73a3e59e..3f56dce7779fc2cbca2e799b4f9c1ac62bcfed3f 100644 --- a/src/Elements/OpalCavity.cpp +++ b/src/Elements/OpalCavity.cpp @@ -80,26 +80,6 @@ OpalCavity::OpalCavity(): itsAttr[FREQUENCY_MODEL] = Attributes::makeString("FREQUENCY_MODEL", "The name of the frequency time dependence model."); - registerRealAttribute("VOLT"); - registerRealAttribute("DVOLT"); - registerRealAttribute("FREQ"); - registerRealAttribute("LAG"); - registerRealAttribute("DLAG"); - registerStringAttribute("FMAPFN"); - registerStringAttribute("GEOMETRY"); - registerRealAttribute("RMIN"); - registerRealAttribute("RMAX"); - registerRealAttribute("ANGLE"); - registerRealAttribute("PDIS"); - registerRealAttribute("GAPWIDTH"); - registerRealAttribute("PHI0"); - registerRealAttribute("DESIGNENERGY"); - - // attibutes for timedependent values - registerStringAttribute("PHASE_MODEL"); - registerStringAttribute("AMPLITUDE_MODEL"); - registerStringAttribute("FREQUENCY_MODEL"); - registerOwnership(); setElement(new RFCavityRep("RFCAVITY")); @@ -125,18 +105,6 @@ OpalCavity *OpalCavity::clone(const std::string &name) { } -void OpalCavity::fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const RFCavityRep *rfc = - dynamic_cast<const RFCavityRep *>(&base); - attributeRegistry["VOLT"]->setReal(rfc->getAmplitude()); - attributeRegistry["FREQ"]->setReal(rfc->getFrequency()); - attributeRegistry["LAG"]->setReal(rfc->getPhase()); - attributeRegistry["FMAPFN"]->setString(rfc->getFieldMapFN()); -} - - void OpalCavity::update() { OpalElement::update(); diff --git a/src/Elements/OpalCavity.h b/src/Elements/OpalCavity.h index 6eefff28df456c021ae553c57a3439e87d4e6bd0..bc4694d7b874956d1c02f3b314f3f2a6356d30a6 100644 --- a/src/Elements/OpalCavity.h +++ b/src/Elements/OpalCavity.h @@ -64,9 +64,6 @@ public: /// Make clone. virtual OpalCavity *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC cavity. virtual void update(); diff --git a/src/Elements/OpalCyclotron.cpp b/src/Elements/OpalCyclotron.cpp index b6aee782130753cdc94cfb8b1c3c5747cee3b077..0f1a2fa8bcd1cbaffef0181854f8713951e6483f 100644 --- a/src/Elements/OpalCyclotron.cpp +++ b/src/Elements/OpalCyclotron.cpp @@ -113,32 +113,6 @@ OpalCyclotron::OpalCyclotron(): itsAttr[TRIMCOIL] = Attributes::makeStringArray ("TRIMCOIL", "List of trim coils"); - - registerStringAttribute("FMAPFN"); - registerStringAttribute("GEOMETRY"); - registerStringAttribute("RFMAPFN"); - registerStringAttribute("RFFCFN"); - registerStringAttribute("RFVCFN"); - registerStringAttribute("TYPE"); - registerRealAttribute("CYHARMON"); - registerRealAttribute("RINIT"); - registerRealAttribute("PRINIT"); - registerRealAttribute("PHIINIT"); - registerRealAttribute("ZINIT"); - registerRealAttribute("PZINIT"); - registerRealAttribute("SYMMETRY"); - registerRealAttribute("RFFREQ"); - registerRealAttribute("BSCALE"); - registerRealAttribute("ESCALE"); - registerRealAttribute("RFPHI"); - registerRealAttribute("MINZ"); - registerRealAttribute("MAXZ"); - registerRealAttribute("MINR"); - registerRealAttribute("MAXR"); - registerRealAttribute("FMLOWE"); - registerRealAttribute("FMHIGHE"); - registerRealAttribute("TRIMCOILTHRESHOLD"); - registerOwnership(); setElement(new CyclotronRep("CYCLOTRON")); @@ -160,12 +134,6 @@ OpalCyclotron *OpalCyclotron::clone(const std::string &name) { } -void OpalCyclotron:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - - void OpalCyclotron::update() { CyclotronRep *cycl = dynamic_cast<CyclotronRep *>(getElement()); diff --git a/src/Elements/OpalCyclotron.h b/src/Elements/OpalCyclotron.h index 28d908919a7ebb631562c7a23f25654c54d9351f..9b43e685348c6c38b8e015010062cd7d1ee1cec4 100644 --- a/src/Elements/OpalCyclotron.h +++ b/src/Elements/OpalCyclotron.h @@ -70,9 +70,6 @@ public: /// Make clone. virtual OpalCyclotron *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC cavity. virtual void update(); diff --git a/src/Elements/OpalDegrader.cpp b/src/Elements/OpalDegrader.cpp index 8da696c82392c422a6874d4bd6769b5e5e58c395..3751092eb6e754e50ad6563e392ea29214ae214a 100644 --- a/src/Elements/OpalDegrader.cpp +++ b/src/Elements/OpalDegrader.cpp @@ -32,8 +32,6 @@ OpalDegrader::OpalDegrader(): itsAttr[OUTFN] = Attributes::makeString ("OUTFN", "Degrader output filename"); - registerStringAttribute("OUTFN"); - registerOwnership(); setElement(new DegraderRep("DEGRADER")); @@ -58,11 +56,6 @@ OpalDegrader *OpalDegrader::clone(const std::string &name) { } -void OpalDegrader::fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - - void OpalDegrader::update() { OpalElement::update(); diff --git a/src/Elements/OpalDegrader.h b/src/Elements/OpalDegrader.h index fac710f9896bcee08f9f53037bd46b598a10f6c0..ec26ee35584010a4546a6000a1d148bff5105f00 100644 --- a/src/Elements/OpalDegrader.h +++ b/src/Elements/OpalDegrader.h @@ -42,9 +42,6 @@ public: /// Make clone. virtual OpalDegrader *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC collimator. virtual void update(); diff --git a/src/Elements/OpalDrift.cpp b/src/Elements/OpalDrift.cpp index 98878319a0a12441eeb4ef87ec5392b0c185e815..46e99ce76d6044eca12dc2f9ed6340f02fd2e66a 100644 --- a/src/Elements/OpalDrift.cpp +++ b/src/Elements/OpalDrift.cpp @@ -38,7 +38,6 @@ OpalDrift::OpalDrift(): // itsAttr[LENGTH] = Attributes::makeReal // ("LENGTH", "Drift length"); - // registerRealAttribute("LENGTH"); itsAttr[GEOMETRY] = Attributes::makeString ("GEOMETRY", "BoundaryGeometry for Drifts"); @@ -46,9 +45,6 @@ OpalDrift::OpalDrift(): ("NSLICES", "The number of slices/ steps for this element in Map Tracking", 1); - - registerStringAttribute("GEOMETRY"); - registerRealAttribute("NSLICES"); registerOwnership(); setElement(new DriftRep("DRIFT")); diff --git a/src/Elements/OpalECollimator.cpp b/src/Elements/OpalECollimator.cpp index 53329d657019a94ec2a93667b4348598daee6344..a810918878c4fc45a27f5ad38b67b98626a5838e 100644 --- a/src/Elements/OpalECollimator.cpp +++ b/src/Elements/OpalECollimator.cpp @@ -34,11 +34,6 @@ OpalECollimator::OpalECollimator(): itsAttr[OUTFN] = Attributes::makeString ("OUTFN", "Monitor output filename"); - - registerStringAttribute("OUTFN"); - registerRealAttribute("XSIZE"); - registerRealAttribute("YSIZE"); - registerOwnership(); setElement(new FlexibleCollimatorRep("ECOLLIMATOR")); @@ -63,26 +58,6 @@ OpalECollimator *OpalECollimator::clone(const std::string &name) { } -void OpalECollimator::fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const FlexibleCollimatorRep *coll = - dynamic_cast<const FlexibleCollimatorRep *>(&base); - std::string Double("(-?[0-9]+\\.?[0-9]*([Ee][+-]?[0-9]+)?)"); - std::string desc = coll->getDescription(); - - boost::regex parser("ellipse\\(" + Double + "," + Double + "\\)"); - boost::smatch what; - if (!boost::regex_match(desc, what, parser)) return; - - double width = atof(std::string(what[1]).c_str()); - double height = atof(std::string(what[3]).c_str()); - - attributeRegistry["XSIZE"]->setReal(0.5 * width); - attributeRegistry["YSIZE"]->setReal(0.5 * height); -} - - void OpalECollimator::update() { OpalElement::update(); diff --git a/src/Elements/OpalECollimator.h b/src/Elements/OpalECollimator.h index 10ade1dd04b26cc7cef030498063fdccc894d207..c4bd5c493579fe1556d9ed114eafc4109df33dd8 100644 --- a/src/Elements/OpalECollimator.h +++ b/src/Elements/OpalECollimator.h @@ -42,9 +42,6 @@ public: /// Make clone. virtual OpalECollimator *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC collimator. virtual void update(); diff --git a/src/Elements/OpalElement.cpp b/src/Elements/OpalElement.cpp index 684fc18f62354414ef97a6bbe5bb05471f603e96..1188416ba8a98e4cadd0f57adf39d467676f24c7 100644 --- a/src/Elements/OpalElement.cpp +++ b/src/Elements/OpalElement.cpp @@ -2,14 +2,6 @@ // Class OpalElement // Base class for all beam line elements. // -// It defines a registry for attribute cells, used in the ATTLIST command -// only. The exemplar constructors for all OPAL element commands store all -// defined attribute names in this registry. The ATTLIST command can walk -// through a beam line or sequence, and call the fillRegisteredAttributes() -// method for each element. This method will fill in the values for all -// attributes which exist for this element, and the ATTLIST command can -// look them up with findRegisteredAttribute() to build up a print line. -// // Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland // All rights reserved // @@ -24,7 +16,6 @@ // along with OPAL. If not, see <https://www.gnu.org/licenses/>. // #include "Elements/OpalElement.h" -#include "AbsBeamline/ElementImage.h" #include "AbsBeamline/Bend2D.h" #include "AbstractObjects/Attribute.h" #include "AbstractObjects/Expressions.h" @@ -44,8 +35,6 @@ #include <boost/regex.hpp> -std::map < std::string, OwnPtr<AttCell> > OpalElement::attributeRegistry; - OpalElement::OpalElement(int size, const char *name, const char *help): Element(size, name, help), itsSize(size) { itsAttr[TYPE] = Attributes::makeUpperCaseString @@ -101,32 +90,6 @@ OpalElement::OpalElement(int size, const char *name, const char *help): for (unsigned int i = 0; i < end; ++ i) { AttributeHandler::addAttributeOwner("Any", AttributeHandler::ELEMENT, itsAttr[i].getName()); } - - static bool first = true; - if(first) { - registerStringAttribute("NAME"); - registerStringAttribute("TYPE"); - registerStringAttribute("CLASS"); - registerStringAttribute("KEYWORD"); - registerRealAttribute("L"); - registerStringAttribute("WAKEF"); - registerStringAttribute("PARTICLEMATTERINTERACTION"); - registerStringAttribute("APERT"); - registerRealAttribute("X"); - registerRealAttribute("Y"); - registerRealAttribute("Z"); - registerRealAttribute("THETA"); - registerRealAttribute("PHI"); - registerRealAttribute("PSI"); - registerRealAttribute("DX"); - registerRealAttribute("DY"); - registerRealAttribute("DZ"); - registerRealAttribute("DTHETA"); - registerRealAttribute("DPHI"); - registerRealAttribute("DPSI"); - first = false; - } - } @@ -139,71 +102,6 @@ OpalElement::~OpalElement() {} -void OpalElement:: -fillRegisteredAttributes(const ElementBase &base) { - // Fill in the common data for all elements. - attributeRegistry["NAME"]->setString(getOpalName()); - attributeRegistry["TYPE"]->setString(getTypeName()); - attributeRegistry["CLASS"]->setString(getParent()->getOpalName()); - attributeRegistry["KEYWORD"]->setString(getBaseObject()->getOpalName()); - attributeRegistry["L"]->setReal(base.getElementLength()); - - CoordinateSystemTrafo global2local = base.getCSTrafoGlobal2Local(); - Vector_t origin = global2local.getOrigin(); - Vector_t orientation = Util::getTaitBryantAngles(global2local.getRotation().conjugate()); - attributeRegistry["X"]->setReal(origin[0]); - attributeRegistry["Y"]->setReal(origin[1]); - attributeRegistry["Z"]->setReal(origin[2]); - attributeRegistry["THETA"]->setReal(orientation[0]); - attributeRegistry["PHI"]->setReal(orientation[1]); - attributeRegistry["PSI"]->setReal(orientation[2]); - - // Misalignments. - CoordinateSystemTrafo misalignment = base.getMisalignment(); - Vector_t misalignmentShift = misalignment.getOrigin(); - Vector_t misalignmentAngles = Util::getTaitBryantAngles(misalignment.getRotation().conjugate()); - - attributeRegistry["DX"]->setReal(misalignmentShift(0)); - attributeRegistry["DY"]->setReal(misalignmentShift(1)); - attributeRegistry["DZ"]->setReal(misalignmentShift(2)); - attributeRegistry["DTHETA"]->setReal(misalignmentAngles[0]); - attributeRegistry["DPHI"]->setReal(misalignmentAngles[1]); - attributeRegistry["DPSI"]->setReal(misalignmentAngles[2]); - - // Fill in the "unknown" attributes. - ElementImage *image = base.ElementBase::getImage(); - AttributeSet::const_iterator cur = image->begin(); - AttributeSet::const_iterator end = image->end(); - for(; cur != end; ++cur) { - attributeRegistry[cur->first]->setReal(cur->second); - } -} - - -AttCell *OpalElement::findRegisteredAttribute(const std::string &name) { - AttCell *cell = &*attributeRegistry[name]; - - if(cell == 0) { - std::string::size_type i = 0; - - if(name[i] == 'K') { - ++i; - while(std::isdigit(name[i])) ++i; - if(name[i] == 'S') ++i; - - if(name[i] == 'L' && ++i == name.length()) { - attributeRegistry[name] = cell = new AttReal(); - } else { - throw OpalException("OpalElement::findRegisteredAttribute()", - "There is no element which has an attribute " - "called \"" + name + "\"."); - } - } - } - - return cell; -} - std::pair<ElementBase::ApertureType, std::vector<double> > OpalElement::getApert() const { std::pair<ElementBase::ApertureType, std::vector<double> > retvalue(ElementBase::ELLIPTICAL, @@ -431,18 +329,6 @@ void OpalElement::print(std::ostream &os) const { } -void OpalElement::setRegisteredAttribute -(const std::string &name, double value) { - attributeRegistry[name]->setReal(value); -} - - -void OpalElement::setRegisteredAttribute -(const std::string &name, const std::string &value) { - attributeRegistry[name]->setString(value); -} - - void OpalElement::printMultipoleStrength (std::ostream &os, int order, int &len, const std::string &sName, const std::string &tName, @@ -671,23 +557,6 @@ void OpalElement::printAttribute } -AttCell *OpalElement::registerRealAttribute(const std::string &name) { - OwnPtr<AttCell> &cell = attributeRegistry[name]; - if(! cell.isValid()) { - cell = new AttReal(); - } - return &*cell; -} - - -AttCell *OpalElement::registerStringAttribute(const std::string &name) { - OwnPtr<AttCell> &cell = attributeRegistry[name]; - if(! cell.isValid()) { - cell = new AttString(); - } - return &*cell; -} - void OpalElement::registerOwnership() const { if (getParent() != 0) return; diff --git a/src/Elements/OpalElement.h b/src/Elements/OpalElement.h index 10b4e9ec9cf8711e2e1d9647c76266ecf94fe745..4c43fae214f70adcf37e2ea26aaafff0fbc7a729 100644 --- a/src/Elements/OpalElement.h +++ b/src/Elements/OpalElement.h @@ -2,14 +2,6 @@ // Class OpalElement // Base class for all beam line elements. // -// It defines a registry for attribute cells, used in the ATTLIST command -// only. The exemplar constructors for all OPAL element commands store all -// defined attribute names in this registry. The ATTLIST command can walk -// through a beam line or sequence, and call the fillRegisteredAttributes() -// method for each element. This method will fill in the values for all -// attributes which exist for this element, and the ATTLIST command can -// look them up with findRegisteredAttribute() to build up a print line. -// // Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland // All rights reserved // @@ -27,7 +19,6 @@ #define OPAL_OpalElement_HH #include "AbstractObjects/Element.h" -#include "Elements/AttCell.h" #include "MemoryManagement/OwnPtr.h" #include <map> @@ -65,14 +56,6 @@ public: virtual ~OpalElement(); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - - /// Find a registered attribute. - // Return a pointer to the AttCell for a named attribute. - static AttCell *findRegisteredAttribute(const std::string &name); - - /// Return element length. virtual double getLength() const; @@ -105,12 +88,6 @@ public: // This special version handles special printing in OPAL-8 format. virtual void print(std::ostream &) const; - /// Store a registered real attribute. - static void setRegisteredAttribute(const std::string &, double); - - /// Store a registered string attribute. - static void setRegisteredAttribute(const std::string &, const std::string &); - /// Update the embedded CLASSIC element. virtual void update(); @@ -149,17 +126,6 @@ protected: double value, int &len); - /// Register a ``real'' element attribute. - // A registered attribute can be listed by the ATTLIST command. - static AttCell *registerRealAttribute(const std::string &name); - - /// Register a ``string'' element attribute. - // A registered attribute can be listed by the ATTLIST command. - static AttCell *registerStringAttribute(const std::string &name); - - /// The registry for named attributes. - static std::map < std::string, OwnPtr<AttCell> > attributeRegistry; - void registerOwnership() const; private: diff --git a/src/Elements/OpalFlexibleCollimator.cpp b/src/Elements/OpalFlexibleCollimator.cpp index 20a3b70cad23b13c1f7f493ce60b27d6d71c2df0..00c71d6808601fdf6a7434c3f4afaaad6840000b 100644 --- a/src/Elements/OpalFlexibleCollimator.cpp +++ b/src/Elements/OpalFlexibleCollimator.cpp @@ -35,11 +35,6 @@ OpalFlexibleCollimator::OpalFlexibleCollimator(): ("OUTFN", "File name of log file for deleted particles"); itsAttr[DUMP] = Attributes::makeBool ("DUMP", "Save quadtree and holes of collimator", false); - - registerStringAttribute("OUTFN"); - registerStringAttribute("DESC"); - registerStringAttribute("FNAME"); - registerOwnership(); setElement(new FlexibleCollimatorRep("FLEXIBLECOLLIMATOR")); @@ -64,15 +59,6 @@ OpalFlexibleCollimator *OpalFlexibleCollimator::clone(const std::string &name) { } -void OpalFlexibleCollimator::fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const FlexibleCollimatorRep *coll = - dynamic_cast<const FlexibleCollimatorRep *>(&base); - attributeRegistry["DESCRIPTION"]->setString(coll->getDescription()); -} - - void OpalFlexibleCollimator::update() { OpalElement::update(); diff --git a/src/Elements/OpalFlexibleCollimator.h b/src/Elements/OpalFlexibleCollimator.h index f11ceff8c6d460644f2f81d06a48a6ff858883d7..050aa6403b74bd121d83485b012abf6b6378edc4 100644 --- a/src/Elements/OpalFlexibleCollimator.h +++ b/src/Elements/OpalFlexibleCollimator.h @@ -43,9 +43,6 @@ public: /// Make clone. virtual OpalFlexibleCollimator *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC collimator. virtual void update(); diff --git a/src/Elements/OpalHKicker.cpp b/src/Elements/OpalHKicker.cpp index d4e561d256a5a4cdf14704668eaf2c130fa155e0..202be8bc29fe38a3f7bf679655d46913a42e7069 100644 --- a/src/Elements/OpalHKicker.cpp +++ b/src/Elements/OpalHKicker.cpp @@ -34,10 +34,6 @@ OpalHKicker::OpalHKicker(): itsAttr[K0] = Attributes::makeReal ("K0", "Normal dipole field in T"); - registerRealAttribute("HKICK"); - registerRealAttribute("DESIGNENERGY"); - registerRealAttribute("K0"); - registerOwnership(); setElement(new XCorrectorRep("HKICKER")); @@ -59,19 +55,6 @@ OpalHKicker *OpalHKicker::clone(const std::string &name) { } -void OpalHKicker:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const XCorrectorRep *corr = dynamic_cast<const XCorrectorRep *>(&base); - BDipoleField field = corr->getField(); - - double scale = Physics::c / OpalData::getInstance()->getP0(); - attributeRegistry["HKICK"]->setReal(- field.getBy() * scale); - attributeRegistry["VKICK"]->setReal(+ field.getBx() * scale); -} - - void OpalHKicker::update() { OpalElement::update(); diff --git a/src/Elements/OpalHKicker.h b/src/Elements/OpalHKicker.h index c7ca2f633c47789bf001eeb9d416e7b2a035187f..d229b15e93f70af8092f26ae1d7a9fbe9876b42b 100644 --- a/src/Elements/OpalHKicker.h +++ b/src/Elements/OpalHKicker.h @@ -41,9 +41,6 @@ public: /// Make clone. virtual OpalHKicker *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC corrector. virtual void update(); diff --git a/src/Elements/OpalHMonitor.cpp b/src/Elements/OpalHMonitor.cpp deleted file mode 100644 index bce6380f14b4afeee2a5fb869ecd1c7360b36ec1..0000000000000000000000000000000000000000 --- a/src/Elements/OpalHMonitor.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// -// Class OpalHMonitor -// The HMONITOR element. -// -// Copyright (c) 200x - 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 "Elements/OpalHMonitor.h" -#include "AbstractObjects/Attribute.h" -#include "Attributes/Attributes.h" -#include "BeamlineCore/XMonitorRep.h" - - -OpalHMonitor::OpalHMonitor(): - OpalElement(COMMON, "HMONITOR", - "The \"HMONITOR\" element defines a monitor " - "for the horizontal plane.") { - setElement(new XMonitorRep("HMONITOR")); -} - - -OpalHMonitor::OpalHMonitor(const std::string &name, OpalHMonitor *parent): - OpalElement(name, parent) { - setElement(new XMonitorRep(name)); -} - - -OpalHMonitor::~OpalHMonitor() -{} - - -OpalHMonitor *OpalHMonitor::clone(const std::string &name) { - return new OpalHMonitor(name, this); -} - - -void OpalHMonitor::update() { - OpalElement::update(); - - XMonitorRep *mon = - dynamic_cast<XMonitorRep *>(getElement()); - double length = Attributes::getReal(itsAttr[LENGTH]); - mon->setElementLength(length); - - // Transmit "unknown" attributes. - OpalElement::updateUnknown(mon); -} diff --git a/src/Elements/OpalHMonitor.h b/src/Elements/OpalHMonitor.h deleted file mode 100644 index f1bf499faf096378f318a1d541b081a094c9f789..0000000000000000000000000000000000000000 --- a/src/Elements/OpalHMonitor.h +++ /dev/null @@ -1,48 +0,0 @@ -// -// Class OpalHMonitor -// The HMONITOR element. -// -// Copyright (c) 200x - 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 OPAL_OpalHMonitor_HH -#define OPAL_OpalHMonitor_HH - -#include "Elements/OpalElement.h" - -class OpalHMonitor: public OpalElement { - -public: - - /// Exemplar constructor. - OpalHMonitor(); - - virtual ~OpalHMonitor(); - - /// Make clone. - virtual OpalHMonitor *clone(const std::string &name); - - /// Update the embedded CLASSIC monitor. - virtual void update(); - -private: - - // Not implemented. - OpalHMonitor(const OpalHMonitor &); - void operator=(const OpalHMonitor &); - - // Clone constructor. - OpalHMonitor(const std::string &name, OpalHMonitor *parent); -}; - -#endif // OPAL_OpalHMonitor_HH diff --git a/src/Elements/OpalInstrument.cpp b/src/Elements/OpalInstrument.cpp deleted file mode 100644 index 8dec068ad4a2d3db743add9313ecd263151b7a2f..0000000000000000000000000000000000000000 --- a/src/Elements/OpalInstrument.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: OpalInstrument.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: OpalInstrument -// The class of OPAL generic beam instrumentation. -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:39 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Elements/OpalInstrument.h" -#include "AbstractObjects/Attribute.h" -#include "Attributes/Attributes.h" -#include "BeamlineCore/DriftRep.h" - - -// Class OpalInstrument -// ------------------------------------------------------------------------ - -OpalInstrument::OpalInstrument(): - OpalElement(COMMON, "INSTRUMENT", - "The \"INSTRUMENT\" element defines a generic " - "beam observation device.") { - setElement(new DriftRep("INSTRUMENT")); -} - - -OpalInstrument::OpalInstrument(const std::string &name, OpalInstrument *parent): - OpalElement(name, parent) { - setElement(new DriftRep(name)); -} - - -OpalInstrument::~OpalInstrument() -{} - - -OpalInstrument *OpalInstrument::clone(const std::string &name) { - return new OpalInstrument(name, this); -} - - -void OpalInstrument::update() { - DriftRep *ins = dynamic_cast<DriftRep *>(getElement()); - double length = Attributes::getReal(itsAttr[LENGTH]); - ins->setElementLength(length); - - // Transmit "unknown" attributes. - OpalElement::updateUnknown(ins); -} diff --git a/src/Elements/OpalInstrument.h b/src/Elements/OpalInstrument.h deleted file mode 100644 index aff673b2ef1c23784a7b95bf6214ed0085e9c724..0000000000000000000000000000000000000000 --- a/src/Elements/OpalInstrument.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef OPAL_OpalInstrument_HH -#define OPAL_OpalInstrument_HH - -// ------------------------------------------------------------------------ -// $RCSfile: OpalInstrument.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: OpalInstrument -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:39 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Elements/OpalElement.h" - - -// Class OpalInstrument -// ------------------------------------------------------------------------ -/// The INSTRUMENT element. - -class OpalInstrument: public OpalElement { - -public: - - /// Exemplar constructor. - OpalInstrument(); - - virtual ~OpalInstrument(); - - /// Make clone. - virtual OpalInstrument *clone(const std::string &name); - - /// Update the embedded CLASSIC drift. - virtual void update(); - -private: - - // Not implemented. - OpalInstrument(const OpalInstrument &); - void operator=(const OpalInstrument &); - - // Clone constructor. - OpalInstrument(const std::string &name, OpalInstrument *parent); -}; - -#endif // OPAL_OpalInstrument_HH diff --git a/src/Elements/OpalKicker.cpp b/src/Elements/OpalKicker.cpp index 33cfd409c83fa88f6cfb1b1dc192ebc2a4ed92fb..72d08b84c2fd23208f4cee50fefc4b34c663f53a 100644 --- a/src/Elements/OpalKicker.cpp +++ b/src/Elements/OpalKicker.cpp @@ -42,12 +42,6 @@ OpalKicker::OpalKicker(): itsAttr[K0S] = Attributes::makeReal ("K0S", "Skew dipole field in T"); - registerRealAttribute("HKICK"); - registerRealAttribute("VKICK"); - registerRealAttribute("DESIGNENERGY"); - registerRealAttribute("K0"); - registerRealAttribute("K0S"); - registerOwnership(); setElement(new CorrectorRep("KICKER")); @@ -69,26 +63,6 @@ OpalKicker *OpalKicker::clone(const std::string &name) { } -void OpalKicker:: -fillRegisteredAttributes(const ElementBase &base) { - Inform m("fillRegisteredAttributes "); - - OpalElement::fillRegisteredAttributes(base); - - const CorrectorRep *corr = dynamic_cast<const CorrectorRep *>(&base); - - BDipoleField field = corr->getField(); - - double scale = Physics::c / OpalData::getInstance()->getP0(); - attributeRegistry["HKICK"]->setReal(- field.getBy() * scale); - attributeRegistry["VKICK"]->setReal(+ field.getBx() * scale); - - m << "P= " << OpalData::getInstance()->getP0() - << " Bx= " << field.getBx() - << " By= " << field.getBy() << endl; -} - - void OpalKicker::update() { OpalElement::update(); diff --git a/src/Elements/OpalKicker.h b/src/Elements/OpalKicker.h index e0eaa8eae316d84ec09e2ff66fd090cc67e3329d..57d8819100dcf1ff7e1e16e9832711cabd20a0d2 100644 --- a/src/Elements/OpalKicker.h +++ b/src/Elements/OpalKicker.h @@ -53,9 +53,6 @@ public: // virtual void print(std::ostream &) const; //END JMJ 15/12/2000, adding missing print method - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC corrector. virtual void update(); diff --git a/src/Elements/OpalMonitor.cpp b/src/Elements/OpalMonitor.cpp index d3c03265cbbfa292de372c20f8e65edda1b44300..95d0a162f500a10dd039ab1ea57069825f8698d5 100644 --- a/src/Elements/OpalMonitor.cpp +++ b/src/Elements/OpalMonitor.cpp @@ -29,8 +29,6 @@ OpalMonitor::OpalMonitor(): itsAttr[OUTFN] = Attributes::makeString ("OUTFN", "Monitor output filename"); - registerStringAttribute("OUTFN"); - registerOwnership(); setElement(new MonitorRep("MONITOR")); diff --git a/src/Elements/OpalMultipole.cpp b/src/Elements/OpalMultipole.cpp index 64f197f9ad4fcaf81ca144ee2527e27204119094..6fbccb65cd0b7b50dfa75fbba895723e9d641ec8 100644 --- a/src/Elements/OpalMultipole.cpp +++ b/src/Elements/OpalMultipole.cpp @@ -71,34 +71,6 @@ void OpalMultipole::print(std::ostream &os) const { } -void OpalMultipole:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const MultipoleRep *mult = dynamic_cast<const MultipoleRep *>(&base); - - BMultipoleField field = mult->getField(); - - double length = getLength(); - double scale = Physics::c / OpalData::getInstance()->getP0(); - if(length != 0.0) scale *= length; - - for(int order = 1; order <= field.order(); ++order) { - std::ostringstream ss; - ss << (order - 1) << std::ends; - std::string orderString = ss.str(); - - std::string normName = "K" + orderString + "L"; - registerRealAttribute(normName)->setReal(scale * field.normal(order)); - - std::string skewName = "K" + orderString + "SL"; - registerRealAttribute(skewName)->setReal(scale * field.skew(order)); - - scale *= double(order); - } -} - - void OpalMultipole::update() { OpalElement::update(); diff --git a/src/Elements/OpalMultipole.h b/src/Elements/OpalMultipole.h index 765080edc9483e5b0f66df2776816c1140fed38c..5ff1f5733f2b33724cfcbdc7c58821b91558e534 100644 --- a/src/Elements/OpalMultipole.h +++ b/src/Elements/OpalMultipole.h @@ -46,9 +46,6 @@ public: // Handle printing in OPAL-8 format. virtual void print(std::ostream &) const; - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC multipole. virtual void update(); diff --git a/src/Elements/OpalMultipoleT.cpp b/src/Elements/OpalMultipoleT.cpp index 7e5925f7064ed038f1823ba4335a339ea797761e..f529ecd7a7baad09a2e02b69ac084e2738c99d52 100644 --- a/src/Elements/OpalMultipoleT.cpp +++ b/src/Elements/OpalMultipoleT.cpp @@ -40,9 +40,6 @@ #include <vector> -// Class OpalMultipoleT -// ------------------------------------------------------------------------ - OpalMultipoleT::OpalMultipoleT(): OpalElement(SIZE, "MULTIPOLET", "The \"MULTIPOLET\" element defines a combined function multipole.") { @@ -103,32 +100,6 @@ void OpalMultipoleT::print(std::ostream &os) const { } -void OpalMultipoleT:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - const MultipoleT *multT = - dynamic_cast<const MultipoleT*>(&base); - for(unsigned int order = 1; order <= multT->getTransMaxOrder(); order++) { - std::ostringstream ss; - ss << order; - std::string orderString = ss.str(); - std::string attrName = "TP" + orderString; - registerRealAttribute(attrName)->setReal(multT->getTransProfile(order)); - } - - registerRealAttribute("LFRINGE")->setReal(multT->getFringeLength().at(0)); - registerRealAttribute("RFRINGE")->setReal(multT->getFringeLength().at(1)); - registerRealAttribute("VAPERT")->setReal(multT->getAperture()[0]); - registerRealAttribute("HAPERT")->setReal(multT->getAperture()[1]); - registerRealAttribute("MAXFORDER")->setReal(multT->getMaxOrder()); - registerRealAttribute("MAXXORDER")->setReal(multT->getMaxXOrder()); - registerRealAttribute("ROTATION")->setReal(multT->getRotation()); - registerRealAttribute("EANGLE")->setReal(multT->getEntranceAngle()); - //registerRealAttribute("VARRADIUS")->setBool(multT->getVarRadius()); - registerRealAttribute("BBLENGTH")->setReal(multT->getBoundingBoxLength()); -} - - void OpalMultipoleT::update() { OpalElement::update(); diff --git a/src/Elements/OpalMultipoleT.h b/src/Elements/OpalMultipoleT.h index d024da231a3db60a0d117e8bcb2766bf407c7c62..341577659daaba2edf2fc8bca44845a62e096b2b 100644 --- a/src/Elements/OpalMultipoleT.h +++ b/src/Elements/OpalMultipoleT.h @@ -66,12 +66,6 @@ public: /** Inherited copy constructor */ virtual OpalMultipoleT *clone(const std::string &name); - /** Fill in all registered attributes - * - * Just calls fillRegisteredAttributes on the base class - */ - virtual void fillRegisteredAttributes(const ElementBase &); - /** Update the MultipoleT with new parameters from UI parser */ virtual void update(); diff --git a/src/Elements/OpalMultipoleTCurvedConstRadius.cpp b/src/Elements/OpalMultipoleTCurvedConstRadius.cpp index c228143443ae5d4d6144729e5f10393593aaefb8..1d2351d45b1885f5b4b4aa3eee8ff3aa4f330bd7 100644 --- a/src/Elements/OpalMultipoleTCurvedConstRadius.cpp +++ b/src/Elements/OpalMultipoleTCurvedConstRadius.cpp @@ -102,34 +102,6 @@ void OpalMultipoleTCurvedConstRadius::print(std::ostream &os) const { } -void OpalMultipoleTCurvedConstRadius:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - const MultipoleTCurvedConstRadius *multT = - dynamic_cast<const MultipoleTCurvedConstRadius*>(&base); - - for(unsigned int order = 1; order <= multT->getTransMaxOrder(); order++) { - std::ostringstream ss; - ss << order; - std::string orderString = ss.str(); - std::string attrName = "TP" + orderString; - registerRealAttribute(attrName)->setReal(multT->getTransProfile(order)); - } - - registerRealAttribute("LFRINGE")->setReal(multT->getFringeLength().at(0)); - registerRealAttribute("RFRINGE")->setReal(multT->getFringeLength().at(1)); - registerRealAttribute("VAPERT")->setReal(multT->getAperture()[0]); - registerRealAttribute("HAPERT")->setReal(multT->getAperture()[1]); - registerRealAttribute("MAXFORDER")->setReal(multT->getMaxOrder()); - registerRealAttribute("MAXXORDER")->setReal(multT->getMaxXOrder()); - registerRealAttribute("ROTATION")->setReal(multT->getRotation()); - registerRealAttribute("ANGLE")->setReal(multT->getBendAngle()); - registerRealAttribute("EANGLE")->setReal(multT->getEntranceAngle()); - registerRealAttribute("BBLENGTH")->setReal(multT->getBoundingBoxLength()); - -} - - void OpalMultipoleTCurvedConstRadius::update() { OpalElement::update(); diff --git a/src/Elements/OpalMultipoleTCurvedConstRadius.h b/src/Elements/OpalMultipoleTCurvedConstRadius.h index 3ddfc592fb25431821a7671bfd6ec33d8cee634a..5c780bd33caf543a1e4ef9fbea6f986ff684b1b4 100644 --- a/src/Elements/OpalMultipoleTCurvedConstRadius.h +++ b/src/Elements/OpalMultipoleTCurvedConstRadius.h @@ -66,12 +66,6 @@ public: /** Inherited copy constructor */ virtual OpalMultipoleTCurvedConstRadius *clone(const std::string &name); - /** Fill in all registered attributes - * - * Just calls fillRegisteredAttributes on the base class - */ - virtual void fillRegisteredAttributes(const ElementBase &); - /** Update the MultipoleTCurvedConstRadius with new parameters from UI parser */ virtual void update(); diff --git a/src/Elements/OpalMultipoleTCurvedVarRadius.cpp b/src/Elements/OpalMultipoleTCurvedVarRadius.cpp index 1fbe0989b3b6eae2faeaf396b1f9951307a60427..d356dc41c3db8281a30675dd9e5693ccf9cbf573 100644 --- a/src/Elements/OpalMultipoleTCurvedVarRadius.cpp +++ b/src/Elements/OpalMultipoleTCurvedVarRadius.cpp @@ -101,33 +101,6 @@ void OpalMultipoleTCurvedVarRadius::print(std::ostream &os) const { } -void OpalMultipoleTCurvedVarRadius:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - const MultipoleTCurvedVarRadius *multT = - dynamic_cast<const MultipoleTCurvedVarRadius*>(&base); - - for(unsigned int order = 1; order <= multT->getTransMaxOrder(); order++) { - std::ostringstream ss; - ss << order; - std::string orderString = ss.str(); - std::string attrName = "TP" + orderString; - registerRealAttribute(attrName)->setReal(multT->getTransProfile(order)); - } - - registerRealAttribute("LFRINGE")->setReal(multT->getFringeLength().at(0)); - registerRealAttribute("RFRINGE")->setReal(multT->getFringeLength().at(1)); - registerRealAttribute("VAPERT")->setReal(multT->getAperture()[0]); - registerRealAttribute("HAPERT")->setReal(multT->getAperture()[1]); - registerRealAttribute("MAXFORDER")->setReal(multT->getMaxOrder()); - registerRealAttribute("MAXXORDER")->setReal(multT->getMaxXOrder()); - registerRealAttribute("ROTATION")->setReal(multT->getRotation()); - registerRealAttribute("EANGLE")->setReal(multT->getEntranceAngle()); - registerRealAttribute("BBLENGTH")->setReal(multT->getBoundingBoxLength()); - -} - - void OpalMultipoleTCurvedVarRadius::update() { OpalElement::update(); diff --git a/src/Elements/OpalMultipoleTCurvedVarRadius.h b/src/Elements/OpalMultipoleTCurvedVarRadius.h index 5e26379735c038678af9f8cdb02dd370d6392da7..2aededa4527f0ddf07f09c14c83258dfef95a739 100644 --- a/src/Elements/OpalMultipoleTCurvedVarRadius.h +++ b/src/Elements/OpalMultipoleTCurvedVarRadius.h @@ -66,12 +66,6 @@ public: /** Inherited copy constructor */ virtual OpalMultipoleTCurvedVarRadius *clone(const std::string &name); - /** Fill in all registered attributes - * - * Just calls fillRegisteredAttributes on the base class - */ - virtual void fillRegisteredAttributes(const ElementBase &); - /** Update the MultipoleTCurvedVarRadius with new parameters from UI parser */ virtual void update(); diff --git a/src/Elements/OpalMultipoleTStraight.cpp b/src/Elements/OpalMultipoleTStraight.cpp index 9312206e34734f1bc27edb616681dd11f5f2a61e..c87677119809777677bf35943fc5184b80fa6516 100644 --- a/src/Elements/OpalMultipoleTStraight.cpp +++ b/src/Elements/OpalMultipoleTStraight.cpp @@ -96,32 +96,6 @@ void OpalMultipoleTStraight::print(std::ostream &os) const { } -void OpalMultipoleTStraight:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - const MultipoleTStraight *multT = - dynamic_cast<const MultipoleTStraight*>(&base); - - for(unsigned int order = 1; order <= multT->getTransMaxOrder(); order++) { - std::ostringstream ss; - ss << order; - std::string orderString = ss.str(); - std::string attrName = "TP" + orderString; - registerRealAttribute(attrName)->setReal(multT->getTransProfile(order)); - } - - registerRealAttribute("LFRINGE")->setReal(multT->getFringeLength().at(0)); - registerRealAttribute("RFRINGE")->setReal(multT->getFringeLength().at(1)); - registerRealAttribute("VAPERT")->setReal(multT->getAperture()[0]); - registerRealAttribute("HAPERT")->setReal(multT->getAperture()[1]); - registerRealAttribute("MAXFORDER")->setReal(multT->getMaxOrder()); - registerRealAttribute("ROTATION")->setReal(multT->getRotation()); - registerRealAttribute("EANGLE")->setReal(multT->getEntranceAngle()); - registerRealAttribute("BBLENGTH")->setReal(multT->getBoundingBoxLength()); - -} - - void OpalMultipoleTStraight::update() { OpalElement::update(); diff --git a/src/Elements/OpalMultipoleTStraight.h b/src/Elements/OpalMultipoleTStraight.h index 8f379c6cfd6aad736854d34051ebef2448ef6cdb..6b2bfa395add8379713b48193fefec633a7625e8 100644 --- a/src/Elements/OpalMultipoleTStraight.h +++ b/src/Elements/OpalMultipoleTStraight.h @@ -64,12 +64,6 @@ public: /** Inherited copy constructor */ virtual OpalMultipoleTStraight *clone(const std::string &name); - /** Fill in all registered attributes - * - * Just calls fillRegisteredAttributes on the base class - */ - virtual void fillRegisteredAttributes(const ElementBase &); - /** Update the MultipoleT with new parameters from UI parser */ virtual void update(); diff --git a/src/Elements/OpalOctupole.cpp b/src/Elements/OpalOctupole.cpp index d4276a71db7f6a61230f466d5c1669991d98a146..176b69041008c18e68ea5ca92ccede9dee12025f 100644 --- a/src/Elements/OpalOctupole.cpp +++ b/src/Elements/OpalOctupole.cpp @@ -65,33 +65,6 @@ void OpalOctupole::print(std::ostream &os) const { } -void OpalOctupole:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const MultipoleRep *oct = dynamic_cast<const MultipoleRep *>(&base); - BMultipoleField field = oct->getField(); - - double length = getLength(); - double scale = Physics::c / OpalData::getInstance()->getP0(); - if(length != 0.0) scale *= length; - - for(int order = 1; order <= field.order(); ++order) { - std::ostringstream ss; - ss << (order - 1) << std::ends; - std::string orderString = ss.str(); - - std::string normName = "K" + orderString + "L"; - registerRealAttribute(normName)->setReal(scale * field.normal(order)); - - std::string skewName = "K" + orderString + "SL"; - registerRealAttribute(skewName)->setReal(scale * field.skew(order)); - - scale *= double(order); - } -} - - void OpalOctupole::update() { OpalElement::update(); diff --git a/src/Elements/OpalOctupole.h b/src/Elements/OpalOctupole.h index 0a7800e7e92c35d27fc5bc7361fc2b2da6cd6bc4..920ed83b2805bc09ce2efccec7e4c2f405c80838 100644 --- a/src/Elements/OpalOctupole.h +++ b/src/Elements/OpalOctupole.h @@ -47,9 +47,6 @@ public: // Handle printing in OPAL-8 format. virtual void print(std::ostream &) const; - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC multipole. virtual void update(); diff --git a/src/Elements/OpalOffset/OpalGlobalCartesianOffset.cpp b/src/Elements/OpalOffset/OpalGlobalCartesianOffset.cpp index 9e2185829072b548b5c2832271cff4dd36cec24c..41ffeac21ba9be8f5d7d9d0c2f38155d4060359e 100644 --- a/src/Elements/OpalOffset/OpalGlobalCartesianOffset.cpp +++ b/src/Elements/OpalOffset/OpalGlobalCartesianOffset.cpp @@ -53,10 +53,6 @@ OpalGlobalCartesianOffset::OpalGlobalCartesianOffset() "x component of normal of end of the offset in coordinate system of the end of the upstream element."); itsAttr[END_NORMAL_Y] = Attributes::makeReal("END_NORMAL_Y", "y component of normal of end of the offset in coordinate system of the end of the upstream element."); - registerRealAttribute("END_POSITION_X"); - registerRealAttribute("END_POSITION_Y"); - registerRealAttribute("END_NORMAL_X"); - registerRealAttribute("END_NORMAL_Y"); registerOwnership(); } @@ -75,11 +71,6 @@ OpalGlobalCartesianOffset::OpalGlobalCartesianOffset(const std::string &name, Op OpalGlobalCartesianOffset::~OpalGlobalCartesianOffset() {} -void OpalGlobalCartesianOffset::fillRegisteredAttributes - (const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - void OpalGlobalCartesianOffset::update() { // getOpalName() comes from AbstractObjects/Object.h std::string name = getOpalName(); diff --git a/src/Elements/OpalOffset/OpalGlobalCartesianOffset.h b/src/Elements/OpalOffset/OpalGlobalCartesianOffset.h index 2191e01db60f2a8470df6cf00a69e7be963674c9..7d151d41161f3ef38c4f1414e8e2c40b18700ce3 100644 --- a/src/Elements/OpalOffset/OpalGlobalCartesianOffset.h +++ b/src/Elements/OpalOffset/OpalGlobalCartesianOffset.h @@ -61,9 +61,6 @@ class OpalGlobalCartesianOffset : public OpalElement { /** Inherited copy constructor */ virtual OpalGlobalCartesianOffset *clone(const std::string &name); - /** Calls fillRegisteredAttributes on the OpalElement */ - void fillRegisteredAttributes(const ElementBase &base); - /** Receive parameters from the parser and hand them off to the * OpalCylindricalOffset */ diff --git a/src/Elements/OpalOffset/OpalGlobalCylindricalOffset.cpp b/src/Elements/OpalOffset/OpalGlobalCylindricalOffset.cpp index bc6aa09c12b9099c74ad3e6e1029a7e1c8f9f030..2c7e01e3cab55f61f36e4bac2fbe220544d2a28d 100644 --- a/src/Elements/OpalOffset/OpalGlobalCylindricalOffset.cpp +++ b/src/Elements/OpalOffset/OpalGlobalCylindricalOffset.cpp @@ -51,9 +51,6 @@ OpalGlobalCylindricalOffset::OpalGlobalCylindricalOffset() "Angle between the displacement vector and the next element."); itsAttr[TANGENTIAL_OFFSET] = Attributes::makeReal("TANGENTIAL_OFFSET", "Length of the offset."); - registerRealAttribute("RADIUS"); - registerRealAttribute("AZIMUTHAL_ANGLE"); - registerRealAttribute("TANGENTIAL_OFFSET"); registerOwnership(); } @@ -72,11 +69,6 @@ OpalGlobalCylindricalOffset::OpalGlobalCylindricalOffset(const std::string &name OpalGlobalCylindricalOffset::~OpalGlobalCylindricalOffset() {} -void OpalGlobalCylindricalOffset::fillRegisteredAttributes - (const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - void OpalGlobalCylindricalOffset::update() { // getOpalName() comes from AbstractObjects/Object.h std::string name = getOpalName(); diff --git a/src/Elements/OpalOffset/OpalGlobalCylindricalOffset.h b/src/Elements/OpalOffset/OpalGlobalCylindricalOffset.h index a9dd909ee23b522eaf2f80fb5ff690381e3a9e90..b3d700ca87c088020a76e3b3d7b4eb1f0ae2bca1 100644 --- a/src/Elements/OpalOffset/OpalGlobalCylindricalOffset.h +++ b/src/Elements/OpalOffset/OpalGlobalCylindricalOffset.h @@ -56,9 +56,6 @@ class OpalGlobalCylindricalOffset : public OpalElement { /** Inherited copy constructor */ virtual OpalGlobalCylindricalOffset *clone(const std::string &name); - /** Calls fillRegisteredAttributes on the OpalElement */ - void fillRegisteredAttributes(const ElementBase &base); - /** Receive parameters from the parser and hand them off to the * OpalCylindricalOffset */ diff --git a/src/Elements/OpalOffset/OpalLocalCartesianOffset.cpp b/src/Elements/OpalOffset/OpalLocalCartesianOffset.cpp index 57275b322dcbade7426bf74ef7c530cdb4265f4c..3ef23349fe84a99d47b1a1b837cfb81a284eda68 100644 --- a/src/Elements/OpalOffset/OpalLocalCartesianOffset.cpp +++ b/src/Elements/OpalOffset/OpalLocalCartesianOffset.cpp @@ -54,10 +54,6 @@ OpalLocalCartesianOffset::OpalLocalCartesianOffset() "x component of normal of end of the offset in coordinate system of the end of the upstream element [m]."); itsAttr[END_NORMAL_Y] = Attributes::makeReal("END_NORMAL_Y", "y component of normal of end of the offset in coordinate system of the end of the upstream element [m]."); - registerRealAttribute("END_POSITION_X"); - registerRealAttribute("END_POSITION_Y"); - registerRealAttribute("END_NORMAL_X"); - registerRealAttribute("END_NORMAL_Y"); registerOwnership(); @@ -84,23 +80,6 @@ OpalLocalCartesianOffset::OpalLocalCartesianOffset(const std::string &name, Opal OpalLocalCartesianOffset::~OpalLocalCartesianOffset() {} -void OpalLocalCartesianOffset::fillRegisteredAttributes - (const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - const Offset* offset = dynamic_cast<const Offset*>(&base); - if (offset == NULL) { - throw OpalException("OpalLocalCartesianOffset::fillRegisteredAttributes", - "Failed to cast ElementBase to a OpalLocalCartesianOffset"); - } - - Euclid3D trans = offset->getGeometry().getTotalTransform(); - double rot = trans.getRotation().getAxis()(1); - attributeRegistry["END_POSITION_X"]->setReal(trans.getVector()(2)); - attributeRegistry["END_POSITION_Y"]->setReal(trans.getVector()(0)); - attributeRegistry["END_NORMAL_X"]->setReal(cos(rot)); - attributeRegistry["END_NORMAL_Y"]->setReal(sin(rot)); -} - void OpalLocalCartesianOffset::update() { // getOpalName() comes from AbstractObjects/Object.h Offset *offset = dynamic_cast<Offset*>(getElement()); diff --git a/src/Elements/OpalOffset/OpalLocalCartesianOffset.h b/src/Elements/OpalOffset/OpalLocalCartesianOffset.h index 07f3dbd7cf06ed941343be93b1c95a66636c398f..59a8fb9506660db941b7b3b08552a60f136fe77a 100644 --- a/src/Elements/OpalOffset/OpalLocalCartesianOffset.h +++ b/src/Elements/OpalOffset/OpalLocalCartesianOffset.h @@ -63,9 +63,6 @@ class OpalLocalCartesianOffset : public OpalElement { /** Inherited copy constructor */ virtual OpalLocalCartesianOffset *clone(const std::string &name); - /** Calls fillRegisteredAttributes on the OpalElement */ - void fillRegisteredAttributes(const ElementBase &base); - /** Receive parameters from the parser and hand them off to the * OpalCylindricalOffset */ diff --git a/src/Elements/OpalOffset/OpalLocalCylindricalOffset.cpp b/src/Elements/OpalOffset/OpalLocalCylindricalOffset.cpp index bed08e52c7741176da9ecfa4c9a0d21d21e60129..6a445d90aa7223c80cb92d5170a2d15dfaf0d502 100644 --- a/src/Elements/OpalOffset/OpalLocalCylindricalOffset.cpp +++ b/src/Elements/OpalOffset/OpalLocalCylindricalOffset.cpp @@ -50,9 +50,6 @@ OpalLocalCylindricalOffset::OpalLocalCylindricalOffset() itsAttr[THETA_OUT] = Attributes::makeReal("THETA_OUT", "Angle between the displacement vector and the next element [rad]."); itsAttr[LENGTH] = Attributes::makeReal("LENGTH", "Length of the offset [m]."); - registerRealAttribute("THETA_IN"); - registerRealAttribute("THETA_OUT"); - registerRealAttribute("LENGTH"); registerOwnership(); } @@ -71,11 +68,6 @@ OpalLocalCylindricalOffset::OpalLocalCylindricalOffset(const std::string &name, OpalLocalCylindricalOffset::~OpalLocalCylindricalOffset() {} -void OpalLocalCylindricalOffset::fillRegisteredAttributes - (const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - void OpalLocalCylindricalOffset::update() { // getOpalName() comes from AbstractObjects/Object.h std::string name = getOpalName(); diff --git a/src/Elements/OpalOffset/OpalLocalCylindricalOffset.h b/src/Elements/OpalOffset/OpalLocalCylindricalOffset.h index 29822f53ed00c79feb0e897fde229428a289e565..96e1a5e8199e270e0944b12a8f0aec8ac0a2047f 100644 --- a/src/Elements/OpalOffset/OpalLocalCylindricalOffset.h +++ b/src/Elements/OpalOffset/OpalLocalCylindricalOffset.h @@ -60,9 +60,6 @@ class OpalLocalCylindricalOffset : public OpalElement { /** Inherited copy constructor */ virtual OpalLocalCylindricalOffset *clone(const std::string &name); - /** Calls fillRegisteredAttributes on the OpalElement */ - void fillRegisteredAttributes(const ElementBase &base); - /** Receive parameters from the parser and hand them off to the * OpalCylindricalOffset */ diff --git a/src/Elements/OpalParallelPlate.cpp b/src/Elements/OpalParallelPlate.cpp deleted file mode 100644 index 9140886db48ca3b15725e1103d0aee66a31f0f34..0000000000000000000000000000000000000000 --- a/src/Elements/OpalParallelPlate.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// -// Class OpalParallelPlate -// The ParallelPlate element. -// -// Copyright (c) 200x - 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 "Elements/OpalParallelPlate.h" -#include "Structure/BoundaryGeometry.h" -#include "AbstractObjects/Attribute.h" -#include "Attributes/Attributes.h" -#include "BeamlineCore/ParallelPlateRep.h" -#include "Physics/Physics.h" - -extern Inform *gmsg; - -OpalParallelPlate::OpalParallelPlate(): - OpalElement(SIZE, "PARALLELPLATE", - "The \"PARALLELPLATE\" element defines an cavity."), - obgeo_m(NULL) -{ - itsAttr[VOLT] = Attributes::makeReal - ("VOLT", " voltage in MV"); - itsAttr[FREQ] = Attributes::makeReal - ("FREQ", " frequency in MHz"); - itsAttr[LAG] = Attributes::makeReal - ("LAG", "Phase lag (rad), !!!! was before in multiples of (2*pi) !!!!"); - - itsAttr[GEOMETRY] = Attributes::makeString - ("GEOMETRY", "BoundaryGeometry for ParallelPlate"); - - itsAttr[PLENGTH] = Attributes::makeReal - ("PLENGTH", " Gap length in Meter"); - - - registerRealAttribute("VOLT"); - registerRealAttribute("FREQ"); - registerRealAttribute("LAG"); - registerStringAttribute("GEOMETRY"); - registerRealAttribute("PLENGTH"); - - registerOwnership(); - - setElement(new ParallelPlateRep("ParallelPlate")); -} - - -OpalParallelPlate::OpalParallelPlate(const std::string &name, OpalParallelPlate *parent): - OpalElement(name, parent), - obgeo_m(NULL) -{ - setElement(new ParallelPlateRep(name)); -} - - -OpalParallelPlate::~OpalParallelPlate() { - -} - - -OpalParallelPlate *OpalParallelPlate::clone(const std::string &name) { - return new OpalParallelPlate(name, this); -} - - -void OpalParallelPlate::fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const ParallelPlateRep *pplate = - dynamic_cast<const ParallelPlateRep *>(&base); - attributeRegistry["VOLT"]->setReal(pplate->getAmplitude()); - attributeRegistry["FREQ"]->setReal(pplate->getFrequency()); - attributeRegistry["LAG"]->setReal(pplate->getPhase()); - attributeRegistry["PLENGTH"]->setReal(pplate->getElementLength()); -} - - -void OpalParallelPlate::update() { - OpalElement::update(); - - ParallelPlateRep *pplate = - dynamic_cast<ParallelPlateRep *>(getElement()); - - double vPeak = Attributes::getReal(itsAttr[VOLT]); - // double phase = two_pi * Attributes::getReal(itsAttr[LAG]); - double phase = Attributes::getReal(itsAttr[LAG]); - double freq = (1.0e6 * Physics::two_pi) * Attributes::getReal(itsAttr[FREQ]); - double length = Attributes::getReal(itsAttr[PLENGTH]); - - if(itsAttr[GEOMETRY] && obgeo_m == NULL) { - obgeo_m = (BoundaryGeometry::find(Attributes::getString(itsAttr[GEOMETRY])))->clone(getOpalName() + std::string("_geometry")); - if(obgeo_m) { - //obgeo_m->initialize(); - - pplate->setBoundaryGeometry(obgeo_m); - } - } - - pplate->setAmplitude(1.0e6 * vPeak); - pplate->setFrequency(freq); - pplate->setPhase(phase); - - pplate->setElementLength(length); - - // Transmit "unknown" attributes. - OpalElement::updateUnknown(pplate); -} \ No newline at end of file diff --git a/src/Elements/OpalParallelPlate.h b/src/Elements/OpalParallelPlate.h deleted file mode 100644 index 665685013c96e405206d1bfdea8793336c95dc8d..0000000000000000000000000000000000000000 --- a/src/Elements/OpalParallelPlate.h +++ /dev/null @@ -1,70 +0,0 @@ -// -// Class OpalParallelPlate -// The ParallelPlate element. -// -// Copyright (c) 200x - 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 OPAL_OpalParallelPlate_HH -#define OPAL_OpalParallelPlate_HH - -#include "Elements/OpalElement.h" - -class BoundaryGeometry; - -class OpalParallelPlate: public OpalElement { - -public: - - /// The attributes of class OpalParallelPlate. - enum { - VOLT = COMMON, // The peak voltage. - GEOMETRY, // geometry of boundary - FREQ, // The RF frequency. - LAG, // The phase lag. - - PLENGTH, //distance between two plates or length in s direction - SIZE - }; - - /// Exemplar constructor. - OpalParallelPlate(); - - virtual ~OpalParallelPlate(); - - /// Make clone. - virtual OpalParallelPlate *clone(const std::string &name); - - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - - /// Update the embedded CLASSIC cavity. - virtual void update(); - -private: - - // Not implemented. - OpalParallelPlate(const OpalParallelPlate &); - void operator=(const OpalParallelPlate &); - - // Clone constructor. - OpalParallelPlate(const std::string &name, OpalParallelPlate *parent); - - - - BoundaryGeometry *obgeo_m; - - -}; - -#endif // OPAL_OpalParallelPlate_HH diff --git a/src/Elements/OpalPatch.cpp b/src/Elements/OpalPatch.cpp deleted file mode 100644 index 05b03569e7ae8f99680112f1bab6d36ecf17166e..0000000000000000000000000000000000000000 --- a/src/Elements/OpalPatch.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: OpalPatch.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: OpalPatch -// The class of OPAL patch spaces. -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:40 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Elements/OpalPatch.h" -#include "Attributes/Attributes.h" -#include "BeamlineCore/PatchRep.h" - - -// Class OpalPatch -// ------------------------------------------------------------------------ - -OpalPatch::OpalPatch(): - OpalElement(SIZE, "PATCH", - "The \"PATCH\" element implements a local reference change.") { - itsAttr[LENGTH].setReadOnly(true); - itsAttr[HORD] = Attributes::makeReal("HORD", "Horizontal orbit shift"); - itsAttr[VERTD] = Attributes::makeReal("VERTD", "Vertical orbit shift"); - itsAttr[LONGD] = Attributes::makeReal("LONGD", "Longitudinal orbit shift"); - itsAttr[VX] = Attributes::makeReal("VX", "Rotation around x-axis."); - itsAttr[VY] = Attributes::makeReal("VY", "Rotation around y-axis."); - itsAttr[VS] = Attributes::makeReal("VS", "Rotation around s-axis."); - - registerOwnership(); - - setElement(new PatchRep("PATCH")); -} - - -OpalPatch::OpalPatch(const std::string &name, OpalPatch *parent): - OpalElement(name, parent) { - setElement(new PatchRep(name)); -} - - -OpalPatch::~OpalPatch() -{} - - -OpalPatch *OpalPatch::clone(const std::string &name) { - return new OpalPatch(name, this); -} - - -bool OpalPatch::isPatch() const { - return true; -} - - -void OpalPatch::update() { - OpalElement::update(); - - PatchRep *patch = static_cast<PatchRep *>(getElement()); - double dx = Attributes::getReal(itsAttr[HORD]); - double dy = Attributes::getReal(itsAttr[VERTD]); - double ds = Attributes::getReal(itsAttr[LONGD]); - double vx = Attributes::getReal(itsAttr[VX]); - double vy = Attributes::getReal(itsAttr[VY]); - double vs = Attributes::getReal(itsAttr[VS]); - Euclid3D shift(dx, dy, ds, vx, vy, vs); - patch->setPatch(shift); - - // Transmit "unknown" attributes. - OpalElement::updateUnknown(patch); -} \ No newline at end of file diff --git a/src/Elements/OpalPatch.h b/src/Elements/OpalPatch.h deleted file mode 100644 index 4e4b4d6f34ef7693692af4025346ad431dbfd8ce..0000000000000000000000000000000000000000 --- a/src/Elements/OpalPatch.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef OPAL_OpalPatch_HH -#define OPAL_OpalPatch_HH - -// ------------------------------------------------------------------------ -// $RCSfile: OpalPatch.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: OpalPatch -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:40 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Elements/OpalElement.h" - - -// Class OpalPatch -// ------------------------------------------------------------------------ -/// The PATCH element. - -class OpalPatch: public OpalElement { - -public: - - /// The attributes of class OpalPatch. - enum { - HORD = COMMON, // The horizontal orbit displacement. - VERTD, // The vertical orbit displacement. - LONGD, // The longitudinal orbit displacement. - VX, // The rotation around the x-axis. - VY, // The rotation around the y-axis. - VS, // The rotation around the s-axis. - SIZE - }; - - /// Exemplar constructor. - OpalPatch(); - - virtual ~OpalPatch(); - - /// Make clone. - virtual OpalPatch *clone(const std::string &name); - - /// Test for patch. - // Return true. - virtual bool isPatch() const; - - /// Update the embedded CLASSIC patch. - virtual void update(); - -private: - - // Not implemented. - OpalPatch(const OpalPatch &); - void operator=(const OpalPatch &); - - // Clone constructor. - OpalPatch(const std::string &name, OpalPatch *parent); -}; - -#endif // OPAL_OpalPatch_HH \ No newline at end of file diff --git a/src/Elements/OpalPepperPot.cpp b/src/Elements/OpalPepperPot.cpp index 5543d7a19f5afd11c87678c8d9606e80a12adaa3..29177e0b58067790977eacdb4f58783b01006c7e 100644 --- a/src/Elements/OpalPepperPot.cpp +++ b/src/Elements/OpalPepperPot.cpp @@ -39,13 +39,6 @@ OpalPepperPot::OpalPepperPot(): itsAttr[R] = Attributes::makeReal ("R", "Radios of a holes in m"); - registerStringAttribute("OUTFN"); - registerRealAttribute("XSIZE"); - registerRealAttribute("YSIZE"); - registerRealAttribute("R"); - registerRealAttribute("NHOLX"); - registerRealAttribute("NHOLY"); - registerOwnership(); setElement(new FlexibleCollimatorRep("PEPPERPOT")); @@ -70,17 +63,6 @@ OpalPepperPot *OpalPepperPot::clone(const std::string &name) { } -void OpalPepperPot::fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - - // const FlexibleCollimatorRep *ppo = - // dynamic_cast<const FlexibleCollimatorRep *>(&base); - // attributeRegistry["XSIZE"]->setReal(ppo->getXsize()); - // attributeRegistry["YSIZE"]->setReal(ppo->getYsize()); - -} - void OpalPepperPot::update() { OpalElement::update(); diff --git a/src/Elements/OpalPepperPot.h b/src/Elements/OpalPepperPot.h index 820e11cf48e62aead0c83302b5777f92c27c93ca..7f1b1d638c572f25509f30d142907768ebc38cef 100644 --- a/src/Elements/OpalPepperPot.h +++ b/src/Elements/OpalPepperPot.h @@ -47,9 +47,6 @@ public: /// Make clone. virtual OpalPepperPot *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC collimator. virtual void update(); diff --git a/src/Elements/OpalPolynomialTimeDependence.cpp b/src/Elements/OpalPolynomialTimeDependence.cpp index aad8501ef28d2aa7c791f4a2987b90edf6a5792c..d7beb38abcbe17a728e0e984570ec3432e107f11 100644 --- a/src/Elements/OpalPolynomialTimeDependence.cpp +++ b/src/Elements/OpalPolynomialTimeDependence.cpp @@ -53,10 +53,6 @@ OpalPolynomialTimeDependence::OpalPolynomialTimeDependence() "Second order (quadratic) term in the polynomial expansion."); itsAttr[P3] = Attributes::makeReal("P3", "Third order (cubic) term in the polynomial expansion."); - registerRealAttribute("P0"); - registerRealAttribute("P1"); - registerRealAttribute("P2"); - registerRealAttribute("P3"); registerOwnership(); } @@ -75,11 +71,6 @@ OpalPolynomialTimeDependence::OpalPolynomialTimeDependence(const std::string &na OpalPolynomialTimeDependence::~OpalPolynomialTimeDependence() {} -void OpalPolynomialTimeDependence::fillRegisteredAttributes - (const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - void OpalPolynomialTimeDependence::update() { // getOpalName() comes from AbstractObjects/Object.h std::vector<double> polynomial_coefficients; diff --git a/src/Elements/OpalPolynomialTimeDependence.h b/src/Elements/OpalPolynomialTimeDependence.h index 175ea72567bc8eb0959129e47f7262e577a9807f..0cbd831253a80eb4e55bdf228c3470d1117c0b5e 100644 --- a/src/Elements/OpalPolynomialTimeDependence.h +++ b/src/Elements/OpalPolynomialTimeDependence.h @@ -54,9 +54,6 @@ class OpalPolynomialTimeDependence : public OpalElement { /** Inherited copy constructor */ virtual OpalPolynomialTimeDependence *clone(const std::string &name); - /** Calls fillRegisteredAttributes on the OpalElement */ - void fillRegisteredAttributes(const ElementBase &base); - /** Receive parameters from the parser and hand them off to the * PolynomialTimeDependence */ diff --git a/src/Elements/OpalProbe.cpp b/src/Elements/OpalProbe.cpp index ba927c533476dd529a2742bb0e2c4212f8b6bd8c..699657c4940304b16ed97320b1ea74625061ece4 100644 --- a/src/Elements/OpalProbe.cpp +++ b/src/Elements/OpalProbe.cpp @@ -43,14 +43,6 @@ OpalProbe::OpalProbe(): itsAttr[OUTFN] = Attributes::makeString ("OUTFN", "Output filename"); - registerRealAttribute("XSTART"); - registerRealAttribute("XEND"); - registerRealAttribute("YSTART"); - registerRealAttribute("YEND"); - registerRealAttribute("WIDTH"); - registerRealAttribute("STEP"); - registerStringAttribute("OUTFN"); - registerOwnership(); setElement(new ProbeRep("PROBE")); @@ -74,11 +66,6 @@ OpalProbe *OpalProbe::clone(const std::string &name) { } -void OpalProbe::fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - - void OpalProbe::update() { OpalElement::update(); diff --git a/src/Elements/OpalProbe.h b/src/Elements/OpalProbe.h index 3ee47889cd5087a7095af37819336a866fbb7036..76a773156c3150ec7ffbb6f32303d3c911d44b10 100644 --- a/src/Elements/OpalProbe.h +++ b/src/Elements/OpalProbe.h @@ -45,9 +45,6 @@ public: /// Make clone. virtual OpalProbe *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC probe. virtual void update(); diff --git a/src/Elements/OpalQuadrupole.cpp b/src/Elements/OpalQuadrupole.cpp index a42b0f49026bd6f397ffd0d4f3e62661465e9f13..2c8a2bc71c02e7992266b93e55f79fd9776ed56d 100644 --- a/src/Elements/OpalQuadrupole.cpp +++ b/src/Elements/OpalQuadrupole.cpp @@ -47,12 +47,6 @@ OpalQuadrupole::OpalQuadrupole(): ("NSLICES", "The number of slices/ steps for this element in Map Tracking", 1); - registerRealAttribute("K1"); - registerRealAttribute("DK1"); - registerRealAttribute("K1S"); - registerRealAttribute("DK1S"); - registerRealAttribute("NSLICES"); - registerOwnership(); setElement((new MultipoleRep("QUADRUPOLE"))); @@ -82,33 +76,6 @@ void OpalQuadrupole::print(std::ostream &os) const { } -void OpalQuadrupole:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const MultipoleRep *quad = dynamic_cast<const MultipoleRep *>(&base); - BMultipoleField field = quad->getField(); - - double length = getLength(); - double scale = Physics::c / OpalData::getInstance()->getP0(); - if(length != 0.0) scale *= length; - - for(int order = 1; order <= field.order(); ++order) { - std::ostringstream ss; - ss << (order - 1) << std::ends; - std::string orderString = ss.str(); - - std::string normName = "K" + orderString + "L"; - registerRealAttribute(normName)->setReal(scale * field.normal(order)); - - std::string skewName = "K" + orderString + "SL"; - registerRealAttribute(skewName)->setReal(scale * field.skew(order)); - - scale *= double(order); - } -} - - void OpalQuadrupole::update() { OpalElement::update(); diff --git a/src/Elements/OpalQuadrupole.h b/src/Elements/OpalQuadrupole.h index fa0abaabb3caa13352782a63f35ea4184378c885..626b61379e2a4f40ea3bf59d5be0abd55d607daf 100644 --- a/src/Elements/OpalQuadrupole.h +++ b/src/Elements/OpalQuadrupole.h @@ -48,9 +48,6 @@ public: // Handle printing in OPAL-8 format. virtual void print(std::ostream &) const; - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC multipole. virtual void update(); diff --git a/src/Elements/OpalRBend.cpp b/src/Elements/OpalRBend.cpp index 97f10fe226b6b2cb893cf4281528840a96091e3a..d15b8b5282e413c0df81bf8e3a3ee78a8e75599a 100644 --- a/src/Elements/OpalRBend.cpp +++ b/src/Elements/OpalRBend.cpp @@ -56,40 +56,6 @@ OpalRBend *OpalRBend::clone(const std::string &name) { } -void OpalRBend:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const RBendRep *bend = dynamic_cast<const RBendRep *>(&base); - BMultipoleField field = bend->getField(); - - double length = getLength(); - double scale = Physics::c / OpalData::getInstance()->getP0(); - if(length != 0.0) scale *= length; - - for(int i = 1; i <= field.order(); ++i) { - std::string normName("K0L"); - normName[1] += (i - 1); - attributeRegistry[normName]->setReal(scale * field.normal(i)); - - std::string skewName("K0SL"); - skewName[1] += (i - 1); - attributeRegistry[skewName]->setReal(scale * field.skew(i)); - scale *= double(i); - } - - // Store pole face information. - attributeRegistry["E1"]->setReal(bend->getEntryFaceRotation()); - attributeRegistry["E2"]->setReal(bend->getExitFaceRotation()); - attributeRegistry["H1"]->setReal(bend->getEntryFaceCurvature()); - attributeRegistry["H2"]->setReal(bend->getExitFaceCurvature()); - - // Store integration parameters. - attributeRegistry["SLICES"]->setReal(bend->getSlices()); - attributeRegistry["STEPSIZE"]->setReal(bend->getStepsize()); -} - - void OpalRBend::update() { OpalElement::update(); diff --git a/src/Elements/OpalRBend.h b/src/Elements/OpalRBend.h index 2bc1c527f521e107b2079c1c802410d9034f8fe8..f5b65c2496a19864ccd3f876015646ad808c9e8f 100644 --- a/src/Elements/OpalRBend.h +++ b/src/Elements/OpalRBend.h @@ -35,9 +35,6 @@ public: /// Make clone. virtual OpalRBend *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC bend. virtual void update(); diff --git a/src/Elements/OpalRBend3D.cpp b/src/Elements/OpalRBend3D.cpp index e1175d63fcd64bce123bf92242e2bd0dfbb925b3..8c6773e62346acf38fae67ba44d4048ae577cf21 100644 --- a/src/Elements/OpalRBend3D.cpp +++ b/src/Elements/OpalRBend3D.cpp @@ -48,16 +48,6 @@ OpalRBend3D::OpalRBend3D(): itsAttr[DESIGNENERGY] = Attributes::makeReal ("DESIGNENERGY", "the mean energy of the particles in MeV"); - registerRealAttribute("ANGLE"); - registerRealAttribute("K0L"); - registerRealAttribute("K0SL"); - registerRealAttribute("E1"); - registerRealAttribute("E2"); - registerStringAttribute("FMAPFN"); - registerRealAttribute("GAP"); - registerRealAttribute("HAPERT"); - registerRealAttribute("DESIGNENERGY"); - registerOwnership(); setElement(new RBend3D("RBEND3D")); @@ -81,11 +71,6 @@ OpalRBend3D *OpalRBend3D::clone(const std::string &name) { } -void OpalRBend3D:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - void OpalRBend3D::update() { OpalElement::update(); diff --git a/src/Elements/OpalRBend3D.h b/src/Elements/OpalRBend3D.h index 650fddc223bb9059a17d80ba5e53d98d3471b15a..1ba95ac2962ba1ca6be8e3d39f08cea9549473c6 100644 --- a/src/Elements/OpalRBend3D.h +++ b/src/Elements/OpalRBend3D.h @@ -51,9 +51,6 @@ public: /// Make clone. virtual OpalRBend3D *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC bend. virtual void update(); diff --git a/src/Elements/OpalRCollimator.cpp b/src/Elements/OpalRCollimator.cpp index cec559076531f3010368ea4d4d95e4a1cb15f478..688756589527aca38725614863aaae3388d2c4af 100644 --- a/src/Elements/OpalRCollimator.cpp +++ b/src/Elements/OpalRCollimator.cpp @@ -35,10 +35,6 @@ OpalRCollimator::OpalRCollimator(): itsAttr[OUTFN] = Attributes::makeString ("OUTFN", "Monitor output filename"); - registerStringAttribute("OUTFN"); - registerRealAttribute("XSIZE"); - registerRealAttribute("YSIZE"); - registerOwnership(); setElement(new FlexibleCollimatorRep("RCOLLIMATOR")); @@ -62,28 +58,6 @@ OpalRCollimator *OpalRCollimator::clone(const std::string &name) { } -void OpalRCollimator:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const FlexibleCollimatorRep *coll = - dynamic_cast<const FlexibleCollimatorRep *>(&base); - - std::string Double("(-?[0-9]+\\.?[0-9]*([Ee][+-]?[0-9]+)?)"); - std::string desc = coll->getDescription(); - - boost::regex parser("rectangle\\(" + Double + "," + Double + "\\)"); - boost::smatch what; - if (!boost::regex_match(desc, what, parser)) return; - - double width = atof(std::string(what[1]).c_str()); - double height = atof(std::string(what[3]).c_str()); - - attributeRegistry["XSIZE"]->setReal(0.5 * width); - attributeRegistry["YSIZE"]->setReal(0.5 * height); -} - - void OpalRCollimator::update() { OpalElement::update(); diff --git a/src/Elements/OpalRCollimator.h b/src/Elements/OpalRCollimator.h index 12dfbf436534609b1cb02cff8e7a9347743439ca..415419e4f93bbd66f1e9163591fcc3eb7b980217 100644 --- a/src/Elements/OpalRCollimator.h +++ b/src/Elements/OpalRCollimator.h @@ -42,9 +42,6 @@ public: /// Make clone. virtual OpalRCollimator *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC collimator. virtual void update(); diff --git a/src/Elements/OpalRingDefinition.cpp b/src/Elements/OpalRingDefinition.cpp index b99b160cf02f655c5e390219ea9c51b50bb2e8e5..c4ba09f3907b81268e9386e08c2f83d5c914778e 100644 --- a/src/Elements/OpalRingDefinition.cpp +++ b/src/Elements/OpalRingDefinition.cpp @@ -64,21 +64,6 @@ OpalRingDefinition::OpalRingDefinition() : itsAttr[MAX_R] = Attributes::makeReal("MAX_R", "Maximum allowed radius during tracking [m]. If not defined, any radius is allowed. If MAX_R is defined, MIN_R must also be defined."); - registerRealAttribute("LAT_RINIT"); - registerRealAttribute("LAT_PHIINIT"); - registerRealAttribute("LAT_THETAINIT"); - registerRealAttribute("BEAM_RINIT"); - registerRealAttribute("BEAM_PHIINIT"); - registerRealAttribute("BEAM_PRINIT"); - registerRealAttribute("HARMONIC_NUMBER"); - registerRealAttribute("SYMMETRY"); - registerRealAttribute("SCALE"); - registerRealAttribute("RFFREQ"); - registerStringAttribute("IS_CLOSED"); - registerRealAttribute("SCALE"); - registerRealAttribute("MIN_R"); - registerRealAttribute("MAX_R"); - registerOwnership(); setElement(new Ring("RING")); @@ -99,11 +84,6 @@ OpalRingDefinition::OpalRingDefinition(const std::string &name, OpalRingDefiniti OpalRingDefinition::~OpalRingDefinition() {} -void OpalRingDefinition::fillRegisteredAttributes -(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - void OpalRingDefinition::update() { Ring *ring = dynamic_cast<Ring*>(getElement()); double degree = Physics::pi/180.; diff --git a/src/Elements/OpalRingDefinition.h b/src/Elements/OpalRingDefinition.h index 7fe2755e45cdaef88701c95e3dc358b0fa15551b..2c89d8f06d51718a2ed75c0379661b2383acbef7 100644 --- a/src/Elements/OpalRingDefinition.h +++ b/src/Elements/OpalRingDefinition.h @@ -67,9 +67,6 @@ class OpalRingDefinition: public OpalElement { /** Inherited copy constructor */ virtual OpalRingDefinition *clone(const std::string &name); - /** Calls fillRegisteredAttributes on the OpalElement */ - void fillRegisteredAttributes(const ElementBase &base); - /** Receive parameters from the parser and hand them off to the Ring */ void update(); diff --git a/src/Elements/OpalSBend.cpp b/src/Elements/OpalSBend.cpp index ffa9518bafdbf2c91291713014fa215c11b4037f..287603ffa984380d5ded2a649e9f54f9833e74c7 100644 --- a/src/Elements/OpalSBend.cpp +++ b/src/Elements/OpalSBend.cpp @@ -56,41 +56,6 @@ OpalSBend *OpalSBend::clone(const std::string &name) { } -void OpalSBend:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const SBendRep *bend = dynamic_cast<const SBendRep *>(&base); - BMultipoleField field = bend->getField(); - - double length = getLength(); - double scale = Physics::c / OpalData::getInstance()->getP0(); - if(length != 0.0) scale *= length; - - for(int i = 1; i <= field.order(); ++i) { - std::string normName("K0L"); - normName[1] += (i - 1); - attributeRegistry[normName]->setReal(scale * field.normal(i)); - - std::string skewName("K0SL"); - skewName[1] += (i - 1); - attributeRegistry[skewName]->setReal(scale * field.skew(i)); - scale *= double(i); - } - - // Store pole face information. - attributeRegistry["E1"]->setReal(bend->getEntryFaceRotation()); - attributeRegistry["E2"]->setReal(bend->getExitFaceRotation()); - attributeRegistry["H1"]->setReal(bend->getEntryFaceCurvature()); - attributeRegistry["H2"]->setReal(bend->getExitFaceCurvature()); - - // Store integration parameters. - attributeRegistry["SLICES"]->setReal(bend->getSlices()); - attributeRegistry["STEPSIZE"]->setReal(bend->getStepsize()); - //attributeRegistry["FMAPFN"]->setString(bend->getFieldMapFN()); -} - - void OpalSBend::update() { OpalElement::update(); diff --git a/src/Elements/OpalSBend.h b/src/Elements/OpalSBend.h index 007d8dd18dde8c0d772578fa952359f0bbd79717..0e6f7ae6b8f54301f0b0333d1ff9de718c12d8ab 100644 --- a/src/Elements/OpalSBend.h +++ b/src/Elements/OpalSBend.h @@ -35,9 +35,6 @@ public: /// Make clone. virtual OpalSBend *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC bend. virtual void update(); diff --git a/src/Elements/OpalSBend3D.cpp b/src/Elements/OpalSBend3D.cpp index f668c8fa48957e418c1c3301f54a00632ac2ee86..8e54037955b4fd68cd287f6a34c3c38fe47e2929 100644 --- a/src/Elements/OpalSBend3D.cpp +++ b/src/Elements/OpalSBend3D.cpp @@ -42,9 +42,6 @@ OpalSBend3D::OpalSBend3D(): "Scale the field map up or down by this factor (default 1. is T)."); itsAttr[LENGTH_UNITS] = Attributes::makeReal("LENGTH_UNITS", "Units for length coordinates (default 1. is mm)."); - registerStringAttribute("FMAPFN"); - registerRealAttribute("FIELD_UNITS"); - registerRealAttribute("LENGTH_UNITS"); registerOwnership(); @@ -67,12 +64,6 @@ OpalSBend3D *OpalSBend3D::clone(const std::string &name) { } -void OpalSBend3D:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - - void OpalSBend3D::update() { SBend3D *bend = dynamic_cast<SBend3D*>(getElement()); if (itsAttr[FIELD_UNITS]) diff --git a/src/Elements/OpalSBend3D.h b/src/Elements/OpalSBend3D.h index 61c53dd3d2a24f6d8306178ac1d0268df858732a..ab25f17b30e8013d93b5638f3f2d45adbf6c801a 100644 --- a/src/Elements/OpalSBend3D.h +++ b/src/Elements/OpalSBend3D.h @@ -53,12 +53,6 @@ class OpalSBend3D: public OpalElement { /** Inherited copy constructor */ virtual OpalSBend3D *clone(const std::string &name); - /** Fill in all registered attributes - * - * Just calls fillRegisteredAttributes on the base class - */ - virtual void fillRegisteredAttributes(const ElementBase &); - /** Update the SBend3D with new parameters from UI parser */ virtual void update(); diff --git a/src/Elements/OpalSRot.cpp b/src/Elements/OpalSRot.cpp deleted file mode 100644 index 61d3ef9f247d2a7044a92973e28451ed83200ab1..0000000000000000000000000000000000000000 --- a/src/Elements/OpalSRot.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: OpalSRot.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: OpalSRot -// The class of OPAL SROT coordinate transforms. -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:40 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Elements/OpalSRot.h" -#include "Attributes/Attributes.h" -#include "BeamlineCore/PatchRep.h" - - -// Class OpalSRot -// ------------------------------------------------------------------------ - -OpalSRot::OpalSRot(): - OpalElement(SIZE, "SROT", - "The \"SRot\" element defines a coordinate rotation " - "around the s-axis.") { - itsAttr[ANGLE] = Attributes::makeReal - ("ANGLE", "Angle for the transformation"); - - registerRealAttribute("ANGLE"); - - registerOwnership(); - - setElement(new PatchRep("SROT")); -} - - -OpalSRot::OpalSRot(const std::string &name, OpalSRot *parent): - OpalElement(name, parent) { - setElement(new PatchRep(name)); -} - - -OpalSRot::~OpalSRot() -{} - - -OpalSRot *OpalSRot::clone(const std::string &name) { - return new OpalSRot(name, this); -} - - -void OpalSRot:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - double angle = Attributes::getReal(itsAttr[ANGLE]); - attributeRegistry["SANGLE"]->setReal(angle); -} - - -void OpalSRot::update() { - // Define geometry. - PatchRep *srot = dynamic_cast<PatchRep *>(getElement()); - double angle = Attributes::getReal(itsAttr[ANGLE]); - Euclid3D rot = Euclid3D::ZRotation(angle); - srot->setPatch(rot); - - // Transmit "unknown" attributes. - OpalElement::updateUnknown(srot); -} \ No newline at end of file diff --git a/src/Elements/OpalSRot.h b/src/Elements/OpalSRot.h deleted file mode 100644 index a150cbdb07283a5a27ca2a66801d08a483a07f17..0000000000000000000000000000000000000000 --- a/src/Elements/OpalSRot.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef OPAL_OpalSRot_HH -#define OPAL_OpalSRot_HH - -// ------------------------------------------------------------------------ -// $RCSfile: OpalSRot.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// CopSRight: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: OpalSRot -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:40 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Elements/OpalElement.h" - - -// Class OpalSRot -// ------------------------------------------------------------------------ -/// The SROT element. - -class OpalSRot: public OpalElement { - -public: - - /// The attributes of class OpalSRot. - enum { - ANGLE = COMMON, // The rotation angle. - SIZE // Total number of attributes. - }; - - /// Exemplar constructor. - OpalSRot(); - - virtual ~OpalSRot(); - - /// Make clone. - virtual OpalSRot *clone(const std::string &name); - - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - - /// Update the embedded CLASSIC patch. - virtual void update(); - -private: - - // Not implemented. - OpalSRot(const OpalSRot &); - void operator=(const OpalSRot &); - - // Clone constructor. - OpalSRot(const std::string &name, OpalSRot *parent); -}; - -#endif // OPAL_OpalSRot_HH diff --git a/src/Elements/OpalScalingFFAMagnet.cpp b/src/Elements/OpalScalingFFAMagnet.cpp index f6c4dd36689783fa023482b344a989cc7f72a804..edb8bcdca314b5270025743eb680d57e366c7e1f 100644 --- a/src/Elements/OpalScalingFFAMagnet.cpp +++ b/src/Elements/OpalScalingFFAMagnet.cpp @@ -62,19 +62,6 @@ OpalScalingFFAMagnet::OpalScalingFFAMagnet() : "Offset to the end of the magnet, i.e. placement of the next element. Default is centre_length + 4*end_length."); itsAttr[AZIMUTHAL_EXTENT] = Attributes::makeReal("AZIMUTHAL_EXTENT", "The field will be assumed zero if particles are more than AZIMUTHAL_EXTENT from the magnet centre (psi=0). Default is CENTRE_LENGTH/2.+5.*END_LENGTH [m]."); - registerRealAttribute("B0"); - registerRealAttribute("R0"); - registerRealAttribute("FIELD_INDEX"); - registerRealAttribute("TAN_DELTA"); - registerRealAttribute("MAX_Y_POWER"); - registerRealAttribute("END_LENGTH"); - registerRealAttribute("CENTRE_LENGTH"); - registerRealAttribute("RADIAL_NEG_EXTENT"); - registerRealAttribute("RADIAL_POS_EXTENT"); - registerRealAttribute("HEIGHT"); - registerRealAttribute("MAGNET_START"); - registerRealAttribute("MAGNET_END"); - registerRealAttribute("AZIMUTHAL_EXTENT"); registerOwnership(); ScalingFFAMagnet* magnet = new ScalingFFAMagnet("ScalingFFAMagnet"); @@ -101,12 +88,6 @@ OpalScalingFFAMagnet *OpalScalingFFAMagnet::clone(const std::string &name) { } -void OpalScalingFFAMagnet:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - - void OpalScalingFFAMagnet::update() { ScalingFFAMagnet *magnet = dynamic_cast<ScalingFFAMagnet*>(getElement()); diff --git a/src/Elements/OpalScalingFFAMagnet.h b/src/Elements/OpalScalingFFAMagnet.h index 3a58d768cf10f35958279452e6d5d526baeea045..b670b693122c210995dffed10c9844e340f437ec 100644 --- a/src/Elements/OpalScalingFFAMagnet.h +++ b/src/Elements/OpalScalingFFAMagnet.h @@ -63,12 +63,6 @@ class OpalScalingFFAMagnet : public OpalElement { /** Inherited copy constructor */ virtual OpalScalingFFAMagnet *clone(const std::string &name); - /** Fill in all registered attributes - * - * Just calls fillRegisteredAttributes on the base class - */ - virtual void fillRegisteredAttributes(const ElementBase &); - /** Update the ScalingFFA with new parameters from UI parser */ virtual void update(); diff --git a/src/Elements/OpalSeparator.cpp b/src/Elements/OpalSeparator.cpp deleted file mode 100644 index 1dd3eac9a8ca3722faaa42e3e4eaabbc7dc2cf69..0000000000000000000000000000000000000000 --- a/src/Elements/OpalSeparator.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// -// Class OpalSeparator -// The ELSEPARATOR element. -// -// Copyright (c) 200x - 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 "Elements/OpalSeparator.h" -#include "Attributes/Attributes.h" -#include "BeamlineCore/SeparatorRep.h" - - -OpalSeparator::OpalSeparator(): - OpalElement(SIZE, "SEPARATOR", - "The \"SEPARATOR\" element defines an electrostatic separator.") { - itsAttr[EX] = Attributes::makeReal - ("EX", "The horizontal electrostatic field in MV"); - itsAttr[EY] = Attributes::makeReal - ("EY", "The vertical electrostatic field in MV"); - - registerRealAttribute("EXL"); - registerRealAttribute("EYL"); - - registerOwnership(); - - setElement(new SeparatorRep("SEPARATOR")); -} - - -OpalSeparator::OpalSeparator(const std::string &name, OpalSeparator *parent): - OpalElement(name, parent) { - setElement(new SeparatorRep(name)); -} - - -OpalSeparator::~OpalSeparator() -{} - - -OpalSeparator *OpalSeparator::clone(const std::string &name) { - return new OpalSeparator(name, this); -} - - -void OpalSeparator:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const SeparatorRep *sep = dynamic_cast<const SeparatorRep *>(&base); - double length = sep->getElementLength(); - attributeRegistry["EXL"]->setReal(length * sep->getEx()); - attributeRegistry["EYL"]->setReal(length * sep->getEy()); -} - - -void OpalSeparator::update() { - OpalElement::update(); - - SeparatorRep *sep = - dynamic_cast<SeparatorRep *>(getElement()); - double length = Attributes::getReal(itsAttr[LENGTH]); - double Ex = Attributes::getReal(itsAttr[EX]) * 1.0e6; - double Ey = Attributes::getReal(itsAttr[EY]) * 1.0e6; - sep->setElementLength(length); - sep->setEx(Ex); - sep->setEy(Ey); - - // Transmit "unknown" attributes. - OpalElement::updateUnknown(sep); -} \ No newline at end of file diff --git a/src/Elements/OpalSeparator.h b/src/Elements/OpalSeparator.h deleted file mode 100644 index 29061161fd7233ba860cba62e778ae25970ea46d..0000000000000000000000000000000000000000 --- a/src/Elements/OpalSeparator.h +++ /dev/null @@ -1,59 +0,0 @@ -// -// Class OpalSeparator -// The ELSEPARATOR element. -// -// Copyright (c) 200x - 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 OPAL_OpalSeparator_HH -#define OPAL_OpalSeparator_HH - -#include "Elements/OpalElement.h" - - -class OpalSeparator: public OpalElement { - -public: - - /// The attributes of class OpalSeparator. - enum { - EX = COMMON, // The horizontal field. - EY, // The vertical field. - SIZE - }; - - /// Exemplar constructor. - OpalSeparator(); - - virtual ~OpalSeparator(); - - /// Make clone. - virtual OpalSeparator *clone(const std::string &name); - - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - - /// Update the embedded CLASSIC separator. - virtual void update(); - -private: - - // Not implemented. - OpalSeparator(const OpalSeparator &); - void operator=(const OpalSeparator &); - - // Clone constructor. - OpalSeparator(const std::string &name, OpalSeparator *parent); -}; - -#endif // OPAL_OpalSeparator_HH diff --git a/src/Elements/OpalSeptum.cpp b/src/Elements/OpalSeptum.cpp index 91c224e46b76364c7c2ae9aaff02387c2383056b..acb3a2df422db7e429b10d8df5783115751fdb4b 100644 --- a/src/Elements/OpalSeptum.cpp +++ b/src/Elements/OpalSeptum.cpp @@ -41,13 +41,6 @@ OpalSeptum::OpalSeptum(): itsAttr[OUTFN] = Attributes::makeString ("OUTFN", "Output filename"); - registerRealAttribute("XSTART"); - registerRealAttribute("XEND"); - registerRealAttribute("YSTART"); - registerRealAttribute("YEND"); - registerRealAttribute("WIDTH"); - registerStringAttribute("OUTFN"); - registerOwnership(); setElement(new SeptumRep("SEPTUM")); @@ -72,12 +65,6 @@ OpalSeptum *OpalSeptum::clone(const std::string &name) { } -void OpalSeptum::fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - -} - - void OpalSeptum::update() { OpalElement::update(); diff --git a/src/Elements/OpalSeptum.h b/src/Elements/OpalSeptum.h index ab9a22d386c6279ddd7f3f192a845c0ea9c7a619..76d444d8ffa1130ce67052db96e865e087a9865a 100644 --- a/src/Elements/OpalSeptum.h +++ b/src/Elements/OpalSeptum.h @@ -44,9 +44,6 @@ public: /// Make clone. virtual OpalSeptum *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC septum. virtual void update(); diff --git a/src/Elements/OpalSextupole.cpp b/src/Elements/OpalSextupole.cpp index 357120ebde33cb37d6414e8f7315597684ada644..fc0e21be132a5d696119cc23e5b687921c4e3bd2 100644 --- a/src/Elements/OpalSextupole.cpp +++ b/src/Elements/OpalSextupole.cpp @@ -66,33 +66,6 @@ void OpalSextupole::print(std::ostream &os) const { } -void OpalSextupole:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const MultipoleRep *sext = dynamic_cast<const MultipoleRep *>(&base); - BMultipoleField field = sext->getField(); - - double length = getLength(); - double scale = Physics::c / OpalData::getInstance()->getP0(); - if(length != 0.0) scale *= length; - - for(int order = 1; order <= field.order(); ++order) { - std::ostringstream ss; - ss << (order - 1) << std::ends; - std::string orderString = ss.str(); - - std::string normName = "K" + orderString + "L"; - registerRealAttribute(normName)->setReal(scale * field.normal(order)); - - std::string skewName = "K" + orderString + "SL"; - registerRealAttribute(skewName)->setReal(scale * field.skew(order)); - - scale *= double(order); - } -} - - void OpalSextupole::update() { OpalElement::update(); diff --git a/src/Elements/OpalSextupole.h b/src/Elements/OpalSextupole.h index 24f4e29913804adc459ad7d87b9d812168a88acd..fb79ca4e4fbe851d293ee83ed16d7de022bfbc14 100644 --- a/src/Elements/OpalSextupole.h +++ b/src/Elements/OpalSextupole.h @@ -46,9 +46,6 @@ public: // Handle printing in OPAL-8 format. virtual void print(std::ostream &) const; - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC multipole. virtual void update(); diff --git a/src/Elements/OpalSlit.cpp b/src/Elements/OpalSlit.cpp index 6199e286f74233a1d4ea1e9046ee53bd51c02e82..890086cb965b74087a272a3d2fd4905a42465b1c 100644 --- a/src/Elements/OpalSlit.cpp +++ b/src/Elements/OpalSlit.cpp @@ -34,11 +34,6 @@ OpalSlit::OpalSlit(): itsAttr[OUTFN] = Attributes::makeString ("OUTFN", "Monitor output filename"); - - registerStringAttribute("OUTFN"); - registerRealAttribute("XSIZE"); - registerRealAttribute("YSIZE"); - registerOwnership(); setElement(new FlexibleCollimatorRep("SLIT")); @@ -63,27 +58,6 @@ OpalSlit *OpalSlit::clone(const std::string &name) { } -void OpalSlit::fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const FlexibleCollimatorRep *coll = - dynamic_cast<const FlexibleCollimatorRep *>(&base); - - std::string Double("(-?[0-9]+\\.?[0-9]*([Ee][+-]?[0-9]+)?)"); - std::string desc = coll->getDescription(); - - boost::regex parser("rectangle\\(" + Double + "," + Double + "\\)"); - boost::smatch what; - if (!boost::regex_match(desc, what, parser)) return; - - double width = atof(std::string(what[1]).c_str()); - double height = atof(std::string(what[3]).c_str()); - - attributeRegistry["XSIZE"]->setReal(0.5 * width); - attributeRegistry["YSIZE"]->setReal(0.5 * height); -} - - void OpalSlit::update() { OpalElement::update(); diff --git a/src/Elements/OpalSlit.h b/src/Elements/OpalSlit.h index b3e38e67c07eaa82a696a5ce0fdc794e18cf79a4..dbf9722087dd726612cd67dcd0745f33a8abee39 100644 --- a/src/Elements/OpalSlit.h +++ b/src/Elements/OpalSlit.h @@ -42,9 +42,6 @@ public: /// Make clone. virtual OpalSlit *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC collimator. virtual void update(); diff --git a/src/Elements/OpalSolenoid.cpp b/src/Elements/OpalSolenoid.cpp index 241bdfd832f23ba2422e7b8d7e85c50495f372f4..3148704aae408d8738c53153e11b89e71cded02a 100644 --- a/src/Elements/OpalSolenoid.cpp +++ b/src/Elements/OpalSolenoid.cpp @@ -34,10 +34,6 @@ OpalSolenoid::OpalSolenoid(): itsAttr[FAST] = Attributes::makeBool ("FAST", "Faster but less accurate", true); - registerRealAttribute("KS"); - registerRealAttribute("DKS"); - registerStringAttribute("FMAPFN"); - registerOwnership(); setElement(new SolenoidRep("SOLENOID")); @@ -59,18 +55,6 @@ OpalSolenoid *OpalSolenoid::clone(const std::string &name) { } -void OpalSolenoid:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const SolenoidRep *sol = - dynamic_cast<const SolenoidRep *>(&base); - double length = sol->getElementLength(); - double ks = length * sol->getBz() * Physics::c / OpalData::getInstance()->getP0(); - attributeRegistry["KS"]->setReal(ks); -} - - void OpalSolenoid::update() { OpalElement::update(); diff --git a/src/Elements/OpalSolenoid.h b/src/Elements/OpalSolenoid.h index 268dee5c1f1bcbb6eb60b797775c09e700785c8b..9ea42068c3377a765270da90397840c27e6c36be 100644 --- a/src/Elements/OpalSolenoid.h +++ b/src/Elements/OpalSolenoid.h @@ -42,9 +42,6 @@ public: /// Make clone. virtual OpalSolenoid *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC solenoid. virtual void update(); diff --git a/src/Elements/OpalSource.cpp b/src/Elements/OpalSource.cpp index 92b54d6f25a5d06367ac99a16f3329103e2e7227..e21a75f6c9daa9208fedb608996ec0fa8c766a02 100644 --- a/src/Elements/OpalSource.cpp +++ b/src/Elements/OpalSource.cpp @@ -28,8 +28,6 @@ OpalSource::OpalSource(): itsAttr[DISTRIBUTION] = Attributes::makeStringArray ("DISTRIBUTION", "List of particle distributions to be used "); - registerStringAttribute("DISTRIBUTION"); - registerOwnership(); setElement(new SourceRep("SOURCE")); @@ -51,12 +49,6 @@ OpalSource *OpalSource::clone(const std::string &name) { } -void OpalSource:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - - void OpalSource::update() { OpalElement::update(); diff --git a/src/Elements/OpalSource.h b/src/Elements/OpalSource.h index 1801b3aaa26e49b486639ffd303ab00c6fbb7218..7addfd83e94a87ee70d4b42cf2c61628cb0d1933 100644 --- a/src/Elements/OpalSource.h +++ b/src/Elements/OpalSource.h @@ -39,9 +39,6 @@ public: /// Make clone. virtual OpalSource *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC solenoid. virtual void update(); diff --git a/src/Elements/OpalSplineTimeDependence.cpp b/src/Elements/OpalSplineTimeDependence.cpp index 909dd381cf863850de2a62987aac04bda1959d83..64b5992958328faf11ac5876a43fac58bd4130aa 100644 --- a/src/Elements/OpalSplineTimeDependence.cpp +++ b/src/Elements/OpalSplineTimeDependence.cpp @@ -56,10 +56,6 @@ OpalSplineTimeDependence::OpalSplineTimeDependence() std::string("Array of real values. The length of \"VALUES\" must be the ")+ std::string("same as the length of \"TIMES\".")); - registerRealAttribute("ORDER"); - registerRealAttribute("TIMES"); - registerRealAttribute("VALUES"); - registerOwnership(); } @@ -78,11 +74,6 @@ OpalSplineTimeDependence::OpalSplineTimeDependence(const std::string &name, OpalSplineTimeDependence::~OpalSplineTimeDependence() {} -void OpalSplineTimeDependence::fillRegisteredAttributes - (const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - void OpalSplineTimeDependence::update() { double orderReal = Attributes::getReal(itsAttr[ORDER])+1e-10; diff --git a/src/Elements/OpalSplineTimeDependence.h b/src/Elements/OpalSplineTimeDependence.h index 64fd3fcc886e974efdf555c99ebae6e2cd7aaa9c..e524e2a1e3eb942caba39bfc1d59cc333c4acb27 100644 --- a/src/Elements/OpalSplineTimeDependence.h +++ b/src/Elements/OpalSplineTimeDependence.h @@ -54,9 +54,6 @@ class OpalSplineTimeDependence : public OpalElement { /** Inherited copy constructor */ virtual OpalSplineTimeDependence *clone(const std::string &name); - /** Calls fillRegisteredAttributes on the OpalElement */ - void fillRegisteredAttributes(const ElementBase &base); - /** Receive parameters from the parser and hand them off to the * SplineTimeDependence */ diff --git a/src/Elements/OpalStripper.cpp b/src/Elements/OpalStripper.cpp index 92974494e935b615cc7bbecfb9308e423b38c9c1..8a0b8175913e5332a14fe1045f6c589d88f8dadb 100644 --- a/src/Elements/OpalStripper.cpp +++ b/src/Elements/OpalStripper.cpp @@ -55,16 +55,6 @@ OpalStripper::OpalStripper(): itsAttr[OUTFN] = Attributes::makeString ("OUTFN", "Output filename"); - registerRealAttribute("XSTART"); - registerRealAttribute("XEND"); - registerRealAttribute("YSTART"); - registerRealAttribute("YEND"); - registerRealAttribute("WIDTH"); - registerRealAttribute("OPCHARGE"); - registerRealAttribute("OPMASS"); - registerRealAttribute("OPYIELD"); - registerStringAttribute("OUTFN"); - registerOwnership(); setElement(new StripperRep("STRIPPER")); @@ -86,12 +76,6 @@ OpalStripper *OpalStripper::clone(const std::string &name) { } -void OpalStripper::fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - -} - - void OpalStripper::update() { OpalElement::update(); diff --git a/src/Elements/OpalStripper.h b/src/Elements/OpalStripper.h index b542542043666877299a6933db0bb82c46735467..d911d418c9002c22659063fcb45d0a062a3112ac 100644 --- a/src/Elements/OpalStripper.h +++ b/src/Elements/OpalStripper.h @@ -54,9 +54,6 @@ public: /// Make clone. virtual OpalStripper *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC septum. virtual void update(); diff --git a/src/Elements/OpalTravelingWave.cpp b/src/Elements/OpalTravelingWave.cpp index 3970f8f7ebec9d421efae2e40d82473ff4dbf383..48761df3b4e14cda50b17050110dbb681b118ef6 100644 --- a/src/Elements/OpalTravelingWave.cpp +++ b/src/Elements/OpalTravelingWave.cpp @@ -61,17 +61,6 @@ OpalTravelingWave::OpalTravelingWave(): itsAttr[MODE] = Attributes::makeReal ("MODE", "The phase shift between neighboring cells in 2*pi", 1.0/3.0); - registerRealAttribute("VOLT"); - registerRealAttribute("DVOLT"); - registerRealAttribute("FREQ"); - registerRealAttribute("LAG"); - registerRealAttribute("DLAG"); - registerStringAttribute("FMAPFN"); - registerStringAttribute("CAVITYTYPE"); - registerRealAttribute("NUMCELLS"); - registerRealAttribute("DESIGNENERGY"); - registerRealAttribute("MODE"); - registerOwnership(); setElement(new TravelingWaveRep("TRAVELINGWAVE")); @@ -96,21 +85,6 @@ OpalTravelingWave *OpalTravelingWave::clone(const std::string &name) { } -void OpalTravelingWave:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - - const TravelingWaveRep *rfc = - dynamic_cast<const TravelingWaveRep *>(&base); - attributeRegistry["VOLT"]->setReal(rfc->getAmplitude()); - attributeRegistry["DVOLT"]->setReal(rfc->getAmplitudeError()); - attributeRegistry["FREQ"]->setReal(rfc->getFrequency()); - attributeRegistry["LAG"]->setReal(rfc->getPhase()); - attributeRegistry["DLAG"]->setReal(rfc->getPhaseError()); - attributeRegistry["FMAPFN"]->setString(rfc->getFieldMapFN()); -} - - void OpalTravelingWave::update() { OpalElement::update(); diff --git a/src/Elements/OpalTravelingWave.h b/src/Elements/OpalTravelingWave.h index 2efa3da3e9a7acebc3ed170276a69eb622e2c0a1..2456e934cb7eccc1ae73a7f47c6dcd07d80b8bfc 100644 --- a/src/Elements/OpalTravelingWave.h +++ b/src/Elements/OpalTravelingWave.h @@ -56,9 +56,6 @@ public: /// Make clone. virtual OpalTravelingWave *clone(const std::string &name); - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC cavity. virtual void update(); diff --git a/src/Elements/OpalVKicker.cpp b/src/Elements/OpalVKicker.cpp index 45ef1250f6dff746cf065c3ffc9a3521b2325d7f..95579f332eae0c090ac2acbc4c5b39bdefd88b66 100644 --- a/src/Elements/OpalVKicker.cpp +++ b/src/Elements/OpalVKicker.cpp @@ -35,10 +35,6 @@ OpalVKicker::OpalVKicker(): itsAttr[K0] = Attributes::makeReal ("K0", "Normal dipole field in T"); - registerRealAttribute("KICK"); - registerRealAttribute("DESIGNENERGY"); - registerRealAttribute("K0"); - registerOwnership(); setElement(new YCorrectorRep("VKICKER")); @@ -60,25 +56,6 @@ OpalVKicker *OpalVKicker::clone(const std::string &name) { } -void OpalVKicker:: -fillRegisteredAttributes(const ElementBase &base) { - Inform m("fillRegisteredAttributes "); - OpalElement::fillRegisteredAttributes(base); - - const YCorrectorRep *corr = dynamic_cast<const YCorrectorRep *>(&base); - BDipoleField field = corr->getField(); - - double scale = Physics::c / OpalData::getInstance()->getP0(); - attributeRegistry["HKICK"]->setReal(- field.getBy() * scale); - attributeRegistry["VKICK"]->setReal(+ field.getBx() * scale); - - m << "P= " << OpalData::getInstance()->getP0() - << " Bx= " << field.getBx() - << " By= " << field.getBy() << endl; - -} - - void OpalVKicker::update() { OpalElement::update(); diff --git a/src/Elements/OpalVKicker.h b/src/Elements/OpalVKicker.h index 5df108519d88f1c375be7621147abc570c7ea7af..d684b50d68007cedfcdc02c3aaee685a096ff8ae 100644 --- a/src/Elements/OpalVKicker.h +++ b/src/Elements/OpalVKicker.h @@ -50,9 +50,6 @@ public: // virtual void print(std::ostream &) const; //END JMJ 15/12/2000, adding missing print method - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - /// Update the embedded CLASSIC corrector. virtual void update(); diff --git a/src/Elements/OpalVMonitor.cpp b/src/Elements/OpalVMonitor.cpp deleted file mode 100644 index 9d33b37302cfb17f283c6fa1297d1705934d9f1d..0000000000000000000000000000000000000000 --- a/src/Elements/OpalVMonitor.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// -// Class OpalVMonitor -// The VMONITOR element. -// -// Copyright (c) 200x - 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 "Elements/OpalVMonitor.h" -#include "Attributes/Attributes.h" -#include "BeamlineCore/YMonitorRep.h" - - -OpalVMonitor::OpalVMonitor(): - OpalElement(COMMON, "VMONITOR", - "The \"VMONITOR\" element defines a monitor " - "for the vertical plane.") { - setElement(new YMonitorRep("VMONITOR")); -} - - -OpalVMonitor::OpalVMonitor(const std::string &name, OpalVMonitor *parent): - OpalElement(name, parent) { - setElement(new YMonitorRep(name)); -} - - -OpalVMonitor::~OpalVMonitor() -{} - - -OpalVMonitor *OpalVMonitor::clone(const std::string &name) { - return new OpalVMonitor(name, this); -} - - -void OpalVMonitor::update() { - OpalElement::update(); - - YMonitorRep *mon = - dynamic_cast<YMonitorRep *>(getElement()); - double length = Attributes::getReal(itsAttr[LENGTH]); - mon->setElementLength(length); - - // Transmit "unknown" attributes. - OpalElement::updateUnknown(mon); -} diff --git a/src/Elements/OpalVMonitor.h b/src/Elements/OpalVMonitor.h deleted file mode 100644 index 7602ee2c3be0c188e033ed640f9bb372aa60377b..0000000000000000000000000000000000000000 --- a/src/Elements/OpalVMonitor.h +++ /dev/null @@ -1,49 +0,0 @@ -// -// Class OpalVMonitor -// The VMONITOR element. -// -// Copyright (c) 200x - 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 OPAL_OpalVMonitor_HH -#define OPAL_OpalVMonitor_HH - -#include "Elements/OpalElement.h" - - -class OpalVMonitor: public OpalElement { - -public: - - /// Exemplar constructor. - OpalVMonitor(); - - virtual ~OpalVMonitor(); - - /// Make clone. - virtual OpalVMonitor *clone(const std::string &name); - - /// Update the embedded CLASSIC monitor. - virtual void update(); - -private: - - // Not implemented. - OpalVMonitor(const OpalVMonitor &); - void operator=(const OpalVMonitor &); - - // Clone constructor. - OpalVMonitor(const std::string &name, OpalVMonitor *parent); -}; - -#endif // OPAL_OpalVMonitor_HH diff --git a/src/Elements/OpalVariableRFCavity.cpp b/src/Elements/OpalVariableRFCavity.cpp index 20342804708ef95ebb2a04daa69e8bf84eeec04f..e5cf544b0c4c0e62e3db6a8a76443d8e44a5dce9 100644 --- a/src/Elements/OpalVariableRFCavity.cpp +++ b/src/Elements/OpalVariableRFCavity.cpp @@ -51,11 +51,6 @@ OpalVariableRFCavity::OpalVariableRFCavity(): "Full width of the cavity [m]."); itsAttr[HEIGHT] = Attributes::makeReal("HEIGHT", "Full height of the cavity [m]."); - registerStringAttribute("PHASE_MODEL"); - registerStringAttribute("AMPLITUDE_MODEL"); - registerStringAttribute("FREQUENCY_MODEL"); - registerRealAttribute("WIDTH"); - registerRealAttribute("HEIGHT"); registerOwnership(); @@ -81,29 +76,6 @@ OpalVariableRFCavity *OpalVariableRFCavity::clone() { return new OpalVariableRFCavity(this->getOpalName(), this); } -void OpalVariableRFCavity:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - const VariableRFCavity* cavity = dynamic_cast<const VariableRFCavity*>(&base); - if (cavity == NULL) { - throw OpalException("OpalVariableRFCavity::fillRegisteredAttributes", - "Failed to cast ElementBase to a VariableRFCavity"); - } - - attributeRegistry["L"]->setReal(cavity->getLength()); - std::shared_ptr<AbstractTimeDependence> phase_model = cavity->getPhaseModel(); - std::shared_ptr<AbstractTimeDependence> freq_model = cavity->getFrequencyModel(); - std::shared_ptr<AbstractTimeDependence> amp_model = cavity->getAmplitudeModel(); - std::string phase_name = AbstractTimeDependence::getName(phase_model); - std::string amp_name = AbstractTimeDependence::getName(amp_model); - std::string freq_name = AbstractTimeDependence::getName(freq_model); - attributeRegistry["PHASE_MODEL"]->setString(phase_name); - attributeRegistry["AMPLITUDE_MODEL"]->setString(amp_name); - attributeRegistry["FREQUENCY_MODEL"]->setString(freq_name); - attributeRegistry["WIDTH"]->setReal(cavity->getWidth()); - attributeRegistry["HEIGHT"]->setReal(cavity->getHeight()); -} - void OpalVariableRFCavity::update() { OpalElement::update(); diff --git a/src/Elements/OpalVariableRFCavity.h b/src/Elements/OpalVariableRFCavity.h index a403926eeaf6733b5538c7ceb5ad4ee562ea2957..fe20a07f57740096a2a0b703b3354c528bf69dda 100644 --- a/src/Elements/OpalVariableRFCavity.h +++ b/src/Elements/OpalVariableRFCavity.h @@ -65,12 +65,6 @@ class OpalVariableRFCavity: public OpalElement { /** Destructor does nothing */ virtual ~OpalVariableRFCavity(); - /** Fill in all registered attributes - * - * This updates the registered attributed with values from the ElementBase - */ - virtual void fillRegisteredAttributes(const ElementBase &); - /** Update the OpalVariableRFCavity with new parameters from UI parser */ virtual void update(); diff --git a/src/Elements/OpalVariableRFCavityFringeField.cpp b/src/Elements/OpalVariableRFCavityFringeField.cpp index 1aeec095812b59a74043664b9e1547b2932eb58c..a427a7eb7d1f72ed700ad68c561ab5c2bc534673 100644 --- a/src/Elements/OpalVariableRFCavityFringeField.cpp +++ b/src/Elements/OpalVariableRFCavityFringeField.cpp @@ -60,16 +60,6 @@ OpalVariableRFCavityFringeField::OpalVariableRFCavityFringeField(): itsAttr[MAX_ORDER] = Attributes::makeReal("MAX_ORDER", "Maximum power of y that will be evaluated in field calculations."); - registerStringAttribute("PHASE_MODEL"); - registerStringAttribute("AMPLITUDE_MODEL"); - registerStringAttribute("FREQUENCY_MODEL"); - registerRealAttribute("WIDTH"); - registerRealAttribute("HEIGHT"); - registerRealAttribute("CENTRE_LENGTH"); - registerRealAttribute("END_LENGTH"); - registerRealAttribute("CAVITY_CENTRE"); - registerRealAttribute("MAX_ORDER"); - registerOwnership(); setElement(new VariableRFCavityFringeField("VARIABLE_RF_CAVITY_FRINGE_FIELD")); @@ -96,44 +86,6 @@ OpalVariableRFCavityFringeField *OpalVariableRFCavityFringeField::clone() { return new OpalVariableRFCavityFringeField(this->getOpalName(), this); } -void OpalVariableRFCavityFringeField:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - const VariableRFCavityFringeField* cavity = - dynamic_cast<const VariableRFCavityFringeField*>(&base); - if (cavity == NULL) { - throw OpalException("OpalVariableRFCavityFringeField::fillRegisteredAttributes", - "Failed to cast ElementBase to a VariableRFCavityFringeField"); - } - std::shared_ptr<endfieldmodel::EndFieldModel> model = cavity->getEndField(); - endfieldmodel::Tanh* tanh = dynamic_cast<endfieldmodel::Tanh*>(model.get()); - if (tanh == NULL) { - throw OpalException("OpalVariableRFCavityFringeField::fillRegisteredAttributes", - "Failed to cast EndField to a Tanh model"); - } - - - attributeRegistry["L"]->setReal(cavity->getLength()); - std::shared_ptr<AbstractTimeDependence> phase_model = cavity->getPhaseModel(); - std::shared_ptr<AbstractTimeDependence> freq_model = cavity->getFrequencyModel(); - std::shared_ptr<AbstractTimeDependence> amp_model = cavity->getAmplitudeModel(); - std::string phase_name = AbstractTimeDependence::getName(phase_model); - std::string amp_name = AbstractTimeDependence::getName(amp_model); - std::string freq_name = AbstractTimeDependence::getName(freq_model); - attributeRegistry["PHASE_MODEL"]->setString(phase_name); - attributeRegistry["AMPLITUDE_MODEL"]->setString(amp_name); - attributeRegistry["FREQUENCY_MODEL"]->setString(freq_name); - attributeRegistry["WIDTH"]->setReal(cavity->getWidth()); - attributeRegistry["HEIGHT"]->setReal(cavity->getHeight()); - // flat top length is 2*x0 - attributeRegistry["CENTRE_LENGTH"]->setReal(tanh->getX0()/2.); - attributeRegistry["END_LENGTH"]->setReal(tanh->getLambda()); - attributeRegistry["CAVITY_CENTRE"]->setReal(cavity->getCavityCentre()); - attributeRegistry["MAX_ORDER"]->setReal(cavity->getMaxOrder()); -} - - - void OpalVariableRFCavityFringeField::update() { OpalElement::update(); diff --git a/src/Elements/OpalVariableRFCavityFringeField.h b/src/Elements/OpalVariableRFCavityFringeField.h index a01548499e2b060de044ab5d2860ccd33a1878b2..9efa4fa0655a046296a5efeee5cec75a1a9a2a79 100644 --- a/src/Elements/OpalVariableRFCavityFringeField.h +++ b/src/Elements/OpalVariableRFCavityFringeField.h @@ -70,12 +70,6 @@ class OpalVariableRFCavityFringeField : public OpalElement { /** Destructor does nothing */ virtual ~OpalVariableRFCavityFringeField(); - /** Fill in all registered attributes - * - * This updates the registered attributed with values from the ElementBase - */ - virtual void fillRegisteredAttributes(const ElementBase &); - /** Update the OpalVariableRFCavity with new parameters from UI parser */ virtual void update(); private: diff --git a/src/Elements/OpalVerticalFFAMagnet.cpp b/src/Elements/OpalVerticalFFAMagnet.cpp index 10167c1513bce229fff60a919732a2b3465144ca..d3b5526a3b62588b549d1528579ad2b243d9e3f4 100644 --- a/src/Elements/OpalVerticalFFAMagnet.cpp +++ b/src/Elements/OpalVerticalFFAMagnet.cpp @@ -45,15 +45,7 @@ OpalVerticalFFAMagnet::OpalVerticalFFAMagnet() : "Height of the magnet above z=0. Particles moving upwards more than HEIGHT_POS_EXTENT are out of the aperture [m]."); itsAttr[HEIGHT_NEG_EXTENT] = Attributes::makeReal("HEIGHT_NEG_EXTENT", "Height of the magnet below z=0. Particles moving downwards more than HEIGHT_NEG_EXTENT are out of the aperture [m]."); - registerRealAttribute("B0"); - registerRealAttribute("FIELD_INDEX"); - registerRealAttribute("WIDTH"); - registerRealAttribute("MAX_HORIZONTAL_POWER"); - registerRealAttribute("END_LENGTH"); - registerRealAttribute("CENTRE_LENGTH"); - registerRealAttribute("BB_LENGTH"); - registerRealAttribute("HEIGHT_NEG_EXTENT"); - registerRealAttribute("HEIGHT_POS_EXTENT"); + registerOwnership(); VerticalFFAMagnet* magnet = new VerticalFFAMagnet("VerticalFFAMagnet"); @@ -80,12 +72,6 @@ OpalVerticalFFAMagnet *OpalVerticalFFAMagnet::clone(const std::string &name) { } -void OpalVerticalFFAMagnet:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); -} - - void OpalVerticalFFAMagnet::update() { VerticalFFAMagnet *magnet = dynamic_cast<VerticalFFAMagnet*>(getElement()); diff --git a/src/Elements/OpalVerticalFFAMagnet.h b/src/Elements/OpalVerticalFFAMagnet.h index b7494ae91075362ff0b4b2b5a0cddbd1bb04a5f7..3a7cc79b71d52ac98f60e173ce3ab2fac77b2f37 100644 --- a/src/Elements/OpalVerticalFFAMagnet.h +++ b/src/Elements/OpalVerticalFFAMagnet.h @@ -45,12 +45,6 @@ class OpalVerticalFFAMagnet : public OpalElement { /** Inherited copy constructor */ virtual OpalVerticalFFAMagnet *clone(const std::string &name); - /** Fill in all registered attributes - * - * Just calls fillRegisteredAttributes on the base class - */ - virtual void fillRegisteredAttributes(const ElementBase &); - /** Update the VerticalFFA with new parameters from UI parser */ virtual void update(); diff --git a/src/Elements/OpalYRot.cpp b/src/Elements/OpalYRot.cpp deleted file mode 100644 index 3438e320b2284160ba06d833e1058459b703ca48..0000000000000000000000000000000000000000 --- a/src/Elements/OpalYRot.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: OpalYRot.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: OpalYRot -// The class of OPAL YROT coordinate transforms. -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:40 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Elements/OpalYRot.h" -#include "Attributes/Attributes.h" -#include "BeamlineCore/PatchRep.h" - - -// Class OpalYRot -// ------------------------------------------------------------------------ - -OpalYRot::OpalYRot(): - OpalElement(SIZE, "YROT", - "The \"YROT\" element defines a coordinate rotation " - "around the y-axis.") { - itsAttr[ANGLE] = Attributes::makeReal - ("ANGLE", "Angle for the transformation"); - - registerRealAttribute("YANGLE"); - - registerOwnership(); - - setElement(new PatchRep("YROT")); -} - - -OpalYRot::OpalYRot(const std::string &name, OpalYRot *parent): - OpalElement(name, parent) { - setElement(new PatchRep(name)); -} - - -OpalYRot::~OpalYRot() -{} - - -OpalYRot *OpalYRot::clone(const std::string &name) { - return new OpalYRot(name, this); -} - - -void OpalYRot:: -fillRegisteredAttributes(const ElementBase &base) { - OpalElement::fillRegisteredAttributes(base); - double angle = Attributes::getReal(itsAttr[ANGLE]); - attributeRegistry["SANGLE"]->setReal(angle); -} - - -void OpalYRot::update() { - // Define geometry. - PatchRep *yrot = dynamic_cast<PatchRep *>(getElement()); - double angle = Attributes::getReal(itsAttr[ANGLE]); - Euclid3D rot = Euclid3D::YRotation(- angle); - yrot->setPatch(rot); - - // Transmit "unknown" attributes. - OpalElement::updateUnknown(yrot); -} \ No newline at end of file diff --git a/src/Elements/OpalYRot.h b/src/Elements/OpalYRot.h deleted file mode 100644 index 311d5a62a5945e1afe297568e80cf2e16b2b4f58..0000000000000000000000000000000000000000 --- a/src/Elements/OpalYRot.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef OPAL_OpalYRot_HH -#define OPAL_OpalYRot_HH - -// ------------------------------------------------------------------------ -// $RCSfile: OpalYRot.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// CopSRight: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: OpalYRot -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:40 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Elements/OpalElement.h" - - -// Class OpalYRot -// ------------------------------------------------------------------------ -/// The YROT element. - -class OpalYRot: public OpalElement { - -public: - - /// The attributes of class OpalYRot. - enum { - ANGLE = COMMON, // The rotation angle. - SIZE // Total number of attributes. - }; - - /// Exemplar constructor. - OpalYRot(); - - virtual ~OpalYRot(); - - /// Make clone. - virtual OpalYRot *clone(const std::string &name); - - /// Fill in all registered attributes. - virtual void fillRegisteredAttributes(const ElementBase &); - - /// Update the embedded CLASSIC patch. - virtual void update(); - -private: - - // Not implemented. - OpalYRot(const OpalYRot &); - void operator=(const OpalYRot &); - - // Clone constructor. - OpalYRot(const std::string &name, OpalYRot *parent); -}; - -#endif // OPAL_OpalYRot_HH diff --git a/src/Expressions/ARefAttr.h b/src/Expressions/ARefAttr.h deleted file mode 100644 index c68e0bd697b2b219f678c75934b1ecfe82ae1671..0000000000000000000000000000000000000000 --- a/src/Expressions/ARefAttr.h +++ /dev/null @@ -1,227 +0,0 @@ -#ifndef OPAL_ARefBas_HH -#define OPAL_ARefAttr_HH - -// ------------------------------------------------------------------------ -// $RCSfile: ARefAttr.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.2 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Template class ARefAttr<T> -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/04/07 12:02:51 $ -// $Author: opal $ -// -// ------------------------------------------------------------------------ - -#include "AbstractObjects/AttributeBase.h" -#include "AbstractObjects/OpalData.h" -#include "AbstractObjects/Object.h" -#include "Expressions/ADeferred.h" -#include "Utilities/OpalException.h" -#include "Utilities/Options.h" -#include <vector> - - -namespace Expressions { - - // Class ARefAttr - // ---------------------------------------------------------------------- - /// An attribute defined as a reference to an array. - // The components of the array may be real, logical or string. - // When a reference is seen, the pointers to the relevant object and - // attribute are left zero. When the expression value is required, - // the object and the attribute are searched, and the pointers cached. - // The reference is registered with the object. If the object referred - // to is deleted, it calls the invalidate() method of all reference - // expressions referring to it. This resets the pointers to zero, so - // that the next evaluation forces to search for a replacement object. - - template <class T> - class ARefAttr: public AttributeBase { - - public: - - /// Constructor. - // Use object name [b]oName[/b] to identify the object containing - // the array, and [b]aName[/b] to identify the array itself. - ARefAttr(const string &oName, const string &aName); - - ARefAttr(const ARefAttr &); - virtual ~ARefAttr(); - - /// Make clone. - virtual ARefAttr<T> *clone() const; - - /// Evaluate. - // Evaluate the reference and return the value. - virtual std::vector<T> evaluate() const; - - /// Return real array value. - // This function has been added for speed of access. - virtual vector<double> getRealArray(); - - /// Invalidate. - // Force re-evaluation of the reference. - virtual void invalidate(); - - /// Print the reference. - virtual void print(std::ostream &) const; - - /// Store new value. - // Evaluate the reference and assign to the array referred to. - virtual void set(const std::vector<T> &) const; - - private: - - // Not implemented. - ARefAttr(); - void operator=(const ARefAttr &); - - // Fill in the reference. - void fill() const; - - // The name of the type referred to. - static const string typeName; - - // The referred object and attribute. - const string obj_name; - const string att_name; - - // The object and attribute referred to. - mutable Object *itsObject; - mutable Attribute *itsAttr; - }; - - - template <class T> - inline std::ostream &operator<<(std::ostream &os, const ARefAttr<T> &a) { - a.print(os); - return os; - } - - - // Implementation of class ARefAttr<T>. - // ------------------------------------------------------------------------ - - template <class T> - ARefAttr<T>::ARefAttr(const string &oName, const string &aName): - obj_name(oName), att_name(aName), itsObject(0), itsAttr(0) - {} - - - template <class T> - ARefAttr<T>::ARefAttr(const ARefAttr &rhs): - obj_name(rhs.obj_name), att_name(rhs.att_name), - itsObject(rhs.itsObject), itsAttr(rhs.itsAttr) - {} - - - template <class T> - ARefAttr<T>::~ARefAttr() { - if(itsObject) itsObject->unregisterReference(this); - } - - - template <class T> - ARefAttr<T> *ARefAttr<T>::clone() const { - return new ARefAttr<T>(*this); - } - - - template <class T> - std::vector<T> ARefAttr<T>::evaluate() const { - fill(); - - if(AttributeBase *base = &itsAttr->getBase()) { - if(ADeferred<T> *value = dynamic_cast<ADeferred<T> *>(base)) { - return value->evaluate(); - } else { - throw OpalException("Real::get()", "Attribute \"" + - itsAttr->getName() + "\" is of the wrong type."); - } - } else { - return 0.0; - } - } - - - template <class T> - void ARefAttr<T>::invalidate() { - itsObject = 0; - itsAttr = 0; - } - - - template <class T> - void ARefAttr<T>::print(std::ostream &os) const { - os << obj_name; - if(! att_name.empty()) os << "->" << att_name; - return; - } - - - template <class T> - void ARefAttr<T>::fill() const { - if(itsObject == 0) { - itsObject = OpalData::getInstance()->find(obj_name); - if(itsObject == 0) { - throw OpalException("ARefAttr::fill()", - "Object \"" + obj_name + "\" is unknown."); - } - - // Register the reference with the object, to allow invalidation - // when the object is deleted. - itsObject->registerReference(const_cast<ARefAttr<T>*>(this)); - - if(att_name.empty()) { - itsAttr = itsObject->findAttribute("VALUE"); - if(itsAttr == 0) { - throw OpalException("ARefAttr::fill()", "Object \"" + obj_name + - "\" is not a variable, constant or vector."); - } - } else { - itsAttr = itsObject->findAttribute(att_name); - if(itsAttr == 0) { - throw OpalException("ARefAttr::fill()", "Attribute \"" + obj_name + - "->" + att_name + "\" is unknown."); - } - } - } - } - - - template <class T> - vector<double> ARefAttr<T>::getRealArray() { - throw OpalException("AValue<T>::getRealArray()", - "Attribute is not of real array type."); - } - - - template <> inline - vector<double> ARefAttr<double>::getRealArray() { - return evaluate(); - } - - - template <class T> - void ARefAttr<T>::set(const std::vector<T> &value) const { - fill(); - - if(AttributeBase *base = &itsAttr->getBase()) { - if(dynamic_cast<ADeferred<T> *>(base)) { - return itsAttr->set(new ADeferred<T>(value)); - } else { - throw OpalException("Real::get()", "Attribute \"" + - itsAttr->getName() + "\" is of the wrong type."); - } - } - } - -} - -#endif // OPAL_ARefAttr_HH diff --git a/src/Expressions/CMakeLists.txt b/src/Expressions/CMakeLists.txt index 73b128fa1fb936ce5ac5fbbb9e15bacca8d9f838..f2bf86868ed4a2a7aaf2dcac1e11fc07d9b2d502 100644 --- a/src/Expressions/CMakeLists.txt +++ b/src/Expressions/CMakeLists.txt @@ -20,7 +20,6 @@ set (HDRS AColumn.h ADeferred.h AList.h - ARefAttr.h ARefExpr.h ARow.h ASUnary.h diff --git a/src/OpalConfigure/Configure.cpp b/src/OpalConfigure/Configure.cpp index cfcbcef75056d439a87ac75c1de27eda2bab29f3..b4dd72d56d2389fde538095673f9c585ecb47e4f 100644 --- a/src/OpalConfigure/Configure.cpp +++ b/src/OpalConfigure/Configure.cpp @@ -1,22 +1,27 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Configure.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.3 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Namespace: Configure -// Contains methods for configuring the OPAL-9 program. +// Namespace Configure +// The OPAL configurator. +// This class must be modified to configure the commands to be contained +// in an executable OPAL program. For each command an exemplar object +// is constructed and linked to the main directory. This exemplar is then +// available to the OPAL parser for cloning. +// This class could be part of the class OpalData. It is separated from +// that class and opale into a special module in order to reduce +// dependencies between modules. // -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/05/03 12:40:49 $ -// $Author: opal $ +// 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/>. // -// JMJ & JP adding Aperture and Split 18/4/2000 -// ------------------------------------------------------------------------ - #include "OpalConfigure/Configure.h" #include "AbstractObjects/OpalData.h" @@ -24,18 +29,14 @@ // Basic action commands. #include "BasicActions/Call.h" -#include "BasicActions/Dump.h" #include "BasicActions/DumpFields.h" #include "BasicActions/DumpEMFields.h" #include "BasicActions/Echo.h" #include "BasicActions/Help.h" #include "BasicActions/Option.h" -#include "BasicActions/Save.h" #include "BasicActions/Select.h" -#include "BasicActions/Show.h" #include "BasicActions/Stop.h" #include "BasicActions/Quit.h" -#include "BasicActions/What.h" #include "BasicActions/System.h" #include "BasicActions/PSystem.h" #include "BasicActions/Title.h" @@ -55,11 +56,7 @@ #include "Structure/ParticleMatterInteraction.h" #include "Utilities/OpalFilter.h" #include "TrimCoils/OpalTrimCoil.h" -#include "Tables/AttList.h" -#include "Tables/Insertion.h" #include "Tables/List.h" -#include "Tables/Period.h" -#include "Tables/Survey.h" // Value definitions commands. #include "ValueDefinitions/BoolConstant.h" @@ -78,8 +75,6 @@ #include "Elements/OpalFlexibleCollimator.h" #include "Elements/OpalDegrader.h" #include "Elements/OpalHKicker.h" -#include "Elements/OpalHMonitor.h" -#include "Elements/OpalInstrument.h" #include "Elements/OpalKicker.h" #include "Elements/OpalMarker.h" #include "Elements/OpalMonitor.h" @@ -94,7 +89,6 @@ #include "Elements/OpalOffset/OpalGlobalCartesianOffset.h" #include "Elements/OpalOffset/OpalGlobalCylindricalOffset.h" #include "Elements/OpalPepperPot.h" -#include "Elements/OpalPatch.h" #include "Elements/OpalProbe.h" #include "Elements/OpalQuadrupole.h" #include "Elements/OpalPolynomialTimeDependence.h" @@ -104,19 +98,14 @@ #include "Elements/OpalSBend.h" #include "Elements/OpalSBend3D.h" #include "Elements/OpalScalingFFAMagnet.h" -#include "Elements/OpalSeparator.h" #include "Elements/OpalSeptum.h" #include "Elements/OpalSextupole.h" #include "Elements/OpalSlit.h" #include "Elements/OpalSolenoid.h" #include "Elements/OpalSource.h" -#include "Elements/OpalSRot.h" #include "Elements/OpalTravelingWave.h" #include "Elements/OpalVKicker.h" -#include "Elements/OpalVMonitor.h" //#include "Elements/OpalWire.h" -#include "Elements/OpalYRot.h" -#include "Elements/OpalParallelPlate.h" #include "Elements/OpalStripper.h" #include "Elements/OpalRingDefinition.h" #include "Elements/OpalVariableRFCavity.h" @@ -147,7 +136,6 @@ namespace { void makeActions() { OpalData *opal = OpalData::getInstance(); opal->create(new Call()); - opal->create(new Dump()); opal->create(new DumpFields()); opal->create(new DumpEMFields()); opal->create(new Echo()); @@ -156,9 +144,7 @@ namespace { opal->create(new Option()); opal->create(new OptimizeCmd()); opal->create(new SampleCmd()); - opal->create(new Save()); opal->create(new Select()); - opal->create(new Show()); opal->create(new Stop()); opal->create(new Quit()); opal->create(new PSystem()); @@ -166,7 +152,6 @@ namespace { opal->create(new Title()); opal->create(new TrackCmd()); opal->create(new Value()); - opal->create(new What()); } @@ -179,7 +164,6 @@ namespace { opal->create(new RealVector()); opal->create(new StringConstant()); - opal->create(new AttList()); opal->create(new Beam()); opal->create(new FieldSolver()); opal->create(new BoundaryGeometry()); @@ -192,9 +176,6 @@ namespace { opal->create(new Distribution()); opal->create(new MacroCmd()); - opal->create(new Period()); - opal->create(new Insertion()); - opal->create(new Survey()); opal->create(new DVar()); opal->create(new Objective()); @@ -215,8 +196,6 @@ namespace { opal->create(new OpalFlexibleCollimator()); opal->create(new OpalDegrader()); opal->create(new OpalHKicker()); - opal->create(new OpalHMonitor()); - opal->create(new OpalInstrument()); opal->create(new OpalKicker()); opal->create(new OpalMarker()); opal->create(new OpalMonitor()); @@ -230,7 +209,6 @@ namespace { // opal->create(new OpalOffset::OpalLocalCylindricalOffset()); // opal->create(new OpalOffset::OpalGlobalCartesianOffset()); // opal->create(new OpalOffset::OpalGlobalCylindricalOffset()); - opal->create(new OpalPatch()); opal->create(new OpalProbe()); opal->create(new OpalPepperPot()); opal->create(new OpalPolynomialTimeDependence()); @@ -241,22 +219,17 @@ namespace { opal->create(new OpalSBend()); opal->create(new OpalSBend3D()); opal->create(new OpalScalingFFAMagnet()); - opal->create(new OpalSeparator()); opal->create(new OpalSeptum()); opal->create(new OpalSextupole()); opal->create(new OpalSlit()); opal->create(new OpalSolenoid()); opal->create(new OpalSource()); - opal->create(new OpalSRot()); opal->create(new OpalTravelingWave()); opal->create(new OpalVariableRFCavity()); opal->create(new OpalVariableRFCavityFringeField()); opal->create(new OpalVerticalFFAMagnet()); opal->create(new OpalVKicker()); - opal->create(new OpalVMonitor()); // opal->create(new OpalWire()); - opal->create(new OpalYRot()); - opal->create(new OpalParallelPlate()); opal->create(new OpalStripper()); opal->create(new Line()); opal->create(new Sequence()); diff --git a/src/OpalConfigure/Configure.h b/src/OpalConfigure/Configure.h index aea42345f87100646eef2acb34c1ae7cdc6e502c..c726e10de5b94c540981f8bc4ed6b5a28717da19 100644 --- a/src/OpalConfigure/Configure.h +++ b/src/OpalConfigure/Configure.h @@ -1,34 +1,29 @@ -#ifndef OPAL_Configure_HH -#define OPAL_Configure_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Configure.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Namespace: Configure +// Namespace Configure +// The OPAL configurator. +// This class must be modified to configure the commands to be contained +// in an executable OPAL program. For each command an exemplar object +// is constructed and linked to the main directory. This exemplar is then +// available to the OPAL parser for cloning. +// This class could be part of the class OpalData. It is separated from +// that class and opale into a special module in order to reduce +// dependencies between modules. // -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:33:38 $ -// $Author: Andreas Adelmann $ +// This file is part of OPAL. // -// ------------------------------------------------------------------------ - - -// Namespace Configure -// ------------------------------------------------------------------------ -/// The OPAL configurator. -// This class must be modified to configure the commands to be contained -// in an executable OPAL-9 program. For each command an exemplar object -// is constructed and linked to the main directory. This exemplar is then -// available to the OPAL parser for cloning. -// This class could be part of the class OpalData. It is separated from -// that class and opale into a special module in order to reduce -// dependencies between modules. +// 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_Configure_HH +#define OPAL_Configure_HH namespace Configure { diff --git a/src/Tables/AttList.cpp b/src/Tables/AttList.cpp deleted file mode 100644 index 67ca1e738ab55b1fd6fa49101dcafad317acba51..0000000000000000000000000000000000000000 --- a/src/Tables/AttList.cpp +++ /dev/null @@ -1,157 +0,0 @@ -// -// Class AttList -// The ATTLIST command. -// -// Copyright (c) 200x - 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 "Tables/AttList.h" -#include "AbstractObjects/BeamSequence.h" -#include "AbstractObjects/Table.h" -#include "Attributes/Attributes.h" -#include "Beamlines/Beamline.h" -#include "Elements/AttCell.h" -#include "Elements/OpalElement.h" -#include "Tables/AttWriter.h" -#include "AbstractObjects/OpalData.h" -#include "Utilities/OpalException.h" -#include <fstream> -#include <iostream> -#include <vector> - -using std::vector; - - -namespace { - - // The attributes of class AttList. - enum { - LINE, // The name of the line to be listed. - FNAME, // The name of the file to be written. - ALL, // If true, list all columns. - COLUMN, // The columns to be written. - SIZE - }; -} - - -AttList::AttList(): - Action(SIZE, "ATTLIST", - "The \"ATTLIST\" statement lists the element strengths " - "in a beam line or a sequence.") { - itsAttr[LINE] = Attributes::makeString - ("LINE", "Name of line to be listed"); - itsAttr[FNAME] = Attributes::makeString - ("FILE", "Name of file to receive output", "ATTLIST"); - itsAttr[ALL] = Attributes::makeBool - ("ALL", "Are all columns desired?"); - itsAttr[COLUMN] = Attributes::makeStringArray - ("COLUMN", "The columns to be written"); - - registerOwnership(AttributeHandler::STATEMENT); -} - - -AttList::AttList(const std::string &name, AttList *parent): - Action(name, parent) -{} - - -AttList::~AttList() -{} - - -AttList *AttList::clone(const std::string &name) { - return new AttList(name, this); -} - - -void AttList::execute() { - // Find beam sequence or table definition. - const std::string name = Attributes::getString(itsAttr[LINE]); - const Beamline *line = 0; - - if(Object *obj = OpalData::getInstance()->find(name)) { - if(BeamSequence *beamLine = dynamic_cast<BeamSequence *>(obj)) { - line = beamLine->fetchLine(); - } else if(Table *table = dynamic_cast<Table *>(obj)) { - line = table->getLine(); - } else { - throw OpalException("Select::execute()", - "You cannot do an \"ATTLIST\" on \"" + name + - "\", it is neither a line nor a table."); - } - } else { - throw OpalException("Select::execute()", - "Object \"" + name + "\" not found."); - } - - // Select the file to be used. - const std::string &fileName = Attributes::getString(itsAttr[FNAME]); - if(fileName == "TERM") { - writeTable(*line, std::cout); - } else { - std::ofstream os(fileName.c_str()); - - if(os.good()) { - writeTable(*line, os); - } else { - throw OpalException("AttList::execute()", - "Unable to open output stream \"" + - fileName + "\"."); - } - } -} - - -void AttList::writeTable(const Beamline &line, std::ostream &os) { - // Construct column access table. - // This may throw, if a column is unknown. - vector<std::string> header = Attributes::getStringArray(itsAttr[COLUMN]); - vector<std::string>::size_type n = header.size(); - vector<AttCell *> buffer(n); - for(vector<std::string>::size_type i = 0; i < n; ++i) { - buffer[i] = OpalElement::findRegisteredAttribute(header[i]); - } - - // Write table descriptors. - OPALTimer::Timer timer; - os << "@ TYPE %s ATTRIBUTE\n" - << "@ LINE %s " << line.getName() << "\n" - << "@ DATE %s " << timer.date() << "\n" - << "@ TIME %s " << timer.time() << "\n" - << "@ ORIGIN %s OPAL_9.5/4\n" - << "@ COMMENT %s \"\n"; - OpalData::getInstance()->printTitle(os); - os << "\"\n"; - - // Write column header names. - os << '*'; - for(vector<std::string>::size_type i = 0; i < n; ++i) { - os << ' ' << header[i]; - } - os << '\n'; - - // Write column header formats. - os << '$'; - for(vector<std::string>::size_type i = 0; i < n; ++i) { - os << ' '; - buffer[i]->printFormat(os); - buffer[i]->clearValue(); - } - os << '\n'; - - // List the table body. - AttWriter writer(line, os, buffer); - writer.execute(); -} \ No newline at end of file diff --git a/src/Tables/AttList.h b/src/Tables/AttList.h deleted file mode 100644 index 8821fc1799082f19674818b24dc7c1690e90fa6f..0000000000000000000000000000000000000000 --- a/src/Tables/AttList.h +++ /dev/null @@ -1,55 +0,0 @@ -// -// Class AttList -// The ATTLIST command. -// -// Copyright (c) 200x - 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 OPAL_AttList_HH -#define OPAL_AttList_HH - -#include "AbstractObjects/Action.h" -#include <iosfwd> - -class Beamline; - - -class AttList: public Action { - -public: - - /// Exemplar constructor. - AttList(); - - virtual ~AttList(); - - /// Make clone. - virtual AttList *clone(const std::string &name); - - /// Execute the command. - virtual void execute(); - -private: - - // Not implemented. - AttList(const AttList &); - void operator=(const AttList &); - - // Clone constructor. - AttList(const std::string &name, AttList *parent); - - // The working routine. - void writeTable(const Beamline &line, std::ostream &os); -}; - -#endif // OPAL_AttList_HH diff --git a/src/Tables/AttWriter.cpp b/src/Tables/AttWriter.cpp deleted file mode 100644 index f5f0e20abcea899e3968a326dd5fa62b0b05ef2e..0000000000000000000000000000000000000000 --- a/src/Tables/AttWriter.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: AttWriter.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.4 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: AttWriter -// The worker class for OPAL ATTLIST commands. -// -// ------------------------------------------------------------------------ -// -// $Date: 2002/03/28 21:27:54 $ -// $Author: jsberg $ -// -// ------------------------------------------------------------------------ - -#include "Tables/AttWriter.h" - -#include "AbsBeamline/CCollimator.h" -#include "AbsBeamline/FlexibleCollimator.h" -#include "AbsBeamline/Corrector.h" -#include "AbsBeamline/Drift.h" -#include "AbsBeamline/ElementBase.h" -#include "AbsBeamline/Multipole.h" -#include "AbsBeamline/Patch.h" -#include "AbsBeamline/RBend.h" -#include "AbsBeamline/RFCavity.h" -#include "AbsBeamline/TravelingWave.h" -#include "AbsBeamline/SBend.h" -#include "AbsBeamline/Separator.h" -#include "AbsBeamline/Solenoid.h" - -#include "AbstractObjects/BeamSequence.h" -#include "AbstractObjects/Element.h" -#include "AbstractObjects/OpalData.h" -#include "Algorithms/DefaultVisitor.h" -#include "Beamlines/Beamline.h" -#include "Beamlines/FlaggedElmPtr.h" -#include "Elements/AttCell.h" -#include "Elements/OpalElement.h" -#include "Physics/Physics.h" -#include "Utilities/Timer.h" -#include <fstream> -#include <vector> - - -// Class AttWriter -// ------------------------------------------------------------------------ - -AttWriter::AttWriter(const Beamline &line, - std::ostream &os, - const std::vector<AttCell *> &buffer): - DefaultVisitor(line, false, false), - itsStream(os), - itsBuffer(buffer) -{} - - -AttWriter::~AttWriter() -{} - - -void AttWriter::visitFlaggedElmPtr(const FlaggedElmPtr &fep) { - ElementBase *base = fep.getElement(); - const std::string &nam = base->getName(); - if(dynamic_cast<Beamline *>(base)) { - DefaultVisitor::visitFlaggedElmPtr(fep); - } else if(fep.getSelectionFlag()) { - // Fill the line buffer. - if(nam[0] == '[') { - OpalElement::setRegisteredAttribute("L", base->getElementLength()); - OpalElement::setRegisteredAttribute("KEYWORD", "DRIFT"); - } else { - OpalElement *elem = dynamic_cast<OpalElement *>(OpalData::getInstance()->find(nam)); - elem->fillRegisteredAttributes(*fep.getElement()); - } - - // Write the current output line and clear it. - itsStream << ' '; - std::vector<AttCell *>::size_type n = itsBuffer.size(); - std::vector<AttCell *>::size_type i; - for(i = 0; i < n; ++i) { - itsStream << ' '; - itsBuffer[i]->printValue(itsStream); - itsBuffer[i]->clearValue(); - } - itsStream << '\n'; - } -} \ No newline at end of file diff --git a/src/Tables/AttWriter.h b/src/Tables/AttWriter.h deleted file mode 100644 index 8110b3fa81b96e01287e5cf1ed8deddd8147ed96..0000000000000000000000000000000000000000 --- a/src/Tables/AttWriter.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef OPAL_AttWriter_HH -#define OPAL_AttWriter_HH 1 - -// ------------------------------------------------------------------------ -// $RCSfile: AttWriter.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.2 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: AttWriter -// -// ------------------------------------------------------------------------ -// -// $Date: 2001/08/13 15:25:21 $ -// $Author: jowett $ -// -// ------------------------------------------------------------------------ - -#include "AbstractObjects/Element.h" -#include "Algorithms/DefaultVisitor.h" -#include "Beamlines/FlaggedElmPtr.h" -#include "Elements/OpalElement.h" -#include "Utilities/Timer.h" -#include <iosfwd> -#include <string> -#include <vector> - -class AttCell; -class Beamline; -class CCollimator; -class Corrector; -class Drift; -class ElementBase; -class Multipole; -class Patch; -class RBend; -class RFCavity; -class TravelingWave; -class SBend; -class Separator; -class Solenoid; - - -// Class AttWriter -// ------------------------------------------------------------------------ -/// The worker class for ATTLIST commands. -// A ``Visitor'' which looks at all elements in turn. For each element -// it asks to store all defined attributes in a registry, and then -// requests the desired values from that registry to build a print line. - -class AttWriter: public DefaultVisitor { - -public: - - /// Constructor. - AttWriter(const Beamline &, - std::ostream &, - const std::vector<AttCell *> &); - - virtual ~AttWriter(); - - - /// Apply the algorithm to a FlaggedElmPtr. - virtual void visitFlaggedElmPtr(const FlaggedElmPtr &); - -private: - - // Not implemented. - AttWriter(); - AttWriter(const AttWriter &); - void operator=(const AttWriter &); - - // The output stream. - std::ostream &itsStream; - - // The current output line representation. - const std::vector<AttCell *> &itsBuffer; -}; - -#endif // OPAL_AttWriter_HH diff --git a/src/Tables/CMakeLists.txt b/src/Tables/CMakeLists.txt index c667db1090c14302c78c6ccf12cbc1d32ff7b297..5f086e4d91379b8a01907992fa2924112e896399 100644 --- a/src/Tables/CMakeLists.txt +++ b/src/Tables/CMakeLists.txt @@ -1,13 +1,7 @@ set (_SRCS - AttList.cpp - AttWriter.cpp - Insertion.cpp List.cpp - Period.cpp RangeSelector.cpp Selector.cpp - Survey.cpp - Twiss.cpp ) include_directories ( @@ -17,16 +11,9 @@ include_directories ( add_opal_sources(${_SRCS}) set (HDRS - AttList.h - AttWriter.h - Flatten.h - Insertion.h List.h - Period.h RangeSelector.h Selector.h - Survey.h - Twiss.h ) install (FILES ${HDRS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/Tables") diff --git a/src/Tables/Flatten.h b/src/Tables/Flatten.h deleted file mode 100644 index 250da6f6d37dc65158e3736b9cb6b16cad82ddf1..0000000000000000000000000000000000000000 --- a/src/Tables/Flatten.h +++ /dev/null @@ -1,132 +0,0 @@ -// -// Class Flatten -// Flatten a beamline. -// The type of beam line members in the flat line is given as a template -// parameter. It may be any class derived from ElmPtr. Execution of -// this visitor yields a flat line of the type defined by the template -// parameter Member. -// -// Copyright (c) 200x - 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 OPAL_Flatten_HH -#define OPAL_Flatten_HH - -#include "Tables/RangeSelector.h" -#include "AbsBeamline/ElementBase.h" -#include "AbstractObjects/Element.h" -#include "BeamlineCore/PatchRep.h" -#include "BeamlineGeometry/Euclid3D.h" -#include "Beamlines/TBeamline.h" -#include "Beamlines/FlaggedElmPtr.h" - -class RangeRep; - - -template <class Member> class Flatten: public RangeSelector { - -public: - - /// Constructor. - // Attach this visitor to [b]bl[/b], [b]mem[/b] will receive the range - // [b]range[/b] ot the flat line. - Flatten(const Beamline &bl, TBeamline<Member> &mem, const RangeRep &range); - - virtual ~Flatten(); - - /// Apply the algorithm to the top-level beamline. - virtual void execute(); - -protected: - - /// The operation to be done for beamlines. - virtual void handleBeamline(const FlaggedElmPtr &); - - /// The operation to be done for elements. - virtual void handleElement(const FlaggedElmPtr &); - - /// The flat list to be filled. - TBeamline<Member> &itsTable; - -private: - - // Not implemented. - Flatten(); - Flatten(const Flatten<Member> &); - void operator=(const Flatten<Member> &); -}; - - -// Implementation of template class Flatten -// ------------------------------------------------------------------------ - -template <class Member> inline -Flatten<Member>::Flatten(const Beamline &beamline, TBeamline<Member> &list, - const RangeRep &range): - RangeSelector(beamline, range), itsTable(list) -{} - - -template <class Member> inline -Flatten<Member>::~Flatten() -{} - - -template <class Member> inline -void Flatten<Member>::execute() { - itsTable.push_back(Member(Element::find("#S")->getElement(), 0)); - RangeSelector::execute(); - itsTable.push_back(Member(Element::find("#E")->getElement(), 0)); -} - - -template <class Member> inline void -Flatten<Member>::handleBeamline(const FlaggedElmPtr &/*fep*/) { -// AlignWrapper &wrap = -// dynamic_cast<AlignWrapper &>(*fep.getElement()->makeAlignWrapper()); -// -// if(itsRange.isActive()) { -// // Append the entrance misalignment patch. -// Euclid3D transform = wrap.getEntranceTransform(); -// PatchRep *patch = new PatchRep("[BEGIN]" + wrap.getName()); -// patch->setPatch(transform); -// Member member(patch, 0); -// itsTable.push_back(member); -// } -// -// // Delegate algorithm to the beamline. -// RangeSelector::handleBeamline(fep); -// -// if(itsRange.isActive()) { -// // Append the exit misalignment patch. -// Euclid3D transform = wrap.getExitTransform(); -// PatchRep *patch = new PatchRep("[END]" + wrap.getName()); -// patch->setPatch(transform); -// Member member(patch, 0); -// itsTable.push_back(member); -// } -} - - -template <class Member> void -Flatten<Member>::handleElement(const FlaggedElmPtr &fep) { - if(itsRange.isActive()) { - const std::string &name = fep.getElement()->getName(); - if(name[0] != '#') { - Member member(fep); - itsTable.push_back(member); - } - } -} - -#endif // OPAL_Flatten_HH diff --git a/src/Tables/Insertion.cpp b/src/Tables/Insertion.cpp deleted file mode 100644 index 1b9a0e3ff430daca38155af3a338c12c79ff08fe..0000000000000000000000000000000000000000 --- a/src/Tables/Insertion.cpp +++ /dev/null @@ -1,223 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Insertion.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.2.4.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Insertion -// The class for the OPAL TWISSTRACK command. -// -// ------------------------------------------------------------------------ -// -// $Date: 2004/11/12 20:10:11 $ -// $Author: adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Tables/Insertion.h" -#include "AbstractObjects/PlaceRep.h" -#include "AbstractObjects/TableRowRep.h" -#include "Algorithms/Mapper.h" -#include "Attributes/Attributes.h" -#include "BeamlineGeometry/Euclid3D.h" -#include "FixedAlgebra/FMatrix.h" -#include "FixedAlgebra/FVector.h" -#include "FixedAlgebra/FTps.h" -#include "FixedAlgebra/LinearMap.h" -#include "Structure/Beam.h" -#include "Utilities/OpalException.h" -#include <iomanip> -#include <iostream> - -using std::setw; - - -// Class Insertion -// ------------------------------------------------------------------------ - -Insertion::Insertion(): - Twiss(SIZE, "TWISSTRACK", - "The \"TWISSTRACK\" command defines a table of lattice functions\n" - "which can be matched or tabulated for an insertion.") { - itsAttr[INIT] = Attributes::makeTableRow - ("INIT", "If given, this table position is used to initialise\n" - "\t\t\t\tif not given, use the following parameters to initialise"); - itsAttr[BETX] = Attributes::makeReal - ("BETX", "Initial horizontal beta", 1.0); - itsAttr[ALFX] = Attributes::makeReal - ("ALFX", "Initial horizontal alpha"); - itsAttr[BETY] = Attributes::makeReal - ("BETY", "Initial vertical beta", 1.0); - itsAttr[ALFY] = Attributes::makeReal - ("ALFY", "Initial vertical alpha"); - itsAttr[DX] = Attributes::makeReal - ("DX", "Initial horizontal dispersion"); - itsAttr[DPX] = Attributes::makeReal - ("DPX", "Initial slope of horizontal dispersion"); - itsAttr[DY] = Attributes::makeReal - ("DY", "Initial vertical dispersion"); - itsAttr[DPY] = Attributes::makeReal - ("DPY", "Initial slope of vertical dispersion"); - itsAttr[XC] = Attributes::makeReal - ("XC", "Initial horizontal position"); - itsAttr[PXC] = Attributes::makeReal - ("PXC", "Initial horizontal slope"); - itsAttr[YC] = Attributes::makeReal - ("YC", "Initial vertical position"); - itsAttr[PYC] = Attributes::makeReal - ("PYC", "Initial vertical slope"); - itsAttr[TC] = Attributes::makeReal - ("TC", "Initial time difference"); - itsAttr[PTC] = Attributes::makeReal - ("PTC", "Initial relative momentum error"); - - // READ ONLY. - itsAttr[LENGTH] = Attributes::makeReal - ("LENGTH", "Total length in m"); - itsAttr[LENGTH].setReadOnly(true); - - itsAttr[MU1] = Attributes::makeReal - ("MU1", "Phase for mode 1"); - itsAttr[MU1].setReadOnly(true); - - itsAttr[MU2] = Attributes::makeReal - ("MU2", "Phase for mode 2"); - itsAttr[MU2].setReadOnly(true); - - itsAttr[MU3] = Attributes::makeReal - ("MU3", "Phase for mode 3"); - itsAttr[MU3].setReadOnly(true); - - itsAttr[DELTAP] = Attributes::makeReal - ("DELTAP", "Differential momentum variation"); - itsAttr[DELTAP].setReadOnly(true); - - registerOwnership(AttributeHandler::COMMAND); -} - - -Insertion::Insertion(const std::string &name, Insertion *parent): - Twiss(name, parent) -{} - - -Insertion::~Insertion() -{} - - -Insertion *Insertion::clone(const std::string &name) { - return new Insertion(name, this); -} - - -void Insertion::fill() { - if(refill) { - // Set truncation order. - FTps<double, 6>::setGlobalTruncOrder(order); - - // Reset the mapper. - if(itsAttr[INIT]) { - TableRowRep rowrep = Attributes::getTableRow(itsAttr[INIT]); - Table *init = Table::find(rowrep.getTabName()); - - if(matches(init)) { - PlaceRep pinit = rowrep.getPosition(); - Twiss *tinit = dynamic_cast<Twiss *>(init); - Row &row = tinit->findRow(pinit); - tinit->fill(); - orbit = tinit->getOrbit(row); - curly_A = tinit->getCurlyA(row); - itsMapper->setMap(LinearMap<double, 6>() + orbit); - } else { - throw OpalException("Insertion::fill()", - "Table \"" + rowrep.getTabName() + - "\" is not suitable for initialising insertion \"" + - getOpalName() + "\"."); - } - } else { - FMatrix<double, 6, 6> B, H; - for(int i = 0; i < 6; ++i) B(i, i) = H(i, i) = 1.0; - - // Betatron matrix. - B(0, 0) = sqrt(Attributes::getReal(itsAttr[BETX])); - B(1, 1) = 1.0 / B(0, 0); - B(1, 0) = - Attributes::getReal(itsAttr[ALFX]) * B(1, 1); - B(2, 2) = sqrt(Attributes::getReal(itsAttr[BETY])); - B(3, 3) = 1.0 / B(2, 2); - B(3, 2) = - Attributes::getReal(itsAttr[ALFY]) * B(3, 3); - B(4, 4) = 1.0; - B(5, 5) = 1.0; - - // Dispersion matrix. - H(0, 5) = Attributes::getReal(itsAttr[DX]); - H(1, 5) = Attributes::getReal(itsAttr[DPX]); - H(2, 5) = Attributes::getReal(itsAttr[DY]); - H(3, 5) = Attributes::getReal(itsAttr[DPY]); - H(4, 0) = - H(1, 5); - H(4, 1) = H(0, 5); - H(4, 2) = - H(3, 5); - H(4, 3) = H(2, 5); - - curly_A = H * B; - orbit(0) = Attributes::getReal(itsAttr[XC]); - orbit(1) = Attributes::getReal(itsAttr[PXC]); - orbit(2) = Attributes::getReal(itsAttr[YC]); - orbit(3) = Attributes::getReal(itsAttr[PYC]); - orbit(4) = Attributes::getReal(itsAttr[TC]); - orbit(5) = Attributes::getReal(itsAttr[PTC]); - itsMapper->setMap(LinearMap<double, 6>() + orbit); - } - - put(); - refill = false; - - // Fill in the read-only data. - const Row &row = itsTable->back(); - double arc = getS(row); - Attributes::setReal(itsAttr[LENGTH], arc); - Attributes::setReal(itsAttr[MU1], getMUi(row, 0)); - Attributes::setReal(itsAttr[MU2], getMUi(row, 1)); - Attributes::setReal(itsAttr[MU3], getMUi(row, 2)); - } -} - - -void Insertion::printTable(std::ostream &os, const CellArray &cells) const { - // Save the formatting flags. - std::streamsize old_prec = os.precision(6); - os.setf(std::ios::fixed, std::ios::floatfield); - - // Print table header. - printTableTitle(os, "Track lattice functions"); - - // Print table body. - printTableBody(os, cells); - - // Write table specific summary. - const Row &row = itsTable->back(); - os << "Insert length = " << setw(16) << getS(row) - << " Mux = " << setw(16) << getMUi(row, 0) - << " Muy = " << setw(16) << getMUi(row, 1) - << '\n' - << " " - << " BetaX(max) = " << setw(16) << Attributes::getReal(itsAttr[BETXMAX]) - << " BetaY(max) = " << setw(16) << Attributes::getReal(itsAttr[BETYMAX]) << '\n' - << " " - << " x(max) = " << setw(16) << Attributes::getReal(itsAttr[XCMAX]) - << " y(max) = " << setw(16) << Attributes::getReal(itsAttr[YCMAX]) << '\n' - << " " - << " x(rms) = " << setw(16) << Attributes::getReal(itsAttr[XCRMS]) - << " y(rms) = " << setw(16) << Attributes::getReal(itsAttr[YCRMS]) << '\n' - << " " - << " Dx(max) = " << setw(16) << Attributes::getReal(itsAttr[DXMAX]) - << " Dy(max) = " << setw(16) << Attributes::getReal(itsAttr[DYMAX]) << '\n' - << " " - << " Dx(rms) = " << setw(16) << Attributes::getReal(itsAttr[DXRMS]) - << " Dy(rms) = " << setw(16) << Attributes::getReal(itsAttr[DYRMS]) << '\n'; - - // Restore the formatting flags. - os.precision(old_prec); - os.setf(std::ios::fixed, std::ios::floatfield); -} \ No newline at end of file diff --git a/src/Tables/Insertion.h b/src/Tables/Insertion.h deleted file mode 100644 index e9916eba645d2627f0017cc114c6e4c7f566b114..0000000000000000000000000000000000000000 --- a/src/Tables/Insertion.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef OPAL_Insertion_HH -#define OPAL_Insertion_HH 1 - -// ------------------------------------------------------------------------ -// $RCSfile: Insertion.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1.4.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Insertion -// -// ------------------------------------------------------------------------ -// -// $Date: 2004/11/12 20:10:11 $ -// $Author: adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Tables/Twiss.h" - - -// Class Insertion -// ------------------------------------------------------------------------ -/// The TWISSTRACK command. - -class Insertion: public Twiss { - -public: - - /// Exemplar construction. - Insertion(); - - virtual ~Insertion(); - - /// Make clone. - virtual Insertion *clone(const std::string &name); - - /// Fill the buffer using the defined algorithm. - virtual void fill(); - - /// Print the table on an ASCII stream. - virtual void printTable(std::ostream &, const CellArray &) const; - -private: - - // Not implemented. - Insertion(const Insertion &); - void operator=(const Insertion &); - - // Clone constructor. - Insertion(const std::string &name, Insertion *parent); - - // The attribute of class Insertion. - enum { - // Input values. - INIT = Twiss::SIZE, // A table row defining the initial conditions. - BETX, // Initial lattice functions. - ALFX, - BETY, - ALFY, - DX, // Initial dispersion. - DPX, - DY, - DPY, - XC, // Initial orbit. - PXC, - YC, - PYC, - TC, - PTC, - // Read-only values. - LENGTH, // Total length. - MU1, // Phases. - MU2, - MU3, - DELTAP, // Differential momentum variation - SIZE - }; -}; - -#endif // OPAL_Insertion_HH diff --git a/src/Tables/Period.cpp b/src/Tables/Period.cpp deleted file mode 100644 index e51a2d6f30b158e6f81609796442f02c22fbfacb..0000000000000000000000000000000000000000 --- a/src/Tables/Period.cpp +++ /dev/null @@ -1,326 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Period.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.2.4.2 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Period -// The class for the OPAL TWISS command. -// -// ------------------------------------------------------------------------ -// -// $Date: 2004/11/12 20:10:11 $ -// $Author: adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Tables/Period.h" -#include "Algorithms/Mapper.h" -#include "Attributes/Attributes.h" -#include "BeamlineGeometry/Euclid3D.h" -#include "FixedAlgebra/FNormalForm.h" -#include "FixedAlgebra/FStaticFP.h" -#include "FixedAlgebra/LinearFun.h" -#include "FixedAlgebra/LinearMap.h" -#include "FixedAlgebra/FTps.h" -#include "FixedAlgebra/FVps.h" -#include "Physics/Physics.h" -#include "Structure/Beam.h" -#include "Utilities/OpalException.h" -#include "Utilities/Options.h" -#include <cmath> -#include <iomanip> -#include <iostream> - -using std::setw; - - -// Class Period -// ------------------------------------------------------------------------ - -Period::Period(): - Twiss(SIZE, "TWISS", - "The \"TWISS\" command defines a table of lattice functions\n" - "which can be matched or tabulated over a periodic line.") { - itsAttr[MICADO] = Attributes::makeReal - ("MICADO", "Number of iterations for MICADO algorithm", 0.0); - itsAttr[CORRECTORS] = Attributes::makeReal - ("CORRECTORS", "Number of correctors for MICADO algorithm", 0.0); - itsAttr[THREAD] = Attributes::makeString - ("THREAD", "Name of method for closed orbit threader"); - itsAttr[TOLQ] = Attributes::makeReal - ("TOLQ", "Tolerance for positions in closed orbit threader", 1.0e-3); - itsAttr[TOLP] = Attributes::makeReal - ("TOLP", "Tolerance for momenta in closed orbit threader", 1.0e-3); - - // READ ONLY. - itsAttr[CIRCUM] = Attributes::makeReal - ("CIRCUM", "Circumference in m"); - itsAttr[CIRCUM].setReadOnly(true); - - itsAttr[FREQ] = Attributes::makeReal - ("FREQ0", "Revolution frequency in Hz"); - itsAttr[FREQ].setReadOnly(true); - - itsAttr[Q1] = Attributes::makeReal - ("Q1", "Tune for mode 1"); - itsAttr[Q1].setReadOnly(true); - - itsAttr[Q2] = Attributes::makeReal - ("Q2", "Tune for mode 2"); - itsAttr[Q2].setReadOnly(true); - - itsAttr[Q3] = Attributes::makeReal - ("Q3", "Tune for mode 3"); - itsAttr[Q3].setReadOnly(true); - - itsAttr[U0] = Attributes::makeReal - ("U0", "Energy loss per turn in MeV"); - itsAttr[U0].setReadOnly(true); - - itsAttr[J1] = Attributes::makeReal - ("J1", "Damping partition number for mode 1"); - itsAttr[J1].setReadOnly(true); - - itsAttr[J2] = Attributes::makeReal - ("J2", "Damping partition number for mode 2"); - itsAttr[J2].setReadOnly(true); - - itsAttr[J3] = Attributes::makeReal - ("J3", "Damping partition number for mode 3"); - itsAttr[J3].setReadOnly(true); - - itsAttr[DELTAP] = Attributes::makeReal - ("DELTAP", "Differential momentum variation"); - itsAttr[DELTAP].setReadOnly(true); - - registerOwnership(AttributeHandler::COMMAND); -} - - -Period::Period(const std::string &name, Period *parent): - Twiss(name, parent) -{} - - -Period::~Period() -{} - - -Period *Period::clone(const std::string &name) { - return new Period(name, this); -} - - -void Period::fill() { - //std::cerr << "==> In Period::fill()..." << std::endl; - if(refill) { - // Set truncation order. - //DTA: FTps<double,6>::setGlobalTruncOrder(order); - - // Search for closed orbit. - findClosedOrbit(); - //std::cerr << "Closed orbit \"found\"" << std::endl; - - // Now map is the map around the fixed point. - FVps<double, 6> map; - itsMapper->getMap(map); - orbit = map.constantTerm(); - //std::cerr << " co = " << orbit << std::endl; - //std::cerr << " map = " << map << std::endl; - for(int i = 0; i < 6; ++i) map[i][0] = 0.0; - FTps<double, 6> A_lie; - FVps<double, 6> A_scr; - if(map[5] == FTps<double, 6>::makeVariable(5)) { - // Map is static. - //std::cerr << " static map = " << map << std::endl; - FStaticFP<6> fix(map); - //std::cerr << " fix(map) constructed" << std::endl; - map = fix.getFixedPointMap(); - //std::cerr << " got fixedPt map --> " << map << std::endl; - const FNormalForm<6> normal(map); - A_lie = normal.normalisingMap(); - //std::cerr << " got Lie form of normalising map --> " << A_lie << std::endl; - A_scr = FVps<double, 6>(normal.eigenVectors()); - //std::cerr << " got matrix form of normalising map --> " << A_scr << std::endl; - for(int i = order; i >= 3; --i) { - A_scr = ExpMap(A_lie.filter(i, i), A_scr); - //std::cerr << " A_scr(" << i << ") --> " << A_scr << std::endl; - } - A_scr = fix.getFixedPoint().substitute(A_scr) + fixPoint; - //std::cerr << " A_scr(-1) --> " << A_scr << std::endl; - } else { - // Map is dynamic; fixed point is already known. - const FNormalForm<6> normal(map); - A_lie = normal.normalisingMap(); - A_scr = FVps<double, 6>(normal.eigenVectors()); - for(int i = order; i >= 3; --i) { - A_scr = ExpMap(A_lie.filter(i, i), A_scr); - } - A_scr += fixPoint; - - if(Options::warn) { - std::cerr << "\n### Warning ### Momentum is not constant, " - << "Twiss is three-dimensional.\n" << std::endl; - } - } - - // Initialise mapper, clear local data, and fill table. - curly_A = A_scr.linearTerms(); - itsMapper->setMap(LinearMap<double, 6>() + orbit); - put(); - - // Fill in the read-only data. - const Row &row = itsTable->back(); - double arc = getS(row); - Attributes::setReal(itsAttr[CIRCUM], arc); - Attributes::setReal(itsAttr[FREQ], Physics::c * reference->getBeta() / arc); - Attributes::setReal(itsAttr[Q1], getMUi(row, 0)); - Attributes::setReal(itsAttr[Q2], getMUi(row, 1)); - Attributes::setReal(itsAttr[Q3], getMUi(row, 2)); - - // Fill is complete. - refill = false; - } - //std::cerr << "==> Leaving Period::fill()" << std::endl; -} - - -void Period::printTable(std::ostream &os, const CellArray &cells) const { - // Save the formatting flags. - std::streamsize old_prec = os.precision(6); - os.setf(std::ios::fixed, std::ios::floatfield); - - // Print table header. - printTableTitle(os, "Periodic lattice functions"); - - // Print table body. - printTableBody(os, cells); - - // Write table specific summary. - const Row &row = itsTable->back(); - os << "Period length = " << setw(16) - << Attributes::getReal(itsAttr[CIRCUM]) - << " Qx = " << setw(16) << getMUi(row, 0) - << " Qy = " << setw(16) << getMUi(row, 1) - << '\n' - << "DeltaP = " << setw(16) - << Attributes::getReal(itsAttr[DELTAP]) - << " BetaX(max) = " << setw(16) - << Attributes::getReal(itsAttr[BETXMAX]) - << " BetaY(max) = " << setw(16) - << Attributes::getReal(itsAttr[BETYMAX]) << '\n' - << " " - << " x(max) = " << setw(16) - << Attributes::getReal(itsAttr[XCMAX]) - << " y(max) = " << setw(16) - << Attributes::getReal(itsAttr[YCMAX]) << '\n' - << " " - << " x(rms) = " << setw(16) - << Attributes::getReal(itsAttr[XCRMS]) - << " y(rms) = " << setw(16) - << Attributes::getReal(itsAttr[YCRMS]) << '\n' - << " " - << " Dx(max) = " << setw(16) - << Attributes::getReal(itsAttr[DXMAX]) - << " Dy(max) = " << setw(16) - << Attributes::getReal(itsAttr[DYMAX]) << '\n' - << " " - << " Dx(rms) = " << setw(16) - << Attributes::getReal(itsAttr[DXRMS]) - << " Dy(rms) = " << setw(16) - << Attributes::getReal(itsAttr[DYRMS]) << '\n'; - - // Restore the formatting flags. - os.precision(old_prec); - os.setf(std::ios::fixed, std::ios::floatfield); -} - - -void Period::findClosedOrbit() { - //std::cerr << "==> In Period::findClosedOrbit()" << std::endl; - static const int iteration_limit = 20; - static const double itsTolerance = 1.0e-8; - static const LinearFun<double, 6> nrgy = LinearFun<double, 6>::makeVariable(5); - double deltap = Attributes::getReal(itsAttr[DELTAP]); - - // Initialize fixPoint. - fixPoint[0] = 0.e0; - fixPoint[1] = 0.e0; - fixPoint[2] = 0.e0; - fixPoint[3] = 0.e0; - fixPoint[4] = 0.e0; - fixPoint[5] = deltap; - //fixPoint[5]=0.e0; - //std::cerr << " [findCO:] fixPoint =" << fixPoint << std::endl; - - double error = 0.0; - for(int count = 0; count < iteration_limit; ++count) { - //std::cerr << " [findCO:] count = " << count << std::endl; - // Initial guess for closed orbit. - LinearMap<double, 6> identity; - LinearMap<double, 6> mapAtEnd; - - // Compute the one-turn map around the closed orbit. - //std::cerr << " [findCO:] computing map about fixPoint = " << fixPoint << std::endl; - itsMapper->setMap(identity + fixPoint); - itsMapper->execute(); - itsMapper->getMap(mapAtEnd); - //std::cerr << " [findCO:] have map about fixPoint" << std::endl; - - // Get system of equations for fixed point. - FMatrix<double, 6, 6> A = mapAtEnd.linearTerms(); - FVector<double, 6> Error = mapAtEnd.constantTerm() - fixPoint; - double errold = error; - error = 0.0; - - //std::cerr << " [findCO:] count " << count << ": Error =\n {"; - //for(int i=0;i<6;i++) std::cerr << " " << Error(i); - //std::cerr << " }" << std::endl; - //std::cerr << " [findCO:] A =\n" << A << std::endl; - - //std::cerr << " [findCO:] finding fixed point "; - if(mapAtEnd[5] == nrgy + deltap) { - // Finding static fixed point. - //std::cerr << "for static map ...\n" << std::endl; - for(int i = 0; i < 4; i++) { - A(i, i) -= 1.0; - if(std::abs(Error(i)) > error) error = std::abs(Error(i)); - } - for(int i = 4; i < 6; i++) { - for(int j = 0; j < 6; j++) A(i, j) = A(j, i) = 0.0; - A(i, i) = 1.0; - Error(i) = 0.0; - } - } else { - // Finding dynamic fixed point. - //std::cerr << "for dynamic map ...\n" << std::endl; - for(int i = 0; i < 6; i++) { - A(i, i) -= 1.0; - if(std::abs(Error(i)) > error) error = std::abs(Error(i)); - } - } - - //std::cerr << " [findCO:] count " << count << ": Error =\n {"; - //for(int i=0;i<6;i++) std::cerr << " " << Error(i); - //std::cerr << " }" << std::endl; - //std::cerr << " [findCO:] A =\n" << A << std::endl; - - // Correction for fixed point. - FLUMatrix<double, 6> lu(A); - //std::cerr << " [findCO:] have lu(A)" << std::endl; - lu.backSubstitute(Error); - //std::cerr << " [findCO:] backSub done" << std::endl; - fixPoint -= Error; - //std::cerr << " [findCO:] count errold error" << count << errold << error << std::endl; - // return if the error vanishes or the error has fallen below some crude - // tolerance (machineEps^(1/2)) and bounced (because of round-off error) - if(count && (error == 0.0 || (error < itsTolerance && error >= errold))) break; - //if (error<itsTolerance) break; - //std::cerr << " [findCO:] again" << std::endl; - } - //std::cerr << " [findCO:] fixPoint = " << fixPoint << std::endl; - //std::cerr << "==> Leaving Period::findClosedOrbit()" << std::endl; -} \ No newline at end of file diff --git a/src/Tables/Period.h b/src/Tables/Period.h deleted file mode 100644 index 25cf4cc62320ba36478cac362c7e622224c30adb..0000000000000000000000000000000000000000 --- a/src/Tables/Period.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef OPAL_Period_HH -#define OPAL_Period_HH -// ------------------------------------------------------------------------ -// $RCSfile: Period.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1.4.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Period -// -// ------------------------------------------------------------------------ -// -// $Date: 2004/11/12 20:10:11 $ -// $Author: adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Tables/Twiss.h" -#include "FixedAlgebra/FVector.h" - - -// Class Period -// ------------------------------------------------------------------------ -/// The TWISS command. - -class Period: public Twiss { - -public: - - /// Exemplar constructor. - Period(); - - virtual ~Period(); - - /// Make clone. - virtual Period *clone(const std::string &name); - - /// Fill the buffer using the defined algorithm. - virtual void fill(); - - /// Print the table on an ASCII stream. - virtual void printTable(std::ostream &, const CellArray &) const; - -private: - - // Not implemented. - Period(const Period &); - void operator=(const Period &); - - // Clone constructor. - Period(const std::string &name, Period *parent); - - // Find the closed orbit. - void findClosedOrbit(); - - // The initial closed orbit. - FVector<double, 6> fixPoint; - - // Additional values for class Period. - enum { - MICADO = Twiss::SIZE, // Number of iterations for MICADO - CORRECTORS, // Number of correctors for MICADO - THREAD, // Name of threader method - TOLQ, // Tolerances for closed orbit search - TOLP, - - // Computed values (read-only): - CIRCUM, // Machine circumference or line length - Q1, // Tunes - Q2, - Q3, - FREQ, // Revolution frequencey in Hz. - U0, // Energy loss per turn in MeV - J1, // Damping partition numbers - J2, - J3, - DELTAP, // Differential momentum variation - SIZE - }; -}; - -#endif // OPAL_Period_HH diff --git a/src/Tables/Survey.cpp b/src/Tables/Survey.cpp deleted file mode 100644 index a165b907fad5e577e2a246ee9bc5f73d4552517f..0000000000000000000000000000000000000000 --- a/src/Tables/Survey.cpp +++ /dev/null @@ -1,639 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Survey.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.2.4.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Survey -// The Survey class implements a buffer for survey tables. -// -// ------------------------------------------------------------------------ -// -// $Date: 2002/12/09 15:06:08 $ -// $Author: jsberg $ -// -// ------------------------------------------------------------------------ - -#include "Tables/Survey.h" -#include "AbstractObjects/BeamSequence.h" -#include "AbstractObjects/Element.h" -#include "AbstractObjects/Expressions.h" -#include "AbstractObjects/OpalData.h" -#include "AbstractObjects/PlaceRep.h" -#include "AbstractObjects/RangeRep.h" -#include "AbstractObjects/TableRowRep.h" -#include "Attributes/Attributes.h" -#include "Algorithms/Surveyor.h" -#include "BeamlineGeometry/Euclid3D.h" -#include "Physics/Physics.h" -#include "Tables/Flatten.h" -#include "Utilities/OpalException.h" -#include "Utilities/Options.h" - -#include <cmath> -#include <iomanip> -#include <iostream> -#include <sstream> - - -// Local structures. -// ------------------------------------------------------------------------ - -namespace { - - // Describe a column with name and function to get it. - struct ColDesc { - - // The column name. - const char *colName; - - // Method to return the selected column from the given row. - double(Survey::*get)(const Survey::Row &, int, int) const; - - int printWidth; - int printPrecision; - - int ind_1; - int ind_2; - }; - - // The column entries table. - const ColDesc allColumns[] = { - { "S", &Survey::getS, 14, 6, 0, 0 }, - - { "X", &Survey::getX, 10, 6, 0, 0 }, - { "Y", &Survey::getY, 10, 6, 0, 0 }, - { "Z", &Survey::getZ, 10, 6, 0, 0 }, - - { "THETA", &Survey::getTheta, 14, 10, 0, 0 }, - { "PHI", &Survey::getPhi, 14, 10, 0, 0 }, - { "PSI", &Survey::getPsi, 14, 10, 0, 0 }, - - { "W11", &Survey::getW, 10, 6, 1, 1 }, - { "W21", &Survey::getW, 10, 6, 2, 1 }, - { "W31", &Survey::getW, 10, 6, 3, 1 }, - { "W12", &Survey::getW, 10, 6, 1, 2 }, - { "W22", &Survey::getW, 10, 6, 2, 2 }, - { "W32", &Survey::getW, 10, 6, 3, 2 }, - { "W13", &Survey::getW, 10, 6, 1, 3 }, - { "W23", &Survey::getW, 10, 6, 2, 3 }, - { "W33", &Survey::getW, 10, 6, 3, 3 }, - - { 0, 0, 0, 0, 0, 0 } - }; - - - // The print column entries table. - const ColDesc printColumns[] = { - { "S", &Survey::getS, 14, 6, 0, 0 }, - - { "X", &Survey::getX, 10, 6, 0, 0 }, - { "Y", &Survey::getY, 10, 6, 0, 0 }, - { "Z", &Survey::getZ, 10, 6, 0, 0 }, - - { "THETA", &Survey::getTheta, 14, 10, 0, 0 }, - { "PHI", &Survey::getPhi, 14, 10, 0, 0 }, - { "PSI", &Survey::getPsi, 14, 10, 0, 0 }, - - { 0, 0, 0, 0, 0, 0 } - }; - - - // Find a column by name. - const ColDesc *findCol(const Survey &table, const std::string &colName) { - for(const ColDesc *col = allColumns; col->colName; ++col) { - if(colName == col->colName) { - return col; - } - } - - throw OpalException("Survey::findCol()", - "Survey table \"" + table.getOpalName() + - "\" has no column named \"" + colName + "\"."); - } - - - // Local class Column. - // Returns the value for a given column in the current row of a given - // table. - class Column: public Expressions::Scalar<double> { - - public: - - //: Constructor. - // Identify the table by its name [b]tab[/b], and the column by its - // name [b]col[/b] and the function [b]col[/b]. - // The row is specified as the ``current'' row of the table. - Column(const Survey &tab, const std::string &scol, const ColDesc &col); - - Column(const Column &); - virtual ~Column(); - - //: Make clone. - virtual Expressions::Scalar<double> *clone() const; - - //: Evaluate. - virtual double evaluate() const; - - //: Print expression. - virtual void print(std::ostream &os, int precedence = 99) const; - - private: - - // Not implemented. - Column(); - const Column &operator=(const Column &); - - // The Table referred. - const Survey &itsTable; - - // Column name. - std::string colName; - - // The function returning the column value from the given row. - double(Survey::*get)(const Survey::Row &, int, int) const; - - // Indices for calling get(). - int ind_1, ind_2; - }; - - - // Implementation. - // ------------------------------------------------------------------------ - - Column::Column(const Survey &tab, - const std::string &name, - const ColDesc &desc): - itsTable(tab), - colName(name), - get(desc.get), - ind_1(desc.ind_1), - ind_2(desc.ind_2) - {} - - - Column::Column(const Column &rhs): - Scalar<double>(rhs), - itsTable(rhs.itsTable), - colName(rhs.colName), - get(rhs.get), - ind_1(rhs.ind_1), - ind_2(rhs.ind_2) - {} - - - Column::~Column() - {} - - - Expressions::Scalar<double> *Column::clone() const { - return new Column(*this); - } - - - double Column::evaluate() const { - // Apply the function to the current row of the table. - return (itsTable.*get)(itsTable.getCurrent(), ind_1, ind_2); - } - - - void Column::print(std::ostream &os, int) const { - os << colName; - } -}; - - -// Class Survey::Row -// ------------------------------------------------------------------------ - -Survey::Row::Row(ElementBase *elem, int occur): - FlaggedElmPtr(elem) { - setCounter(occur); -} - - -Survey::Row::Row(const FlaggedElmPtr &rhs): - FlaggedElmPtr(rhs) -{} - - -Survey::Row::~Row() -{} - - -double Survey::Row::getS() const { - return s; -} - - -const Euclid3D &Survey::Row::getMap() const { - return euclid; -} - - -// Class Survey -// ------------------------------------------------------------------------ - -// The attributes of class Survey. -namespace { - enum { - LINE, // The lattice to be used. - RANGE, // The range in the lattice. - STATIC, // The flag for suppressing recalculation. - INIT, // If given, take initial values from another table. - X0, // The initial position X. - Y0, // The initial position Y. - Z0, // The initial position Z. - THETA0, // The initial azimuth THETA. - PHI0, // The initial elevation PHI. - PSI0, // The initial roll PSI. - L, // Sum of design lengths. - SIZE - }; -} - - -Survey::Survey(): - Table(SIZE, "SURVEY", - "The \"SURVEY\" command defines a table of survey data which " - "can be matched or tabulated."), - itsTable(0), itsVisitor(0) { - itsAttr[LINE] = Attributes::makeString - ("LINE", "Name of the lattice to be surveyed"); - itsAttr[RANGE] = Attributes::makeRange - ("RANGE", "The range in the lattice"); - itsAttr[STATIC] = Attributes::makeBool - ("STATIC", "If true, the table is not recalculated at each iteration"); - itsAttr[INIT] = Attributes::makeTableRow - ("INIT", "If given, this table position is used to initialise"); - itsAttr[X0] = Attributes::makeReal - ("X0", "Initial X position in m"); - itsAttr[Y0] = Attributes::makeReal - ("Y0", "Initial Y position in m"); - itsAttr[Z0] = Attributes::makeReal - ("Z0", "Initial Z position in m"); - itsAttr[THETA0] = Attributes::makeReal - ("THETA0", "Initial azimuth angle in rad"); - itsAttr[PHI0] = Attributes::makeReal - ("PHI0", "Initial pitch angle in rad"); - itsAttr[PSI0] = Attributes::makeReal - ("PSI0", "Initial roll angle in rad"); - - // READ ONLY. - itsAttr[L] = Attributes::makeReal - ("L", "Sum of design lengths in m"); - itsAttr[L].setReadOnly(true); - - registerOwnership(AttributeHandler::COMMAND); -} - - -Survey::Survey(const std::string &name, Survey *parent): - Table(name, parent), itsTable(new TLine(name)), itsVisitor(0) -{} - - -Survey::~Survey() { - delete itsTable; - delete itsVisitor; -} - - -Survey *Survey::clone(const std::string &name) { - return new Survey(name, this); -} - - -void Survey::execute() { - // Find BeamSequence definition. - itsLine = Attributes::getString(itsAttr[LINE]); - BeamSequence *use = BeamSequence::find(itsLine); - - // Make sure all is up-to-date. - OpalData::getInstance()->update(); - - // Create flat list with space for data storage. - RangeRep range = Attributes::getRange(itsAttr[RANGE]); - Flatten<Row> flattener(*use->fetchLine(), *itsTable, range); - flattener.execute(); - - if(itsTable->empty() && Options::warn) { - std::cerr << "\n### Warning ### Survey table \"" << getOpalName() - << "\" contains no elements.\n" << std::endl; - } else { - itsTable->front().setSelectionFlag(true); - itsTable->back().setSelectionFlag(true); - } - - // Fill the table. - itsVisitor = new Surveyor(*itsTable, false); - fill(); - - // Set static flag. - if(Attributes::getBool(itsAttr[STATIC])) dynamic = false; - printTable(std::cout, getDefault()); -} - - -void Survey::fill() { - if(refill) { - // Reset the surveyor. - double x, y, z, phi, theta, psi; - if(itsAttr[INIT]) { - TableRowRep rowrep = Attributes::getTableRow(itsAttr[INIT]); - Table *init = Table::find(rowrep.getTabName()); - - if(matches(init)) { - PlaceRep pinit = rowrep.getPosition(); - Survey *sinit = dynamic_cast<Survey *>(init); - sinit->fill(); - const Row &row = sinit->findRow(pinit); - itsVisitor->setMap(sinit->getMap(row)); - } else { - throw OpalException("Survey::fill()", "Table \"" + rowrep.getTabName() + - "\" is not suitable for initialising survey \"" + - getOpalName() + "\"."); - } - } else { - x = Attributes::getReal(itsAttr[X0]); - y = Attributes::getReal(itsAttr[Y0]); - z = Attributes::getReal(itsAttr[Z0]); - phi = Attributes::getReal(itsAttr[PHI0]); - theta = Attributes::getReal(itsAttr[THETA0]); - psi = Attributes::getReal(itsAttr[PSI0]); - - // Use the OPAL-8 conventions. - Rotation3D rot = Rotation3D::YRotation(theta) * - Rotation3D::XRotation(- phi) * Rotation3D::ZRotation(psi); - itsVisitor->setMap(Euclid3D(Vector3D(x, y, z), rot)); - } - - s = 0.0; - - for(TLine::iterator i = itsTable->begin(); i != itsTable->end(); ++i) { - // Advance through element. - i->accept(*itsVisitor); - - // Update accumulated length. - ElementBase &elem = *i->getElement(); - if(! dynamic_cast<Beamline *>(&elem)) { - s += elem.getElementLength(); - } - - // Copy row to table line. - itsVisitor->getMap(i->euclid); - i->s = s; - } - - Euclid3D map; - itsVisitor->getMap(map); - map.getAll(x, y, z, phi, theta, psi); - Attributes::setReal(itsAttr[L], s); - refill = false; - } -} - - -const Survey::Row &Survey::findRow(const PlaceRep &place) { - PlaceRep row(place); - row.initialize(); - for(TLine::const_iterator i = itsTable->begin(); - i != itsTable->end(); ++i) { - row.enter(*i); - if(row.isActive()) return *i; - row.leave(*i); - } - - std::ostringstream os; - os << row << std::ends; - throw OpalException("Survey::setRow()", "Row \"" + os.str() + - "\" not found in survey table \"" + getOpalName() + "\"."); -} - - -double Survey::getCell(const PlaceRep &place, const std::string &name) { - const Row &row = findRow(place); - const ColDesc *col = findCol(*this, name); - return (this->*(col->get))(row, col->ind_1, col->ind_2); -} - - -Table::CellArray Survey::getDefault() const { - CellArray columns; - for(const ColDesc *col = printColumns; col->colName; ++col) { - Expressions::PtrToScalar<double> expr = - new Column(*this, col->colName, *col); - columns.push_back(Cell(expr, col->printWidth, col->printPrecision)); - } - return columns; -} - - -std::vector<double> Survey::getColumn(const RangeRep &rng, const std::string &name) { - // Find proper column function. - const ColDesc *col = findCol(*this, name); - RangeRep range(rng); - range.initialize(); - std::vector<double> column; - - for(current = itsTable->begin(); current != itsTable->end(); ++current) { - range.enter(*current); - if(range.isActive()) { - column.push_back((this->*(col->get))(*current, col->ind_1, col->ind_2)); - } - range.leave(*current); - } - - return column; -} - - -const Survey::Row &Survey::getCurrent() const { - return *current; -} - - -double Survey::getLength() { - return itsTable->getElementLength(); -} - - -const Beamline *Survey::getLine() const { - return itsTable; -} - - -std::vector<double> -Survey::getRow(const PlaceRep &pos, const std::vector<std::string> &columns) { - const Row &row = findRow(pos); - std::vector<double> result; - - if(columns.empty()) { - // Standard column selection. - for(const ColDesc *col = printColumns; col->colName != 0; ++col) { - result.push_back((this->*(col->get))(row, col->ind_1, col->ind_2)); - } - } else { - // User column selection. - for(std::vector<std::string>::const_iterator name = columns.begin(); - name != columns.end(); ++name) { - const ColDesc *col = findCol(*this, *name); - result.push_back((this->*(col->get))(row, col->ind_1, col->ind_2)); - } - } - - return result; -} - - -bool Survey::isDependent(const std::string &name) const { - // Test if name refers to LINE attribute. - if(itsLine == name) return true; - - // Test if name occurs in table. - for(TLine::const_iterator i = itsTable->begin(); i != itsTable->end(); ++i) { - if(i->getElement()->getName() == name) return true; - } - - // Otherwise replacement is not required. - return false; -} - - -Expressions::PtrToScalar<double> -Survey::makeColumnExpression(const std::string &colName) const { - return new Column(*this, colName, *findCol(*this, colName)); -} - - -bool Survey::matches(Table *rhs) const { - return dynamic_cast<Survey *>(rhs) != 0; -} - - -void Survey::printTable(std::ostream &os, const CellArray &cells) const { - // Write table specific header. - OpalData::getInstance()->printTitle(os); - os << '\n'; - os << "Geometric layout for line: " << itsAttr[LINE] - << ", range: " << itsAttr[RANGE] << "." << '\n'; - - // Find line length. - int lineLength = 16; - for(CellArray::const_iterator cell = cells.begin(); - cell < cells.end(); ++cell) { - lineLength += cell->printWidth; - } - os << std::string(lineLength, '-') << '\n'; - - // Print table header. - os << "Element "; - for(CellArray::const_iterator cell = cells.begin(); - cell < cells.end(); ++cell) { - std::ostringstream ss; - cell->itsExpr->print(ss, 0); - ss << std::ends; - std::string image = ss.str(); - - if(int(image.length()) < cell->printWidth) { - // Right adjust the column header. - os << std::string(cell->printWidth - image.length(), ' ') << image; - } else { - // Truncate the column header. - os << ' ' << std::string(image, 0, cell->printWidth - 3) << ".."; - } - } - os << '\n'; - os << std::string(lineLength, '-') << '\n'; - - // Save the formatting flags. - std::streamsize old_prec = os.precision(6); - os.setf(std::ios::fixed, std::ios::floatfield); - - // Write table body. - for(current = itsTable->begin(); current != itsTable->end(); ++current) { - if(current->getSelectionFlag()) { - std::string name = current->getElement()->getName(); - if(int occur = current->getCounter()) { - std::ostringstream tos; - tos << name << '[' << occur << ']' << std::ends; - name = tos.str(); - } - - if(name.length() > 16) { - // Truncate the element name. - os << std::string(name, 0, 13) << ".. "; - } else { - // Left adjust the element name. - os << name << std::string(16 - name.length(), ' '); - } - - for(CellArray::const_iterator cell = cells.begin(); - cell != cells.end(); ++cell) { - os << std::setw(cell->printWidth) - << std::setprecision(cell->printPrecision) - << cell->itsExpr->evaluate(); - } - os << '\n'; - } - } - - // Write table specific summary. - os << std::string(lineLength, '-') << '\n'; - - // Restore the formatting flags. - os.precision(old_prec); - os.setf(std::ios::fixed, std::ios::floatfield); -} - - -double Survey::getS(const Survey::Row &/*row*/, int, int) const { - return current->getS(); -} - - -const Euclid3D &Survey::getMap(const Survey::Row &row) const { - return row.getMap(); -} - - -double Survey::getX(const Survey::Row &row, int, int) const { - return row.getMap().getX(); -} - - -double Survey::getY(const Survey::Row &row, int, int) const { - return row.getMap().getY(); -} - - -double Survey::getZ(const Survey::Row &row, int, int) const { - return row.getMap().getZ(); -} - - -double Survey::getPhi(const Survey::Row &row, int, int) const { - const Rotation3D &rot = row.getMap().getRotation(); - return atan2(rot(1, 2), sqrt(rot(1, 0) * rot(1, 0) + rot(1, 1) * rot(1, 1))); -} - - -double Survey::getTheta(const Survey::Row &row, int, int) const { - const Rotation3D &rot = row.getMap().getRotation(); - double arg = std::abs(rot(0, 2)) + std::abs(rot(2, 2)); - return (arg > 1.0e-10) ? atan2(rot(0, 2), rot(2, 2)) : 0.0; -} - - -double Survey::getPsi(const Survey::Row &row, int, int) const { - const Rotation3D &rot = row.getMap().getRotation(); - double arg = std::abs(rot(1, 0)) + std::abs(rot(1, 1)); - return (arg > 1.0e-10) ? atan2(rot(1, 0), rot(1, 1)) : 0.0; -} - - -double Survey::getW(const Survey::Row &row, int ind_1, int ind_2) const { - return row.getMap().M(ind_1, ind_2); -} \ No newline at end of file diff --git a/src/Tables/Survey.h b/src/Tables/Survey.h deleted file mode 100644 index 1202b3107e6699e885816c2ccbf79cac2f87f8e4..0000000000000000000000000000000000000000 --- a/src/Tables/Survey.h +++ /dev/null @@ -1,188 +0,0 @@ -#ifndef OPAL_Survey_HH -#define OPAL_Survey_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Survey.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.2 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Survey -// -// ------------------------------------------------------------------------ -// -// $Date: 2001/08/13 15:25:22 $ -// $Author: jowett $ -// -// ------------------------------------------------------------------------ - -#include "AbstractObjects/Table.h" -#include "AbstractObjects/Expressions.h" -#include "BeamlineGeometry/Euclid3D.h" -#include "Beamlines/FlaggedElmPtr.h" -#include "Beamlines/TBeamline.h" -#include <iosfwd> -#include <vector> - -class PlaceRep; -class RangeRep; -class Surveyor; - - -// Class Survey -// ------------------------------------------------------------------------ -/// The SURVEY command. - -class Survey: public Table { - -public: - - /// The class for one row of the survey table. - class Row: public FlaggedElmPtr { - - friend class ::Survey; - - public: - - Row(ElementBase *, int); - explicit Row(const FlaggedElmPtr &); - ~Row(); - - /// Return the accumulated geometry transform. - const Euclid3D &getMap() const; - - /// Return the accumulated length. - double getS() const; - - private: - - /// The accumulated geometry transform. - Euclid3D euclid; - - /// The accumulated length. - double s; - }; - - /// Exemplar constructor. - Survey(); - - virtual ~Survey(); - - /// Make clone. - virtual Survey *clone(const std::string &name); - - /// Check validity of survey definition. - virtual void execute(); - - /// Fill the buffer using the survey algorithm. - virtual void fill(); - - /// Return a selected value in a selected row. - virtual double getCell(const PlaceRep &row, const std::string &col); - - /// Return the default print columns. - virtual CellArray getDefault() const; - - /// Return column [b]col[/b] of this table, limited by [b]range[/b]. - virtual std::vector<double> - getColumn(const RangeRep &range, const std::string &col); - - /// Return current row of table. - const Row &getCurrent() const; - - - /// Return the length of the table. - virtual double getLength(); - - /// Return embedded CLASSIC beamline. - virtual const Beamline *getLine() const; - - /// Return a table row, possible user-defined. - virtual std::vector<double> - getRow(const PlaceRep &, const std::vector<std::string> &); - - - /// Arc length for given row. - double getS(const Row &, int = 0, int = 0) const; - - /// Position and orientation of local system. - const Euclid3D &getMap(const Row &) const; - - /// X component of displacement. - double getX(const Row &, int = 0, int = 0) const; - - /// Y component of displacement. - double getY(const Row &, int = 0, int = 0) const; - - /// Z component of displacement. - double getZ(const Row &, int = 0, int = 0) const; - - /// Rotation about X. - double getPhi(const Row &, int = 0, int = 0) const; - - /// Rotation about Y. - double getTheta(const Row &, int = 0, int = 0) const; - - /// Rotation about Z. - double getPsi(const Row &, int = 0, int = 0) const; - - /// Local axis vectors. - // First index (1 ... 3) is coordinate, second index (1 ... 3) is vector. - double getW(const Row &, int i1, int i2) const; - - - /// Find dependency. - // Return true, if this table depends on the named object. - virtual bool isDependent(const std::string &name) const; - - /// Return column. - // Return an expression which denotes the selected column, - // identified by its name. - virtual Expressions::PtrToScalar<double> - makeColumnExpression(const std::string &colName) const; - - /// Check compatibility. - // True, if [b]rhs[/b] is a survey table. - virtual bool matches(Table *rhs) const; - - /// Print list for the table. - virtual void printTable(std::ostream &, const CellArray &) const; - -private: - - // Not implemented. - Survey(const Survey &); - void operator=(const Survey &); - - // Clone constructor. - Survey(const std::string &name, Survey *parent); - - - // Set the current table row for a given place specification. - const Row &findRow(const PlaceRep &row); - - // The contained beamline type. - typedef TBeamline<Row> TLine; - - // Access to current table row. - mutable TLine::const_iterator current; - - // The table contents. - TLine *itsTable; - - // The algorithm for filling the buffer. - Surveyor *itsVisitor; - - // Current accumulated design length. - double s; - - // The name of the surveyed line. - std::string itsLine; - - /// Number of table columns. - static const int numColumns = 7; -}; - -#endif // OPAL_Survey_HH diff --git a/src/Tables/Twiss.cpp b/src/Tables/Twiss.cpp deleted file mode 100644 index 75e298d1e2c9b563c0c8ef4bf73bb0ecf3b4d1c4..0000000000000000000000000000000000000000 --- a/src/Tables/Twiss.cpp +++ /dev/null @@ -1,1293 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: Twiss.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.4.2.3 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Twiss -// The abstract class Twiss implements the interface for a table buffer -// holding lattice function. -// -// ------------------------------------------------------------------------ -// -// $Date: 2004/11/12 20:10:11 $ -// $Author: adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Tables/Twiss.h" -#include "AbstractObjects/BeamSequence.h" -#include "AbstractObjects/Element.h" -#include "AbstractObjects/Expressions.h" -#include "AbstractObjects/OpalData.h" -#include "AbstractObjects/PlaceRep.h" -#include "AbstractObjects/RangeRep.h" -#include "Algorithms/ThickMapper.h" -#include "Algorithms/LinearMapper.h" -#include "Algorithms/ThinMapper.h" -#include "Attributes/Attributes.h" -#include "FixedAlgebra/FMatrix.h" -#include "FixedAlgebra/FVector.h" -#include "Physics/Physics.h" -#include "Structure/Beam.h" -#include "Tables/Flatten.h" -#include "Utilities/OpalException.h" -#include "Utilities/Options.h" - -#include <cmath> -#include <iomanip> -#include <iostream> -#include <sstream> - -// Local structures. -// ------------------------------------------------------------------------ - -namespace { - - struct ColDesc { - - // Column name. - const char *colName; - - // Pointer to the row method which returns the column value. - double(Twiss::*get)(const Twiss::Row &, int, int) const; - - // Default field width and precision. - int printWidth, printPrecision; - - // Indices to be given to get(). - int ind_1, ind_2; - }; - - - // The complete column entries table. - const ColDesc allColumns[] = { - - // Arc length. - { "S", &Twiss::getS, 14, 6, 0, 0 }, - - // "Naive" Twiss. - { "ALFX", &Twiss::getALFi, 10, 6, 0, 0 }, - { "ALFY", &Twiss::getALFi, 10, 6, 1, 0 }, - { "ALFT", &Twiss::getALFi, 10, 6, 2, 0 }, - - { "BETX", &Twiss::getBETi, 10, 3, 0, 0 }, - { "BETY", &Twiss::getBETi, 10, 3, 1, 0 }, - { "BETT", &Twiss::getBETi, 10, 3, 2, 0 }, - - { "MUX", &Twiss::getMUi, 10, 6, 0, 0 }, - { "MUY", &Twiss::getMUi, 10, 6, 1, 0 }, - { "MUT", &Twiss::getMUi, 10, 6, 2, 0 }, - - // Mais-Ripken functions. - { "ALFX1", &Twiss::getALFik, 8, 3, 0, 0 }, - { "ALFX2", &Twiss::getALFik, 8, 3, 0, 1 }, - { "ALFX3", &Twiss::getALFik, 8, 3, 0, 2 }, - { "ALFY1", &Twiss::getALFik, 8, 3, 1, 0 }, - { "ALFY2", &Twiss::getALFik, 8, 3, 1, 1 }, - { "ALFY3", &Twiss::getALFik, 8, 3, 1, 2 }, - { "ALFT1", &Twiss::getALFik, 8, 3, 2, 0 }, - { "ALFT2", &Twiss::getALFik, 8, 3, 2, 1 }, - { "ALFT3", &Twiss::getALFik, 8, 3, 2, 2 }, - - { "BETX1", &Twiss::getBETik, 10, 3, 0, 0 }, - { "BETX2", &Twiss::getBETik, 10, 3, 0, 1 }, - { "BETX3", &Twiss::getBETik, 10, 3, 0, 2 }, - { "BETY1", &Twiss::getBETik, 10, 3, 1, 0 }, - { "BETY2", &Twiss::getBETik, 10, 3, 1, 1 }, - { "BETY3", &Twiss::getBETik, 10, 3, 1, 2 }, - { "BETT1", &Twiss::getBETik, 10, 3, 2, 0 }, - { "BETT2", &Twiss::getBETik, 10, 3, 2, 1 }, - { "BETT3", &Twiss::getBETik, 10, 3, 2, 2 }, - - { "GAMX1", &Twiss::getGAMik, 10, 3, 0, 0 }, - { "GAMX2", &Twiss::getGAMik, 10, 3, 0, 1 }, - { "GAMX3", &Twiss::getGAMik, 10, 3, 0, 2 }, - { "GAMY1", &Twiss::getGAMik, 10, 3, 1, 0 }, - { "GAMY2", &Twiss::getGAMik, 10, 3, 1, 1 }, - { "GAMY3", &Twiss::getGAMik, 10, 3, 1, 2 }, - { "GAMT1", &Twiss::getGAMik, 10, 3, 2, 0 }, - { "GAMT2", &Twiss::getGAMik, 10, 3, 2, 1 }, - { "GAMT3", &Twiss::getGAMik, 10, 3, 2, 2 }, - - // Closed orbit. - { "XC", &Twiss::getCO, 10, 6, 0, 0 }, - { "PXC", &Twiss::getCO, 10, 6, 1, 0 }, - { "YC", &Twiss::getCO, 10, 6, 2, 0 }, - { "PYC", &Twiss::getCO, 10, 6, 3, 0 }, - { "TC", &Twiss::getCO, 10, 6, 4, 0 }, - { "PTC", &Twiss::getCO, 10, 6, 5, 0 }, - - // Dispersion. - { "DX", &Twiss::getDisp, 10, 6, 0, 0 }, - { "DPX", &Twiss::getDisp, 10, 6, 1, 0 }, - { "DY", &Twiss::getDisp, 10, 6, 2, 0 }, - { "DPY", &Twiss::getDisp, 10, 6, 3, 0 }, - { "DT", &Twiss::getDisp, 10, 6, 4, 0 }, - { "DPT", &Twiss::getDisp, 10, 6, 5, 0 }, - - // Eigenvectors. - { "E11", &Twiss::getEigen, 10, 6, 0, 0 }, - { "E21", &Twiss::getEigen, 10, 6, 1, 0 }, - { "E31", &Twiss::getEigen, 10, 6, 2, 0 }, - { "E41", &Twiss::getEigen, 10, 6, 3, 0 }, - { "E51", &Twiss::getEigen, 10, 6, 4, 0 }, - { "E61", &Twiss::getEigen, 10, 6, 5, 0 }, - { "E12", &Twiss::getEigen, 10, 6, 0, 1 }, - { "E22", &Twiss::getEigen, 10, 6, 1, 1 }, - { "E32", &Twiss::getEigen, 10, 6, 2, 1 }, - { "E42", &Twiss::getEigen, 10, 6, 3, 1 }, - { "E52", &Twiss::getEigen, 10, 6, 4, 1 }, - { "E62", &Twiss::getEigen, 10, 6, 5, 1 }, - { "E13", &Twiss::getEigen, 10, 6, 0, 2 }, - { "E23", &Twiss::getEigen, 10, 6, 1, 2 }, - { "E33", &Twiss::getEigen, 10, 6, 2, 2 }, - { "E43", &Twiss::getEigen, 10, 6, 3, 2 }, - { "E53", &Twiss::getEigen, 10, 6, 4, 2 }, - { "E63", &Twiss::getEigen, 10, 6, 5, 2 }, - { "E14", &Twiss::getEigen, 10, 6, 0, 3 }, - { "E24", &Twiss::getEigen, 10, 6, 1, 3 }, - { "E34", &Twiss::getEigen, 10, 6, 2, 3 }, - { "E44", &Twiss::getEigen, 10, 6, 3, 3 }, - { "E54", &Twiss::getEigen, 10, 6, 4, 3 }, - { "E64", &Twiss::getEigen, 10, 6, 5, 3 }, - { "E15", &Twiss::getEigen, 10, 6, 0, 4 }, - { "E25", &Twiss::getEigen, 10, 6, 1, 4 }, - { "E35", &Twiss::getEigen, 10, 6, 2, 4 }, - { "E45", &Twiss::getEigen, 10, 6, 3, 4 }, - { "E55", &Twiss::getEigen, 10, 6, 4, 4 }, - { "E65", &Twiss::getEigen, 10, 6, 5, 4 }, - { "E16", &Twiss::getEigen, 10, 6, 0, 5 }, - { "E26", &Twiss::getEigen, 10, 6, 1, 5 }, - { "E36", &Twiss::getEigen, 10, 6, 2, 5 }, - { "E46", &Twiss::getEigen, 10, 6, 3, 5 }, - { "E56", &Twiss::getEigen, 10, 6, 4, 5 }, - { "E66", &Twiss::getEigen, 10, 6, 5, 5 }, - - // Sigma matrix. - { "S11", &Twiss::getSigma, 10, 6, 0, 0 }, - { "S21", &Twiss::getSigma, 10, 6, 1, 0 }, - { "S31", &Twiss::getSigma, 10, 6, 2, 0 }, - { "S41", &Twiss::getSigma, 10, 6, 3, 0 }, - { "S51", &Twiss::getSigma, 10, 6, 4, 0 }, - { "S61", &Twiss::getSigma, 10, 6, 5, 0 }, - { "S12", &Twiss::getSigma, 10, 6, 0, 1 }, - { "S22", &Twiss::getSigma, 10, 6, 1, 1 }, - { "S32", &Twiss::getSigma, 10, 6, 2, 1 }, - { "S42", &Twiss::getSigma, 10, 6, 3, 1 }, - { "S52", &Twiss::getSigma, 10, 6, 4, 1 }, - { "S62", &Twiss::getSigma, 10, 6, 5, 1 }, - { "S13", &Twiss::getSigma, 10, 6, 0, 2 }, - { "S23", &Twiss::getSigma, 10, 6, 1, 2 }, - { "S33", &Twiss::getSigma, 10, 6, 2, 2 }, - { "S43", &Twiss::getSigma, 10, 6, 3, 2 }, - { "S53", &Twiss::getSigma, 10, 6, 4, 2 }, - { "S63", &Twiss::getSigma, 10, 6, 5, 2 }, - { "S14", &Twiss::getSigma, 10, 6, 0, 3 }, - { "S24", &Twiss::getSigma, 10, 6, 1, 3 }, - { "S34", &Twiss::getSigma, 10, 6, 2, 3 }, - { "S44", &Twiss::getSigma, 10, 6, 3, 3 }, - { "S54", &Twiss::getSigma, 10, 6, 4, 3 }, - { "S64", &Twiss::getSigma, 10, 6, 5, 3 }, - { "S15", &Twiss::getSigma, 10, 6, 0, 4 }, - { "S25", &Twiss::getSigma, 10, 6, 1, 4 }, - { "S35", &Twiss::getSigma, 10, 6, 2, 4 }, - { "S45", &Twiss::getSigma, 10, 6, 3, 4 }, - { "S55", &Twiss::getSigma, 10, 6, 4, 4 }, - { "S65", &Twiss::getSigma, 10, 6, 5, 4 }, - { "S16", &Twiss::getSigma, 10, 6, 0, 5 }, - { "S26", &Twiss::getSigma, 10, 6, 1, 5 }, - { "S36", &Twiss::getSigma, 10, 6, 2, 5 }, - { "S46", &Twiss::getSigma, 10, 6, 3, 5 }, - { "S56", &Twiss::getSigma, 10, 6, 4, 5 }, - { "S66", &Twiss::getSigma, 10, 6, 5, 5 }, - - // Transfer matrix. - { "R11", &Twiss::getMatrix, 10, 6, 0, 0 }, - { "R21", &Twiss::getMatrix, 10, 6, 1, 0 }, - { "R31", &Twiss::getMatrix, 10, 6, 2, 0 }, - { "R41", &Twiss::getMatrix, 10, 6, 3, 0 }, - { "R51", &Twiss::getMatrix, 10, 6, 4, 0 }, - { "R61", &Twiss::getMatrix, 10, 6, 5, 0 }, - { "R12", &Twiss::getMatrix, 10, 6, 0, 1 }, - { "R22", &Twiss::getMatrix, 10, 6, 1, 1 }, - { "R32", &Twiss::getMatrix, 10, 6, 2, 1 }, - { "R42", &Twiss::getMatrix, 10, 6, 3, 1 }, - { "R52", &Twiss::getMatrix, 10, 6, 4, 1 }, - { "R62", &Twiss::getMatrix, 10, 6, 5, 1 }, - { "R13", &Twiss::getMatrix, 10, 6, 0, 2 }, - { "R23", &Twiss::getMatrix, 10, 6, 1, 2 }, - { "R33", &Twiss::getMatrix, 10, 6, 2, 2 }, - { "R43", &Twiss::getMatrix, 10, 6, 3, 2 }, - { "R53", &Twiss::getMatrix, 10, 6, 4, 2 }, - { "R63", &Twiss::getMatrix, 10, 6, 5, 2 }, - { "R14", &Twiss::getMatrix, 10, 6, 0, 3 }, - { "R24", &Twiss::getMatrix, 10, 6, 1, 3 }, - { "R34", &Twiss::getMatrix, 10, 6, 2, 3 }, - { "R44", &Twiss::getMatrix, 10, 6, 3, 3 }, - { "R54", &Twiss::getMatrix, 10, 6, 4, 3 }, - { "R64", &Twiss::getMatrix, 10, 6, 5, 3 }, - { "R15", &Twiss::getMatrix, 10, 6, 0, 4 }, - { "R25", &Twiss::getMatrix, 10, 6, 1, 4 }, - { "R35", &Twiss::getMatrix, 10, 6, 2, 4 }, - { "R45", &Twiss::getMatrix, 10, 6, 3, 4 }, - { "R55", &Twiss::getMatrix, 10, 6, 4, 4 }, - { "R65", &Twiss::getMatrix, 10, 6, 5, 4 }, - { "R16", &Twiss::getMatrix, 10, 6, 0, 5 }, - { "R26", &Twiss::getMatrix, 10, 6, 1, 5 }, - { "R36", &Twiss::getMatrix, 10, 6, 2, 5 }, - { "R46", &Twiss::getMatrix, 10, 6, 3, 5 }, - { "R56", &Twiss::getMatrix, 10, 6, 4, 5 }, - { "R66", &Twiss::getMatrix, 10, 6, 5, 5 }, - - { 0, 0, 0, 0, 0, 0 } - }; - - - // The default column entries table - const ColDesc defaultColumns[] = { - { "S", &Twiss::getS, 14, 6, 0, 0 }, - - { "MUX", &Twiss::getMUi, 10, 6, 0, 0 }, - { "BETX", &Twiss::getBETi, 10, 3, 0, 0 }, - { "ALFX", &Twiss::getALFi, 10, 6, 0, 0 }, - - { "MUY", &Twiss::getMUi, 10, 6, 1, 0 }, - { "BETY", &Twiss::getBETi, 10, 3, 1, 0 }, - { "ALFY", &Twiss::getALFi, 10, 6, 1, 0 }, - - { "XC", &Twiss::getCO, 10, 6, 0, 0 }, - { "YC", &Twiss::getCO, 10, 6, 2, 0 }, - { "DX", &Twiss::getDisp, 10, 6, 0, 0 }, - { "DPX", &Twiss::getDisp, 10, 6, 1, 0 }, - - { 0, 0, 0, 0, 0, 0 } - }; - - - const ColDesc *findCol(const Twiss &table, const std::string &colName) { - for(const ColDesc *col = allColumns; col->colName; ++col) { - if(colName == col->colName) { - return col; - } - } - - throw OpalException("Twiss::findCol()", - "Twiss table \"" + table.getOpalName() + - "\" has no column named \"" + colName + "\"."); - } - - - // Local class Column. - // Returns the value for a given column in the current row of a given - // table. - class Column: public Expressions::Scalar<double> { - - public: - - //: Constructor. - // Identify the table by its name [b]tab[/b], and the column by its - // name [b]col[/b] and the function [b]col[/b]. - // The row is specified as the ``current'' row of the table. - Column(const Twiss &tab, const std::string &colName, const ColDesc &desc); - - Column(const Column &); - virtual ~Column(); - - //: Make clone. - virtual Expressions::Scalar<double> *clone() const; - - //: Evaluate. - virtual double evaluate() const; - - //: Print expression. - virtual void print(std::ostream &os, int precedence = 99) const; - - private: - - // Not implemented. - Column(); - const Column &operator=(const Column &); - - // The Table referred. - const Twiss &itsTable; - - // Column name. - std::string colName; - - // The function returning the column value. - double(Twiss::*get)(const Twiss::Row &, int, int) const; - - // The indices to be transmitted to get(). - int ind_1, ind_2; - }; - - - // Implementation. - // ------------------------------------------------------------------------ - - Column::Column(const Twiss &tab, const std::string &colName, const ColDesc &desc): - itsTable(tab), colName(colName), - get(desc.get), ind_1(desc.ind_1), ind_2(desc.ind_2) - {} - - - Column::Column(const Column &rhs): - Scalar<double>(rhs), - itsTable(rhs.itsTable), colName(rhs.colName), - get(rhs.get), ind_1(rhs.ind_1), ind_2(rhs.ind_2) - {} - - - Column::~Column() - {} - - - Expressions::Scalar<double> *Column::clone() const { - return new Column(*this); - } - - - double Column::evaluate() const { - return (itsTable.*get)(itsTable.getCurrent(), ind_1, ind_2); - } - - - void Column::print(std::ostream &os, int) const { - os << colName; - } - -}; - - -// Class Twiss::Row -// ------------------------------------------------------------------------ - -Twiss::Row::Row(ElementBase *elem, int occur): - FlaggedElmPtr(elem) { - setCounter(occur); -} - - -Twiss::Row::Row(const FlaggedElmPtr &rhs): - FlaggedElmPtr(rhs) -{} - - -Twiss::Row::~Row() -{} - - -const FVector<double, 6> &Twiss::Row::getCO() const { - return orbit; -} - - -const FMatrix<double, 6, 6> &Twiss::Row::getMatrix() const { - return matrix; -} - - -double Twiss::Row::getS() const { - return arc; -} - - -double Twiss::Row::getMUi(int i) const { - return mu[i]; -} - - -// Class Twiss -// ------------------------------------------------------------------------ - -Twiss::Twiss(int size, const char *name, const char *help): - Table(size, name, help), itsTable(0), itsMapper(0) { - itsAttr[LINE] = Attributes::makeString - ("LINE", "The beam line use for filling"); - itsAttr[BEAM] = Attributes::makeString - ("BEAM", "The beam to be used", "UNNAMED_BEAM"); - itsAttr[RANGE] = Attributes::makeRange - ("RANGE", "The range in the lattice"); - itsAttr[STATIC] = Attributes::makeBool - ("STATIC", "If true, the table is not recalculated at each iteration"); - itsAttr[ORDER] = Attributes::makeReal - ("ORDER", "The order of the calculation", 2); - itsAttr[METHOD] = Attributes::makeString - ("METHOD", "the algorithm used for filling:\n" - "\t\t\t\"LINEAR\", \"THIN\", \"THICK\", or \"TRANSPORT\"\n" - "\t\t\tDefault value is \"LINEAR\"", "LINEAR"); - itsAttr[REVBEAM] = Attributes::makeBool - ("REVBEAM", "Set true to run beam backwards through lattice"); - itsAttr[REVTRACK] = Attributes::makeBool - ("REVTRACK", "Set true to track against the beam"); - - // READ ONLY. - itsAttr[BETXMAX] = Attributes::makeReal - ("BETXMAX", "Maximum horizontal beta in m"); - itsAttr[BETXMAX].setReadOnly(true); - - itsAttr[BETYMAX] = Attributes::makeReal - ("BETYMAX", "Maximum vertical beta in m"); - itsAttr[BETYMAX].setReadOnly(true); - - itsAttr[XCMAX] = Attributes::makeReal - ("XCMAX", "Maximum horizontal closed orbit in m"); - itsAttr[XCMAX].setReadOnly(true); - - itsAttr[YCMAX] = Attributes::makeReal - ("YCMAX", "Maximum vertical closed orbit in m"); - itsAttr[YCMAX].setReadOnly(true); - - itsAttr[XCRMS] = Attributes::makeReal - ("XCRMS", "R.m.s. horizontal closed orbit in m"); - itsAttr[XCRMS].setReadOnly(true); - - itsAttr[YCRMS] = Attributes::makeReal - ("YCRMS", "R.m.s. vertical closed orbit in m"); - itsAttr[YCRMS].setReadOnly(true); - - itsAttr[DXMAX] = Attributes::makeReal - ("DXMAX", "Maximum horizontal dispersion in m"); - itsAttr[DXMAX].setReadOnly(true); - - itsAttr[DYMAX] = Attributes::makeReal - ("DYMAX", "Maximum vertical dispersion in m"); - itsAttr[DYMAX].setReadOnly(true); - - itsAttr[DXRMS] = Attributes::makeReal - ("DXRMS", "R.m.s. horizontal dispersion in m"); - itsAttr[DXRMS].setReadOnly(true); - - itsAttr[DYRMS] = Attributes::makeReal - ("DYRMS", "R.m.s. vertical dispersion in m"); - itsAttr[DYRMS].setReadOnly(true); -} - - -Twiss::Twiss(const std::string &name, Twiss *parent): - Table(name, parent), itsTable(new TLine(name)), itsMapper(0) -{} - - -Twiss::~Twiss() { - delete itsTable; - delete itsMapper; -} - -/* -void Twiss::doomPut(DoomWriter &writer) const { - // Write the definition for this table. - Object::doomPut(writer); - - // Make sure the table is up to date. - // Cast away const, to allow logically constant table to update. - const_cast<Twiss *>(this)->fill(); - - // Make the table header. - const std::string &tableName = getOpalName(); - { - static const int headKeyList[] = { 1, TABLE_HEAD }; - DoomWriter headWriter(tableName, headKeyList); - headWriter.setParentName(itsLine); - headWriter.setTypeName("TABLE_HEADER"); - - static const char *columnName[numColumns] = { - "ALFX", "ALFY", "BETX", "BETY", "DPX", "DPY", "DX", "DY", "MUX", "MUY", "S" - }; - static const int columnNumber[numColumns] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 - }; - for(int i = 0; i < numColumns; ++i) { - headWriter.putInt(i, columnNumber[i]); - headWriter.putString(i, columnName[i]); - } - - int numRows = itsTable->size(); - headWriter.putInt(numColumns + 0, 1); // 1 delta value. - headWriter.putInt(numColumns + 1, numRows); // number of rows. - headWriter.putInt(numColumns + 3, 3); // position at end. - // Header object will be written when headWriter goes out of scope. - } - - // Write the table row by row. - { - static const int rowKeyList[] = { 2, TABLE_BODY, 0 }; - DoomWriter rowWriter(tableName, rowKeyList); - rowWriter.setParentName(itsLine); - rowWriter.setTypeName("SUB_TABLE"); - int lineCount = 0; - int realCount = 0; - for(TLine::const_iterator row = begin(); row != end(); ++row) { - rowWriter.putInt(lineCount, row->getCounter()); - rowWriter.putString(lineCount, row->getElement()->getName()); - rowWriter.putReal(realCount + 0, getALFi(*row, 0, 0)); - rowWriter.putReal(realCount + 1, getALFi(*row, 1, 0)); - rowWriter.putReal(realCount + 2, getBETi(*row, 0, 0)); - rowWriter.putReal(realCount + 3, getBETi(*row, 1, 0)); - rowWriter.putReal(realCount + 4, getDisp(*row, 1, 0)); - rowWriter.putReal(realCount + 5, getDisp(*row, 3, 0)); - rowWriter.putReal(realCount + 6, getDisp(*row, 0, 0)); - rowWriter.putReal(realCount + 7, getDisp(*row, 2, 0)); - rowWriter.putReal(realCount + 8, getMUi(*row, 0, 0)); - rowWriter.putReal(realCount + 9, getMUi(*row, 1, 0)); - rowWriter.putReal(realCount + 10, getS(*row, 0, 0)); - lineCount++; - realCount += numColumns; - } - // Body object will be written when rowWriter goes out of scope. - } -} -*/ - -Twiss::TLine::iterator Twiss::begin() { - return itsTable->begin(); -} - - -Twiss::TLine::const_iterator Twiss::begin() const { - return itsTable->begin(); -} - - -Twiss::TLine::iterator Twiss::end() { - return itsTable->end(); -} - - -Twiss::TLine::const_iterator Twiss::end() const { - return itsTable->end(); -} - - -void Twiss::execute() { - //std::cerr << "In Twiss::execute()" << std::endl; - // Find Table definition. - itsLine = Attributes::getString(itsAttr[LINE]); - BeamSequence *use = BeamSequence::find(itsLine); - - // Find Beam data. - const std::string &beamName = Attributes::getString(itsAttr[BEAM]); - beam = Beam::find(beamName); - reference = &beam->getReference(); - - // Get the algorithm name. - std::string method = Attributes::getString(itsAttr[METHOD]); - - // Make sure all is up-to-date. - OpalData::getInstance()->update(); - - // Create flat list with space for data storage. - RangeRep range = Attributes::getRange(itsAttr[RANGE]); - Flatten<Row> flattener(*use->fetchLine(), *itsTable, range); - flattener.execute(); - - if(itsTable->empty() && Options::warn) { - std::cerr << "\n### Warning ### Lattice function table \"" - << getOpalName() << "\" contains no elements.\n" << std::endl; - } else { - itsTable->front().setSelectionFlag(true); - itsTable->back().setSelectionFlag(true); - } - - // Assign the correct mapper. - revBeam = Attributes::getBool(itsAttr[REVBEAM]); - revTrack = Attributes::getBool(itsAttr[REVTRACK]); - revPath = ( revBeam && !revTrack ) || ( !revBeam && revTrack ); - order = int(std::round(Attributes::getReal(itsAttr[ORDER]))); - - if(method == "THICK") { - //std::cerr << " method == \"THICK\"" << std::endl; - itsMapper = new ThickMapper(*itsTable, *reference, revBeam, revTrack); - } else if(method == "THIN") { - //std::cerr << " method == \"THIN\"" << std::endl; - itsMapper = new ThinMapper(*itsTable, *reference, revBeam, revTrack); - } else if(method == "LINEAR") { - //std::cerr << " method == \"LINEAR\"" << std::endl; - itsMapper = new LinearMapper(*itsTable, *reference, revBeam, revTrack); - } else { - throw OpalException("Twiss::execute()", - "Method name \"" + method + "\" is unknown."); - } - - // Fill the table. - fill(); - - // Set static flag. - if(Attributes::getBool(itsAttr[STATIC])) dynamic = false; - printTable(std::cout, getDefault()); - //std::cerr << "Leaving Twiss::execute()" << std::endl; -} - - -double Twiss::getCell(const PlaceRep &place, const std::string &colName) { - Row &row = findRow(place); - const ColDesc *col = findCol(*this, colName); - return (this->*(col->get))(row, col->ind_1, col->ind_2); -} - - -Table::CellArray Twiss::getDefault() const { - CellArray columns; - for(const ColDesc *col = defaultColumns; col->colName; ++col) { - Expressions::PtrToScalar<double> expr = - new Column(*this, col->colName, *col); - columns.push_back(Cell(expr, col->printWidth, col->printPrecision)); - } - return columns; -} - - -std::vector<double> -Twiss::getColumn(const RangeRep &rng, const std::string &colName) { - // Find proper column function. - const ColDesc *col = findCol(*this, colName); - RangeRep range(rng); - range.initialize(); - std::vector<double> column; - - for(TLine::const_iterator row = begin(); row != end(); ++row) { - range.enter(*row); - if(range.isActive()) { - column.push_back((this->*(col->get))(*row, col->ind_1, col->ind_2)); - } - range.leave(*row); - } - - return column; -} - - -const Twiss::Row &Twiss::getCurrent() const { - return *current; -} - - -FMatrix<double, 6, 6> Twiss::getCurlyA() const { - return curly_A; -} - - -FMatrix<double, 6, 6> Twiss::getCurlyA(const Row &row) const { - return row.matrix * curly_A; -} - - -double Twiss::getEX() const { - return beam->getEX(); -} - - -double Twiss::getEY() const { - return beam->getEY(); -} - - -double Twiss::getET() const { - return beam->getET(); -} - - -double Twiss::getLength() { - return itsTable->getElementLength(); -} - - -const Beamline *Twiss::getLine() const { - return itsTable; -} - - -FMatrix<double, 6, 6> Twiss::getMatrix(const Row &row) const { - return row.matrix; -} - - -FVector<double, 6> Twiss::getOrbit(const Row &row) const { - return row.orbit; -} - - -FVector<double, 6> Twiss::getOrbit() const { - return orbit; -} - - -FMatrix<double, 6, 6> Twiss::getSigma(const Row &row) const { - double E1 = getEX(); - double E2 = getEY(); - double E3 = getET(); - const FMatrix<double, 6, 6> &eigen = getCurlyA(row); - FMatrix<double, 6, 6> sigma; - for(int i = 0; i < 6; ++i) { - for(int j = 0; j <= i; ++j) { - sigma[i][j] = sigma[j][i] = - E1 * (eigen[i][0] * eigen[j][0] + eigen[i][1] * eigen[j][1]) + - E2 * (eigen[i][2] * eigen[j][2] + eigen[i][3] * eigen[j][3]) + - E3 * (eigen[i][4] * eigen[j][4] + eigen[i][5] * eigen[j][5]); - } - } - return sigma; -} - - -std::vector<double> -Twiss::getRow(const PlaceRep &pos, const std::vector<std::string> &cols) { - Row &row = findRow(pos); - std::vector<double> result; - - if(cols.empty()) { - // Standard column selection. - for(const ColDesc *col = defaultColumns; col->colName != 0; ++col) { - result.push_back((this->*col->get)(row, col->ind_1, col->ind_2)); - } - } else { - // User column selection. - for(std::vector<std::string>::const_iterator iter = cols.begin(); - iter != cols.end(); ++iter) { - const ColDesc *col = findCol(*this, *iter); - result.push_back((this->*(col->get))(row, col->ind_1, col->ind_2)); - } - } - - return result; -} - - -bool Twiss::isDependent(const std::string &name) const { - // Test if name refers to USE attribute. - if(itsLine == name) return true; - - // Test if name occurs in table. - for(TLine::const_iterator row = begin(); row != end(); ++row) { - if(row->getElement()->getName() == name) return true; - } - - // Otherwise replacement is not required. - return false; -} - - -Expressions::PtrToScalar<double> -Twiss::makeColumnExpression(const std::string &colName) const { - const ColDesc *col = findCol(*this, colName); - return new Column(*this, colName, *col); -} - - -bool Twiss::matches(Table *rhs) const { - return dynamic_cast<Twiss *>(rhs) != 0; -} - - -void Twiss::printTableBody(std::ostream &os, const CellArray &cells) const { - // Find line length. - int lineLength = 16; - for(CellArray::const_iterator cell = cells.begin(); - cell < cells.end(); ++cell) { - lineLength += cell->printWidth; - } - - // Write table header. - os << std::string(lineLength, '-') << '\n'; - os << "Element "; - for(CellArray::const_iterator cell = cells.begin(); - cell < cells.end(); ++cell) { - std::ostringstream ss; - cell->itsExpr->print(ss, 0); - ss << std::ends; - std::string image = ss.str(); - - if(int(image.length()) < cell->printWidth) { - // Right adjust the column header. - os << std::string(cell->printWidth - image.length(), ' ') << image; - } else { - // Truncate the column header. - os << ' ' << std::string(image, 0, cell->printWidth - 3) << ".."; - } - } - os << '\n'; - os << std::string(lineLength, '-') << '\n'; - - // Write table body. - for(current = begin(); current != end(); ++current) { - if(current->getSelectionFlag()) { - std::string name = current->getElement()->getName(); - if(int occur = current->getCounter()) { - std::ostringstream tos; - tos << name << '[' << occur << ']' << std::ends; - name = tos.str(); - } - - if(name.length() > 16) { - // Truncate the element name. - os << std::string(name, 0, 13) << ".. "; - } else { - // Left adjust the element name. - os << name << std::string(16 - name.length(), ' '); - } - - for(CellArray::const_iterator cell = cells.begin(); - cell != cells.end(); ++cell) { - os << std::setw(cell->printWidth) - << std::setprecision(cell->printPrecision) - << cell->itsExpr->evaluate(); - } - os << '\n'; - } - } - - os << std::string(lineLength, '-') << '\n'; -} - - -void Twiss::printTableTitle(std::ostream &os, const char *title) const { - OpalData::getInstance()->printTitle(os); - os << '\n' << title - << ", LINE: " << itsAttr[LINE] - << ", BEAM: " << itsAttr[BEAM] - << ", RANGE: " << itsAttr[RANGE] - << ", METHOD: " << itsAttr[METHOD] - << ", ORDER: " << order << ".\n"; -} - - -// Protected methods. -// ------------------------------------------------------------------------ - -Twiss::Row &Twiss::findRow(const PlaceRep &place) { - PlaceRep row(place); - row.initialize(); - - for(TLine::iterator i = begin(); i != end(); ++i) { - row.enter(*i); - if(row.isActive()) return *i; - row.leave(*i); - } - - std::ostringstream os; - os << row << std::ends; - throw OpalException("Twiss::findRow()", "Row \"" + os.str() + - "\" not found in twiss table \"" + getOpalName() + "\"."); -} - - -void Twiss::put() { - //std::cerr << "==> In Twiss::put()..." << std::endl; - // Initial (final) phase angles. - static const double epsilon = 1.0e-8; - static const LinearFun<double, 6> nrgy = LinearFun<double, 6>::makeVariable(5); - double arc = 0.0; - LinearMap<double, 6> map; - itsMapper->getMap(map); - bool staticQ = (map[5] == map[5][0] + nrgy); - - //std::cerr << " [Twiss::put] map =\n" << map << std::endl; - //std::cerr << " [Twiss::put] curly_A =\n" << curly_A << std::endl; - int imux = 0; - int imuy = 0; - int imut = 0; - double mux = atan2(curly_A[0][1], curly_A[0][0]) / Physics::two_pi; - double muy = atan2(curly_A[2][3], curly_A[2][2]) / Physics::two_pi; - double mut = atan2(curly_A[4][5], curly_A[4][4]) / Physics::two_pi; - //std::cerr << " tunes = (" << mux << ", " << muy << ", " << mut << ")" << std::endl; - - if(revPath) { - //std::cerr << "Twiss::put(): doing reverse path ..." << std::endl; - for(TLine::reverse_iterator row = itsTable->rbegin(); - row != itsTable->rend(); ++row) { - // Store values at end of element to the table. - row->orbit = map.constantTerm(); - row->matrix = map.linearTerms(); - row->arc = arc; - row->mu[0] = mux + double(imux); - row->mu[1] = muy + double(imuy); - row->mu[2] = mut + double(imut); - - // Traverse element. - row->accept(*itsMapper); - - // Update values for beginning of element. - ElementBase &elem = *row->getElement(); - if(! dynamic_cast<Beamline *>(&elem)) { - arc -= elem.getElementLength(); - } - - itsMapper->getMap(map); - double A11 = 0.0; - double A12 = 0.0; - double A33 = 0.0; - double A34 = 0.0; - double A55 = 0.0; - double A56 = 0.0; - FMatrix<double, 6, 6> matrix = map.linearTerms(); - const double *row1 = matrix[0]; - const double *row3 = matrix[2]; - const double *row5 = matrix[4]; - - for(int i = 0; i < 6; ++i) { - A11 += row1[i] * curly_A[i][0]; - A12 += row1[i] * curly_A[i][1]; - A33 += row3[i] * curly_A[i][2]; - A34 += row3[i] * curly_A[i][3]; - A55 += row5[i] * curly_A[i][4]; - A56 += row5[i] * curly_A[i][5]; - } - - double mu = atan2(A12, A11) / Physics::two_pi; - if(mu - epsilon > mux) --imux; - mux = mu; - mu = atan2(A34, A33) / Physics::two_pi; - if(mu - epsilon > muy) --imuy; - muy = mu; - mu = atan2(A56, A55) / Physics::two_pi; - if(mu - epsilon > mut) --imut; - mut = mu; - - // FMatrix<double,6,6> A_scr = map.linearTerms() * curly_A; - // double mu; - // mu = atan2(A_scr[0][1], A_scr[0][0]) / Physics::two_pi; - // if (mu - epsilon > mux) --imux; - // mux = mu; - // mu = atan2(A_scr[2][3], A_scr[2][2]) / Physics::two_pi; - // if (mu - epsilon > muy) --imuy; - // muy = mu; - // mu = atan2(A_scr[4][5], A_scr[4][4]) / Physics::two_pi; - // if (mu - epsilon > mut) --imut; - // mut = mu; - } - - double arc1 = arc; - arc = - arc; - double mux1 = mux + double(imux); - double muy1 = muy + double(imuy); - double mut1 = mut + double(imut); - - // Change arc length and phases to their values from the origin. - for(TLine::iterator row = begin(); row != end(); ++row) { - row->arc -= arc1; - row->mu[0] -= mux1; - row->mu[1] -= muy1; - row->mu[2] -= mut1; - } - } else { - //std::cerr << "Twiss::put(): doing forward path ..." << std::endl; - double arc1 = 0.0; - double mux1 = mux; - double muy1 = muy; - double mut1 = mut; - - if(staticQ) { // reset 'T' component of map - //std::cerr << "Twiss::put(): resetting 'T' component of map ..." << std::endl; - itsMapper->getMap(map); - map[4][0] = 0.0; - itsMapper->setMap(map); - } - - for(TLine::iterator row = begin(); row != end(); ++row) { - // Traverse element. - row->accept(*itsMapper); - - // Update values for end of element. - ElementBase &elem = *row->getElement(); - if(! dynamic_cast<Beamline *>(&elem)) { - arc += elem.getElementLength(); - } - - // Store values at end of element to the table. - itsMapper->getMap(map); - row->orbit = map.constantTerm(); - //std::cerr << "Twiss::put(): row->orbit =\n" << row->orbit << std::endl; - row->matrix = map.linearTerms(); - double A11 = 0.0; - double A12 = 0.0; - double A33 = 0.0; - double A34 = 0.0; - double A55 = 0.0; - double A56 = 0.0; - FMatrix<double, 6, 6> &matrix = row->matrix; - const double *row1 = matrix[0]; - const double *row3 = matrix[2]; - const double *row5 = matrix[4]; - - //std::cerr << " matrix =\n" << matrix << std::endl; - //std::cerr << " curly_A =\n" << curly_A << std::endl; - - for(int i = 0; i < 6; ++i) { - A11 += row1[i] * curly_A[i][0]; - A12 += row1[i] * curly_A[i][1]; - A33 += row3[i] * curly_A[i][2]; - A34 += row3[i] * curly_A[i][3]; - A55 += row5[i] * curly_A[i][4]; - A56 += row5[i] * curly_A[i][5]; - } - - double mu = atan2(A12, A11) / Physics::two_pi; - if(mu + epsilon < mux) ++imux; - mux = mu; - mu = atan2(A34, A33) / Physics::two_pi; - if(mu + epsilon < muy) ++imuy; - muy = mu; - mu = atan2(A56, A55) / Physics::two_pi; - if(mu + epsilon < mut) ++imut; - mut = mu; - - // FMatrix<double,6,6> A_scr = row->matrix * curly_A; - // double mu; - // mu = atan2(A_scr[0][1], A_scr[0][0]) / Physics::two_pi; - // if (mu + epsilon < mux) ++imux; - // mux = mu; - // mu = atan2(A_scr[2][3], A_scr[2][2]) / Physics::two_pi; - // if (mu + epsilon < muy) ++imuy; - // muy = mu; - // mu = atan2(A_scr[4][5], A_scr[4][4]) / Physics::two_pi; - // if (mu + epsilon < mut) ++imut; - // mut = mu; - - row->arc = arc - arc1; - row->mu[0] = mux + double(imux) - mux1; - row->mu[1] = muy + double(imuy) - muy1; - row->mu[2] = mut + double(imut) - mut1; - } - } - - // Compute statistic quantities. - double betxmax = 0.0; - double betymax = 0.0; - double xmax = 0.0; - double ymax = 0.0; - double xrms = 0.0; - double yrms = 0.0; - double dxmax = 0.0; - double dymax = 0.0; - double dxrms = 0.0; - double dyrms = 0.0; - - for(TLine::iterator row = begin(); row != end(); ++row) { - betxmax = std::max(std::abs(getBETi(*row, 0, 0)), betxmax); - betymax = std::max(std::abs(getBETi(*row, 1, 0)), betymax); - double x = getCO(*row, 0, 0); - double y = getCO(*row, 2, 0); - double dx = getDisp(*row, 0, 0); - double dy = getDisp(*row, 2, 0); - xmax = std::max(std::abs(x), xmax); - ymax = std::max(std::abs(y), ymax); - xrms += x * x; - yrms += y * y; - dxmax = std::max(std::abs(dx), dxmax); - dymax = std::max(std::abs(dy), dymax); - dxrms += dx * dx; - dyrms += dy * dy; - } - - double size = itsTable->size(); - Attributes::setReal(itsAttr[BETXMAX], betxmax); - Attributes::setReal(itsAttr[BETYMAX], betymax); - Attributes::setReal(itsAttr[XCMAX], xmax); - Attributes::setReal(itsAttr[YCMAX], ymax); - Attributes::setReal(itsAttr[DXMAX], dxmax); - Attributes::setReal(itsAttr[DYMAX], dymax); - Attributes::setReal(itsAttr[XCRMS], sqrt(xrms / size)); - Attributes::setReal(itsAttr[YCRMS], sqrt(yrms / size)); - Attributes::setReal(itsAttr[DXRMS], sqrt(dxrms / size)); - Attributes::setReal(itsAttr[DYRMS], sqrt(dyrms / size)); - // std::cerr << "==> Leaving Twiss::put()" << std::endl; -} - - -double Twiss::getS(const Twiss::Row &row, int, int) const { - return row.getS(); -} - - -double Twiss::getMUi(const Twiss::Row &row, int i1, int) const { - return row.getMUi(i1); -} - - -double Twiss::getBETi(const Twiss::Row &row, int i1, int) const { - const double *row1 = row.matrix[2*i1]; - const double *row2 = row.matrix[2*i1+1]; - double r11 = 0.0; - double r12 = 0.0; - double r21 = 0.0; - double r22 = 0.0; - - for(int i = 0; i < 6; ++i) { - double t1 = row1[i]; - r11 += t1 * curly_A[i][2*i1]; - r12 += t1 * curly_A[i][2*i1+1]; - double t2 = row2[i]; - r21 += t2 * curly_A[i][2*i1]; - r22 += t2 * curly_A[i][2*i1+1]; - } - - // const FMatrix<double,6,6> eigen = row.matrix * curly_A; - // const double r11 = eigen[2*i1][2*i1]; - // const double r12 = eigen[2*i1][2*i1+1]; - // const double r21 = eigen[2*i1+1][2*i1]; - // const double r22 = eigen[2*i1+1][2*i1+1]; - return (r11 * r11 + r12 * r12) / (r11 * r22 - r12 * r21); -} - - -double Twiss::getALFi(const Twiss::Row &row, int i1, int) const { - const double *row1 = row.matrix[2*i1]; - const double *row2 = row.matrix[2*i1+1]; - double r11 = 0.0; - double r12 = 0.0; - double r21 = 0.0; - double r22 = 0.0; - - for(int i = 0; i < 6; ++i) { - double t1 = row1[i]; - r11 += t1 * curly_A[i][2*i1]; - r12 += t1 * curly_A[i][2*i1+1]; - double t2 = row2[i]; - r21 += t2 * curly_A[i][2*i1]; - r22 += t2 * curly_A[i][2*i1+1]; - } - - // ada Mon Mar 27 23:45:26 CEST 2000 - // const FMatrix<double,6,6> eigen = row.matrix * curly_A; - // const double r11 = eigen[2*i1][2*i1]; - // const double r12 = eigen[2*i1][2*i1+1]; - // const double r21 = eigen[2*i1+1][2*i1]; - // const double r22 = eigen[2*i1+1][2*i1+1]; - return - (r11 * r21 + r12 * r22) / (r11 * r22 - r12 * r21); -} - - -double Twiss::getBETik(const Twiss::Row &row, int i1, int i2) const { - const double *row1 = row.matrix[2*i1]; - double r11 = 0.0; - double r12 = 0.0; - - for(int i = 0; i < 6; ++i) { - double t1 = row1[i]; - r11 += t1 * curly_A[i][2*i2]; - r12 += t1 * curly_A[i][2*i2+1]; - } - - // ada Mon Mar 27 23:45:26 CEST 2000 - // const FMatrix<double,6,6> eigen = row.matrix * curly_A; - // const double r11 = eigen[2*i1][2*i2]; - // const double r12 = eigen[2*i1][2*i2+1]; - return (r11 * r11 + r12 * r12); -} - - -double Twiss::getALFik(const Twiss::Row &row, int i1, int i2) const { - const double *row1 = row.matrix[2*i1]; - const double *row2 = row.matrix[2*i1+1]; - double r11 = 0.0; - double r12 = 0.0; - double r21 = 0.0; - double r22 = 0.0; - - for(int i = 0; i < 6; ++i) { - double t1 = row1[i]; - r11 += t1 * curly_A[i][2*i2]; - r12 += t1 * curly_A[i][2*i2+1]; - double t2 = row2[i]; - r21 += t2 * curly_A[i][2*i2]; - r22 += t2 * curly_A[i][2*i2+1]; - } - - // ada Mon Mar 27 23:45:26 CEST 2000 - // const FMatrix<double,6,6> eigen = row.matrix * curly_A; - // const double r11 = eigen[2*i1][2*i2]; - // const double r12 = eigen[2*i1][2*i2+1]; - // const double r21 = eigen[2*i1+1][2*i2]; - // const double r22 = eigen[2*i1+1][2*i2+1]; - return (r11 * r21 + r12 * r22); -} - - -double Twiss::getGAMik(const Twiss::Row &row, int i1, int i2) const { - const double *row1 = row.matrix[2*i1+1]; - double r21 = 0.0; - double r22 = 0.0; - - for(int i = 0; i < 6; ++i) { - double t1 = row1[i]; - r21 += t1 * curly_A[i][2*i2]; - r22 += t1 * curly_A[i][2*i2+1]; - } - - // ada Mon Mar 27 23:45:26 CEST 2000 - // const FMatrix<double,6,6> eigen = row.matrix * curly_A; - // const double r21 = eigen[2*i1+1][2*i2]; - // const double r22 = eigen[2*i1+1][2*i2+1]; - return (r21 * r21 + r22 * r22); -} - - -double Twiss::getCO(const Twiss::Row &row, int i1, int) const { - return row.getCO()[i1]; -} - - -double Twiss::getDisp(const Twiss::Row &row, int i1, int) const { - // FMatrix<double,6,6> matrix = row.matrix; - const double *row1 = row.matrix[i1]; - double result = 0.0; - - for(int i = 0; i < 6; ++i) { - // result += matrix[i1][i] * curly_A[i][5]; - result += row1[i] * curly_A[i][5]; - } - - return result; -} - - -double Twiss::getEigen(const Twiss::Row &row, int i1, int i2) const { - // FMatrix<double,6,6> matrix = row.matrix; - const double *row1 = row.matrix[i1]; - double result = 0.0; - - for(int i = 0; i < 6; ++i) { - // result += matrix[i1][i] * curly_A[i][i2]; - result += row1[i] * curly_A[i][i2]; - } - - return result; -} - -/* -1334 double Twiss::getEigen(const Twiss::Row &row, int i1, int i2) const -1335 { -1336 FMatrix<double,6,6> matrix = row.matrix; -1337 const double *row1 = row.matrix[i1]; -1338 double result = 0.0; -1339 -1340 for (int i = 0; i < 6; ++i) { -1341 result += matrix[i1][i] * curly_A[i][i2]; -1342 //result += row1[i] * curly_A[i][i2]; -1343 } -1344 -1345 return result; -1346 } -*/ - - - - -double Twiss::getSigma(const Twiss::Row &row, int i1, int i2) const { - const FMatrix<double, 6, 6> eigen = row.matrix * curly_A; - const double E1 = getEX(); - const double E2 = getEY(); - const double E3 = getET(); - return - (E1 * (eigen[i1][0] * eigen[i2][0] + eigen[i1][1] * eigen[i2][1]) + - E2 * (eigen[i1][2] * eigen[i2][2] + eigen[i1][3] * eigen[i2][3]) + - E3 * (eigen[i1][4] * eigen[i2][4] + eigen[i1][5] * eigen[i2][5])); -} - - -double Twiss::getMatrix(const Twiss::Row &row, int i1, int i2) const { - return row.matrix[i1][i2]; -} \ No newline at end of file diff --git a/src/Tables/Twiss.h b/src/Tables/Twiss.h deleted file mode 100644 index d5d67667b2394733821fa8a812b692a76e4eda6b..0000000000000000000000000000000000000000 --- a/src/Tables/Twiss.h +++ /dev/null @@ -1,313 +0,0 @@ -#ifndef OPAL_Twiss_HH -#define OPAL_Twiss_HH - -// ------------------------------------------------------------------------ -// $RCSfile: Twiss.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.2 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: Twiss -// -// ------------------------------------------------------------------------ -// -// $Date: 2001/08/13 15:25:22 $ -// $Author: jowett $ -// -// ------------------------------------------------------------------------ - -#include "AbstractObjects/Table.h" -#include "AbstractObjects/Expressions.h" -#include "Beamlines/FlaggedElmPtr.h" -#include "Beamlines/TBeamline.h" -#include "FixedAlgebra/FMatrix.h" -#include "FixedAlgebra/FVector.h" -#include <iosfwd> -#include <vector> - -class AbstractMapper; -class Beam; -class PartData; -class PlaceRep; -class RangeRep; - - -/// Class Twiss -// ------------------------------------------------------------------------ -/// Abstract base class for table buffers holding lattice function. - -class Twiss: public Table { - - friend class Insertion; - friend class Period; - -public: - - /// Structure for a row of the Twiss table. - class Row: public FlaggedElmPtr { - - friend class Insertion; - friend class Period; - friend class Twiss; - - public: - - Row(ElementBase *, int); - explicit Row(const FlaggedElmPtr &); - ~Row(); - - /// Closed orbit. - const FVector<double, 6> &getCO() const; - - /// Transfer matrix. - const FMatrix<double, 6, 6> &getMatrix() const; - - /// Arc length. - double getS() const; - - /// Phase for mode i. - double getMUi(int i) const; - - private: - - /// The closed orbit after the element. - FVector<double, 6> orbit; - - /// The transfer matrix up to and including the element. - FMatrix<double, 6, 6> matrix; - - /// The accumulated arc length. - double arc; - - /// Phases for the three modes. - double mu[3]; - }; - - // The contained beamline type. - typedef TBeamline<Row> TLine; - - virtual ~Twiss(); - - /// Access to first row. - // Version for constant table. - TLine::const_iterator begin() const; - - /// Access to first row. - // Version for non-constant table. - TLine::iterator begin(); - - /// Access to last row. - // Version for constant table. - TLine::const_iterator end() const; - - /// Access to last row. - // Version for non-constant table. - TLine::iterator end(); - - /// Check validity of the table definition. - virtual void execute(); - - /// Return a selected value in a selected row. - virtual double getCell(const PlaceRep &row, const std::string &col); - - /// Return the default print columns. - virtual CellArray getDefault() const; - - /// Return column [b]col[/b] of this table, limited by [b]range[/b]. - virtual std::vector<double> - getColumn(const RangeRep &range, const std::string &col); - - /// Return current table row in iteration. - const Row &getCurrent() const; - - /// Return emittance for mode 1. - double getEX() const; - - /// Return emittance for mode 2. - double getEY() const; - - /// Return emittance for mode 3. - double getET() const; - - /// Return the length of the table. - virtual double getLength(); - - /// Return embedded CLASSIC beamline. - virtual const Beamline *getLine() const; - - /// Return a table row, possible user-defined. - virtual std::vector<double> - getRow(const PlaceRep &, const std::vector<std::string> &); - - /// Check dependency. - // Return true, if this table depends on the named object. - virtual bool isDependent(const std::string &name) const; - - /// Return column expression. - // Return an expression which denotes a column of the twiss table, - // identified by its name. - virtual Expressions::PtrToScalar<double> - makeColumnExpression(const std::string &colName) const; - - /// Check compatibility. - // True, if [b]rhs[/b] is derived from [b]Twiss[/b]. - virtual bool matches(Table *rhs) const; - - /// Print the body to this TWISS table. - void printTableBody(std::ostream &, const CellArray &) const; - - /// Print standard information about the TWISS table. - void printTableTitle(std::ostream &, const char *title) const; - - // Access to items in the table. - // ---------------------------------------------------------------------- - /// Return initial curly A matrix. - FMatrix<double, 6, 6> getCurlyA() const; - - /// Curly A map for given row. - FMatrix<double, 6, 6> getCurlyA(const Row &) const; - - /// Accumulated transfer map. - FMatrix<double, 6, 6> getMatrix(const Row &) const; - - /// Return initial closed orbit. - FVector<double, 6> getOrbit() const; - - /// Get orbit in given row. - FVector<double, 6> getOrbit(const Row &) const; - - /// Initial envelope (Sigma) matrix. - FMatrix<double, 6, 6> getSigma() const; - - /// Envelope (Sigma) matrix for given row. - FMatrix<double, 6, 6> getSigma(const Row &) const; - - - /// Arc length for given row. - double getS(const Row &, int = 0, int = 0) const; - - /// Three modes, "naive" Twiss functions. - // Index (0 ... 2) is mode. - double getMUi(const Row &, int i1, int = 0) const; - double getBETi(const Row &, int i1, int = 0) const; - double getALFi(const Row &, int i1, int = 0) const; - - /// Mais-Ripken beta functions. - // First index (0 ... 2) is plane, second index (0 ... 2) is mode. - double getBETik(const Row &, int i1, int i2) const; - - /// Mais-Ripken alpha functions. - // First index (0 ... 2) is plane, second index (0 ... 2) is mode. - double getALFik(const Row &, int i1, int i2) const; - - /// Mais-Ripken gamma functions. - // First index (0 ... 2) is plane, second index (0 ... 2) is mode. - double getGAMik(const Row &, int i1, int i2) const; - - /// Closed orbit. - // Index (0 ... 5) is plane. - double getCO(const Row &, int i1, int = 0) const; - - /// Dispersion. - // Index (0 ... 5) is plane. - double getDisp(const Row &, int i1, int = 0) const; - - /// Eigenvectors. - // First index (0 ... 5) is plane, second index (0 ... 5) is column. - double getEigen(const Row &, int i1, int i2) const; - - /// Sigma matrix. - // Both indices (0 ... 5) refer to planes. - double getSigma(const Row &, int i1, int i2) const; - - /// Transfer matrix. - // First index (0 ... 5) is row, second index (0 ... 5) is column. - double getMatrix(const Row &, int i1, int i2) const; - -protected: - - /// The common attributes for all objects having the "TWISS" interface. - // Must be accessible to classes Insertion and Period. - enum { - // User-definable attributes: - LINE, // The beam line for the table, - BEAM, // The beam to be used. - RANGE, // The range in the lattice. - ORDER, // The order for the calculation. - STATIC, // The flag for suppressing recalculation. - METHOD, // the algorithm for filling - REVBEAM, // If true, beam runs backwrads. - REVTRACK, // If true, track lattice functions against the beam. - - // Read-only attributes: - BETXMAX, // Maximum beta functions - BETYMAX, - XCMAX, // Maximum closed orbit excursion - YCMAX, - XCRMS, // R.M.S. closed orbit excursion - YCRMS, - DXMAX, // Maximum dispersion - DYMAX, - DXRMS, // R.M.S. dispersion - DYRMS, - SIZE - }; - - /// Exemplar constructor. - Twiss(int size, const char *name, const char *help); - - /// Clone constructor. - Twiss(const std::string &name, Twiss *parent); - - - /// Number of table columns. - static const int numColumns = 11; - - /// The initial closed orbit. - FVector<double, 6> orbit; - - /// The initial curly A matrix. - FMatrix<double, 6, 6> curly_A; - -private: - - // Not implemented. - Twiss(const Twiss &); - void operator=(const Twiss &); - - // Return the table row. - Row &findRow(const PlaceRep &row); - - // This method is called to fill the table after initialising. - void put(); - - // Access to current table row. - mutable TLine::const_iterator current; - - // The table contents. - TLine *itsTable; - - // Pointer to the filling algorithm. - AbstractMapper *itsMapper; - - // The attached beam. - const Beam *beam; - - // The particle reference data. - const PartData *reference; - - // The truncation order (1 for LINEAR, 2 for all other). - int order; - - // The direction flags. - bool revBeam; // true, if beam runs from right (s=C) to left (s=0). - bool revTrack; // true, if tracking against the beam. - bool revPath; // true, if tracking from right (s=C) to left (s=0). - - // The name of the analysed line. - std::string itsLine; -}; - -#endif // OPAL_Twiss_HH diff --git a/src/Track/CMakeLists.txt b/src/Track/CMakeLists.txt index 770840dac0afd22a0f9d9daf605bff8fb2f3d16c..eee07c0e5442ebec25fb9039dd01a08d6eb6129d 100644 --- a/src/Track/CMakeLists.txt +++ b/src/Track/CMakeLists.txt @@ -4,8 +4,6 @@ set (_SRCS TrackEnd.cpp TrackParser.cpp TrackRun.cpp - TrackSave.cpp - TrackStart.cpp ) include_directories ( @@ -20,8 +18,6 @@ set (HDRS Track.h TrackParser.h TrackRun.h - TrackSave.h - TrackStart.h ) install (FILES ${HDRS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/Track") diff --git a/src/Track/TrackParser.cpp b/src/Track/TrackParser.cpp index b0691849b44173b26576ff346b43b751d068440b..ab7117679e06fde20f2d45287a7544f2d37df926 100644 --- a/src/Track/TrackParser.cpp +++ b/src/Track/TrackParser.cpp @@ -1,39 +1,31 @@ -// ------------------------------------------------------------------------ -// $RCSfile: TrackParser.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: TrackParser -// The parser class for the OPAL tracking module. +// Class TrackParser +// The parser class used by the OPAL tracking module. +// As long as control remains in this class, OPAL recognizes only the +// commands allowed in tracking mode. Thus this parser has its own +// command directory with a find() method which is used to find commands. // -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2000/03/27 09:33:46 $ -// $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/>. // -// ------------------------------------------------------------------------ - #include "Track/TrackParser.h" #include "Track/TrackEnd.h" #include "Track/TrackRun.h" -#include "Track/TrackSave.h" -#include "Track/TrackStart.h" - - -// Class TrackParser -// ------------------------------------------------------------------------ - TrackParser::TrackParser(): trackDirectory() { trackDirectory.insert("ENDTRACK", new TrackEnd()); - //trackDirectory.insert("NOISE", new TrackNoise()); trackDirectory.insert("RUN", new TrackRun()); - trackDirectory.insert("TSAVE", new TrackSave()); - trackDirectory.insert("START", new TrackStart()); } diff --git a/src/Track/TrackParser.h b/src/Track/TrackParser.h index a3fa45fc52dcd33e48dc9c4ed3422fc9aa16ae2e..46df4303697552664ca662f2d0d278edeec42dac 100644 --- a/src/Track/TrackParser.h +++ b/src/Track/TrackParser.h @@ -1,34 +1,30 @@ -#ifndef OPAL_TrackParser_HH -#define OPAL_TrackParser_HH - -// ------------------------------------------------------------------------ -// $RCSfile: TrackParser.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: TrackParser +// Class TrackParser +// The parser class used by the OPAL tracking module. +// As long as control remains in this class, OPAL recognizes only the +// commands allowed in tracking mode. Thus this parser has its own +// command directory with a find() method which is used to find commands. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// ------------------------------------------------------------------------ +// This file is part of OPAL. // -// $Date: 2000/03/27 09:33:47 $ -// $Author: Andreas Adelmann $ +// 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_TrackParser_HH +#define OPAL_TrackParser_HH #include "OpalParser/OpalParser.h" #include "AbstractObjects/Directory.h" -// Class TrackParser -// ------------------------------------------------------------------------ -/// The parser class used by the OPAL tracking module. -// As long as control remains in this class, OPAL recognizes only the -// commands allowed in tracking mode. Thus this parser has its own -// command directory with a find() method which is used to find commands. - class TrackParser: public OpalParser { public: diff --git a/src/Track/TrackRun.cpp b/src/Track/TrackRun.cpp index d93931e3d0bd6ef7e9489b36f88a605cc2a8d932..fc046a22974beb346340e05494acf6a561010e17 100644 --- a/src/Track/TrackRun.cpp +++ b/src/Track/TrackRun.cpp @@ -1,32 +1,29 @@ -// ----------------------------------------------------------------------- -// /*$RCSfile*/: TrackRun.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1.4.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: TrackRun -// The class for the OPAL RUN command. +// Class TrackRun +// The RUN command. // -// ------------------------------------------------------------------------ +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// $Date: 2004/11/12 20:10:11 $ -// $Author: 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/>. // -// ------------------------------------------------------------------------ - #include "Track/TrackRun.h" #include "AbstractObjects/BeamSequence.h" #include "AbstractObjects/OpalData.h" #include "AbstractObjects/ObjectFunction.h" #include "Algorithms/Tracker.h" -#include "Algorithms/ThinTracker.h" #include "Algorithms/ThickTracker.h" #include "Algorithms/ParallelTTracker.h" #include "Algorithms/ParallelCyclotronTracker.h" -#include "Algorithms/NilTracker.h" #include "Attributes/Attributes.h" #include "Beamlines/TBeamline.h" @@ -53,8 +50,6 @@ extern Inform *gmsg; -// ------------------------------------------------------------------------ - namespace { // The attributes of class TrackRun. @@ -173,12 +168,7 @@ void TrackRun::execute() { // Get algorithm to use. std::string method = Attributes::getString(itsAttr[METHOD]); - if(method == "THIN") { - *gmsg << " Method == \"THIN\"" << endl; - itsTracker = new ThinTracker(*Track::block->use->fetchLine(), - Track::block->bunch, Track::block->reference, - false, false); - } else if(method == "THICK") { + if (method == "THICK") { setupThickTracker(); } else if(method == "PARALLEL-T" || method == "OPAL-T") { setupTTracker(); diff --git a/src/Track/TrackRun.h b/src/Track/TrackRun.h index c1d972b6ec7bd66e1306ffb482a02ea6261f90ca..c27f0d33972de676fa3f40b616a59c2bf10f0728 100644 --- a/src/Track/TrackRun.h +++ b/src/Track/TrackRun.h @@ -1,22 +1,22 @@ -#ifndef OPAL_TrackRun_HH -#define OPAL_TrackRun_HH - -// ------------------------------------------------------------------------ -// $RCSfile: TrackRun.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1.4.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ // -// Class: TrackRun +// Class TrackRun +// The RUN command. +// +// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// All rights reserved // -// ------------------------------------------------------------------------ +// This file is part of OPAL. // -// $Date: 2004/11/12 20:10:12 $ -// $Author: adelmann $ +// 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_TrackRun_HH +#define OPAL_TrackRun_HH #include "AbstractObjects/Action.h" @@ -32,10 +32,6 @@ class ParallelTTracker; class FieldSolver; class H5PartWrapper; -// Class TrackRun -// ------------------------------------------------------------------------ -/// The RUN command. - class TrackRun: public Action { public: diff --git a/src/Track/TrackSave.cpp b/src/Track/TrackSave.cpp deleted file mode 100644 index 09fcd26e303592ca9123122d4062831a32d55d20..0000000000000000000000000000000000000000 --- a/src/Track/TrackSave.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: TrackSave.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: TrackSave -// The class for the OPAL TSAVE command. -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:47 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Track/TrackSave.h" -#include "Algorithms/PartBunchBase.h" -#include "Attributes/Attributes.h" -#include "Track/Track.h" -#include "Utilities/OpalException.h" -#include <fstream> -#include <iomanip> - - -// Class TrackSave -// ------------------------------------------------------------------------ - - -TrackSave::TrackSave(): - Action(1, "TSAVE", - "The \"TSAVE\" sub-command saves the defined particles " - "on the given file.") { - itsAttr[0] = Attributes::makeString - ("FILE", "Name of file to be written", "TRACKSAVE"); - - registerOwnership(AttributeHandler::SUB_COMMAND); -} - - -TrackSave::TrackSave(const std::string &name, TrackSave *parent): - Action(name, parent) -{} - - -TrackSave::~TrackSave() -{} - - -TrackSave *TrackSave::clone(const std::string &name) { - return new TrackSave(name, this); -} - - -void TrackSave::execute() { - // open output file. - std::string file = Attributes::getString(itsAttr[0]); - std::ofstream os(file.c_str()); - - if(os.bad()) { - throw OpalException("TrackSave::execute()", - "Unable to open output file \"" + file + "\"."); - } - - os << "\nSaved particle positions:\n"; - std::streamsize old_prec = os.precision(8); - os.setf(std::ios::fixed, std::ios::floatfield); - PartBunchBase<double, 3> *bunch = Track::block->bunch; - - for(unsigned int i = 0; i < bunch->getLocalNum(); i++) { - OpalParticle part = bunch->get_part(i); - os << part.x() << ' ' << part.px() << ' ' - << part.y() << ' ' << part.py() << ' ' - << part.t() << ' ' << part.pt() << '\n'; - } - - os << std::flush; - os.precision(old_prec); - os.setf(std::ios::fixed, std::ios::floatfield); -} \ No newline at end of file diff --git a/src/Track/TrackSave.h b/src/Track/TrackSave.h deleted file mode 100644 index 60b48fa90cb11c8f21e85dbeca388e9de95f5c39..0000000000000000000000000000000000000000 --- a/src/Track/TrackSave.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef OPAL_TrackSave_HH -#define OPAL_TrackSave_HH - -// ------------------------------------------------------------------------ -// $RCSfile: TrackSave.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: TrackSave -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:47 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "AbstractObjects/Action.h" - - -// Class TrackSave -// ------------------------------------------------------------------------ -/// The TSAVE command. - -class TrackSave: public Action { - -public: - - /// Exemplar constructor. - TrackSave(); - - virtual ~TrackSave(); - - /// Make clone. - virtual TrackSave *clone(const std::string &name); - - /// Execute the command. - virtual void execute(); - -private: - - // Not implemented. - TrackSave(const TrackSave &); - void operator=(const TrackSave &); - - // Clone constructor. - TrackSave(const std::string &name, TrackSave *parent); -}; - -#endif // OPAL_TrackSave_HH diff --git a/src/Track/TrackStart.cpp b/src/Track/TrackStart.cpp deleted file mode 100644 index e7c1c8e2bc4cc11630b4a99a3ad34e36392977d8..0000000000000000000000000000000000000000 --- a/src/Track/TrackStart.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// ------------------------------------------------------------------------ -// $RCSfile: TrackStart.cpp,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: TrackStart -// The class for the OPAL START command. -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:47 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "Track/TrackStart.h" -#include "Attributes/Attributes.h" -#include "Track/Track.h" -#include "Algorithms/PartBunchBase.h" - - -// Class TrackStart -// ------------------------------------------------------------------------ - -// The attributes of class TrackStart. -namespace { - enum { - X, // The initial horizontal position in m. - Y, // The initial vertical position in m. - T, // The initial longitudinal position in m. - PX, // The initial horizontal momentum in rad. - PY, // The initial vertical momentum in rad. - PT, // The initial longitudinal momentum in rad. - SIZE - }; -} - - -TrackStart::TrackStart(): - Action(SIZE, "START", - "The \"START\" sub-command defines one particle for tracking " - "through the given lattice.") { - itsAttr[X] = Attributes::makeReal - ("X", "Initial horizontal position in m"); - itsAttr[PX] = Attributes::makeReal - ("PX", "Initial horizontal momentum in 1"); - itsAttr[Y] = Attributes::makeReal - ("Y", "Initial horizontal position in m"); - itsAttr[PY] = Attributes::makeReal - ("PY", "Initial horizontal momentum in 1"); - itsAttr[T] = Attributes::makeReal - ("T", "Initial horizontal position in m"); - itsAttr[PT] = Attributes::makeReal - ("PT", "Initial horizontal momentum in 1"); - - registerOwnership(AttributeHandler::SUB_COMMAND); -} - - -TrackStart::TrackStart(const std::string &name, TrackStart *parent): - Action(name, parent) -{} - - -TrackStart::~TrackStart() -{} - - -TrackStart *TrackStart::clone(const std::string &name) { - return new TrackStart(name, this); -} - - -void TrackStart::execute() { - double x = Attributes::getReal(itsAttr[X]); - double y = Attributes::getReal(itsAttr[Y]); - double t = Attributes::getReal(itsAttr[T]); - double px = Attributes::getReal(itsAttr[PX]); - double py = Attributes::getReal(itsAttr[PY]); - double pt = Attributes::getReal(itsAttr[PT]); - Track::block->bunch->push_back(OpalParticle(x, px, y, py, t, pt)); -} \ No newline at end of file diff --git a/src/Track/TrackStart.h b/src/Track/TrackStart.h deleted file mode 100644 index a98251b5c4376ec037b100939f9de2cd00a5d23f..0000000000000000000000000000000000000000 --- a/src/Track/TrackStart.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef OPAL_TrackStart_HH -#define OPAL_TrackStart_HH - -// ------------------------------------------------------------------------ -// $RCSfile: TrackStart.h,v $ -// ------------------------------------------------------------------------ -// $Revision: 1.1.1.1 $ -// ------------------------------------------------------------------------ -// Copyright: see Copyright.readme -// ------------------------------------------------------------------------ -// -// Class: TrackStart -// -// ------------------------------------------------------------------------ -// -// $Date: 2000/03/27 09:33:47 $ -// $Author: Andreas Adelmann $ -// -// ------------------------------------------------------------------------ - -#include "AbstractObjects/Action.h" - - -// Class TrackStart -// ------------------------------------------------------------------------ -/// The START command. - -class TrackStart: public Action { - -public: - - /// Exemplar constructor. - TrackStart(); - - virtual ~TrackStart(); - - /// Make clone. - virtual TrackStart *clone(const std::string &name); - - /// Execute the command. - virtual void execute(); - -private: - - // Not implemented. - TrackStart(const TrackStart &); - void operator=(const TrackStart &); - - // Clone constructor. - TrackStart(const std::string &name, TrackStart *parent); -}; - -#endif // OPAL_TrackStart_HH