Commit aeb3e26a authored by gsell's avatar gsell

Merge branch 'master' of gitorious.psi.ch:opal/src

parents 18f1b1c5 b4728120
......@@ -43,15 +43,6 @@ else ()
message (STATUS "Unknown C++ compiler. Please use the GNU or Intel compiler, IF you are having problems.")
endif ()
#FIND_PACKAGE (IPPL REQUIRED HINTS $ENV{IPPL_PREFIX} $ENV{IPPL_DIR} $ENV{IPPL})
#MESSAGE (STATUS "Found IPPL library: ${IPPL_LIBRARY}")
#MESSAGE (STATUS "Found IPPL include dir: ${IPPL_INCLUDE_DIR}")
SET(IPPL_CMAKE_CXX_FLAGS "-DIPPL_LINUX -DIPPL_STRINGSTREAM -std=c++1y -DIPPL_MPI -DMPICH_SKIP_MPICXX -DIPPL_GCC -DIPPL_DONT_POOL -DIPPL_USE_XDIV_RNG -DIPPL_NO_STRINGSTREAM -DPETE_BITWISE_COPY -DIPPL_HAS_TEMPLATED_COMPLEX -DIPPL_USE_STANDARD_HEADERS -DIPPL_USE_PARTIAL_SPECIALIZATION -DIPPL_STDSTL -DIPPL_LONGLONG -DWITH_BRICK -DnoCOMP_GNUOLD -Drestrict=__restrict__ -DNOCTAssert ")
set (IPPL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ippl/src")
set (IPPL_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ippl/src")
set (IPPL_LIBRARY "ippl")
FIND_PACKAGE (H5Hut REQUIRED)
FIND_PACKAGE (HDF5 REQUIRED)
FIND_PACKAGE (GSL REQUIRED)
......@@ -60,7 +51,7 @@ set (BOOSTROOT $ENV{BOOST_DIR})
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package (Boost 1.55.0 COMPONENTS regex filesystem system)
find_package (Boost 1.55.0 REQUIRED COMPONENTS regex filesystem system)
if (Boost_INCLUDE_DIRS)
message (STATUS "Found boost include dir: ${Boost_INCLUDE_DIR}")
message (STATUS "Found boost library dir: ${Boost_LIBRARY_DIR}")
......@@ -172,28 +163,17 @@ IF (NO_FIELD_ASSIGN_OPTIMIZATION)
)
ENDIF (NO_FIELD_ASSIGN_OPTIMIZATION)
INCLUDE(FindSubversion)
IF(Subversion_SVN_EXECUTABLE)
EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} info ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE OPAL_WC_INFO
ERROR_VARIABLE Subversion_svn_info_error
RESULT_VARIABLE Subversion_svn_info_result
OUTPUT_STRIP_TRAILING_WHITESPACE)
IF(${Subversion_svn_info_result} EQUAL 0)
Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} OPAL)
ELSE()
SET (OPAL_WC_REVISION 0)
EXECUTE_PROCESS(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND git rev-parse HEAD
OUTPUT_VARIABLE GIT_OUT OUTPUT_STRIP_TRAILING_WHITESPACE
)
SET (OPAL_WC_REVISION \"${GIT_OUT}\")
ENDIF()
INCLUDE(FindGit)
IF(GIT_FOUND)
SET (OPAL_WC_REVISION 0)
EXECUTE_PROCESS(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND git rev-parse HEAD
OUTPUT_VARIABLE GIT_OUT OUTPUT_STRIP_TRAILING_WHITESPACE
)
SET (OPAL_WC_REVISION \"${GIT_OUT}\")
ELSE()
MESSAGE (STATUS "could not find subversion")
MESSAGE (STATUS "could not find git")
SET (OPAL_WC_REVISION \"\")
ENDIF()
......
......@@ -92,7 +92,7 @@ const BGeometryBase &AlignWrapper::getGeometry() const {
}
const std::string &AlignWrapper::getType() const {
ElementBase::ElementBase::ElementType AlignWrapper::getType() const {
return itsElement->getType();
}
......@@ -157,4 +157,4 @@ AlignWrapper::~AlignWrapper()
AlignWrapper::AlignWrapper(ElementBase *elem):
ElementBase(elem->getName()), itsElement(elem), itsOffset() {
shareFlag = false;
}
}
\ No newline at end of file
......@@ -95,7 +95,7 @@ public:
/// Get element type std::string.
// Returns the type std::string for the enclosed item.
virtual const std::string &getType() const;
virtual ElementBase::ElementBase::ElementType getType() const;
/// Disallow misalignment of an already misaligned object.
// This method returns [b]this[/b], since "this" is already an
......@@ -158,4 +158,4 @@ private:
mutable Euclid3D itsOffset;
};
#endif // CLASSIC_AlignWrapper_HH
#endif // CLASSIC_AlignWrapper_HH
\ No newline at end of file
......@@ -76,7 +76,6 @@ void BeamBeam::getDimensions(double &zBegin, double &zEnd) const {
}
const std::string &BeamBeam::getType() const {
static const std::string type("BeamBeam");
return type;
ElementBase::ElementType BeamBeam::getType() const {
return BEAMBEAM;
}
......@@ -75,7 +75,7 @@ public:
virtual bool bends() const;
virtual const std::string &getType() const;
virtual ElementBase::ElementType getType() const;
virtual void getDimensions(double &zBegin, double &zEnd) const;
......
......@@ -316,7 +316,7 @@ void Collimator::initialise(PartBunch *bunch, double &startField, double &endFie
lossDs_m = std::unique_ptr<LossDataSink>(new LossDataSink(filename_m.substr(0, filename_m.rfind(".")), !Options::asciidump));
}
goOnline();
goOnline(-1e6);
}
void Collimator::initialise(PartBunch *bunch, const double &scaleFactor) {
......@@ -331,7 +331,7 @@ void Collimator::initialise(PartBunch *bunch, const double &scaleFactor) {
lossDs_m = std::unique_ptr<LossDataSink>(new LossDataSink(filename_m.substr(0, filename_m.rfind(".")), !Options::asciidump));
}
goOnline();
goOnline(-1e6);
}
void Collimator::finalise()
......@@ -341,7 +341,7 @@ void Collimator::finalise()
*gmsg << "* Finalize probe" << endl;
}
void Collimator::goOnline() {
void Collimator::goOnline(const double &) {
if(RefPartBunch_m == NULL) {
if(!informed_m) {
std::string errormsg = Fieldmap::typeset_msg("BUNCH SIZE NOT SET", "warning");
......@@ -569,9 +569,8 @@ void Collimator::getDimensions(double &zBegin, double &zEnd) const {
}
const std::string &Collimator::getType() const {
static const std::string type("Collimator");
return type;
ElementBase::ElementType Collimator::getType() const {
return COLLIMATOR;
}
string Collimator::getCollimatorShape() {
......
......@@ -85,11 +85,11 @@ public:
virtual bool bends() const;
virtual void goOnline();
virtual void goOnline(const double &kineticEnergy);
virtual void goOffline();
virtual const std::string &getType() const;
virtual ElementBase::ElementType getType() const;
virtual void getDimensions(double &zBegin, double &zEnd) const;
......
......@@ -87,7 +87,7 @@ trackMap(FVps<double, 6> &, const PartData &, bool, bool) const {
"Called for component \"" + getName() + "\".");
}
void Component::goOnline() {
void Component::goOnline(const double &) {
online_m = true;
}
......@@ -111,7 +111,6 @@ void Component::getMisalignment(double &x, double &y, double &s) const {
s = ds_m;
}
const std::string &Component::getType() const {
static const std::string type("");
return type;
}
ElementBase::ElementType Component::getType() const {
return ElementBase::ANY;
}
\ No newline at end of file
......@@ -116,7 +116,7 @@ public:
// virtual bool determineEntryPoint(const double &kineticEnergy, const double &tolerance) = 0;
virtual void goOnline();
virtual void goOnline(const double &kineticEnergy);
virtual void goOffline();
......@@ -132,7 +132,7 @@ public:
virtual void getDimensions(double &zBegin, double &zEnd) const = 0;
virtual const std::string &getType() const;
virtual ElementBase::ElementType getType() const;
virtual void setComponentType(std::string name) { };
virtual std::string getComponentType() const { return ""; };
......
......@@ -20,7 +20,9 @@
#include "AbsBeamline/Corrector.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Algorithms/PartBunch.h"
#include "Physics/Physics.h"
#include "Utilities/GeneralClassicException.h"
// Class Corrector
// ------------------------------------------------------------------------
......@@ -77,20 +79,32 @@ bool Corrector::apply(const Vector_t &R, const Vector_t &centroid, const double
}
void Corrector::initialise(PartBunch *bunch, double &startField, double &endField, const double &scaleFactor) {
Inform m("Corrector::initialise ");
endField_m = endField = startField + getElementLength();
RefPartBunch_m = bunch;
startField_m = startField;
BDipoleField f = getField();
kickField_m = Vector_t(f.getBx(),f.getBy(),0.0);
m << "B= " << kickField_m << endl;
endField_m = endField = startField + getElementLength();
RefPartBunch_m = bunch;
startField_m = startField;
}
void Corrector::finalise()
{ }
void Corrector::goOnline(const double &kineticEnergy) {
if (kineticEnergy < 0.0) {
throw GeneralClassicException("Corrector::goOnline", "given kinetic energy is negative");
}
const double pathLength = getGeometry().getElementLength();
const double minLength = Physics::c * RefPartBunch_m->getdT();
if (pathLength < minLength) throw GeneralClassicException("Corrector::goOnline", "length of corrector, L= " + std::to_string(pathLength) + ", shorter than distance covered during one time step, dS= " + std::to_string(minLength));
const double momentum = sqrt(std::pow(kineticEnergy * 1e6, 2.0) + 2.0 * kineticEnergy * 1e6 * RefPartBunch_m->getM());
const double magnitude = momentum / (Physics::c * pathLength);
kickField_m = magnitude * RefPartBunch_m->getQ() * Vector_t(kickY_m, -kickX_m, 0.0);
INFOMSG("Corrector::goOnline " << "at Ekin= " << kineticEnergy << " MeV, B= " << kickField_m << " T"<< endl);
online_m = true;
}
bool Corrector::bends() const {
return false;
}
......@@ -101,15 +115,6 @@ void Corrector::getDimensions(double &zBegin, double &zEnd) const
zEnd = startField_m + getElementLength();
}
const std::string &Corrector::getType() const {
static const std::string type("Corrector");
return type;
ElementBase::ElementType Corrector::getType() const {
return CORRECTOR;
}
void Corrector::SetKickX(double k) {kickX_m = k; }
void Corrector::SetKickY(double k) {kickY_m = k; }
double Corrector::GetKickX() const {return kickX_m; }
double Corrector::GetKickY() const {return kickY_m; }
......@@ -85,24 +85,26 @@ public:
virtual void initialise(PartBunch *bunch, double &startField, double &endField, const double &scaleFactor);
virtual void goOnline(const double &kineticEnergy);
virtual void finalise();
virtual bool bends() const;
virtual const std::string &getType() const;
virtual ElementBase::ElementType getType() const;
virtual void getDimensions(double &zBegin, double &zEnd) const;
void SetKickX(double k);
void setKickX(double k);
void SetKickY(double k);
void setKickY(double k);
double GetKickX() const;
double getKickX() const;
double GetKickY() const;
double getKickY() const;
private:
private:
double startField_m;
double endField_m;
double kickX_m;
......@@ -123,4 +125,24 @@ protected:
};
#endif // CLASSIC_Corrector_HH
inline
void Corrector::setKickX(double k) {
kickX_m = k;
}
inline
void Corrector::setKickY(double k) {
kickY_m = k;
}
inline
double Corrector::getKickX() const {
return kickX_m;
}
inline
double Corrector::getKickY() const {
return kickY_m;
}
#endif // CLASSIC_Corrector_HH
\ No newline at end of file
......@@ -174,10 +174,14 @@ void Cyclotron::setType(std::string t) {
type_m = t;
}
const std::string &Cyclotron::getType() const {
const std::string &Cyclotron::getCyclotronType() const {
return type_m;
}
ElementBase::ElementType Cyclotron::getType() const {
return CYCLOTRON;
}
void Cyclotron::setCyclHarm(double h) {
harm_m = h;
}
......
......@@ -37,21 +37,21 @@ struct BfieldData {
//~ double *dbt; //dBz/dtheta
//~ double *dbtt; //d2Bz/dtheta2
//~ double *dbttt; //d3Bz/dtheta3
//~
//~
//~ // to be calculated in getdiffs: all other derivatives:
//~ double *dbr; // dBz/dr
//~ double *dbrr; // ...
//~ double *dbrrr;
//~
//~
//~ double *dbrt;
//~ double *dbrrt;
//~ double *dbrtt;
//~
//~
//~ // used to get (Br,Btheta,Bz) at any off-plane point
//~ double *f2; // for Bz
//~ double *f3; // for Br
//~ double *g3; // for Btheta
//~
//~
std::vector<double> bfld; //Bz
std::vector<double> dbt; //dBz/dtheta
std::vector<double> dbtt; //d2Bz/dtheta2
......@@ -132,7 +132,8 @@ public:
void setRfFieldMapFN(std::vector<std::string> rffmapfn);
void setType(std::string t);
virtual const std::string &getType() const;
const std::string &getCyclotronType() const;
virtual ElementBase::ElementType getType() const;
virtual void getDimensions(double &zBegin, double &zEnd) const;
......@@ -158,7 +159,7 @@ public:
void setZinit(double zinit);
virtual double getZinit() const;
void setPZinit(double zinit);
virtual double getPZinit() const;
......@@ -221,7 +222,7 @@ private:
std::vector<double> rffrequ_m;
std::vector<double> rfphi_m;
std::vector<double> escale_m; // a scale factor for the E-field
std::vector<bool> superpose_m; // electric fields are superposed or not
std::vector<bool> superpose_m; // electric fields are superposed or not
double symmetry_m;
......@@ -260,13 +261,13 @@ private:
BPositions BP;
BFieldType myBFieldType_m;
// RF field map handler
// Fieldmap *RFfield;
std::vector<Fieldmap *> RFfields_m;
std::vector<Fieldmap *> RFfields_m;
std::vector<std::string> RFfilename_m;
// handling for store the particle out of region
// handling for store the particle out of region
std::unique_ptr<LossDataSink> lossDs_m;
void getdiffs();
......@@ -286,4 +287,4 @@ private:
};
#endif // CLASSIC_Cyclotron_HH
#endif // CLASSIC_Cyclotron_HH
\ No newline at end of file
......@@ -185,7 +185,7 @@ bool CyclotronValley::bends() const {
}
void CyclotronValley::goOnline() {
void CyclotronValley::goOnline(const double &) {
Fieldmap::readMap(filename_m);
online_m = true;
}
......@@ -205,7 +205,6 @@ void CyclotronValley::getDimensions(double &zBegin, double &zEnd) const {
}
const std::string &CyclotronValley::getType() const {
static const std::string type("CyclotronValley");
return type;
ElementBase::ElementType CyclotronValley::getType() const {
return CYCLOTRONVALLEY;
}
......@@ -57,7 +57,7 @@ public:
void setFast(bool fast);
bool getFast() const;
const std::string &getType() const;
ElementBase::ElementType getType() const;
virtual bool apply(const size_t &i, const double &t, double E[], double B[]);
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B);
......@@ -72,7 +72,7 @@ public:
virtual bool bends() const;
virtual void goOnline();
virtual void goOnline(const double &kineticEnergy);
virtual void goOffline();
......
......@@ -166,7 +166,7 @@ void Degrader::finalise()
*gmsg << "* Finalize Degrader" << endl;
}
void Degrader::goOnline() {
void Degrader::goOnline(const double &) {
Inform msg("Degrader::goOnline ");
if(RefPartBunch_m == NULL) {
if(!informed_m) {
......@@ -229,9 +229,8 @@ void Degrader::getDimensions(double &zBegin, double &zEnd) const {
}
const std::string &Degrader::getType() const {
static const std::string type("DEGRADER");
return type;
ElementBase::ElementType Degrader::getType() const {
return DEGRADER;
}
string Degrader::getDegraderShape() {
......
......@@ -74,11 +74,11 @@ public:
virtual bool bends() const;
virtual void goOnline();
virtual void goOnline(const double &kineticEnergy);
virtual void goOffline();
virtual const std::string &getType() const;
virtual ElementBase::ElementType getType() const;
virtual void getDimensions(double &zBegin, double &zEnd) const;
......
......@@ -71,9 +71,8 @@ bool Diagnostic::bends() const {
return false;
}
const std::string &Diagnostic::getType() const {
static const std::string type("Diagnostic");
return type;
ElementBase::ElementType Diagnostic::getType() const {
return DIAGNOSTIC;
}
void Diagnostic::getDimensions(double &zBegin, double &zEnd) const
......
......@@ -55,7 +55,7 @@ public:
virtual bool bends() const;
virtual const std::string &getType() const;
virtual ElementBase::ElementType getType() const;
virtual void getDimensions(double &zBegin, double &zEnd) const;
......
......@@ -79,7 +79,6 @@ void Drift::getDimensions(double &zBegin, double &zEnd) const {
zEnd = startField_m + getElementLength();
}
const std::string &Drift::getType() const {
static const std::string type("Drift");
return type;
ElementBase::ElementType Drift::getType() const {
return DRIFT;
}
......@@ -56,7 +56,7 @@ public:
virtual bool bends() const;
virtual const std::string &getType() const;
virtual ElementBase::ElementType getType() const;
virtual void getDimensions(double &zBegin, double &zEnd) const;
......
......@@ -145,8 +145,79 @@ const ConstChannel *ElementBase::getConstChannel(const std::string &aKey) const
}
std::string ElementBase::getTypeString() const {
switch (getType()) {
case ALIGNWRAPPER:
return "AlignWrapper";
case BEAMBEAM:
return "BeamBeam";
case BEAMLINE:
return "Beamline";
case COLLIMATOR:
return "Collimator";
case CORRECTOR:
return "Corrector";
case CYCLOTRON:
return "Cyclotron";
case CYCLOTRONVALLEY:
return "CyclotronValley";
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:
return "Monitor";
case MULTIPOLE:
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:
return "Solenoid";
case STRIPPER:
return "Stripper";
case TRAVELINGWAVE:
return "TravelingWave";
case VARIABLERFCAVITY:
return "VariableRFCavity";
case ANY:
default:
return "";
}
}
ElementImage *ElementBase::getImage() const {
return new ElementImage(getName(), getType(), userAttribs);
std::string type = getTypeString();
return new ElementImage(getName(), type, userAttribs);
}
......@@ -229,4 +300,4 @@ void ElementBase::setBoundaryGeometry(BoundaryGeometry *geo) {
void ElementBase::setSurfacePhysics(SurfacePhysicsHandler *sphys) {
sphys_m = sphys;
}
}
\ No newline at end of file