OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
OpalVacuum.cpp
Go to the documentation of this file.
1 //
2 // Class OpalVacuum
3 // The class of OPAL Vacuum.
4 //
5 // Copyright (c) 2018-2019, Pedro Calvo, CIEMAT, Spain
6 // All rights reserved
7 //
8 // Implemented as part of the PhD thesis
9 // "Optimizing the radioisotope production of the novel AMIT
10 // superconducting weak focusing cyclotron"
11 //
12 // This file is part of OPAL.
13 //
14 // OPAL is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
21 //
22 #include "Elements/OpalVacuum.h"
23 
24 #include "Attributes/Attributes.h"
25 #include "BeamlineCore/VacuumRep.h"
26 #include "Physics/Physics.h"
28 
29 
31  OpalElement(SIZE, "VACUUM",
32  "The \"VACUUM\" element defines the vacuum conditions for beam stripping interactions"),
33  parmatint_m(NULL) {
35  ("PRESSURE", " Pressure in the accelerator, [mbar]");
37  ("TEMPERATURE", " Temperature of the accelerator, [K]");
39  ("PMAPFN", "Filename for the Pressure fieldmap");
41  ("PSCALE", "Scale factor for the P-field", 1.0);
43  ("GAS", "The composition of residual gas", {"AIR", "H2"});
45  ("STOP", "Option Whether stop tracking after beam stripping. Default: true", true);
46 
48 
49  setElement(new VacuumRep("VACUUM"));
50 }
51 
52 
53 OpalVacuum::OpalVacuum(const std::string& name, OpalVacuum* parent):
54  OpalElement(name, parent),
55  parmatint_m(NULL) {
57 }
58 
59 
61  delete parmatint_m;
62 }
63 
64 
65 OpalVacuum* OpalVacuum::clone(const std::string& name) {
66  return new OpalVacuum(name, this);
67 }
68 
69 
72 
73  VacuumRep* vac =
74  dynamic_cast<VacuumRep*>(getElement());
75 
76  double pressure = Attributes::getReal(itsAttr[PRESSURE]);
77  double temperature = Attributes::getReal(itsAttr[TEMPERATURE]);
78  std::string pmap = Attributes::getString(itsAttr[PMAPFN]);
79  double pscale = Attributes::getReal(itsAttr[PSCALE]);
80  bool stop = Attributes::getBool(itsAttr[STOP]);
81  std::string gas = Attributes::getString(itsAttr[GAS]);
82 
83  vac->setPressure(pressure);
84  vac->setTemperature(temperature);
85  vac->setPressureMapFN(pmap);
86  vac->setPScale(pscale);
87  vac->setStop(stop);
88  vac->setResidualGas(gas);
89 
91  const std::string matterDescriptor = Attributes::getString(itsAttr[PARTICLEMATTERINTERACTION]);
93  parmatint_m = orig->clone(matterDescriptor);
96  }
97 
98  // Transmit "unknown" attributes.
100 }
@ SIZE
Definition: IndexMap.cpp:174
const std::string name
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
Definition: Attributes.cpp:90
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:252
Attribute makePredefinedString(const std::string &name, const std::string &help, const std::initializer_list< std::string > &predefinedStrings)
Make predefined string attribute.
Definition: Attributes.cpp:409
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
bool getBool(const Attribute &attr)
Return logical value.
Definition: Attributes.cpp:100
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:332
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:120
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:125
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
virtual void setParticleMatterInteraction(ParticleMatterInteractionHandler *spys)
void setPScale(double ps)
Definition: Vacuum.cpp:127
void setTemperature(double temperature)
Definition: Vacuum.cpp:106
void setPressureMapFN(std::string pmapfn)
Definition: Vacuum.cpp:119
void setPressure(double pressure)
Definition: Vacuum.cpp:93
void setResidualGas(std::string gas)
Definition: Vacuum.cpp:140
void setStop(bool stopflag)
Definition: Vacuum.cpp:167
@ PARTICLEMATTERINTERACTION
Definition: OpalElement.h:39
virtual void updateUnknown(ElementBase *)
Transmit the `‘unknown’' (not known to OPAL) attributes to CLASSIC.
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const
OpalVacuum()
Exemplar constructor.
Definition: OpalVacuum.cpp:30
ParticleMatterInteraction * parmatint_m
Definition: OpalVacuum.h:63
virtual ~OpalVacuum()
Definition: OpalVacuum.cpp:60
virtual OpalVacuum * clone(const std::string &name)
Make clone.
Definition: OpalVacuum.cpp:65
virtual void update()
Update the embedded CLASSIC vacuum.
Definition: OpalVacuum.cpp:70
virtual ParticleMatterInteraction * clone(const std::string &name)
Make clone.
static ParticleMatterInteraction * find(const std::string &name)
Find named PARTICLEMATTERINTERACTION.
ParticleMatterInteractionHandler * handler_m
void initParticleMatterInteractionHandler(ElementBase &element)