diff --git a/src/Algorithms/CavityAutophaser.cpp b/src/Algorithms/CavityAutophaser.cpp index a73c317d55496f12b3ff32337aec2faab9c7949c..818e2b8157338ceb77f1432d796a2b95ee394dec 100644 --- a/src/Algorithms/CavityAutophaser.cpp +++ b/src/Algorithms/CavityAutophaser.cpp @@ -1,3 +1,24 @@ +// +// Class CavityAutophaser +// +// This class determines the phase of an RF cavity for which the reference particle +// is accelerated to the highest energy. +// +// Copyright (c) 2016, Christof Metzger-Kraus, Helmholtz-Zentrum Berlin, Germany +// 2017 - 2020 Christof Metzger-Kraus +// +// 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/CavityAutophaser.h" #include "Algorithms/Vektor.h" #include "AbsBeamline/RFCavity.h" diff --git a/src/Algorithms/CavityAutophaser.h b/src/Algorithms/CavityAutophaser.h index 7d40c57479d60f32e87722dd7285a7eac9ded521..01aea29e6e7d466d7721b5d28b1b523d85babd9b 100644 --- a/src/Algorithms/CavityAutophaser.h +++ b/src/Algorithms/CavityAutophaser.h @@ -1,3 +1,24 @@ +// +// Class CavityAutophaser +// +// This class determines the phase of an RF cavity for which the reference particle +// is accelerated to the highest energy. +// +// Copyright (c) 2016, Christof Metzger-Kraus, Helmholtz-Zentrum Berlin, Germany +// 2017 - 2020 Christof Metzger-Kraus +// +// 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 CAVITYAUTOPHASER #define CAVITYAUTOPHASER diff --git a/src/Algorithms/OrbitThreader.cpp b/src/Algorithms/OrbitThreader.cpp index 400671ea8352e64a2262a0386df43b399bbc105a..a1a8e5f67befb81d0ffffef5f5e5112dd085e883 100644 --- a/src/Algorithms/OrbitThreader.cpp +++ b/src/Algorithms/OrbitThreader.cpp @@ -1,3 +1,25 @@ +// +// Class OrbitThreader +// +// This class determines the design path by tracking the reference particle through +// the 3D lattice. +// +// Copyright (c) 2016, Christof Metzger-Kraus, Helmholtz-Zentrum Berlin, Germany +// 2017 - 2020 Christof Metzger-Kraus +// +// 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/OrbitThreader.h" #include "Algorithms/CavityAutophaser.h" @@ -410,14 +432,7 @@ double OrbitThreader::computeDriftLengthToBoundingBox(const std::set<std::shared if (elements.empty() || (elements.size() == 1 && (*elements.begin())->getType() == ElementBase::ElementType::DRIFT)) { boost::optional<Vector_t> intersectionPoint = globalBoundingBox_m.getPointOfIntersection(position, direction); - double maxDrift = intersectionPoint ? euclidean_norm(intersectionPoint.get() - position): 10.0; - if (intersectionPoint) { - std::ofstream traj("trajectories.gpl", std::ios::app); - traj << position(0) << "\t" << position(1) << "\t" << position(2) << std::endl; - traj << intersectionPoint.get()(0) << "\t" << intersectionPoint.get()(1) << "\t" << intersectionPoint.get()(2) << std::endl; - traj << std::endl; - } - return maxDrift; + return intersectionPoint ? euclidean_norm(intersectionPoint.get() - position): 10.0; } return std::numeric_limits<double>::max(); diff --git a/src/Algorithms/OrbitThreader.h b/src/Algorithms/OrbitThreader.h index c56b4a7a4b9feca0ffeaf993d68b9caab65c1842..72d9407e7ffce7234dce9091f8e5531ba4fadd2c 100644 --- a/src/Algorithms/OrbitThreader.h +++ b/src/Algorithms/OrbitThreader.h @@ -1,3 +1,24 @@ +// +// Class OrbitThreader +// +// This class determines the design path by tracking the reference particle through +// the 3D lattice. +// +// Copyright (c) 2016, Christof Metzger-Kraus, Helmholtz-Zentrum Berlin, Germany +// 2017 - 2020 Christof Metzger-Kraus +// +// 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_ORBITTHREADER_H #define OPAL_ORBITTHREADER_H diff --git a/src/Algorithms/ParallelTTracker.cpp b/src/Algorithms/ParallelTTracker.cpp index 0d4c4abd6343cbcb0d311853c68b22bce318ceb3..7c55f788876ef10fb4e88c8a48b0a1dbfcc2e1a5 100644 --- a/src/Algorithms/ParallelTTracker.cpp +++ b/src/Algorithms/ParallelTTracker.cpp @@ -4,7 +4,9 @@ // The visitor class for tracking particles with time as independent // variable. // -// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// Copyright (c) 200x - 2014, Christof Kraus, Paul Scherrer Institut, Villigen PSI, Switzerland +// 2015 - 2016, Christof Metzger-Kraus, Helmholtz-Zentrum Berlin, Germany +// 2017 - 2020, Christof Metzger-Kraus // All rights reserved // // This file is part of OPAL. diff --git a/src/Algorithms/ParallelTTracker.h b/src/Algorithms/ParallelTTracker.h index 52085d88bcdfd6eef964583549b423fa48d379d2..8db9a7e9b0535bc0ba2d4ab3eb6d08b65eda84cd 100644 --- a/src/Algorithms/ParallelTTracker.h +++ b/src/Algorithms/ParallelTTracker.h @@ -4,7 +4,9 @@ // The visitor class for tracking particles with time as independent // variable. // -// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland +// Copyright (c) 200x - 2014, Christof Kraus, Paul Scherrer Institut, Villigen PSI, Switzerland +// 2015 - 2016, Christof Metzger-Kraus, Helmholtz-Zentrum Berlin, Germany +// 2017 - 2020, Christof Metzger-Kraus // All rights reserved // // This file is part of OPAL. diff --git a/src/Classic/AbsBeamline/ElementBase.cpp b/src/Classic/AbsBeamline/ElementBase.cpp index 2e7336b231c0a850b43e56f691ffefad2c36e6f4..2582d9b2b96fa0f972910adb41bcbbc25fa173ff 100644 --- a/src/Classic/AbsBeamline/ElementBase.cpp +++ b/src/Classic/AbsBeamline/ElementBase.cpp @@ -352,35 +352,22 @@ ElementBase::BoundingBox::getPointOfIntersection(const Vector_t & position, Vector_t relativePosition = lowerLeftCorner - position; Vector_t diagonal = upperRightCorner - lowerLeftCorner; Vector_t normalizedDirection = direction / euclidean_norm(direction); - // *gmsg << "position: " << position << "\n" - // << "normalizedDirection: " << normalizedDirection << "\n" - // << "lowerLeftCorner: " << lowerLeftCorner << "\n" - // << "upperRightCorner: " << upperRightCorner << "\n" - // << "diagonal: " << diagonal << endl; - for (int i = -1; i < 2; i += 2) { + for (int i : {-1, 1}) { for (unsigned int d = 0; d < 3; ++ d) { double projectedDirection = normalizedDirection[d]; - // *gmsg << "\n" << "projectedDirection: " << projectedDirection << "\n"; if (std::abs(projectedDirection) < 1e-10) { continue; } double distanceNearestPoint = relativePosition[d]; double tau = distanceNearestPoint / projectedDirection; - // *gmsg << "distanceNearestPoint: " << distanceNearestPoint << "\n" - // << "relativePosition: " << relativePosition << "\n" - // << "tau: " << tau << "\n"; if (tau < 0) { continue; } Vector_t delta = tau * normalizedDirection; Vector_t relativeIntersectionPoint = i * (relativePosition - delta); - // *gmsg << "delta: " << delta << "\n" - // << "relativeIntersectionPoint: " << relativeIntersectionPoint << endl; - - // *gmsg << sign * intersectionPoint[(d + 1) % 3] << "\t" << sign * relativeIntersectionPoint[(d + 2) % 3] << "\t"; if (relativeIntersectionPoint[(d + 1) % 3] < 0.0 || relativeIntersectionPoint[(d + 1) % 3] > diagonal[(d + 1) % 3] || relativeIntersectionPoint[(d + 2) % 3] < 0.0 || @@ -392,7 +379,7 @@ ElementBase::BoundingBox::getPointOfIntersection(const Vector_t & position, } relativePosition = upperRightCorner - position; } - // *gmsg << endl; + return boost::none; } diff --git a/src/Classic/AbsBeamline/ElementBase.h b/src/Classic/AbsBeamline/ElementBase.h index 4c3f6d50ca2e45c0fcb3c7decfb24d15fbab692b..2a8d5da5c63915b7af821dba7d89702a34b9499e 100644 --- a/src/Classic/AbsBeamline/ElementBase.h +++ b/src/Classic/AbsBeamline/ElementBase.h @@ -82,11 +82,6 @@ class Channel; class ConstChannel; class ElementImage; -struct BoundaryBox { - Vector_t lowerLeftEdge; - Vector_t upperRightEdge; -}; - class ParticleMatterInteractionHandler; class WakeFunction; @@ -373,6 +368,15 @@ public: } bool isInside(const Vector_t &) const; + + /*! Computes the intersection point between a bounding box and the ray which + * has the direction 'direction' and starts at the position 'position'. If + * the position is inside the box then the algorithm should find an inter- + * section point should be found. + * + * @param position the position where the ray starts + * @param direction the direction of the ray + */ boost::optional<Vector_t> getPointOfIntersection(const Vector_t & position, const Vector_t & direction) const; }; diff --git a/src/Classic/Fields/Astra1DDynamic_fast.cpp b/src/Classic/Fields/Astra1DDynamic_fast.cpp index dc57e81a44bfbbbee56d829cfd5cf808909a8ae8..738e81cabcd2af9feb76c81cd32c6841c7ff8f57 100644 --- a/src/Classic/Fields/Astra1DDynamic_fast.cpp +++ b/src/Classic/Fields/Astra1DDynamic_fast.cpp @@ -1,3 +1,24 @@ +// +// Class Astra1DDynamic_fast +// +// This class provides a reader for Astra style field maps. It pre-computes the field +// on a lattice to increase the performance during simulation. +// +// Copyright (c) 2016, Christof Metzger-Kraus, Helmholtz-Zentrum Berlin, Germany +// 2017 - 2020 Christof Metzger-Kraus +// +// 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 "Fields/Astra1DDynamic_fast.h" #include "Utilities/GeneralClassicException.h" #include "Utilities/Util.h" @@ -7,7 +28,6 @@ #include <fstream> #include <ios> -extern Inform *gmsg; Astra1DDynamic_fast::Astra1DDynamic_fast(std::string aFilename): Astra1D_fast(aFilename) { @@ -91,7 +111,7 @@ bool Astra1DDynamic_fast::getFieldstrength(const Vector_t &R, Vector_t &E, Vecto ezpp = gsl_spline_eval(onAxisInterpolants_m[2], R(2) - zbegin_m, onAxisAccel_m[2]); ezppp = gsl_spline_eval(onAxisInterpolants_m[3], R(2) - zbegin_m, onAxisAccel_m[3]); } catch (OpalException const& e) { - throw OpalException("Astra1DDynamice_fast::getFieldstrength", + throw OpalException("Astra1DDynamic_fast::getFieldstrength", "The requested interpolation point, " + std::to_string(R(2)) + " is out of range"); } // expand the field off-axis diff --git a/src/Classic/Fields/Astra1DDynamic_fast.h b/src/Classic/Fields/Astra1DDynamic_fast.h index 52dc68b19a9b3ee82a487384753d19743dacc10e..c00fed089cc792cbba4516a021728273442a6b71 100644 --- a/src/Classic/Fields/Astra1DDynamic_fast.h +++ b/src/Classic/Fields/Astra1DDynamic_fast.h @@ -1,3 +1,24 @@ +// +// Class Astra1DDynamic_fast +// +// This class provides a reader for Astra style field maps. It pre-computes the field +// on a lattice to increase the performance during simulation. +// +// Copyright (c) 2016, Christof Metzger-Kraus, Helmholtz-Zentrum Berlin, Germany +// 2017 - 2020 Christof Metzger-Kraus +// +// 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_AstraFIELDMAP1DDYNAMICFAST_HH #define CLASSIC_AstraFIELDMAP1DDYNAMICFAST_HH