BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSMagnetOuterFactoryPolesBase.hh
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#ifndef BDSMAGNETOUTERFACTORYPOLESBASE_H
20#define BDSMAGNETOUTERFACTORYPOLESBASE_H
21
22#include "BDSMagnetOuter.hh"
23#include "BDSMagnetOuterFactoryBase.hh"
24
25#include "globals.hh" // geant4 globals / types
26#include "G4TwoVector.hh"
27
28#include <vector>
29
30class BDSBeamPipe;
32class G4Material;
33class G4VSolid;
34
50{
51public:
53 explicit BDSMagnetOuterFactoryPolesBase(G4double poleStopFactorIn);
55
57 virtual BDSMagnetOuter* CreateSectorBend(G4String name, // name
58 G4double length, // full length [mm]
59 const BDSBeamPipe* beamPipe, // beampipe
60 G4double containerLength, // full length to make AccComp container
61 const BDSMagnetOuterInfo* recipe); // recipe for geometry
62
64 virtual BDSMagnetOuter* CreateRectangularBend(G4String name, // name
65 G4double length, // full length [mm]
66 const BDSBeamPipe* beamPipe, // beampipe
67 G4double containerLength, // full length to make AccComp container
68 const BDSMagnetOuterInfo* recipe); // recipe for geometry
69
71 virtual BDSMagnetOuter* CreateQuadrupole(G4String name, // name
72 G4double length, // length [mm]
73 BDSBeamPipe* beamPipe, // beampipe
74 G4double containerLength, // full length to make AccComp container
75 const BDSMagnetOuterInfo* recipe); // geometry recipe
76
78 virtual BDSMagnetOuter* CreateSextupole(G4String name, // name
79 G4double length, // length [mm]
80 BDSBeamPipe* beamPipe, // beampipe
81 G4double containerLength, // full length to make AccComp container
82 const BDSMagnetOuterInfo* recipe); // geometry recipe
83
85 virtual BDSMagnetOuter* CreateOctupole(G4String name, // name
86 G4double length, // length [mm]
87 BDSBeamPipe* beamPipe, // beampipe
88 G4double containerLength, // full length to make AccComp container
89 const BDSMagnetOuterInfo* recipe); // geometry recipe
90
92 virtual BDSMagnetOuter* CreateDecapole(G4String name, // name
93 G4double length, // length
94 BDSBeamPipe* beamPipe, // beampipe
95 G4double containerLength, // full length to make AccComp container
96 const BDSMagnetOuterInfo* recipe); // geometry recipe
97
99 virtual BDSMagnetOuter* CreateSolenoid(G4String name, // name
100 G4double length, // length
101 BDSBeamPipe* beamPipe, // beampipe
102 G4double containerLength, // full length to make AccComp container
103 const BDSMagnetOuterInfo* recipe); // geometry recipe
104
106 virtual BDSMagnetOuter* CreateMultipole(G4String name, // name
107 G4double length, // length
108 BDSBeamPipe* beamPipe, // beampipe
109 G4double containerLength, // full length to make AccComp container
110 const BDSMagnetOuterInfo* recipe); // geometry recipe
111
113 virtual BDSMagnetOuter* CreateRfCavity(G4String name, // name
114 G4double length, // length
115 BDSBeamPipe* beamPipe, // beampipe
116 G4double containerLength, // full length to make AccComp container
117 const BDSMagnetOuterInfo* recipe); // geometry recipe
118
120 virtual BDSMagnetOuter* CreateMuonSpoiler(G4String name, // name
121 G4double length, // length
122 BDSBeamPipe* beamPipe, // beampipe
123 G4double containerLength, // full length to make AccComp container
124 const BDSMagnetOuterInfo* recipe); // geometry recipe
125
127 virtual BDSMagnetOuter* CreateKicker(G4String name, // name
128 G4double length, // length
129 const BDSBeamPipe* beamPipe, // beampipe
130 G4double containerLength, // full length to make AccComp container
131 const BDSMagnetOuterInfo* recipe, // geometry recipe
132 G4bool vertical); // is it a vertical kicker?
133
134protected:
135 // geometry parameters
138 const G4double poleFraction;
139
141 const G4double poleAngularFraction;
142
145 const G4double poleTipFraction;
146
149 const G4double poleAnnulusFraction;
150
154 const G4double bendHeightFraction;
155
159 const G4double poleStopFactor;
160
164 G4bool buildPole;
169 G4double segmentAngle;
170 G4double poleAngle;
171 G4ThreeVector poleTranslation;
172 G4double coilHeight;
174 G4double endPieceLength;
175 G4double endPieceInnerR;
176 G4double endPieceOuterR;
177
179 G4VSolid* coilLeftSolid;
180 G4VSolid* coilRightSolid;
182 G4LogicalVolume* coilLeftLV;
183 G4LogicalVolume* coilRightLV;
184 G4LogicalVolume* endPieceCoilLV;
185 G4LogicalVolume* endPieceContainerLV;
187
188 std::vector<G4TwoVector> leftPoints;
189 std::vector<G4TwoVector> rightPoints;
190 std::vector<G4TwoVector> endPiecePoints;
191
193 virtual void CleanUp();
194
196 void CleanUpPolesBase();
197
199 virtual BDSMagnetOuter* CommonConstructor(const G4String& name,
200 G4double length,
201 BDSBeamPipe* beamPipe,
202 G4int order,
203 G4double magnetContainerLength,
204 const BDSMagnetOuterInfo* recipe);
205
209 virtual void CalculatePoleAndYoke(G4double horizontalWidth,
210 BDSBeamPipe* beamPipe,
211 G4int order);
212
218 virtual void CreatePoleSolid(const G4String& name, // name
219 G4double length, // length [mm]
220 G4int order); // Nx2 poles
221
223 virtual void CreateCoilSolids(const G4String& name,
224 G4double length);
225
227 virtual void CreateCoilPoints();
228
232 virtual void CreateYokeAndContainerSolid(const G4String& name,
233 G4double length,
234 G4int order,
235 G4double magnetContainerLength,
236 G4double magnetContainerRadiusIn); // so as not to clash with member name
237
239 virtual void IntersectPoleWithYoke(const G4String& name,
240 G4double length,
241 G4int order);
242
243 virtual void CreateLogicalVolumes(const G4String& name,
244 G4Colour* colour,
245 G4Material* outerMaterial);
246
250 virtual void CreateLogicalVolumesCoil(const G4String& name);
251
254 virtual void CreateEndPiece(const G4String& name);
255
257 virtual void PlaceComponents(const G4String& name,
258 G4int order);
259
261 virtual void PlaceComponentsCoils(const G4String& name,
262 G4int order);
263
267 void TestCoilFractions(G4double& coilWidthFraction,
268 G4double& coilHeightFraction);
269
273 void DipoleCommonPreConstruction(const G4String& name,
274 G4double angleIn,
275 G4double angleOut,
276 G4double length,
277 G4double& horizontalWidth,
278 G4Material*& material,
279 G4double& vhRatio);
280
283 void DipoleCalculations(G4bool hStyle,
284 G4bool buildVertically,
285 const BDSBeamPipe* beamPipe,
286 G4double length,
287 G4double horizontalWidth,
288 G4double angleIn,
289 G4double angleOut,
290 G4double yokeThicknessFraction,
291 G4double vhRatio,
292 G4double coilWidthFraction,
293 G4double coilHeightFraction,
294 G4double& cShapeOuterEdge,
295 G4double& poleHalfGap,
296 G4double& poleWidth,
297 G4double& poleHeight,
298 G4double& yokeWidth,
299 G4double& yokeHalfHeight,
300 G4double& yokeThickness,
301 G4double& yokeOverHang,
302 G4double& coilWidth,
303 G4double& coilHeightIn, // to avoid shadowing member variable
304 G4double& coilToYokeGap,
305 G4double& coilToPoleGap,
306 G4double& sLength,
307 G4double& containerSLength,
308 G4double& intersectionRadius);
309
312 std::vector<G4ThreeVector> CalculateCoilDisplacements(G4double poleHalfWidthIn,
313 G4double poleHalfGapIn,
314 G4double coilWidthIn,
315 G4double coilHeightIn,
316 G4double cDY,
317 G4double& coilDY);
318
321 BDSMagnetOuter* CreateDipoleC(const G4String& name,
322 G4double length,
323 const BDSBeamPipe* beamPipe,
324 G4double containerLength,
325 const BDSMagnetOuterInfo* recipe,
326 G4bool buildVertically);
327
329 BDSMagnetOuter* CreateDipoleH(const G4String& name,
330 G4double length,
331 const BDSBeamPipe* beamPipe,
332 G4double containerLength,
333 const BDSMagnetOuterInfo* recipe,
334 G4bool buildVertically);
335
336 BDSMagnetOuter* DipoleCommonConstruction(const G4String& name,
337 G4double horizontalWidth,
338 G4bool buildEndPiece,
339 G4double coilWidth,
340 G4double length,
341 G4double containerLength,
342 G4double sLength,
343 G4double angleIn,
344 G4double angleOut,
345 G4Colour* colour,
346 G4Material* material,
347 std::vector<G4ThreeVector>& coilDisps,
348 G4bool buildVertically,
349 BDSExtent& ext,
350 G4double poleHalfWidth,
351 G4double poleHalfGap,
352 G4double cDY,
353 G4double coilDY,
354 G4double intersectionRadius);
355
357};
358
359#endif
A holder class for a piece of beam pipe geometry.
Definition: BDSBeamPipe.hh:45
Holder for +- extents in 3 dimensions.
Definition: BDSExtent.hh:39
Abstract base class for magnet outer volume factories.
Factory class for outer volume of magnets. Produces magnets with 2N-poles around the beampipe with a ...
void DipoleCommonPreConstruction(const G4String &name, G4double angleIn, G4double angleOut, G4double length, G4double &horizontalWidth, G4Material *&material, G4double &vhRatio)
virtual void CalculatePoleAndYoke(G4double horizontalWidth, BDSBeamPipe *beamPipe, G4int order)
BDSMagnetOuter * CreateDipoleH(const G4String &name, G4double length, const BDSBeamPipe *beamPipe, G4double containerLength, const BDSMagnetOuterInfo *recipe, G4bool buildVertically)
Routine to construct an H shaped dipole magnet and can optionally be built vertically.
void CleanUpPolesBase()
Non-virtual clean up to be used in constructor.
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.
virtual void CreateEndPiece(const G4String &name)
virtual void IntersectPoleWithYoke(const G4String &name, G4double length, G4int order)
Chop off the top of the pole to match the appropriate yoke geometry.
G4double endPieceOuterR
Outer radius for end piece container.
std::vector< G4ThreeVector > CalculateCoilDisplacements(G4double poleHalfWidthIn, G4double poleHalfGapIn, G4double coilWidthIn, G4double coilHeightIn, G4double cDY, G4double &coilDY)
virtual BDSMagnetOuter * CreateRectangularBend(G4String name, G4double length, const BDSBeamPipe *beamPipe, G4double containerLength, const BDSMagnetOuterInfo *recipe)
rectangular bend outer volume
BDSMagnetOuter * CreateDipoleC(const G4String &name, G4double length, const BDSBeamPipe *beamPipe, G4double containerLength, const BDSMagnetOuterInfo *recipe, G4bool buildVertically)
void DipoleCalculations(G4bool hStyle, G4bool buildVertically, const BDSBeamPipe *beamPipe, G4double length, G4double horizontalWidth, G4double angleIn, G4double angleOut, G4double yokeThicknessFraction, G4double vhRatio, G4double coilWidthFraction, G4double coilHeightFraction, G4double &cShapeOuterEdge, G4double &poleHalfGap, G4double &poleWidth, G4double &poleHeight, G4double &yokeWidth, G4double &yokeHalfHeight, G4double &yokeThickness, G4double &yokeOverHang, G4double &coilWidth, G4double &coilHeightIn, G4double &coilToYokeGap, G4double &coilToPoleGap, G4double &sLength, G4double &containerSLength, G4double &intersectionRadius)
virtual BDSMagnetOuter * CreateMuonSpoiler(G4String name, G4double length, BDSBeamPipe *beamPipe, G4double containerLength, const BDSMagnetOuterInfo *recipe)
muon spoiler outer volume
G4VSolid * coilLeftSolid
Left coil solid for one pole built upright along y axis.
virtual void CreateLogicalVolumes(const G4String &name, G4Colour *colour, G4Material *outerMaterial)
virtual BDSMagnetOuter * CreateDecapole(G4String name, G4double length, BDSBeamPipe *beamPipe, G4double containerLength, const BDSMagnetOuterInfo *recipe)
decapole outer volume
BDSSimpleComponent * endPiece
Fully constructed end piece.
virtual void CreateCoilSolids(const G4String &name, G4double length)
Create the coil solids corresponding to the pole solid.
const G4double poleAngularFraction
Fraction of 2pi/Npoles that the pole will occupy - always < 1.
G4VSolid * poleIntersectionSolid
Solid used to chop off pole.
G4double poleSquareStartRadius
Radius from magnet centre that constant width section starts.
G4LogicalVolume * endPieceCoilLV
Logical volume for end piece single coil piece.
virtual BDSMagnetOuter * CreateSextupole(G4String name, G4double length, BDSBeamPipe *beamPipe, G4double containerLength, const BDSMagnetOuterInfo *recipe)
sextupole outer volume
virtual BDSMagnetOuter * CreateSectorBend(G4String name, G4double length, const BDSBeamPipe *beamPipe, G4double containerLength, const BDSMagnetOuterInfo *recipe)
sector bend outer volume
G4double magnetContainerRadius
Radius of the container solid for the outer geometry.
G4double poleAngle
The angle allowed for the pole to occupy - less than segmentAngle.
virtual void CreatePoleSolid(const G4String &name, G4double length, G4int order)
virtual void PlaceComponents(const G4String &name, G4int order)
Place the poles and yoke in the container volume.
G4LogicalVolume * endPieceContainerLV
Logical volume for end piece container.
G4double coilCentreRadius
Radius from magnet centre that the centre of the coils exist at.
G4VSolid * endPieceContainerSolid
End piece container solid.
virtual void PlaceComponentsCoils(const G4String &name, G4int order)
If we're building coils, place two coils for each pole.
virtual void CleanUp()
Empty containers for next use - this class is never deleted so can't rely on scope.
std::vector< G4TwoVector > rightPoints
Vector of 2D points for right coil.
std::vector< G4TwoVector > endPiecePoints
Vector of 2D points for end piece looking from above down z.
void TestCoilFractions(G4double &coilWidthFraction, G4double &coilHeightFraction)
G4double poleFinishRadius
Finish radius of the pole from magnet centre.
BDSMagnetOuterFactoryBase * cylindrical
Default factory to fall back to.
virtual void CreateLogicalVolumesCoil(const G4String &name)
G4double endPieceInnerR
Inner radius for end piece container.
std::vector< G4TwoVector > leftPoints
Vector of 2D points for left coil.
G4double endPieceLength
Length of the coil end piece along what will be curvilinear S.
G4double poleStartRadius
Start radius of the pole from magnet centre.
virtual void CreateCoilPoints()
Create all the points that make up the extruded solid of the pole.
virtual BDSMagnetOuter * CreateSolenoid(G4String name, G4double length, BDSBeamPipe *beamPipe, G4double containerLength, const BDSMagnetOuterInfo *recipe)
solenoid outer volume
virtual void CreateYokeAndContainerSolid(const G4String &name, G4double length, G4int order, G4double magnetContainerLength, G4double magnetContainerRadiusIn)
G4LogicalVolume * coilRightLV
Logical volume for right coil.
virtual BDSMagnetOuter * CreateRfCavity(G4String name, G4double length, BDSBeamPipe *beamPipe, G4double containerLength, const BDSMagnetOuterInfo *recipe)
RF cavity outer volume.
G4bool buildPole
Whether or not to build poles (and therefore coils).
G4double yokeStartRadius
Start radius of yoke geometry from magnet cetnre.
G4double coilHeight
Height along y for coil for coil beside 1 upgright pole aligned with y axis.
virtual BDSMagnetOuter * CreateQuadrupole(G4String name, G4double length, BDSBeamPipe *beamPipe, G4double containerLength, const BDSMagnetOuterInfo *recipe)
quadrupole outer volume
virtual BDSMagnetOuter * CreateMultipole(G4String name, G4double length, BDSBeamPipe *beamPipe, G4double containerLength, const BDSMagnetOuterInfo *recipe)
general multipole outer volume - could be any 2N order multipole
G4ThreeVector poleTranslation
Offste of pole for placement from magnet centre.
virtual BDSMagnetOuter * CreateOctupole(G4String name, G4double length, BDSBeamPipe *beamPipe, G4double containerLength, const BDSMagnetOuterInfo *recipe)
octupole outer volume
virtual BDSMagnetOuter * CommonConstructor(const G4String &name, G4double length, BDSBeamPipe *beamPipe, G4int order, G4double magnetContainerLength, const BDSMagnetOuterInfo *recipe)
Common construction tasks to all methods - assemble yoke and poles in container.
G4double poleSquareWidth
Full width of pole in constant width section.
G4LogicalVolume * coilLeftLV
Logical volume for left coil.
virtual BDSMagnetOuter * CreateKicker(G4String name, G4double length, const BDSBeamPipe *beamPipe, G4double containerLength, const BDSMagnetOuterInfo *recipe, G4bool vertical)
horizontal and vertical kicker outer volume
Holder struct of all information required to create the outer geometry of a magnet.
An object for both the returned magnet outer body but also a tight fitting container for the whole ma...
A BDSAcceleratorComponent wrapper for BDSGeometryComponent.