OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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"
24#include "BeamlineCore/VacuumRep.h"
25#include "Structure/ParticleMatterInteraction.h"
26
29 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
36 itsAttr[PRESSURE] = Attributes::makeReal("PRESSURE", " Pressure in the accelerator, [mbar]");
37
38 itsAttr[PMAPFN] = Attributes::makeString("PMAPFN", "Filename for the Pressure fieldmap");
39
40 itsAttr[PSCALE] = Attributes::makeReal("PSCALE", "Scale factor for the P-field", 1.0);
41
43 Attributes::makeReal("TEMPERATURE", " Temperature of the accelerator, [K]");
44
46 "STOP", "Option whether stop tracking after beam stripping. Default: true", true);
47
49
50 setElement(new VacuumRep("VACUUM"));
51}
52
53OpalVacuum::OpalVacuum(const std::string& name, OpalVacuum* parent)
54 : OpalElement(name, parent), parmatint_m(nullptr) {
55 setElement(new VacuumRep(name));
56}
57
59
60OpalVacuum* OpalVacuum::clone(const std::string& name) { return new OpalVacuum(name, this); }
61
64
65 VacuumRep* vac = dynamic_cast<VacuumRep*>(getElement());
66
67 double length = Attributes::getReal(itsAttr[LENGTH]);
68 std::string gas = Attributes::getString(itsAttr[GAS]);
69 double pressure = Attributes::getReal(itsAttr[PRESSURE]);
70 std::string pmap = Attributes::getString(itsAttr[PMAPFN]);
71 double pscale = Attributes::getReal(itsAttr[PSCALE]);
72 double temperature = Attributes::getReal(itsAttr[TEMPERATURE]);
73 bool stop = Attributes::getBool(itsAttr[STOP]);
74
75 vac->setElementLength(length);
76 vac->setResidualGas(gas);
77 vac->setPressure(pressure);
78 vac->setPressureMapFN(pmap);
79 vac->setPScale(pscale);
80 vac->setTemperature(temperature);
81 vac->setStop(stop);
82
83 // Transmit "unknown" attributes.
85}
@ SIZE
Definition IndexMap.cpp:179
ElementBase * getElement() const
Return the embedded OPALX element.
Definition Element.h:119
void setElement(ElementBase *)
Assign new OPALX element.
Definition Element.h:123
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:210
virtual void updateUnknown(ElementBase *)
Transmit the `‘unknown’' (not known to OPALX) attributes to OPALX.
virtual void update()
Update the embedded OPALX element.
void registerOwnership() const
OpalVacuum()
Exemplar constructor.
ParticleMatterInteraction * parmatint_m
Definition OpalVacuum.h:61
virtual ~OpalVacuum()
virtual OpalVacuum * clone(const std::string &name)
Make clone.
virtual void update()
Update the embedded OPALX vacuum.
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
double getReal(const Attribute &attr)
Return real value.
Attribute makePredefinedString(const std::string &name, const std::string &help, const std::initializer_list< std::string > &predefinedStrings)
Make predefined string attribute.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
bool getBool(const Attribute &attr)
Return logical value.
std::string getString(const Attribute &attr)
Get string value.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.