Commit a447198d authored by kraus's avatar kraus

cleaning up

parent afafd7d1
//
// 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"
......
//
// 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
......
//
// 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();
......
//
// 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
......
......@@ -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.
......
......@@ -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.
......
......@@ -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;
}
......
......@@ -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;
};
......
//
// 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
......
//
// 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment