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