BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSCavityFactoryRectangular.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 "BDSCavityFactoryRectangular.hh"
21#include "BDSCavityInfo.hh"
22
23#include "globals.hh"
24#include "G4Box.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
34BDSCavityFactoryRectangular::BDSCavityFactoryRectangular()
35{;}
36
37BDSCavityFactoryRectangular::~BDSCavityFactoryRectangular()
38{;}
39
41 G4double totalChordLength,
42 const BDSCavityInfo* info)
43{
44 G4double thickness = info->thickness;
45 G4double chordLength = totalChordLength;
46 G4double cavityRadius = info->equatorRadius;
47 G4double outerBoxHalf = cavityRadius + thickness;
48 G4VSolid* outerSolid = new G4Box(name + "_outer_solid", // name
49 outerBoxHalf, // dx
50 outerBoxHalf, // dy
51 0.5*chordLength - lengthSafety); // dz
52 G4VSolid* sub = new G4Box(name + "_outer_sub_solid", // name
53 outerBoxHalf - thickness, // dx
54 outerBoxHalf - thickness, // dy
55 0.5*chordLength - thickness); // dz
56 allSolids.insert(outerSolid);
57 allSolids.insert(sub);
58
59 G4VSolid* innerSolid = new G4Tubs(name + "_inner_solid", // name
60 0.0, // inner radius
61 info->irisRadius, // outer radius
62 chordLength, // galf length
63 0.0, // star angle
64 CLHEP::twopi); // sweep angle
65 allSolids.insert(innerSolid);
66
67 // subtraction
68 G4VSolid* cavitySolid1 = new G4SubtractionSolid(name + "_cavity_sub_solid",//name
69 outerSolid, //solid1
70 sub); //minus solid2
71 allSolids.insert(cavitySolid1);
72 cavitySolid = new G4SubtractionSolid(name + "_cavity_solid", // name
73 cavitySolid1,
74 innerSolid);
75
76 // vacuum: union of two solid - one cylinder (VacuumInnerCavity) to fill the centre,
77 // and a longer, thinner cylinder (vacuumAperture) to fill the ends provided by the thickness.
78 G4double vacuumHalfWidth = outerBoxHalf - thickness - lengthSafety;
79 G4VSolid* vacuumInnerCavity = new G4Box(name + "_vacuum_inner_cavity_solid",// name
80 vacuumHalfWidth,
81 vacuumHalfWidth,
82 0.5*chordLength - thickness - lengthSafety);
83
84 G4VSolid* vacuumAperture = new G4Tubs(name + "_vacuum_aperture_solid", // name
85 0.0, // inner radius
86 info->irisRadius - lengthSafety, // outer radius
87 0.5*chordLength - lengthSafety, // half length
88 0.0, // start angle
89 CLHEP::twopi); // sweep angle
90
91 // create the vacuum as a union of the two solides defined prior
92 vacuumSolid = new G4UnionSolid(name + "_vacuum_solid", // name
93 vacuumInnerCavity, // solid one
94 vacuumAperture); // added to solid two.
95 allSolids.insert(vacuumInnerCavity);
96 allSolids.insert(vacuumAperture);
97 allSolids.insert(vacuumSolid);
98
99 G4double containerRadius = cavityRadius + thickness + lengthSafety;
100 containerSolid = new G4Box(name + "_container_solid", // name
101 containerRadius, // innerRadius
102 containerRadius, // outerRadius
103 chordLength*0.5); // half length
104 return containerRadius;
105}
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.