28#include "Utility/Inform.h"
29#include "gtest/gtest.h"
53 const auto fsCmd = std::make_shared<TestableFieldSolverCmd>();
54 fsCmd->setType(
"NONE");
58 fsCmd->setBCX(
"PERIODIC");
59 fsCmd->setBCY(
"PERIODIC");
60 fsCmd->setBCZ(
"PERIODIC");
66 char** argv =
nullptr;
67 ippl::initialize(argc, argv);
69 if (
gmsg ==
nullptr) {
70 gmsg =
new Inform(
nullptr, -1);
75 if (
gmsg !=
nullptr) {
108 apply(pos, {}, t, E, B);
109 return std::hypot(B[0], B[1], B[2]);
116 setBendAngle(1,
false);
119 setFringeField(2, 1, 2);
123 setTransProfile({1, 2, 3});
124 setBoundingBoxLength(7);
126 setScalingName(
"Scaling");
128 std::unique_ptr<MultipoleT> theClone;
129 theClone.reset(
dynamic_cast<MultipoleT*
>(clone()));
130 EXPECT_NE(theClone.get(),
nullptr);
131 EXPECT_EQ(theClone->getMaxFOrder(), getMaxFOrder());
132 EXPECT_EQ(theClone->getMaxXOrder(), getMaxXOrder());
133 EXPECT_EQ(theClone->getTransMaxOrder(), getTransMaxOrder());
134 EXPECT_EQ(theClone->getTransProfile(), getTransProfile());
135 EXPECT_EQ(theClone->getFringeField(), getFringeField());
136 EXPECT_EQ(theClone->getEntryOffset(), getEntryOffset());
137 EXPECT_EQ(theClone->getVariableRadius(), getVariableRadius());
138 EXPECT_EQ(theClone->getBendAngle(), getBendAngle());
139 EXPECT_EQ(theClone->getEntranceAngle(), getEntranceAngle());
140 EXPECT_EQ(theClone->getLength(), getLength());
141 EXPECT_EQ(theClone->getAperture(), getAperture());
142 EXPECT_EQ(theClone->getRotation(), getRotation());
143 EXPECT_EQ(theClone->getBoundingBoxLength(), getBoundingBoxLength());
144 EXPECT_EQ(theClone->getScalingName(), getScalingName());
145 EXPECT_EQ(theClone->getEntryOffset(), getEntryOffset());
151 const auto timeDependence = std::make_shared<SplineTimeDependence>(
152 1, std::vector<double>{0, 1, 1.01, 2}, std::vector<double>{1, 1, 2, 2});
155 setBendAngle(0,
false);
157 setAperture(0.3, 0.3);
158 setFringeField(2, 0.2, 0.2);
160 setTransProfile({1});
161 setScalingName(
"STEPFUNCTION");
165 EXPECT_NEAR(fieldAtT({0.0, 0.0, 2.0}, 0.0), 1.0, 1e-6);
166 EXPECT_NEAR(fieldAtT({0.0, 0.0, 2.0}, 1.0), 1.0, 1e-6);
167 EXPECT_NEAR(fieldAtT({0.0, 0.0, 2.0}, 1.2), 2.0, 1e-6);
168 EXPECT_NEAR(fieldAtT({0.0, 0.0, 2.0}, 2.0), 2.0, 1e-6);
174 EXPECT_NEAR(fieldAtT({0.0, 0.0, 2.0}, 0.0), 1.0, 1e-6);
175 EXPECT_NEAR(fieldAtT({0.0, 0.0, 2.0}, 1.0), 1.0, 1e-6);
176 EXPECT_NEAR(fieldAtT({0.0, 0.0, 2.0}, 1.2), 1.0, 1e-6);
177 EXPECT_NEAR(fieldAtT({0.0, 0.0, 2.0}, 2.0), 1.0, 1e-6);
182 setBendAngle(0,
false);
183 EXPECT_FALSE(bends());
184 setBendAngle(1,
false);
185 EXPECT_TRUE(bends());
191 setBendAngle(0,
false);
193 setAperture(0.3, 0.3);
194 setFringeField(2, 0.2, 0.2);
195 setTransProfile({1});
206 EXPECT_NE(field,
nullptr);
207 auto* constField = &
const_cast<const MultipoleT*
>(magnet)->getField();
208 EXPECT_NE(constField,
nullptr);
209 EXPECT_EQ(field, constField);
211 EXPECT_NO_THROW(finalise());
212 setElementLength(4.0);
213 double a = -1.0, b = -1.0;
214 EXPECT_NO_THROW(getFieldExtend(a, b));
215 EXPECT_DOUBLE_EQ(a, 0.0);
216 EXPECT_DOUBLE_EQ(b, 4.0);
221 setBendAngle(0.0,
false);
222 setElementLength(1.0);
223 setAperture(1.0, 1.0);
224 setFringeField(0.5, 0.1, 0.1);
225 setTransProfile({1.0});
228 const auto dataSink = std::make_shared<DataSink>();
229 const auto fsCmd = makeNoFieldSolver();
230 const auto beam = std::make_shared<Beam>();
232 ASSERT_NE(testBeam,
nullptr);
233 const auto bunch = std::make_shared<PartBunch_t>(
234 std::vector<double>{1.0e-9, 2.0e-9}, std::vector<double>{0.511e-3, 0.938},
235 std::vector<Beam*>{testBeam, testBeam}, std::vector<size_t>{1, 1}, 1.0,
"LF2",
236 fsCmd.get(), dataSink.get());
237 ASSERT_EQ(bunch->getNumParticleContainers(), 2u);
240 double startField = 0.0;
241 double endField = 0.0;
242 initialise(bunch.get(), startField, endField);
ippl::Vector< T, Dim > Vector_t
TEST_F(TestMultipoleT, Cloning)
static void setTimeDependence(const std::string &name, std::shared_ptr< AbstractTimeDependence > time_dep)
static Beam * find(const std::string &name)
Find named BEAM.
An abstract sequence of beam line components.
Component applying a constant accelerating electric field (Ex,Ey,Ez).
Interface for drift space.
A section of a beam line.
Passive OPALX laser element.
EMField & getField() override
bool apply(const std::shared_ptr< ParticleContainer_t > &pc) override
Interface for general multipole.
std::vector< Attribute > itsAttr
The object attributes.
void storeInputFn(const std::string &fn)
store opals input filename
static OpalData * getInstance()
Abstract rectangular bend with straight body and curved reference path.
Interface for standing wave cavities.
Ring describes a ring type geometry for tracking.
Abstract sector bend with planar-arc body geometry.
Abstract class for a solenoid magnet.
void setBCY(const std::string &bc)
void setType(const std::string &t)
void setBCZ(const std::string &bc)
void setBCX(const std::string &bc)
void visitRBend(const RBend &) override
Apply the algorithm to a rectangular bend.
void visitProbe(const Probe &) override
Apply the algorithm to a Probe.
void visitMultipole(const Multipole &) override
Apply the algorithm to a multipole.
void visitRFCavity(const RFCavity &) override
Apply the algorithm to a RF cavity.
void visitSBend(const SBend &) override
Apply the algorithm to a sector bend.
double fieldAtT(const Vector_t< double, 3 > &pos, const double t)
static void TearDownTestSuite()
static void SetUpTestSuite()
void visitRing(const Ring &) override
Apply the algorithm to a Ring element.
void visitMarker(const Marker &) override
Apply the algorithm to a marker.
void visitComponent(const Component &) override
Apply the algorithm to an arbitrary component.
void visitMonitor(const Monitor &) override
Apply the algorithm to a beam position monitor.
void visitDrift(const Drift &) override
Apply the algorithm to a drift space.
void visitSolenoid(const Solenoid &) override
Apply the algorithm to a Solenoid element.
void visitConstantEFieldCavity(const ConstantEFieldCavity &) override
Apply the algorithm to a constant E-field cavity element.
void visitLaser(const Laser &) override
Apply the algorithm to a laser element.
void visitScalingFFAMagnet(const ScalingFFAMagnet &) override
static std::shared_ptr< FieldSolverCmd > makeNoFieldSolver()
void visitVariableRFCavity(const VariableRFCavity &) override
Apply the algorithm to a variable RF cavity.
void visitTravelingWave(const TravelingWave &) override
Apply the algorithm to a traveling wave.
void execute() override
Execute the algorithm on the attached beam line.
void visitBeamline(const Beamline &) override
Apply the algorithm to a beam line.
void visitFlaggedElmPtr(const FlaggedElmPtr &) override
Apply the algorithm to a FlaggedElmPtr.
void visitMultipoleT(const MultipoleT &) override
Apply the algorithm to an arbitrary multipole.
void visitVerticalFFAMagnet(const VerticalFFAMagnet &) override
Apply the algorithm to a vertical FFA magnet.
Interface for traveling wave cavities.
void setPredefinedString(Attribute &attr, const std::string &val)
Set predefined string value.
bool enableHDF5
If true HDF5 files are written.