Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 5fbd4c4b authored by adelmann's avatar adelmann :reminder_ribbon:
Browse files

start adding Undulator

parent e6662f9a
No related branches found
No related tags found
No related merge requests found
Showing with 570 additions and 3 deletions
......@@ -19,6 +19,8 @@
#include "Algorithms/ParallelTTracker.h"
#include "mithra/fieldvector.hh"
#include <cfloat>
#include <iostream>
#include <fstream>
......@@ -1464,4 +1466,4 @@ void ParallelTTracker::evenlyDistributeParticles() {
// mode:c++
// c-basic-offset: 4
// indent-tabs-mode:nil
// End:
\ No newline at end of file
// End:
......@@ -36,6 +36,7 @@
#include "AbsBeamline/Diagnostic.h"
#include "AbsBeamline/Degrader.h"
#include "AbsBeamline/Drift.h"
#include "AbsBeamline/Undulator.h"
#include "AbsBeamline/FlexibleCollimator.h"
#include "AbsBeamline/ElementBase.h"
#include "AbsBeamline/Lambertson.h"
......@@ -122,6 +123,9 @@ public:
/// Apply the algorithm to a Drift.
virtual void visitDrift(const Drift &);
/// Apply the algorithm to a Undulator.
virtual void visitUndulator(const Undulator &);
/// Apply the algorithm to a flexible collimator
virtual void visitFlexibleCollimator(const FlexibleCollimator &);
......@@ -356,6 +360,10 @@ inline void ParallelTTracker::visitDiagnostic(const Diagnostic &diag) {
}
inline void ParallelTTracker::visitUndulator(const Undulator &u) {
itsOpalBeamline_m.visit(u, *this, itsBunch_m);
}
inline void ParallelTTracker::visitDrift(const Drift &drift) {
itsOpalBeamline_m.visit(drift, *this, itsBunch_m);
}
......
......@@ -43,6 +43,7 @@ class CyclotronValley;
class Degrader;
class Diagnostic;
class Drift;
class Undulator;
class FlexibleCollimator;
class Lambertson;
class Marker;
......@@ -130,6 +131,9 @@ public:
/// Apply the algorithm to a drift space.
virtual void visitDrift(const Drift &) = 0;
/// Apply the algorithm to a undulator space.
virtual void visitUndulator(const Undulator &) = 0;
/// Apply the algorithm to a flexible collimator
virtual void visitFlexibleCollimator(const FlexibleCollimator &) = 0;
......
......@@ -16,6 +16,7 @@ set (_SRCS
Degrader.cpp
Diagnostic.cpp
Drift.cpp
Undulator.cpp
ElementBase.cpp
ElementImage.cpp
FlexibleCollimator.cpp
......@@ -73,6 +74,7 @@ set (HDRS
Degrader.h
Diagnostic.h
Drift.h
Undulator.h
ElementBase.h
ElementImage.h
FlexibleCollimator.h
......
......@@ -42,6 +42,7 @@ class ElementImage;
enum ElemType {
isDrift,
isUndulator,
isSolenoid,
isSource,
isRF,
......@@ -160,7 +161,8 @@ public:
, CYCLOTRONVALLEY
, DEGRADER
, DIAGNOSTIC
, DRIFT
, DRIFT
, UNDULATOR
, FLEXIBLECOLLIMATOR
, INTEGRATOR
, LAMBERTSON
......@@ -714,4 +716,4 @@ bool ElementBase::isElementPositionSet() const
{ return elemedgeSet_m; }
#endif // CLASSIC_ElementBase_HH
\ No newline at end of file
#endif // CLASSIC_ElementBase_HH
// ------------------------------------------------------------------------
// $RCSfile: Undulator.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: Undulator
// Defines the abstract interface for a drift space.
//
// ------------------------------------------------------------------------
// Class category: AbsBeamline
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:32:31 $
// $Author: fci $
//
// ------------------------------------------------------------------------
#include "AbsBeamline/Undulator.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Algorithms/PartBunchBase.h"
extern Inform *gmsg;
// Class Undulator
// ------------------------------------------------------------------------
Undulator::Undulator():
Component(),
nSlices_m(1)
{ }
Undulator::Undulator(const Undulator &right):
Component(right),
nSlices_m(right.nSlices_m)
{ }
Undulator::Undulator(const std::string &name):
Component(name),
nSlices_m(1)
{ }
Undulator::~Undulator()
{ }
void Undulator::accept(BeamlineVisitor &visitor) const {
visitor.visitUndulator(*this);
}
void Undulator::initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) {
endField = startField + getElementLength();
RefPartBunch_m = bunch;
startField_m = startField;
}
//set the number of slices for map tracking
void Undulator::setNSlices(const std::size_t& nSlices) {
nSlices_m = nSlices;
}
//get the number of slices for map tracking
std::size_t Undulator::getNSlices() const {
return nSlices_m;
}
void Undulator::finalise() {
}
bool Undulator::bends() const {
return false;
}
void Undulator::getDimensions(double &zBegin, double &zEnd) const {
zBegin = startField_m;
zEnd = startField_m + getElementLength();
}
ElementBase::ElementType Undulator::getType() const {
return UNDULATOR;
}
#ifndef CLASSIC_Undulator_HH
#define CLASSIC_Undulator_HH
// ------------------------------------------------------------------------
// $RCSfile: Undulator.h,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: Undulator
// Defines the abstract interface for a drift space.
//
// ------------------------------------------------------------------------
// Class category: AbsBeamline
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:32:31 $
// $Author: fci $
//
// ------------------------------------------------------------------------
#include "AbsBeamline/Component.h"
// Class Undulator
// ------------------------------------------------------------------------
/// Interface for drift space.
// Class Undulator defines the abstract interface for a drift space.
class Undulator: public Component {
public:
/// Constructor with given name.
explicit Undulator(const std::string &name);
Undulator();
Undulator(const Undulator &right);
virtual ~Undulator();
/// Apply visitor to Undulator.
virtual void accept(BeamlineVisitor &) const;
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;
//set number of slices for map tracking
void setNSlices(const std::size_t& nSlices); // Philippe was here
//set number of slices for map tracking
std::size_t getNSlices() const; // Philippe was here
private:
double startField_m;
std::size_t nSlices_m;
// Not implemented.
void operator=(const Undulator &);
};
#endif // CLASSIC_Undulator_HH
......@@ -6,6 +6,7 @@ set (_SRCS
CyclotronValleyRep.cpp
DegraderRep.cpp
DriftRep.cpp
UndulatorRep.cpp
FlexibleCollimatorRep.cpp
MarkerRep.cpp
MonitorRep.cpp
......@@ -48,6 +49,7 @@ set (HDRS
CyclotronValleyRep.h
DegraderRep.h
DriftRep.h
UndulatorRep.h
FlexibleCollimatorRep.h
MarkerRep.h
MonitorRep.h
......
// ------------------------------------------------------------------------
// $RCSfile: UndulatorRep.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: UndulatorRep
// Defines a concrete drift space representation.
//
// ------------------------------------------------------------------------
// Class category: BeamlineCore
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:32:33 $
// $Author: fci $
//
// ------------------------------------------------------------------------
#include "BeamlineCore/UndulatorRep.h"
#include "AbsBeamline/ElementImage.h"
#include "Channels/IndirectChannel.h"
// Attribute access table.
// ------------------------------------------------------------------------
namespace {
struct Entry {
const char *name;
double(UndulatorRep::*get)() const;
void (UndulatorRep::*set)(double);
};
const Entry entries[] = {
{
"L",
&UndulatorRep::getElementLength,
&UndulatorRep::setElementLength
},
{ 0, 0, 0 }
};
}
// Class UndulatorRep
// ------------------------------------------------------------------------
UndulatorRep::UndulatorRep():
Undulator(),
geometry(0.0)
{}
UndulatorRep::UndulatorRep(const UndulatorRep &right):
Undulator(right),
geometry(right.geometry)
{}
UndulatorRep::UndulatorRep(const std::string &name):
Undulator(name),
geometry()
{}
UndulatorRep::~UndulatorRep()
{}
ElementBase *UndulatorRep::clone() const {
return new UndulatorRep(*this);
}
Channel *UndulatorRep::getChannel(const std::string &aKey, bool create) {
for(const Entry *entry = entries; entry->name != 0; ++entry) {
if(aKey == entry->name) {
return new IndirectChannel<UndulatorRep>(*this, entry->get, entry->set);
}
}
return ElementBase::getChannel(aKey, create);
}
NullField &UndulatorRep::getField() {
return field;
}
const NullField &UndulatorRep::getField() const {
return field;
}
StraightGeometry &UndulatorRep::getGeometry() {
return geometry;
}
const StraightGeometry &UndulatorRep::getGeometry() const {
return geometry;
}
ElementImage *UndulatorRep::getImage() const {
ElementImage *image = ElementBase::getImage();
for(const Entry *entry = entries; entry->name != 0; ++entry) {
image->setAttribute(entry->name, (this->*(entry->get))());
}
return image;
}
#ifndef CLASSIC_UndulatorRep_HH
#define CLASSIC_UndulatorRep_HH
// ------------------------------------------------------------------------
// $RCSfile: UndulatorRep.h,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: UndulatorRep
//
// ------------------------------------------------------------------------
// Class category: BeamlineCore
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:32:33 $
// $Author: fci $
//
// ------------------------------------------------------------------------
#include "AbsBeamline/Undulator.h"
#include "BeamlineGeometry/StraightGeometry.h"
#include "Fields/NullField.h"
// Class UndulatorRep
// ------------------------------------------------------------------------
/// Representation for a drift space.
class UndulatorRep: public Undulator {
public:
/// Constructor with given name.
explicit UndulatorRep(const std::string &name);
UndulatorRep();
UndulatorRep(const UndulatorRep &);
virtual ~UndulatorRep();
/// 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 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;
private:
// Not implemented.
void operator=(const UndulatorRep &);
/// The zero magnetic field.
NullField field;
/// The geometry.
StraightGeometry geometry;
};
#endif // CLASSIC_UndulatorRep_HH
......@@ -8,6 +8,7 @@ set (_SRCS
OpalCCollimator.cpp
OpalCyclotron.cpp
OpalDrift.cpp
OpalUndulator.cpp
OpalECollimator.cpp
OpalFlexibleCollimator.cpp
OpalDegrader.cpp
......@@ -77,6 +78,7 @@ set (HDRS
OpalCyclotronValley.h
OpalDegrader.h
OpalDrift.h
OpalUndulator.h
OpalECollimator.h
OpalElement.h
OpalHKicker.h
......
// ------------------------------------------------------------------------
// $RCSfile: OpalUndulator.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: OpalUndulator
// The class of OPAL drift spaces.
//
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:33:39 $
// $Author: Andreas Adelmann $
//
// ------------------------------------------------------------------------
#include "Elements/OpalUndulator.h"
#include "Structure/BoundaryGeometry.h"
#include "Attributes/Attributes.h"
#include "BeamlineCore/UndulatorRep.h"
#include "Structure/OpalWake.h"
#include "Structure/ParticleMatterInteraction.h"
// Class OpalUndulator
// ------------------------------------------------------------------------
OpalUndulator::OpalUndulator():
OpalElement(SIZE, "DRIFT",
"The \"DRIFT\" element defines a drift space."),
owk_m(NULL),
parmatint_m(NULL),
obgeo_m(NULL) {
// CKR: the following 3 lines are redundant: OpalElement does this already!
// they prevent drift from working properly
//
// itsAttr[LENGTH] = Attributes::makeReal
// ("LENGTH", "Undulator length");
// registerRealAttribute("LENGTH");
itsAttr[GEOMETRY] = Attributes::makeString
("GEOMETRY", "BoundaryGeometry for Undulators");
itsAttr[NSLICES] = Attributes::makeReal
("NSLICES",
"The number of slices/ steps for this element in Map Tracking", 1);
registerStringAttribute("GEOMETRY");
registerRealAttribute("NSLICES");
registerOwnership();
setElement(new UndulatorRep("DRIFT"));
}
OpalUndulator::OpalUndulator(const std::string &name, OpalUndulator *parent):
OpalElement(name, parent),
owk_m(NULL),
parmatint_m(NULL),
obgeo_m(NULL) {
setElement(new UndulatorRep(name));
}
OpalUndulator::~OpalUndulator() {
if(owk_m)
delete owk_m;
if(parmatint_m)
delete parmatint_m;
if(obgeo_m)
delete obgeo_m;
}
OpalUndulator *OpalUndulator::clone(const std::string &name) {
return new OpalUndulator(name, this);
}
bool OpalUndulator::isUndulator() const {
return true;
}
void OpalUndulator::update() {
OpalElement::update();
UndulatorRep *drf = static_cast<UndulatorRep *>(getElement());
drf->setElementLength(Attributes::getReal(itsAttr[LENGTH]));
drf->setNSlices(Attributes::getReal(itsAttr[NSLICES]));
if(itsAttr[WAKEF] && owk_m == NULL) {
owk_m = (OpalWake::find(Attributes::getString(itsAttr[WAKEF])))->clone(getOpalName() + std::string("_wake"));
owk_m->initWakefunction(*drf);
drf->setWake(owk_m->wf_m);
}
if(itsAttr[PARTICLEMATTERINTERACTION] && parmatint_m == NULL) {
parmatint_m = (ParticleMatterInteraction::find(Attributes::getString(itsAttr[PARTICLEMATTERINTERACTION])))->clone(getOpalName() + std::string("_parmatint"));
parmatint_m->initParticleMatterInteractionHandler(*drf);
drf->setParticleMatterInteraction(parmatint_m->handler_m);
}
if(itsAttr[GEOMETRY] && obgeo_m == NULL) {
obgeo_m = (BoundaryGeometry::find(Attributes::getString(itsAttr[GEOMETRY])))->clone(getOpalName() + std::string("_geometry"));
if(obgeo_m) {
drf->setBoundaryGeometry(obgeo_m);
}
}
// Transmit "unknown" attributes.
OpalElement::updateUnknown(drf);
}
#ifndef OPAL_OpalUndulator_HH
#define OPAL_OpalUndulator_HH
// ------------------------------------------------------------------------
// $RCSfile: OpalUndulator.h,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: OpalUndulator
//
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:33:39 $
// $Author: Andreas Adelmann $
//
// ------------------------------------------------------------------------
#include "Elements/OpalElement.h"
class BoundaryGeometry;
// Class OpalUndulator
// ------------------------------------------------------------------------
/// The DRIFT element.
class OpalWake;
class ParticleMatterInteraction;
class OpalUndulator: public OpalElement {
public:
enum {
GEOMETRY = COMMON, // geometry of boundary, one more enum member besides the common ones in OpalElement.
NSLICES, // The number of slices / steps per element for map tracking
SIZE
};
/// Exemplar constructor.
OpalUndulator();
virtual ~OpalUndulator();
/// Make clone.
virtual OpalUndulator *clone(const std::string &name);
/// Test for drift.
// Return true.
virtual bool isUndulator() const;
/// Update the embedded CLASSIC drift.
virtual void update();
private:
// Not implemented.
OpalUndulator(const OpalUndulator &);
void operator=(const OpalUndulator &);
// Clone constructor.
OpalUndulator(const std::string &name, OpalUndulator *parent);
OpalWake *owk_m;
ParticleMatterInteraction *parmatint_m;
BoundaryGeometry *obgeo_m;
};
#endif // OPAL_OpalUndulator_HH
......@@ -94,6 +94,7 @@
#include "Elements/OpalCCollimator.h"
#include "Elements/OpalCyclotron.h"
#include "Elements/OpalDrift.h"
#include "Elements/OpalUndulator.h"
#include "Elements/OpalECollimator.h"
#include "Elements/OpalFlexibleCollimator.h"
#include "Elements/OpalDegrader.h"
......@@ -248,6 +249,7 @@ namespace {
opal->create(new OpalCCollimator());
opal->create(new OpalCyclotron());
opal->create(new OpalDrift());
opal->create(new OpalUndulator());
opal->create(new OpalECollimator());
opal->create(new OpalFlexibleCollimator());
opal->create(new OpalDegrader());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment