-
Notifications
You must be signed in to change notification settings - Fork 18
Muon Cooler solenoid rotations #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
ce8c880
39420b7
5e0030a
606b051
027a818
cfdb52f
53ab05a
f83b754
3c62a43
5b54562
486764b
10c740d
9a66aa0
4adcba1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ along with BDSIM. If not, see <http://www.gnu.org/licenses/>. | |
|
|
||
| BDSFieldMagSolenoidBlock::BDSFieldMagSolenoidBlock(BDSMagnetStrength const* strength, | ||
| G4double innerRadiusIn): | ||
| BDSFieldMagSolenoidBlock((*strength)["field"], false, innerRadiusIn, (*strength)["coilRadialThickness"], (*strength)["length"], 0, 1) | ||
| BDSFieldMagSolenoidBlock((*strength)["field"], false, innerRadiusIn, (*strength)["coilRadialThickness"], (*strength)["length"], 0.0, 0.0, 0.0, 0, 1) | ||
| {;} | ||
|
|
||
|
|
||
|
|
@@ -44,13 +44,19 @@ BDSFieldMagSolenoidBlock::BDSFieldMagSolenoidBlock(G4double strength, | |
| G4double innerRadiusIn, | ||
| G4double radialThicknessIn, | ||
| G4double fullLengthZIn, | ||
| G4double tiltXIn, | ||
| G4double tiltYIn, | ||
| G4double tiltZIn, | ||
| G4double toleranceIn, | ||
| G4int nSheetsIn): | ||
| a(innerRadiusIn), | ||
| radialThickness(radialThicknessIn), | ||
| fullLengthZ(fullLengthZIn), | ||
| B0(0), | ||
| I(0), | ||
| tiltX(tiltXIn), | ||
| tiltY(tiltYIn), | ||
| tiltZ(tiltZIn), | ||
| coilTolerance(toleranceIn/(nSheetsIn*2)), //double the tolerance for each sheet | ||
| nSheetsBlock(nSheetsIn) | ||
| { | ||
|
|
@@ -86,6 +92,9 @@ G4ThreeVector BDSFieldMagSolenoidBlock::GetField(const G4ThreeVector& position, | |
| true, | ||
| a + (sheet * dr) + dr / 2, | ||
| fullLengthZ, | ||
| tiltX, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix indenting |
||
| tiltY, | ||
| tiltZ, | ||
| coilTolerance); | ||
| sheetField = field->GetField(position); | ||
| if (sheetField == G4ThreeVector(0, 0, 0)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,21 +32,27 @@ along with BDSIM. If not, see <http://www.gnu.org/licenses/>. | |
| #include <cmath> | ||
|
|
||
| BDSFieldMagSolenoidSheet::BDSFieldMagSolenoidSheet(BDSMagnetStrength const* strength, | ||
| G4double radiusIn, G4double toleranceIn): | ||
| BDSFieldMagSolenoidSheet((*strength)["field"], false, radiusIn, (*strength)["length"], toleranceIn) | ||
| G4double radiusIn,G4double toleranceIn): | ||
| BDSFieldMagSolenoidSheet((*strength)["field"], false, radiusIn, (*strength)["length"], 0.0, 0.0, 0.0, toleranceIn) | ||
| {;} | ||
|
|
||
| BDSFieldMagSolenoidSheet::BDSFieldMagSolenoidSheet(G4double strength, | ||
| G4bool strengthIsCurrent, | ||
| G4double sheetRadius, | ||
| G4double fullLength, | ||
| G4double tiltX, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix indenting |
||
| G4double tiltY, | ||
| G4double tiltZ, | ||
| G4double toleranceIn): | ||
| a(sheetRadius), | ||
| halfLength(0.5*fullLength), | ||
| B0(0.0), | ||
| I(0.0), | ||
| spatialLimit(std::min(1e-5*sheetRadius, 1e-5*fullLength)), | ||
| normalisation(1.0) , | ||
| rotateX(tiltX), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try to be more consistent in variable names. Could be rotateX(rotateXIn)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree - should be consistent. |
||
| rotateY(tiltY), | ||
| rotateZ(tiltZ), | ||
| coilTolerance(toleranceIn) | ||
| { | ||
| finiteStrength = BDS::IsFinite(std::abs(strength)); | ||
|
|
@@ -72,10 +78,22 @@ BDSFieldMagSolenoidSheet::BDSFieldMagSolenoidSheet(G4double strength, | |
| G4ThreeVector BDSFieldMagSolenoidSheet::GetField(const G4ThreeVector& position, | ||
| const G4double /*t*/) const | ||
| { | ||
| G4double z = position.z(); | ||
| G4double rho = position.perp(); | ||
| G4double phi = position.phi(); // angle about z axis | ||
|
|
||
| // Rotation angles - to be moved to struct later | ||
| //G4double rotationX = CLHEP::pi/4; // 45 degrees to put solenoid along z axis | ||
| //G4double rotationY = 0.0; | ||
| //G4double rotationZ = 0.0; | ||
|
|
||
| // Transform position from global to local coordinates (inverse rotation) | ||
| G4ThreeVector localPosition = position; | ||
|
|
||
| // Apply inverse rotations in reverse order (Z -> Y -> X) | ||
| // to transform from global frame to solenoid's local frame | ||
| localPosition.rotateZ(-rotateZ); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not formulate the transformation and just call the inverse method? |
||
| localPosition.rotateY(-rotateY); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like Stewart mentioned, I would perhaps use a G4RotationMatrix. You can prepare it in the constructor and the inverse as well. Then you can just multiply by the appropriate one each time. |
||
| localPosition.rotateX(-rotateX); | ||
| G4double z = localPosition.z(); | ||
| G4double rho = localPosition.perp(); | ||
| G4double phi = localPosition.phi(); // angle about z axis | ||
| // check if close to current source - function not well-behaved at exactly the rho of | ||
| // the current source or at the boundary of +- halfLength | ||
| if (std::abs(rho - a) < spatialLimit && (std::abs(z) < halfLength+2*spatialLimit)) | ||
|
|
@@ -129,9 +147,17 @@ G4ThreeVector BDSFieldMagSolenoidSheet::GetField(const G4ThreeVector& position, | |
| } | ||
| // we have to be consistent with the phi we calculated at the beginning, | ||
| // so unit rho is in the x direction. | ||
| G4ThreeVector result = G4ThreeVector(Brho,0,Bz)* normalisation; | ||
| result = result.rotateZ(phi); | ||
| return result; | ||
| G4ThreeVector localField = G4ThreeVector(Brho,0,Bz) * normalisation; | ||
| localField = localField.rotateZ(phi); | ||
|
|
||
| // Transform field from local back to global coordinates (forward rotation) | ||
| // Apply rotations in forward order (X -> Y -> Z) | ||
| G4ThreeVector globalField = localField; | ||
| globalField.rotateX(rotateX); | ||
| globalField.rotateY(rotateY); | ||
| globalField.rotateZ(rotateZ); | ||
|
|
||
| return globalField; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please can you change this to some other name. The "globalField" is used in BDSIM to mean in the global frame, whereas this is still in the local frame of the element. You usually use one mega-cooling channel but conceptually it's 'local' as the global transform for the beamline is done in a wrapper class. How about unrotatedField and localField. |
||
| } | ||
|
|
||
| G4double BDSFieldMagSolenoidSheet::OnAxisBz(G4double zp, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"offsets then translate(s)".. just translates. I think not in the global frame but in the coordinate frame of the cooling channel element.