BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSMagnetOuterFactoryPolesFacetCommon.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 "BDSDebug.hh"
20#include "BDSExtent.hh"
21#include "BDSMagnetOuterFactoryPolesFacetCommon.hh"
22
23#include "globals.hh" // geant4 globals / types
24#include "G4Polyhedra.hh"
25#include "G4SubtractionSolid.hh"
26#include "G4Tubs.hh"
27#include "G4VSolid.hh"
28
29#include <set>
30
32 BDSMagnetOuterFactoryPolesBase(/*poleStopFactor=*/2),
33 polyStartAngle(0),
34 poleIntersectionStartAngle(0),
35 factor(factorIn)
36{;}
37
38BDSMagnetOuterFactoryPolesFacetCommon::~BDSMagnetOuterFactoryPolesFacetCommon()
39{;}
40
42{
44 poleIntersectionStartAngle = -segmentAngle*0.5 - CLHEP::halfpi;
45}
46
48 G4double length,
49 G4int order,
50 G4double magnetContainerLength,
51 G4double magnetContainerRadiusIn)
52{
53 G4double zPlanesMagCont[2] = {-magnetContainerLength*0.5, magnetContainerLength*0.5};
54 G4double zPlanesCont[2] = {-length*0.5, length*0.5};
55 G4double zPlanes[2] = {-length*0.5+lengthSafety, length*0.5-lengthSafety};
56 G4double zPlanesLong[2] = {-length, length}; // for intersections
57 G4double innerRadii[2] = {yokeStartRadius, yokeStartRadius};
58 G4double outerRadii[2] = {yokeFinishRadius, yokeFinishRadius};
59 G4double zeroRadii[2] = {0,0};
60 G4double poleEnd = yokeStartRadius - lengthSafetyLarge;
61 G4double poleEndRadii[2] = {poleEnd, poleEnd};
62 G4int numberOfSides = (G4int)factor*2*order;
63
65
66 // The start angle for G4Polyhedra lies on a vertex / point and is at the top
67 // in the positive y direction.
68 yokeSolid = new G4Polyhedra(name + "_yoke_solid", // name
69 polyStartAngle, // start angle
70 CLHEP::twopi, // sweep angle
71 numberOfSides, // number of sides
72 2, // number of z planes
73 zPlanes, // z plane z coordinates
74 innerRadii,
75 outerRadii);
76
77 // pole intersection solid
78 poleIntersectionSolid = new G4Polyhedra(name + "_yoke_intersection_solid", // name
79 poleIntersectionStartAngle, // start angle
80 CLHEP::twopi, // sweep angle
81 numberOfSides, // number of sides
82 2, // number of z planes
83 zPlanesLong, // z plane z coordinates
84 zeroRadii,
85 poleEndRadii);
86 allSolids.insert(poleIntersectionSolid);
87
88 G4double contInnerRadii[2] = {0, 0}; // solid polyhedra
89 G4double contOuterRadii[2] = {yokeFinishRadius + lengthSafety, yokeFinishRadius + lengthSafety};
90 G4VSolid* containerOuterSolid = new G4Polyhedra(name + "_container_outer_solid", // name
91 polyStartAngle, // start angle
92 CLHEP::twopi, // sweep angle
93 numberOfSides, // number of sides
94 2, // number of z planes
95 zPlanesCont, // z plane z coordinates
96 contInnerRadii,
97 contOuterRadii);
98
99 G4VSolid* containerInnerSolid = new G4Tubs(name + "_container_solid", // name
100 0, // start radius
101 poleStartRadius, // finish radius
102 length, // z half length
103 0, // start angle
104 CLHEP::twopi); // sweep angle
105 // z long for unambiguous subtraction
106 allSolids.insert(containerOuterSolid);
107 allSolids.insert(containerInnerSolid);
108
109 containerSolid = new G4SubtractionSolid(name + "_container_solid", // name
110 containerOuterSolid, // this
111 containerInnerSolid); // minus this with no translation or rotation
112
113 G4double magContOuterRadii[2] = {magnetContainerRadiusIn, magnetContainerRadiusIn};
114 magnetContainerSolid = new G4Polyhedra(name + "_container_solid", // name
115 polyStartAngle, // start angle
116 CLHEP::twopi, // sweep angle
117 numberOfSides, // number of sides
118 2, // number of z planes
119 zPlanesMagCont, // z plane z coordinates
120 contInnerRadii,
121 magContOuterRadii);
122
123
124 magContExtent = BDSExtent(magnetContainerRadiusIn,
125 magnetContainerRadiusIn,
126 magnetContainerLength*0.5);
127}
Holder for +- extents in 3 dimensions.
Definition: BDSExtent.hh:39
G4double lengthSafety
Cache of global constants variable.
G4double lengthSafetyLarge
Cache of global constants variable.
G4VSolid * yokeSolid
Solid for outer part that connects all poles.
Factory class for outer volume of magnets. Produces magnets with 2N-poles around the beampipe with a ...
G4double yokeFinishRadius
Finish radius of yoke geometry from magnet centre - less than horizontalWidth.
G4double segmentAngle
2PI / # of poles - angle per segment allocated for each pole.
G4VSolid * poleIntersectionSolid
Solid used to chop off pole.
G4double poleStartRadius
Start radius of the pole from magnet centre.
G4double yokeStartRadius
Start radius of yoke geometry from magnet cetnre.
BDSMagnetOuterFactoryPolesFacetCommon()
Private constructor to force use of supplied one.
virtual void CreateYokeAndContainerSolid(const G4String &name, G4double length, G4int order, G4double magnetContainerLength, G4double magnetContainerRadiusIn)
Create yoke that connects poles and container to put them in.
virtual void CalculateStartAngles()
Calculate start angle of polyhedra based on order and segment angle.
G4double factor
Factor by which number of polyhedra vertices is multiplied by.
G4double poleIntersectionStartAngle
Start angle for pole intersection.