Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4HelixExplicitEuler implementation 26 // G4HelixExplicitEuler implementation 27 // 27 // 28 // Helix Explicit Euler: x_1 = x_0 + helix(h) 28 // Helix Explicit Euler: x_1 = x_0 + helix(h) 29 // with helix(h) being a helix piece of lengt 29 // with helix(h) being a helix piece of length h. 30 // Most simple approach for solving linear di 30 // Most simple approach for solving linear differential equations. 31 // Take the current derivative and add it to 31 // Take the current derivative and add it to the current position. 32 // 32 // 33 // Author: W.Wander <wwc@mit.edu>, 12.09.1997 33 // Author: W.Wander <wwc@mit.edu>, 12.09.1997 34 // ------------------------------------------- 34 // ------------------------------------------------------------------- 35 35 36 #include "G4HelixExplicitEuler.hh" 36 #include "G4HelixExplicitEuler.hh" 37 #include "G4PhysicalConstants.hh" 37 #include "G4PhysicalConstants.hh" 38 #include "G4ThreeVector.hh" 38 #include "G4ThreeVector.hh" 39 39 40 G4HelixExplicitEuler::G4HelixExplicitEuler(G4M 40 G4HelixExplicitEuler::G4HelixExplicitEuler(G4Mag_EqRhs* EqRhs) 41 : G4MagHelicalStepper(EqRhs) 41 : G4MagHelicalStepper(EqRhs) 42 { 42 { 43 } 43 } 44 44 45 G4HelixExplicitEuler::~G4HelixExplicitEuler() << 45 G4HelixExplicitEuler::~G4HelixExplicitEuler() >> 46 { >> 47 } 46 48 47 void G4HelixExplicitEuler::Stepper( const G4do 49 void G4HelixExplicitEuler::Stepper( const G4double yInput[], // [7] 48 const G4do 50 const G4double*, 49 G4do 51 G4double Step, 50 G4do 52 G4double yOut[], // [7] 51 G4do 53 G4double yErr[] ) 52 { 54 { 53 // Estimation of the Stepping Angle 55 // Estimation of the Stepping Angle 54 // 56 // 55 G4ThreeVector Bfld; 57 G4ThreeVector Bfld; 56 MagFieldEvaluate(yInput, Bfld); 58 MagFieldEvaluate(yInput, Bfld); 57 59 58 const G4int nvar = 6 ; 60 const G4int nvar = 6 ; 59 G4double yTemp[8], yIn[8] ; 61 G4double yTemp[8], yIn[8] ; 60 G4ThreeVector Bfld_midpoint; 62 G4ThreeVector Bfld_midpoint; 61 63 62 // Saving yInput because yInput and yOut can 64 // Saving yInput because yInput and yOut can be aliases for same array 63 // 65 // 64 for(G4int i=0; i<nvar; ++i) 66 for(G4int i=0; i<nvar; ++i) 65 { 67 { 66 yIn[i] = yInput[i]; 68 yIn[i] = yInput[i]; 67 } 69 } 68 70 69 G4double h = Step * 0.5; 71 G4double h = Step * 0.5; 70 72 71 // Do full step and two half steps 73 // Do full step and two half steps 72 // 74 // 73 G4double yTemp2[7]; 75 G4double yTemp2[7]; 74 AdvanceHelix(yIn, Bfld, h, yTemp2,yTemp); 76 AdvanceHelix(yIn, Bfld, h, yTemp2,yTemp); 75 MagFieldEvaluate(yTemp2, Bfld_midpoint) ; 77 MagFieldEvaluate(yTemp2, Bfld_midpoint) ; 76 AdvanceHelix(yTemp2, Bfld_midpoint, h, yOut) 78 AdvanceHelix(yTemp2, Bfld_midpoint, h, yOut); 77 SetAngCurve(GetAngCurve() * 2); 79 SetAngCurve(GetAngCurve() * 2); 78 80 79 // Error estimation 81 // Error estimation 80 // 82 // 81 for(G4int i=0; i<nvar; ++i) 83 for(G4int i=0; i<nvar; ++i) 82 { 84 { 83 yErr[i] = yOut[i] - yTemp[i]; 85 yErr[i] = yOut[i] - yTemp[i]; 84 } 86 } 85 } 87 } 86 88 87 G4double G4HelixExplicitEuler::DistChord() c 89 G4double G4HelixExplicitEuler::DistChord() const 88 { 90 { 89 // Implementation : must check whether h/R > 91 // Implementation : must check whether h/R > 2 pi !! 90 // If( h/R < pi) use G4LineSection::DistL 92 // If( h/R < pi) use G4LineSection::DistLine 91 // Else DistChord=R_helix 93 // Else DistChord=R_helix 92 // 94 // 93 G4double distChord; 95 G4double distChord; 94 G4double Ang_curve=GetAngCurve(); 96 G4double Ang_curve=GetAngCurve(); 95 97 96 98 97 if(Ang_curve<=pi) 99 if(Ang_curve<=pi) 98 { 100 { 99 distChord=GetRadHelix()*(1-std::cos(0.5*An 101 distChord=GetRadHelix()*(1-std::cos(0.5*Ang_curve)); 100 } 102 } 101 else if(Ang_curve<twopi) 103 else if(Ang_curve<twopi) 102 { 104 { 103 distChord=GetRadHelix()*(1+std::cos(0.5*(t 105 distChord=GetRadHelix()*(1+std::cos(0.5*(twopi-Ang_curve))); 104 } 106 } 105 else 107 else 106 { 108 { 107 distChord=2.*GetRadHelix(); 109 distChord=2.*GetRadHelix(); 108 } 110 } 109 111 110 return distChord; 112 return distChord; 111 } 113 } 112 114 113 void G4HelixExplicitEuler::DumbStepper( const 115 void G4HelixExplicitEuler::DumbStepper( const G4double yIn[], 114 116 G4ThreeVector Bfld, 115 117 G4double h, 116 118 G4double yOut[] ) 117 { 119 { 118 AdvanceHelix(yIn, Bfld, h, yOut); 120 AdvanceHelix(yIn, Bfld, h, yOut); 119 } 121 } 120 122