G4EqGravityField.cc

Go to the documentation of this file.
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 //  This is the right-hand side for equation of motion for a
00028 //  massive particle in a gravitational field.
00029 //
00030 // History:
00031 // - 14.06.11 P.Gumplinger, Created.
00032 // -------------------------------------------------------------------
00033 // Adopted from G4EqMagElectricField.hh
00034 //
00035 // Thanks to Peter Fierlinger (PSI) and
00036 // A. Capra and A. Fontana (INFN Pavia)
00037 // -------------------------------------------------------------------
00038 
00039 #include "G4EqGravityField.hh"
00040 #include "globals.hh"
00041 #include "G4PhysicalConstants.hh"
00042 
00043 void
00044 G4EqGravityField::SetChargeMomentumMass(G4double,
00045                                         G4double,
00046                                         G4double particleMass )
00047 {
00048   fMass = particleMass;
00049 }
00050 
00051 void
00052 G4EqGravityField::EvaluateRhsGivenB(const G4double y[],
00053                                     const G4double G[],
00054                                     G4double dydx[] ) const
00055 {
00056 
00057   // Components of y:
00058   //    0-2 dr/ds,
00059   //    3-5 dp/ds - momentum derivatives
00060 
00061   G4double momentum_mag_square = y[3]*y[3] + y[4]*y[4] + y[5]*y[5];
00062   G4double inv_momentum_magnitude = 1.0 / std::sqrt( momentum_mag_square );
00063 
00064   G4double Energy = std::sqrt(momentum_mag_square + fMass*fMass);
00065   G4double cof2 = Energy/c_light;
00066   G4double cof1 = inv_momentum_magnitude*fMass;
00067   G4double inverse_velocity = Energy*inv_momentum_magnitude/c_light;
00068 
00069   dydx[0] = y[3]*inv_momentum_magnitude;       //  (d/ds)x = Vx/V
00070   dydx[1] = y[4]*inv_momentum_magnitude;       //  (d/ds)y = Vy/V
00071   dydx[2] = y[5]*inv_momentum_magnitude;       //  (d/ds)z = Vz/V
00072 
00073   dydx[3] = G[0]*cof1*cof2;
00074   dydx[4] = G[1]*cof1*cof2;                    //  m*g
00075   dydx[5] = G[2]*cof1*cof2;
00076 
00077   // Lab Time of flight
00078   dydx[7] = inverse_velocity;
00079 
00080   return;
00081 }

Generated on Mon May 27 17:48:10 2013 for Geant4 by  doxygen 1.4.7