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) 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 "BDSDebug.hh"
19#include "BDSExtent.hh"
20#include "BDSMagnetOuterFactoryPolesFacetCommon.hh"
21
22#include "globals.hh" // geant4 globals / types
23#include "G4Polyhedra.hh"
24#include "G4SubtractionSolid.hh"
25#include "G4Tubs.hh"
26#include "G4VSolid.hh"
27
28#include <set>
29
31 BDSMagnetOuterFactoryPolesBase(/*poleStopFactor=*/2),
32 polyStartAngle(0),
33 poleIntersectionStartAngle(0),
34 factor(factorIn)
35{;}
36
37BDSMagnetOuterFactoryPolesFacetCommon::~BDSMagnetOuterFactoryPolesFacetCommon()
38{;}
39
45
47 G4double length,
48 G4int order,
49 G4double magnetContainerLength,
50 G4double magnetContainerRadiusIn)
51{
52 G4double zPlanesMagCont[2] = {-magnetContainerLength*0.5, magnetContainerLength*0.5};
53 G4double zPlanesCont[2] = {-length*0.5, length*0.5};
54 G4double zPlanes[2] = {-length*0.5+lengthSafety, length*0.5-lengthSafety};
55 G4double zPlanesLong[2] = {-length, length}; // for intersections
56 G4double innerRadii[2] = {yokeStartRadius, yokeStartRadius};
57 G4double outerRadii[2] = {yokeFinishRadius, yokeFinishRadius};
58 G4double zeroRadii[2] = {0,0};
59 G4double poleEnd = yokeStartRadius - lengthSafetyLarge;
60 G4double poleEndRadii[2] = {poleEnd, poleEnd};
61 G4int numberOfSides = (G4int)factor*2*order;
62
64
65 // The start angle for G4Polyhedra lies on a vertex / point and is at the top
66 // in the positive y direction.
67 yokeSolid = new G4Polyhedra(name + "_yoke_solid", // name
68 polyStartAngle, // start angle
69 CLHEP::twopi, // sweep angle
70 numberOfSides, // number of sides
71 2, // number of z planes
72 zPlanes, // z plane z coordinates
73 innerRadii,
74 outerRadii);
75
76 // pole intersection solid
77 poleIntersectionSolid = new G4Polyhedra(name + "_yoke_intersection_solid", // name
78 poleIntersectionStartAngle, // start angle
79 CLHEP::twopi, // sweep angle
80 numberOfSides, // number of sides
81 2, // number of z planes
82 zPlanesLong, // z plane z coordinates
83 zeroRadii,
84 poleEndRadii);
85 allSolids.insert(poleIntersectionSolid);
86
87 G4double contInnerRadii[2] = {0, 0}; // solid polyhedra
88 G4double contOuterRadii[2] = {yokeFinishRadius + lengthSafety, yokeFinishRadius + lengthSafety};
89 G4VSolid* containerOuterSolid = new G4Polyhedra(name + "_container_outer_solid", // name
90 polyStartAngle, // start angle
91 CLHEP::twopi, // sweep angle
92 numberOfSides, // number of sides
93 2, // number of z planes
94 zPlanesCont, // z plane z coordinates
95 contInnerRadii,
96 contOuterRadii);
97
98 G4VSolid* containerInnerSolid = new G4Tubs(name + "_container_solid", // name
99 0, // start radius
100 poleStartRadius, // finish radius
101 length, // z half length
102 0, // start angle
103 CLHEP::twopi); // sweep angle
104 // z long for unambiguous subtraction
105 allSolids.insert(containerOuterSolid);
106 allSolids.insert(containerInnerSolid);
107
108 containerSolid = new G4SubtractionSolid(name + "_container_solid", // name
109 containerOuterSolid, // this
110 containerInnerSolid); // minus this with no translation or rotation
111
112 G4double magContOuterRadii[2] = {magnetContainerRadiusIn, magnetContainerRadiusIn};
113 magnetContainerSolid = new G4Polyhedra(name + "_container_solid", // name
114 polyStartAngle, // start angle
115 CLHEP::twopi, // sweep angle
116 numberOfSides, // number of sides
117 2, // number of z planes
118 zPlanesMagCont, // z plane z coordinates
119 contInnerRadii,
120 magContOuterRadii);
121
122
123 magContExtent = BDSExtent(magnetContainerRadiusIn,
124 magnetContainerRadiusIn,
125 magnetContainerLength*0.5);
126}
Holder for +- extents in 3 dimensions.
Definition BDSExtent.hh:38
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.