BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSCavityFactoryPillBox.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#include "BDSCavity.hh"
20#include "BDSCavityFactoryPillBox.hh"
21#include "BDSCavityInfo.hh"
22
23#include "globals.hh"
24#include "G4LogicalVolume.hh"
25#include "G4SubtractionSolid.hh"
26#include "G4Tubs.hh"
27#include "G4UnionSolid.hh"
28#include "G4VSolid.hh"
29
30#include "CLHEP/Units/SystemOfUnits.h"
31
32#include <set>
33
34BDSCavityFactoryPillBox::BDSCavityFactoryPillBox()
35{;}
36
37BDSCavityFactoryPillBox::~BDSCavityFactoryPillBox()
38{;}
39
41 G4double totalChordLength,
42 const BDSCavityInfo* info)
43{
44 G4double chordLength = totalChordLength;
45 G4double cavityRadius = info->equatorRadius;
46 G4VSolid* outerSolid = new G4Tubs(name + "_outer_solid", // name
47 info->irisRadius, // inner radius
48 cavityRadius + info->thickness, // outer radius
49 0.5*chordLength - lengthSafety, // half length
50 0.0, // start angle
51 CLHEP::twopi); // sweep angle
52 allSolids.insert(outerSolid);
53
54 // creates a cylinder to subtract from larger cylinder.
55 G4VSolid* innerSolid = new G4Tubs(name + "_inner_solid", // name
56 0.0, // inner radius
57 cavityRadius, // outer radius
58 0.5*chordLength - info->thickness,// half length
59 0.0, // star angle
60 CLHEP::twopi); // sweep angle
61 allSolids.insert(innerSolid);
62
63 // subtraction
64 cavitySolid = new G4SubtractionSolid(name + "_cavity_solid", //name
65 outerSolid, //solid1
66 innerSolid); //minus solid2
67 allSolids.insert(cavitySolid);
68
69 // vacuum: union of two solid - one cylinder (VacuumInnerCavity) to fill the centre,
70 // and a longer, thinner cylinder (vacuumAperture) to fill the ends provided by the thickness.
71 G4double vacuumInnerRadius = cavityRadius - info->thickness - lengthSafety;
72 G4double vacuumHalfLength = 0.5*chordLength - info->thickness - lengthSafety;
73 G4VSolid* vacuumInnerCavity = new G4Tubs(name + "_vacuum_inner_cavity_solid",// name
74 0.0, // inner radius
75 vacuumInnerRadius, // outer radius
76 vacuumHalfLength, // half length
77 0.0, // start angle
78 CLHEP::twopi); // sweep angle
79
80 G4VSolid* vacuumAperture = new G4Tubs(name + "_vacuum_aperture_solid", // name
81 0.0, // inner radius
82 info->irisRadius - lengthSafety, // outer radius
83 0.5*chordLength - lengthSafety, // half length
84 0.0, // start angle
85 CLHEP::twopi); // sweep angle
86
87 // create the vacuum as a union of the two solides defined prior
88 vacuumSolid = new G4UnionSolid(name + "_vacuum_solid", // name
89 vacuumInnerCavity, // solid one
90 vacuumAperture); // added to solid two.
91 allSolids.insert(vacuumInnerCavity);
92 allSolids.insert(vacuumAperture);
93 allSolids.insert(vacuumSolid);
94
95 G4double containerRadius = cavityRadius + info->thickness + lengthSafety;
96 containerSolid = new G4Tubs(name + "_container_solid", // name
97 0.0, // innerRadius
98 containerRadius, // outerRadius
99 chordLength*0.5, // half length
100 0.0, // starting angle
101 CLHEP::twopi); // sweep angle
102 return containerRadius;
103}
G4VSolid * vacuumSolid
Cache of particular solid or lv for common functionality in this class.
G4VSolid * containerSolid
Cache of particular solid or lv for common functionality in this class.
G4VSolid * cavitySolid
Cache of particular solid or lv for common functionality in this class.
virtual G4double CreateSolids(G4String name, G4double totalChordLength, const BDSCavityInfo *info)
Create vacuumSolid and cavitySolid. Must return the container radius.
Holder for all Geometrical information required to create an RF cavity.
G4double equatorRadius
Equator radius - half width of widest part.
G4double irisRadius
Iris radius - half width of narrowest part.
G4double thickness
Thickness of wall material.
G4double lengthSafety
Cache of global constants variable.