OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
OpalVacuum.cpp
Go to the documentation of this file.
1 //
2 // Class OpalVacuum
3 // Defines the VACUUM element and its attributes.
4 //
5 // Copyright (c) 2018 - 2021, 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 #include "Attributes/Attributes.h"
24 #include "BeamlineCore/VacuumRep.h"
26 
27 
29  OpalElement(SIZE, "VACUUM",
30  "The \"VACUUM\" element defines the vacuum conditions "
31  "for beam stripping interactions."),
32  parmatint_m(nullptr) {
34  ("GAS", "The composition of residual gas", {"AIR", "H2"});
35 
37  ("PRESSURE", " Pressure in the accelerator, [mbar]");
38 
40  ("PMAPFN", "Filename for the Pressure fieldmap");
41 
42  itsAttr[PSCALE] = Attributes::makeReal
43  ("PSCALE", "Scale factor for the P-field", 1.0);
44 
46  ("TEMPERATURE", " Temperature of the accelerator, [K]");
47 
48  itsAttr[STOP] = Attributes::makeBool
49  ("STOP", "Option whether stop tracking after beam stripping. Default: true", true);
50 
52 
53  setElement(new VacuumRep("VACUUM"));
54 }
55 
56 
57 OpalVacuum::OpalVacuum(const std::string& name, OpalVacuum* parent):
58  OpalElement(name, parent),
59  parmatint_m(nullptr) {
60  setElement(new VacuumRep(name));
61 }
62 
63 
65  delete parmatint_m;
66 }
67 
68 
69 OpalVacuum* OpalVacuum::clone(const std::string& name) {
70  return new OpalVacuum(name, this);
71 }
72 
73 
76 
77  VacuumRep* vac = dynamic_cast<VacuumRep*>(getElement());
78 
79  double length = Attributes::getReal(itsAttr[LENGTH]);
80  std::string gas = Attributes::getString(itsAttr[GAS]);
81  double pressure = Attributes::getReal(itsAttr[PRESSURE]);
82  std::string pmap = Attributes::getString(itsAttr[PMAPFN]);
83  double pscale = Attributes::getReal(itsAttr[PSCALE]);
84  double temperature = Attributes::getReal(itsAttr[TEMPERATURE]);
85  bool stop = Attributes::getBool(itsAttr[STOP]);
86 
87  vac->setElementLength(length);
88  vac->setResidualGas(gas);
89  vac->setPressure(pressure);
90  vac->setPressureMapFN(pmap);
91  vac->setPScale(pscale);
92  vac->setTemperature(temperature);
93  vac->setStop(stop);
94 
95  if (itsAttr[PARTICLEMATTERINTERACTION] && parmatint_m == nullptr) {
96  const std::string matterDescriptor = Attributes::getString(itsAttr[PARTICLEMATTERINTERACTION]);
98  parmatint_m = orig->clone(matterDescriptor);
101  }
102 
103  // Transmit "unknown" attributes.
105 }
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
virtual void setParticleMatterInteraction(ParticleMatterInteractionHandler *spys)
virtual ~OpalVacuum()
Definition: OpalVacuum.cpp:64
static ParticleMatterInteraction * find(const std::string &name)
Find named PARTICLEMATTERINTERACTION.
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:125
void setPressure(double pressure)
Definition: Vacuum.cpp:124
bool getBool(const Attribute &attr)
Return logical value.
Definition: Attributes.cpp:100
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
Definition: Attributes.cpp:90
ParticleMatterInteraction * parmatint_m
Definition: OpalVacuum.h:64
virtual OpalVacuum * clone(const std::string &name)
Make clone.
Definition: OpalVacuum.cpp:69
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
void initParticleMatterInteractionHandler(ElementBase &element)
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:332
void setPressureMapFN(std::string pmapfn)
Definition: Vacuum.cpp:137
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:120
void setTemperature(double temperature)
Definition: Vacuum.cpp:158
void setPScale(double ps)
Definition: Vacuum.cpp:145
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:252
ParticleMatterInteractionHandler * handler_m
virtual ParticleMatterInteraction * clone(const std::string &name)
Make clone.
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:419
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown&#39;&#39; (not known to OPAL) attributes to CLASSIC.
virtual void update()
Update the embedded CLASSIC vacuum.
Definition: OpalVacuum.cpp:74
void setStop(bool stopflag)
Definition: Vacuum.cpp:171
void setResidualGas(std::string gas)
Definition: Vacuum.cpp:102
OpalVacuum()
Exemplar constructor.
Definition: OpalVacuum.cpp:28
virtual void update()
Update the embedded CLASSIC element.
void registerOwnership() const