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