00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id: G4EqMagElectricField.cc 69786 2013-05-15 09:38:51Z gcosmo $ 00028 // 00029 // 00030 // This is the standard right-hand side for equation of motion. 00031 // 00032 // The only case another is required is when using a moving reference 00033 // frame ... or extending the class to include additional Forces, 00034 // eg an electric field 00035 // 00036 // 10.11.98 V.Grichine 00037 // 00038 // ------------------------------------------------------------------- 00039 00040 #include "G4EqMagElectricField.hh" 00041 #include "globals.hh" 00042 #include "G4PhysicalConstants.hh" 00043 #include "G4SystemOfUnits.hh" 00044 00045 void 00046 G4EqMagElectricField::SetChargeMomentumMass(G4double particleCharge, // e+ units 00047 G4double, 00048 G4double particleMass) 00049 { 00050 fElectroMagCof = eplus*particleCharge*c_light ; 00051 fMassCof = particleMass*particleMass ; 00052 } 00053 00054 00055 00056 void 00057 G4EqMagElectricField::EvaluateRhsGivenB(const G4double y[], 00058 const G4double Field[], 00059 G4double dydx[] ) const 00060 { 00061 00062 // Components of y: 00063 // 0-2 dr/ds, 00064 // 3-5 dp/ds - momentum derivatives 00065 00066 G4double pSquared = y[3]*y[3] + y[4]*y[4] + y[5]*y[5] ; 00067 00068 G4double Energy = std::sqrt( pSquared + fMassCof ); 00069 G4double cof2 = Energy/c_light ; 00070 00071 G4double pModuleInverse = 1.0/std::sqrt(pSquared) ; 00072 00073 // G4double inverse_velocity = Energy * c_light * pModuleInverse; 00074 G4double inverse_velocity = Energy * pModuleInverse / c_light; 00075 00076 G4double cof1 = fElectroMagCof*pModuleInverse ; 00077 00078 // G4double vDotE = y[3]*Field[3] + y[4]*Field[4] + y[5]*Field[5] ; 00079 00080 00081 dydx[0] = y[3]*pModuleInverse ; 00082 dydx[1] = y[4]*pModuleInverse ; 00083 dydx[2] = y[5]*pModuleInverse ; 00084 00085 dydx[3] = cof1*(cof2*Field[3] + (y[4]*Field[2] - y[5]*Field[1])) ; 00086 00087 dydx[4] = cof1*(cof2*Field[4] + (y[5]*Field[0] - y[3]*Field[2])) ; 00088 00089 dydx[5] = cof1*(cof2*Field[5] + (y[3]*Field[1] - y[4]*Field[0])) ; 00090 00091 dydx[6] = 0.;//not used 00092 00093 // Lab Time of flight 00094 dydx[7] = inverse_velocity; 00095 return ; 00096 }