Import Geant4 10.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2016-06-30 14:12:05 +02:00
parent a654a7ab1f
commit 4ec577e5c4
2021 changed files with 100995 additions and 78277 deletions
@@ -0,0 +1,106 @@
// Bogacki-Shampine - 4 - 3(2) non-FSAL implementation
//
// An implementation of the embedded RK method from the paper
// [1] P. Bogacki and L. F. Shampine, “A 3(2) pair of Runge - Kutta formulas,”
// Appl. Math. Lett., vol. 2, no. 4, pp. 321325, Jan. 1989.
//
// This version does not utilise the FSAL property of the method,
// which would allow the reuse of the last derivative in the next step.
// (Alternative FSAL implementation created with revised interface)
//
// Implemented by Somnath Banerjee
// Work supported by the Google Summer of Code 2015.
// Supervision / code review: John Apostolakis
//
// First version: 20 May 2015
//
// This code is made available subject to the Geant4 license, a copy of
// which is available at
// http://geant4.org/license
//
///////////////////////////////////////////////////////////////////////////////
#ifndef G4BOGACKI_SHAMPINE23_H
#define G4BOGACKI_SHAMPINE23_H
#include "G4MagIntegratorStepper.hh"
class G4BogackiShampine23 : public G4MagIntegratorStepper{
public:
//constructor
G4BogackiShampine23( G4EquationOfMotion *EqRhs,
G4int numberOfVariables = 6,
G4bool primary= true ) ;
//destructor
~G4BogackiShampine23() ;
//Stepper
void Stepper(const G4double y[],
const G4double dydx[],
G4double h,
G4double yout[],
G4double yerr[] ) ;
G4double DistChord() const;
G4int IntegratorOrder() const { return 2; }
G4bool isFSAL() const{ return true; }
G4double *getLastDydx();
G4BogackiShampine23(const G4BogackiShampine23&);
G4BogackiShampine23& operator=(const G4BogackiShampine23&);
private:
G4double *ak2, *ak3, *ak4, *yTemp, *yIn;
// for storing intermediate 'k' values in stepper
G4double *pseudoDydx_for_DistChord;
G4double fLastStepLength;
G4double *fLastInitialVector, *fLastFinalVector,
*fLastDyDx, *fMidVector, *fMidError;
// for DistChord calculations
G4BogackiShampine23* fAuxStepper;
// G4int No_of_vars;
// G4double hinit, tinit, tmax, *yinit;
// double hmax, hmin, safe_const, err0, Step_factor;
// void (*derivs)(double, double *, double *);
};
#endif /* G4BogackiShampine23 */
@@ -0,0 +1,107 @@
// An implementation of the embedded RK method from the following paper
// by P. Bogacki and L. F. Shampine:
// “An efficient Runge-Kutta (4,5) pair,”
// Comput. Math. with Appl., vol. 32, no. 6, pp. 1528, Sep. 1996.
//
// An interpolation method provides the value of an intermediate
// point in a step -- if a step was sucessful.
//
// This version can provide the FSAL property of the method,
// which allows the reuse of the last derivative in the next step.
// but only by using the additional method GetLastDyDx.
// (Alternative interface for simpler use of FSAL is under development.)
//
// Design & Implementation by Somnath Banerjee
// Supervision & code review: John Apostolakis
//
// Work supported by the Google Summer of Code 2015.
//
// This code is made available subject to the Geant4 license, a copy of
// which is available at
// http://geant4.org/license
//
///////////////////////////////////////////////////////////////////////////////
#ifndef Bogacki_Shampine_45
#define Bogacki_Shampine_45
#include "G4MagIntegratorStepper.hh"
class G4BogackiShampine45 : public G4MagIntegratorStepper
{
public:
G4BogackiShampine45(G4EquationOfMotion *EqRhs,
G4int numberOfVariables = 6,
G4bool primary = true);
~G4BogackiShampine45();
void Stepper( const G4double y[],
const G4double dydx[],
G4double h,
G4double yout[],
G4double yerr[] ) ;
// This Stepper provides 'dense output'. After a successful
// step, it is possible to obtain an estimate of the value
// of the function at an intermediate point of the interval.
// This requires only two additional evaluations of the
// derivative (and thus the field).
inline void SetupInterpolation()
// const G4double yInput[], const G4double dydx[], const G4double Step )
{
SetupInterpolationHigh(); // ( yInput, dydx, Step);
}
//For calculating the output at the tau fraction of Step
inline void Interpolate( // const G4double yInput[],
// const G4double dydx[],
// const G4double Step,
G4double tau,
G4double yOut[]) // Output value
{
InterpolateHigh( tau, yOut);
// InterpolateHigh( yInput, dydx, Step, yOut, tau);
}
void SetupInterpolationHigh();
// Was: ( const G4double yInput[], const G4double, const G4double Step );
// For calculating the output at the tau fraction of Step
void InterpolateHigh( // const G4double yInput[],
// const G4double dydx[],
// const G4double Step,
G4double tau,
G4double yOut[] ) const;
G4double DistChord() const;
G4int IntegratorOrder() const { return 4; }
void GetLastDydx( G4double dyDxLast[] );
void PrepareConstants(); // Initialise the values of the bi[][] array
private :
G4BogackiShampine45(const G4BogackiShampine45&);
G4BogackiShampine45& operator=(const G4BogackiShampine45&);
G4double *ak2, *ak3, *ak4, *ak5, *ak6, *ak7, *ak8,
*ak9, *ak10, *ak11, *yTemp, *yIn;
G4double *p[6];
G4double fLastStepLength;
G4double *fLastInitialVector, *fLastFinalVector, *fLastDyDx,
*fMidVector, *fMidError;
// for DistChord calculations
G4BogackiShampine45* fAuxStepper; // For chord - until interpolation is proven
bool fPreparedInterpolation;
// Class constants
static bool fPreparedConstants;
static G4double bi[12][7];
};
#endif /* defined(__Geant4__G4BogackiShampine45__) */
@@ -67,7 +67,7 @@ class G4CachedMagneticField : public G4MagneticField
void ClearCounts() { fCountCalls = 0; fCountEvaluations=0; }
void ReportStatistics();
virtual G4CachedMagneticField* Clone() const;
virtual G4Field* Clone() const;
private:
G4MagneticField *fpMagneticField;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4CashKarpRKF45.hh 66356 2012-12-18 09:02:32Z gcosmo $
// $Id: G4CashKarpRKF45.hh 97598 2016-06-06 07:19:46Z gcosmo $
//
//
// class G4CashKarpRKF45
@@ -86,7 +86,7 @@ class G4CashKarpRKF45 : public G4MagIntegratorStepper
private:
G4double *ak2, *ak3, *ak4, *ak5, *ak6, *ak7, *yTemp, *yIn;
G4double *ak2, *ak3, *ak4, *ak5, *ak6, *yTemp, *yIn; // *ak7
// scratch space
G4double fLastStepLength;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4DELPHIMagField.hh 68055 2013-03-13 14:43:28Z gcosmo $
// $Id: G4DELPHIMagField.hh 96751 2016-05-04 09:39:38Z gcosmo $
//
//
// class G4DELPHIMagField
@@ -56,7 +56,7 @@ class G4DELPHIMagField : public G4MagneticField
void GetFieldValue(const G4double yTrack[],
G4double B[] ) const;
G4DELPHIMagField* Clone() const;
G4Field* Clone() const;
};
#endif
@@ -0,0 +1,112 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// DoLoMcPri4(3) RK method - header
// Implements the 6-3-4 non-FSAL method ( 6 stage, 3rd & 4th order embedded RK method )
//
// RK tableau / method develoed by
// Dormand Lockyer McGorrigan Prince
// RK4(3)6FD - forced Non-FSAL
//
// Header, design, implementation by Somnath Banerjee
// Supported by Google in Google Summer of Code 2015.
// Supervision / code review: John Apostolakis
//
// First version: 7 July 2015
//
// This code is made available subject to the Geant4 license, a copy of
// which is available at
// http://geant4.org/license
// G4DoLoMcPriRK34.hh
// Geant4
//
// History
// -----------------------------
// Created by Somnath on 7 July 2015
#ifndef DoLo_McPri_34
#define DoLo_McPri_34
#include "G4MagIntegratorStepper.hh"
class G4DoLoMcPriRK34 : public G4MagIntegratorStepper
{
public:
//Constructor using Equation
G4DoLoMcPriRK34(G4EquationOfMotion *EqRhs,
G4int numberOfVariables = 6,
G4bool primary = true);
~G4DoLoMcPriRK34();
void Stepper( const G4double y[],
const G4double dydx[],
G4double h,
G4double yout[],
G4double yerr[] ) ;
//For Preparing the Interpolant and calculating the extra stages
void SetupInterpolation();
void SetupInterpolate( const G4double yInput[],
const G4double dydx[],
const G4double Step );
//For calculating the output at the tau fraction of Step
void Interpolate( const G4double yInput[],
const G4double dydx[],
const G4double Step,
G4double yOut[],
G4double tau );
void Interpolate( G4double tau,
G4double yOut[]);
void interpolate(const G4double yInput[],
const G4double dydx[],
G4double yOut[],
G4double Step,
G4double tau ) ;
G4double DistChord() const;
G4int IntegratorOrder() const {return 3; }
private :
G4DoLoMcPriRK34(const G4DoLoMcPriRK34&);
//Copy constructor kept private
G4DoLoMcPriRK34& operator=(const G4DoLoMcPriRK34&);
//assignment operator overloaded
G4double *ak2, *ak3, *ak4, *ak5, *ak6, *yTemp, *yIn;
G4double fLastStepLength;
G4double *fLastInitialVector, *fLastFinalVector,
*fLastDyDx, *fMidVector, *fMidError;
// for DistChord calculations
G4DoLoMcPriRK34* fAuxStepper;
};
#endif /* defined(__Geant4__G4DoLoMcPriRK34__) */
@@ -0,0 +1,137 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4DormandPrince745.hh 97387 2016-06-02 10:03:42Z gcosmo $
//
// Class desription:
// An implementation of the 5th order embedded RK method from the paper
// J. R. Dormand and P. J. Prince, “A family of embedded Runge-Kutta formulae,”
// Journal of computational and applied …, vol. 6, no. 1, pp. 1926, 1980.
//
// DormandPrince7 - 5(4) embedded RK method
//
// Design & Implementation by Somnath Banerjee
// Supervision & code review: John Apostolakis
//
// Work supported by the Google Summer of Code 2015.
//
// History
// ------------------------------------------
// Created : 25 May 2015. - Somnath
// Revisions :
// * 29 June 2015: Added interpolate() method(s) - Somnath
// * May 2016: Cleanup and first comming in G4 - John Apostolakis
#ifndef Dormand_Prince_745
#define Dormand_Prince_745
#include "G4MagIntegratorStepper.hh"
class G4DormandPrince745 : public G4MagIntegratorStepper
{
public:
G4DormandPrince745(G4EquationOfMotion *EqRhs,
G4int numberOfVariables = 6,
G4bool primary = true);
~G4DormandPrince745();
void Stepper( const G4double y[],
const G4double dydx[],
G4double h,
G4double yout[],
G4double yerr[] ) ;
//For Preparing the Interpolant and calculating the extra stages
void SetupInterpolation_low( /* const G4double yInput[],
const G4double dydx[],
const G4double Step */ );
//For calculating the output at the tau fraction of Step
void Interpolate_low( /* const G4double yInput[],
const G4double dydx[],
const G4double Step, */
G4double yOut[],
G4double tau );
inline void SetupInterpolation()
/* ( const G4double yInput[],
const G4double dydx[],
const G4double Step ) */
{
SetupInterpolation_low( /* yInput, dydx, Step */ );
// SetupInterpolation_high( /* yInput, dydx, Step */ );
}
//For calculating the output at the tau fraction of Step
inline void Interpolate(
/* const G4double yInput[],
const G4double dydx[],
const G4double Step, */
G4double tau,
G4double yOut[]
)
{
Interpolate_low( /* yInput, dydx, Step, */ yOut, tau);
// Interpolate_high( /* yInput, dydx, Step, */ yOut, tau);
}
void SetupInterpolation_high( /* const G4double yInput[],
const G4double dydx[],
const G4double Step */ );
//For calculating the output at the tau fraction of Step
void Interpolate_high( /* const G4double yInput[],
const G4double dydx[],
const G4double Step, */
G4double yOut[],
G4double tau );
G4double DistChord() const;
G4double DistChord2() const;
G4double DistChord3() const;
// Enabling method, with common code between implementations (and steppers)
G4double DistLine( G4double yStart[], G4double yMid[], G4double yEnd[] ) const;
G4int IntegratorOrder() const {return 4; }
//New copy constructor
// G4DormandPrince745(const G4DormandPrince745 &);
private :
G4DormandPrince745& operator=(const G4DormandPrince745&);
G4double *ak2, *ak3, *ak4, *ak5, *ak6, *ak7,
*ak8, *ak9, //For additional stages in the interpolant
*yTemp, *yIn;
G4double fLastStepLength;
G4double *fLastInitialVector, *fLastFinalVector,
*fInitialDyDx, *fMidVector, *fMidError;
// for DistChord calculations
G4DormandPrince745* fAuxStepper;
};
#endif /* defined(__Geant4__G4DormandPrince745__) */
@@ -0,0 +1,134 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Dormand-Prince RK 6(5) non-FSAL implementation by Somnath Banerjee
// Supervision / code review: John Apostolakis
//
// Sponsored by Google in Google Summer of Code 2015.
//
// First version: 26 June 2015
//
// This code is made available subject to the Geant4 license, a copy of
// which is available at
// http://geant4.org/license
// G4DormandPrince745.cc
// Geant4
//
// History
// -----------------------------
// Created by Somnath on 26 June 2015
//
//
///////////////////////////////////////////////////////////////////////////////
#ifndef DORMAND_PRINCE_RK56_H
#define DORMAND_PRINCE_RK56_H
#include "G4MagIntegratorStepper.hh"
class G4DormandPrinceRK56 : public G4MagIntegratorStepper{
public:
//constructor
G4DormandPrinceRK56( G4EquationOfMotion *EqRhs,
G4int numberOfVariables = 6,
G4bool primary= true ) ;
//destructor
~G4DormandPrinceRK56() ;
//Stepper
void Stepper( const G4double y[],
const G4double dydx[],
G4double h,
G4double yout[],
G4double yerr[] ) ;
G4double DistChord() const;
G4int IntegratorOrder() const { return 5; }
G4DormandPrinceRK56(const G4DormandPrinceRK56&);
G4DormandPrinceRK56& operator=(const G4DormandPrinceRK56&);
//For Preparing the Interpolant and calculating the extra stages
void SetupInterpolate_low( const G4double yInput[],
const G4double dydx[],
const G4double Step );
//For calculating the output at the tau fraction of Step
void Interpolate_low( const G4double yInput[],
const G4double dydx[],
const G4double Step,
G4double yOut[],
G4double tau );
void SetupInterpolation()
{ SetupInterpolate( fLastInitialVector, fLastDyDx, fLastStepLength); }
inline void SetupInterpolate( const G4double yInput[],
const G4double dydx[],
const G4double Step ){
SetupInterpolate_low( yInput, dydx, Step);
}
//For calculating the output at the tau fraction of Step
inline void Interpolate( const G4double yInput[],
const G4double dydx[],
const G4double Step,
G4double yOut[],
G4double tau ){
Interpolate_low( yInput, dydx, Step, yOut, tau);
}
void Interpolate( G4double tau, G4double yOut[])
{ Interpolate( fLastInitialVector, fLastDyDx, fLastStepLength, yOut, tau ); }
void SetupInterpolate_high( const G4double yInput[],
const G4double dydx[],
const G4double Step );
//For calculating the output at the tau fraction of Step
void Interpolate_high( const G4double yInput[],
const G4double dydx[],
const G4double Step,
G4double yOut[],
G4double tau );
private:
G4double *ak2, *ak3, *ak4, *ak5, *ak6, *ak7, *ak8, *ak9; // for storing intermediate 'k' values in stepper
G4double *ak10_low, *ak10, *ak11, * ak12; //For the additional stages of Interpolant
G4double *yTemp, *yIn;
G4double fLastStepLength;
G4double *fLastInitialVector, *fLastFinalVector,
*fLastDyDx, *fMidVector, *fMidError;
// for DistChord calculations
G4DormandPrinceRK56* fAuxStepper;
};
#endif /* G4DormandPrinceRK56 */
@@ -0,0 +1,68 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4DormandPrinceRK78.hh
//
// Created by Somnath on 30/06/15.
#ifndef G4Dormand_Prince_RK78_hh
#define G4Dormand_Prince_RK78_hh
#include "G4MagIntegratorStepper.hh"
class G4DormandPrinceRK78 : public G4MagIntegratorStepper
{
public:
G4DormandPrinceRK78(G4EquationOfMotion *EqRhs,
G4int numberOfVariables = 6,
G4bool primary = true);
~G4DormandPrinceRK78();
void Stepper( const G4double y[],
const G4double dydx[],
G4double h,
G4double yout[],
G4double yerr[]) ;
G4double DistChord() const;
G4int IntegratorOrder() const {return 7; }
private :
G4DormandPrinceRK78(const G4DormandPrinceRK78&);
G4DormandPrinceRK78& operator=(const G4DormandPrinceRK78&);
G4double *ak2, *ak3, *ak4, *ak5, *ak6, *ak7, *ak8,
*ak9, *ak10, *ak11, *ak12, *ak13,
*yTemp, *yIn;
G4double fLastStepLength;
G4double *fLastInitialVector, *fLastFinalVector,
*fLastDyDx, *fMidVector, *fMidError;
// for DistChord calculations
G4DormandPrinceRK78* fAuxStepper;
};
#endif /* defined(__G4_DormandPrinceRK78_hh) */
@@ -0,0 +1,88 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Bogacki-Shampine - 8 - 5(4) FSAL implementation by Somnath Banerjee
// Supervision / code review: John Apostolakis
//
// Sponsored by Google in Google Summer of Code 2015.
//
// First version: 26 May 2015
//
// History
// -----------------------------
// Created by Somnath on 26 May 2015
//
//
///////////////////////////////////////////////////////////////////////////////
#ifndef G4FSAL_Bogacki_Shampine_45_hh
#define G4FSAL_Bogacki_Shampine_45_hh
#include "G4VFSALIntegrationStepper.hh"
class G4FSALBogackiShampine45 : public G4VFSALIntegrationStepper
{
public:
G4FSALBogackiShampine45(G4EquationOfMotion *EqRhs,
G4int numberOfVariables = 6,
G4bool primary = true);
~G4FSALBogackiShampine45();
void Stepper( const G4double y[],
const G4double dydx[],
G4double h,
G4double yout[],
G4double yerr[],
G4double nextDydx[]) ;
void interpolate( const G4double yInput[],
const G4double dydx[],
G4double yOut[],
G4double Step,
G4double tau ) ;
G4double DistChord() const;
G4int IntegratorOrder() const { return 4; }
private :
G4FSALBogackiShampine45(const G4FSALBogackiShampine45&);
G4FSALBogackiShampine45& operator=(const G4FSALBogackiShampine45&);
G4double *ak2, *ak3, *ak4, *ak5, *ak6, *ak7, *ak8,
*ak9, *ak10, *ak11,
*yTemp, *yIn;
G4double *pseudoDydx_for_DistChord;
G4double fLastStepLength;
G4double *fLastInitialVector, *fLastFinalVector,
*fLastDyDx, *fMidVector, *fMidError;
// for DistChord calculations
G4FSALBogackiShampine45* fAuxStepper;
};
#endif /* defined( G4FSAL_Bogacki_Shampine_45_hh ) */
@@ -0,0 +1,84 @@
// DormandPrince7 - 5(4) FSAL implementation by Somnath Banerjee
// Supervision / code review: John Apostolakis
//
// Sponsored by Google in Google Summer of Code 2015.
//
// First version: 25 May 2015
//
// This code is made available subject to the Geant4 license, a copy of
// which is available at
// http://geant4.org/license
//
// $ID: FDormandPrince745.hh $
//
// History
// ----------------------------------------------------
// Created : 25 May 2015. - Somnath
//
// Added interpolate() method: - Somnath
// 29 June 2015
#ifndef FFDormand_Prince_745
#define FFDormand_Prince_745
#include "G4VFSALIntegrationStepper.hh"
class G4FSALDormandPrince745 : public G4VFSALIntegrationStepper
{
public:
G4FSALDormandPrince745(G4EquationOfMotion *EqRhs,
G4int numberOfVariables = 6,
G4bool primary = true);
~G4FSALDormandPrince745();
void Stepper( const G4double y[],
const G4double dydx[],
G4double h,
G4double yout[],
G4double yerr[],
G4double nextDydx[]) ;
void interpolate( const G4double yInput[],
const G4double dydx[],
G4double yOut[],
G4double Step,
G4double tau ) ;
//For higher order Interpolant
void SetupInterpolate( const G4double yInput[],
const G4double dydx[],
const G4double Step );
//For calculating the output at the tau fraction of Step
void Interpolate( const G4double yInput[],
const G4double dydx[],
const G4double Step,
G4double yOut[],
G4double tau );
G4double DistChord() const;
G4int IntegratorOrder() const {return 4; }
G4bool isFSAL() const{ return true; }
// G4double *getLastDydx();
private :
G4FSALDormandPrince745(const G4FSALDormandPrince745&);
G4FSALDormandPrince745& operator=(const G4FSALDormandPrince745&);
G4double *ak2, *ak3, *ak4, *ak5, *ak6, *ak7,
*ak8, *ak9, //For additional stages in the interpolant
*yTemp, *yIn;
//Only for use with DistChord :-
G4double *pseudoDydx_for_DistChord;
G4double fLastStepLength;
G4double *fLastInitialVector, *fLastFinalVector,
*fLastDyDx, *fMidVector, *fMidError;
// for DistChord calculations
G4FSALDormandPrince745* fAuxStepper;
};
#endif /* defined(__Geant4__FSALDormandPrince745__) */
@@ -0,0 +1,268 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4FSALIntegrationDriver.hh 97387 2016-06-02 10:03:42Z gcosmo $
//
//
// class G4FSALIntegrationDriver
//
// Class description:
//
// Provides a driver that talks to the Integrator Stepper, and insures that
// the error is within acceptable bounds.
// History:
// - Created. J.Apostolakis.
// --------------------------------------------------------------------
#ifndef G4FSALIntegrationDriver_Def
#define G4FSALIntegrationDriver_Def
#include "G4Types.hh"
#include "G4FieldTrack.hh"
#include "G4VFSALIntegrationStepper.hh"
class G4FSALIntegrationDriver
{
public: // with description
G4bool AccurateAdvance(G4FieldTrack& y_current,
G4double hstep,
G4double eps, // Requested y_err/hstep
G4double hinitial=0.0); // Suggested 1st interval
// Above drivers for integrator (Runge-Kutta) with stepsize control.
// Integrates ODE starting values y_current
// from current s (s=s0) to s=s0+h with accuracy eps.
// On output ystart is replaced by value at end of interval.
// The concept is similar to the odeint routine from NRC p.721-722.
G4bool QuickAdvance( G4FieldTrack& y_val, // INOUT
G4double dydx[],
G4double hstep, // IN
G4double& dchord_step,
G4double& dyerr ) ;
// QuickAdvance just tries one Step - it does not ensure accuracy.
G4bool QuickAdvance( G4FieldTrack& y_posvel, // INOUT
G4double dydx[],
G4double hstep, // IN
G4double& dchord_step,
G4double& dyerr_pos_sq,
G4double& dyerr_mom_rel_sq ) ;
// New QuickAdvance that also just tries one Step
// (so also does not ensure accuracy)
// but does return the errors in position and
// momentum (normalised: Delta_Integration(p^2)/(p^2) )
G4FSALIntegrationDriver( G4double hminimum,
G4VFSALIntegrationStepper *pItsStepper,
G4int numberOfComponents=6,
G4int statisticsVerbosity=1);
~G4FSALIntegrationDriver();
// Constructor, destructor.
inline G4double GetHmin() const;
inline G4double Hmin() const; // Obsolete
inline G4double GetSafety() const;
inline G4double GetPshrnk() const;
inline G4double GetPgrow() const;
inline G4double GetErrcon() const;
inline G4int GetNoTotalSteps() const; //Only for debug purposes
inline void GetDerivatives( const G4FieldTrack &y_curr, // const, INput
G4double dydx[] ); // OUTput
// Accessors.
inline void RenewStepperAndAdjust(G4VFSALIntegrationStepper *pItsStepper);
// Sets a new stepper pItsStepper for this driver. Then it calls
// ReSetParameters to reset its parameters accordingly.
inline void ReSetParameters(G4double new_safety= 0.9 );
// i) sets the exponents (pgrow & pshrnk),
// using the current Stepper's order,
// ii) sets the safety
// ii) calculates "errcon" according to the above values.
inline void SetSafety(G4double valS);
inline void SetPshrnk(G4double valPs);
inline void SetPgrow (G4double valPg);
inline void SetErrcon(G4double valEc);
// When setting safety or pgrow, errcon will be set to a
// compatible value.
inline G4double ComputeAndSetErrcon();
inline const G4VFSALIntegrationStepper* GetStepper() const;
inline G4VFSALIntegrationStepper* GetStepper();
void OneGoodStep( G4double ystart[], // Like old RKF45step()
G4double dydx[],
G4double& x,
G4double htry,
G4double eps, // memb variables ?
G4double& hdid,
G4double& hnext ) ;
// This takes one Step that is as large as possible while
// satisfying the accuracy criterion of:
// yerr < eps * |y_end-y_start|
G4double ComputeNewStepSize( G4double errMaxNorm, // normalised error
G4double hstepCurrent); // current step size
// Taking the last step's normalised error, calculate
// a step size for the next step.
// Do not limit the next step's size within a factor of the
// current one.
G4double ComputeNewStepSize_WithinLimits(
G4double errMaxNorm, // normalised error
G4double hstepCurrent); // current step size
// Taking the last step's normalised error, calculate
// a step size for the next step.
// Limit the next step's size within a range around the current one.
inline G4int GetMaxNoSteps() const;
inline void SetMaxNoSteps( G4int val);
// Modify and Get the Maximum number of Steps that can be
// taken for the integration of a single segment -
// (ie a single call to AccurateAdvance).
//---------------------------------------------------------------------
//The following has been introduced by [hackabot] for testing purposes only
inline G4int GetTotalNoStepperCalls() const;
//---------------------------------------------------------------------
public: // without description
inline void SetHmin(G4double newval);
inline void SetVerboseLevel(G4int newLevel);
inline G4double GetVerboseLevel() const;
inline G4double GetSmallestFraction() const;
void SetSmallestFraction( G4double val );
protected: // without description
void WarnSmallStepSize( G4double hnext, G4double hstep,
G4double h, G4double xDone,
G4int noSteps);
void WarnTooManyStep( G4double x1start, G4double x2end, G4double xCurrent);
void WarnEndPointTooFar (G4double endPointDist,
G4double hStepSize ,
G4double epsilonRelative,
G4int debugFlag);
// Issue warnings for undesirable situations
void PrintStatus( const G4double* StartArr,
G4double xstart,
const G4double* CurrentArr,
G4double xcurrent,
G4double requestStep,
G4int subStepNo );
void PrintStatus( const G4FieldTrack& StartFT,
const G4FieldTrack& CurrentFT,
G4double requestStep,
G4int subStepNo );
void PrintStat_Aux( const G4FieldTrack& aFieldTrack,
G4double requestStep,
G4double actualStep,
G4int subStepNo,
G4double subStepSize,
G4double dotVelocities );
// Verbose output for debugging
void PrintStatisticsReport() ;
// Report on the number of steps, maximum errors etc.
#ifdef QUICK_ADV_TWO
G4bool QuickAdvance( G4double yarrin[], // In
const G4double dydx[],
G4double hstep,
G4double yarrout[], // Out
G4double& dchord_step, // Out
G4double& dyerr ); // in length
#endif
private:
G4FSALIntegrationDriver(const G4FSALIntegrationDriver&);
G4FSALIntegrationDriver& operator=(const G4FSALIntegrationDriver&);
// Private copy constructor and assignment operator.
private:
// ---------------------------------------------------------------
// INVARIANTS
G4double fMinimumStep;
// Minimum Step allowed in a Step (in absolute units)
G4double fSmallestFraction; // Expected range 1e-12 to 5e-15;
// Smallest fraction of (existing) curve length - in relative units
// below this fraction the current step will be the last
const G4int fNoIntegrationVariables; // Number of Variables in integration
const G4int fMinNoVars; // Minimum number for FieldTrack
const G4int fNoVars; // Full number of variable
G4int fMaxNoSteps;
static const G4int fMaxStepBase;
G4double safety;
G4double pshrnk; // exponent for shrinking
G4double pgrow; // exponent for growth
G4double errcon;
// Parameters used to grow and shrink trial stepsize.
static const G4double max_stepping_increase;
static const G4double max_stepping_decrease;
// Maximum stepsize increase/decrease factors.
G4int fStatisticsVerboseLevel;
// ---------------------------------------------------------------
// DEPENDENT Objects
G4VFSALIntegrationStepper *pIntStepper;
// ---------------------------------------------------------------
// STATE
G4int fNoTotalSteps, fNoBadSteps, fNoSmallSteps, fNoInitialSmallSteps;
G4double fDyerr_max, fDyerr_mx2;
G4double fDyerrPos_smTot, fDyerrPos_lgTot, fDyerrVel_lgTot;
G4double fSumH_sm, fSumH_lg;
// Step Statistics
G4int fVerboseLevel; // Verbosity level for printing (debug, ..)
// Could be varied during tracking - to help identify issues
//For Test Purposes :-
G4int TotalNoStepperCalls;
};
#include "G4FSALIntegrationDriver.icc"
#endif /* G4FSALIntegrationDriver_Def */
@@ -0,0 +1,178 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4FSALIntegrationDriver.icc 97387 2016-06-02 10:03:42Z gcosmo $
//
// --------------------------------------------------------------------
inline
G4double G4FSALIntegrationDriver::GetHmin() const
{
return fMinimumStep;
}
inline
G4double G4FSALIntegrationDriver::Hmin() const
{
return fMinimumStep;
}
inline
G4double G4FSALIntegrationDriver::GetSafety() const
{
return safety;
}
inline
G4double G4FSALIntegrationDriver::GetPshrnk() const
{
return pshrnk;
}
inline
G4double G4FSALIntegrationDriver::GetPgrow() const
{
return pgrow;
}
inline
G4double G4FSALIntegrationDriver::GetErrcon() const
{
return errcon;
}
inline
void G4FSALIntegrationDriver::SetHmin(G4double newval)
{
fMinimumStep = newval;
}
inline
G4double G4FSALIntegrationDriver::ComputeAndSetErrcon()
{
errcon = std::pow(max_stepping_increase/GetSafety(),1.0/GetPgrow());
return errcon;
}
inline
void G4FSALIntegrationDriver::ReSetParameters(G4double new_safety)
{
safety = new_safety;
pshrnk = -1.0 / pIntStepper->IntegratorOrder();
pgrow = -1.0 / (1.0 + pIntStepper->IntegratorOrder());
ComputeAndSetErrcon();
}
inline
void G4FSALIntegrationDriver::SetSafety(G4double val)
{
safety=val;
ComputeAndSetErrcon();
}
inline
void G4FSALIntegrationDriver::SetPgrow(G4double val)
{
pgrow=val;
ComputeAndSetErrcon();
}
inline
void G4FSALIntegrationDriver::SetErrcon(G4double val)
{
errcon=val;
}
inline
void G4FSALIntegrationDriver::RenewStepperAndAdjust(G4VFSALIntegrationStepper *pItsStepper)
{
pIntStepper = pItsStepper;
ReSetParameters();
}
inline
const G4VFSALIntegrationStepper* G4FSALIntegrationDriver::GetStepper() const
{
return pIntStepper;
}
inline
G4VFSALIntegrationStepper* G4FSALIntegrationDriver::GetStepper()
{
return pIntStepper;
}
inline
G4int G4FSALIntegrationDriver::GetMaxNoSteps() const
{
return fMaxNoSteps;
}
inline
void G4FSALIntegrationDriver::SetMaxNoSteps(G4int val)
{
fMaxNoSteps= val;
}
inline
void G4FSALIntegrationDriver::GetDerivatives(const G4FieldTrack &y_curr, // const, INput
G4double dydx[]) // OUTput
{
G4double tmpValArr[G4FieldTrack::ncompSVEC];
y_curr.DumpToArray( tmpValArr );
pIntStepper -> RightHandSide( tmpValArr , dydx );
}
inline
G4double G4FSALIntegrationDriver::GetVerboseLevel() const
{
return fVerboseLevel;
}
inline
void G4FSALIntegrationDriver::SetVerboseLevel(G4int newLevel)
{
fVerboseLevel= newLevel;
}
inline
G4double G4FSALIntegrationDriver::GetSmallestFraction() const
{
return fSmallestFraction;
}
inline
G4int G4FSALIntegrationDriver::GetNoTotalSteps() const
{
return fNoTotalSteps;
}
inline
G4int G4FSALIntegrationDriver::GetTotalNoStepperCalls() const
{
return TotalNoStepperCalls;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Field.hh 68055 2013-03-13 14:43:28Z gcosmo $
// $Id: G4Field.hh 96751 2016-05-04 09:39:38Z gcosmo $
//
//
// class G4Field
@@ -83,7 +83,7 @@ class G4Field
G4Field( G4bool gravityOn= false);
G4Field( const G4Field & );
virtual ~G4Field();
inline G4Field& operator = (const G4Field &p);
G4Field& operator = (const G4Field &p);
// A field signature function that can be used to insure
// that the Equation of motion object and the G4Field object
@@ -99,9 +99,11 @@ class G4Field
// Does this field include gravity?
inline void SetGravityActive( G4bool OnOffFlag );
virtual G4Field* Clone() const;
//Implements cloning, needed by G4 MT
virtual G4Field* Clone() const;
// Implements cloning, needed by G4 MT
private:
G4bool fGravityActive;
};
@@ -37,12 +37,20 @@
// it possible to choose other stepper,like G4CashKarpRK45 or G4RKG3_Stepper,
// by setting StepperNumber : new HelixMixedStepper(EqRhs,N)
//
// N=0 G4ExplicitEuler; N=1 G4ImplicitEuler;
// N=2 G4SimpleRunge; N=3 G4SimpleHeum;
// N=4 G4ClassicalRK4; N=5 G4HelixExplicitEuler;
// N=6 G4HelixExplicitEuler; N=7 G4HelixSimpleRunge;
// N=4 G4ClassicalRK4;
// N=6 G4HelixImplicitEuler; N=7 G4HelixSimpleRunge;
// N=8 G4CashKarpRK45; N=9 G4ExactHelixStepper;
// N=10 G4RKG3_Stepper;
// N=10 G4RKG3_Stepper; N=13 G4NystromRK4
// N=23 BogackiShampine23 N=145 TsitourasRK45
// N=45 BogackiShampine45 N=745 DormandPrince745 (ie DoPri5)
//
// For completeness also available are:
// N=11 G4ExplicitEuler N=12 G4ImplicitEuler; -- Likely poor
// N=5 G4HelixExplicitEuler (testing only)
// For recommendations see comments in 'SetupStepper' method.
//
// Note: Like other helix steppers, only applicable in pure magnetic field
//
// History:
// Derived from ExactHelicalStepper 18/05/07
@@ -60,7 +68,7 @@ class G4HelixMixedStepper: public G4MagHelicalStepper
public:
G4HelixMixedStepper(G4Mag_EqRhs *EqRhs,G4int fStepperNumber= -1, G4double Angle_threshold= -1.0);
G4HelixMixedStepper(G4Mag_EqRhs *EqRhs,G4int StepperNumber= -1, G4double Angle_threshold= -1.0);
~G4HelixMixedStepper();
void Stepper( const G4double y[],
@@ -94,8 +102,11 @@ class G4HelixMixedStepper: public G4MagHelicalStepper
G4int IntegratorOrder() const { return 4; }
private:
// Mixed Integration RK4 for 'small' steps
G4MagIntegratorStepper* fRK4Stepper;
G4MagIntegratorStepper* fRK4Stepper;
G4int fStepperNumber; // Int ID of RK stepper
// Threshold angle (in radians ) - above it Helical stepper is used
G4double fAngle_threshold;
private:
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4LineCurrentMagField.hh 68055 2013-03-13 14:43:28Z gcosmo $
// $Id: G4LineCurrentMagField.hh 96751 2016-05-04 09:39:38Z gcosmo $
//
//
// class G4LineCurrentMagField
@@ -54,7 +54,8 @@ class G4LineCurrentMagField : public G4MagneticField
void GetFieldValue(const G4double yTrack[] ,
G4double B[] ) const;
G4LineCurrentMagField* Clone() const;
G4Field* Clone() const;
private:
G4double fFieldConstant;
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4MagIntegratorStepper.hh 66356 2012-12-18 09:02:32Z gcosmo $
// $Id: G4MagIntegratorStepper.hh 97387 2016-06-02 10:03:42Z gcosmo $
//
//
// class G4MagIntegratorStepper
@@ -55,7 +55,10 @@ class G4MagIntegratorStepper
G4MagIntegratorStepper(G4EquationOfMotion *Equation,
G4int numIntegrationVariables,
G4int numStateVariables=12);
G4int numStateVariables=12,
bool isFSAL= false
// , G4int methodOrder
);
virtual ~G4MagIntegratorStepper();
// Constructor and destructor. No actions.
@@ -69,7 +72,7 @@ class G4MagIntegratorStepper
// Integrates ODE starting values y[0 to 6].
// Outputs yout[] and its estimated error yerr[].
virtual G4double DistChord() const = 0;
virtual G4double DistChord() const = 0;
// Estimate the maximum distance of a chord from the true path
// over the segment last integrated.
@@ -87,12 +90,9 @@ class G4MagIntegratorStepper
// Utility method to supply the standard Evaluation of the
// Right Hand side of the associated equation.
inline G4int GetNumberOfVariables() const;
// Get the number of variables that the stepper will integrate over.
// void SetNumberOfVariables(G4int newNo); // Dangerous & obsolete ...
inline G4int GetNumberOfStateVariables() const;
// Get the number of variables of state variables (>= above, integration)
@@ -100,11 +100,25 @@ class G4MagIntegratorStepper
// Returns the order of the integrator
// i.e. its error behaviour is of the order O(h^order).
G4int IntegrationOrder() { return fIntegrationOrder; }
// Replacement method - using new data member
inline G4EquationOfMotion *GetEquationOfMotion();
// As some steppers (eg RKG3) require other methods of Eq_Rhs
// this function allows for access to them.
inline void SetEquationOfMotion(G4EquationOfMotion* newEquation);
inline unsigned long GetfNoRHSCalls(){ return fNoRHSCalls; }
// void IncrementRHSCalls() { fNoRHSCalls++; }
inline void ResetfNORHSCalls(){ fNoRHSCalls = 0; }
// Count number of calls to RHS method(s)
bool IsFSAL() { return fIsFSAL; }
protected:
void SetIntegrationOrder(int order) { fIntegrationOrder= order; }
void SetFSAL( bool flag= true) { fIsFSAL= flag; }
private:
G4MagIntegratorStepper(const G4MagIntegratorStepper&);
@@ -117,6 +131,14 @@ class G4MagIntegratorStepper
const G4int fNoIntegrationVariables; // Number of Variables in integration
const G4int fNoStateVariables; // Number required for FieldTrack
// const G4int fNumberOfVariables;
// Counter for calls to RHS method
mutable unsigned long fNoRHSCalls;
// Parameters of a RK method -- must be shared by all steppers of a type
// -- Invariants for a class
/* const */ int fIntegrationOrder; // all ClassicalRK4 steppers are 4th order
/* const */ bool fIsFSAL; // Depends on RK method & implementation
};
#include "G4MagIntegratorStepper.icc"
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4MagIntegratorStepper.icc 66356 2012-12-18 09:02:32Z gcosmo $
// $Id: G4MagIntegratorStepper.icc 97387 2016-06-02 10:03:42Z gcosmo $
//
inline
@@ -58,6 +58,7 @@ inline
void G4MagIntegratorStepper::RightHandSide( const double y[], double dydx[] )
{
fEquation_Rhs-> RightHandSide(y, dydx);
fNoRHSCalls++; // IncrementRHSCalls();
}
inline
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4QuadrupoleMagField.hh 68055 2013-03-13 14:43:28Z gcosmo $
// $Id: G4QuadrupoleMagField.hh 96751 2016-05-04 09:39:38Z gcosmo $
//
//
// class G4QuadrupoleMagField
@@ -63,7 +63,8 @@ class G4QuadrupoleMagField : public G4MagneticField
void GetFieldValue(const G4double yTrack[],
G4double B[] ) const;
G4QuadrupoleMagField* Clone() const;
G4Field* Clone() const;
private:
G4double fGradient;
@@ -0,0 +1,68 @@
//
// G4TsitourasRK45.hh
// Geant4
//
// Created by hackabot on 11/06/15.
//
//
#ifndef Tsitouras_RK45
#define Tsitouras_RK45
#include "G4MagIntegratorStepper.hh"
class G4TsitourasRK45 : public G4MagIntegratorStepper
{
public:
G4TsitourasRK45(G4EquationOfMotion *EqRhs,
G4int numberOfVariables = 6,
G4bool primary = true);
~G4TsitourasRK45();
void Stepper( const G4double y[],
const G4double dydx[],
G4double h,
G4double yout[],
G4double yerr[] ) ;
void SetupInterpolation( /* const G4double yInput[],
const G4double dydx[],
const G4double Step */ );
//For calculating the output at the tau fraction of Step
void Interpolate( const G4double yInput[],
const G4double dydx[],
const G4double Step,
G4double yOut[],
G4double tau );
void interpolate( const G4double yInput[],
const G4double dydx[],
G4double yOut[],
G4double Step,
G4double tau);
G4double DistChord() const;
G4int IntegratorOrder() const {return 4; }
// G4double *getLastDydx();
private :
G4TsitourasRK45(const G4TsitourasRK45&);
G4TsitourasRK45& operator=(const G4TsitourasRK45&);
G4double *ak2, *ak3, *ak4, *ak5, *ak6, *ak7, *ak8, *yTemp, *yIn;
G4double fLastStepLength;
G4double *fLastInitialVector, *fLastFinalVector,
*fLastDyDx, *fMidVector, *fMidError;
// for DistChord calculations
G4TsitourasRK45* fAuxStepper;
};
#endif /* defined(__Geant4__G4TsitourasRK45__) */
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4UniformElectricField.hh 68055 2013-03-13 14:43:28Z gcosmo $
// $Id: G4UniformElectricField.hh 96751 2016-05-04 09:39:38Z gcosmo $
//
//
// class G4UniformElectricField
@@ -63,7 +63,8 @@ class G4UniformElectricField : public G4ElectricField
virtual void GetFieldValue(const G4double pos[4], G4double *field) const;
virtual G4UniformElectricField* Clone() const;
virtual G4Field* Clone() const;
private:
G4double fFieldComponents[6] ;
@@ -70,7 +70,7 @@ class G4UniformGravityField : public G4Field
virtual void GetFieldValue(const G4double Point[4], G4double *field) const;
virtual G4UniformGravityField* Clone() const;
virtual G4Field* Clone() const;
private:
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4UniformMagField.hh 68055 2013-03-13 14:43:28Z gcosmo $
// $Id: G4UniformMagField.hh 96751 2016-05-04 09:39:38Z gcosmo $
//
//
// class G4UniformMagField
@@ -71,7 +71,7 @@ class G4UniformMagField : public G4MagneticField
G4ThreeVector GetConstantFieldValue() const;
// Return the field value
virtual G4UniformMagField* Clone() const;
virtual G4Field* Clone() const;
private:
@@ -0,0 +1,148 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VFSALIntegrationStepper.hh
//
// class G4VFSALIntegrationStepper
//
// Class description:
// Class similar to G4VMagIntegratorStepper, for steppers which
// estimate the value of the derivative at the projected endpoint
// of integration - at each successful step.
// This ability is known as 'First Same As Last' (FSAL). It
// reduces the number of required calls to the equation's
// RightHandSide method, and, as such the number of calls to the
// (potentially expensive) field evaluation methods.
//
// Based on G4VMagIntegratorStepper
//
// Design/first implementation: Somnath Banerjee, May-Aug 2015,
// Work supported by the Google Summer of Code 2015.
// Supervision/improvement: John Apostolakis 2015-2016
// --------------------------------------------------------------------
#ifndef FSAL_MAGIntegrator_STEPPER
#define FSAL_MAGIntegrator_STEPPER
#include "G4Types.hh"
#include "G4EquationOfMotion.hh"
class G4VFSALIntegrationStepper
{
public: // with description
G4VFSALIntegrationStepper (G4EquationOfMotion* Equation,
G4int numIntegrationVariables,
G4int numStateVariables=12);
virtual ~G4VFSALIntegrationStepper();
// Constructor and destructor. No actions.
virtual void Stepper( const G4double y[],
const G4double dydx[],
G4double h,
G4double yout[],
G4double yerr[],
G4double lastDydx[]) = 0 ;
// The stepper for the Runge Kutta integration.
// The stepsize is fixed, with the Step size given by h.
// Integrates ODE starting values y[0 to 6].
// Outputs yout[] and its estimated error yerr[].
virtual G4double DistChord() const = 0;
// Estimate the maximum distance of a chord from the true path
// over the segment last integrated.
virtual void ComputeRightHandSide( const G4double y[], G4double dydx[] );
// Must compute the RightHandSide as in the method below
// Optionally can cache the input y[] and the dydx[] values computed.
// virtual G4bool isFSAL() const = 0;
// //Return true if the stepper uses FSAL (First Same As Last)
// G4double *getLastDydx() {return 0;}
inline void NormaliseTangentVector( G4double vec[6] );
// Simple utility function to (re)normalise 'unit velocity' vector.
inline void NormalisePolarizationVector( G4double vec[12] );
// Simple utility function to (re)normalise 'unit spin' vector.
void RightHandSide( const double y[], double dydx[] );
// Utility method to supply the standard Evaluation of the
// Right Hand side of the associated equation.
inline G4int GetNumberOfVariables() const;
// Get the number of variables that the stepper will integrate over.
// void SetNumberOfVariables(G4int newNo); // Dangerous & obsolete ...
inline G4int GetNumberOfStateVariables() const;
// Get the number of variables of state variables (>= above, integration)
virtual G4int IntegratorOrder() const = 0;
// Returns the order of the integrator
// i.e. its error behaviour is of the order O(h^order).
inline G4EquationOfMotion *GetEquationOfMotion();
// As some steppers (eg RKG3) require other methods of Eq_Rhs
// this function allows for access to them.
inline void SetEquationOfMotion(G4EquationOfMotion* newEquation);
//--- --- For DEBUG --- ---
inline G4int GetfNoRHSCalls(){
return fNoRHSCalls;
}
void increasefNORHSCalls();
inline void ResetfNORHSCalls(){
fNoRHSCalls = 0;
}
//--- --- ///////// --- ---
private:
G4VFSALIntegrationStepper(const G4VFSALIntegrationStepper&);
G4VFSALIntegrationStepper& operator=(const G4VFSALIntegrationStepper&);
// Private copy constructor and assignment operator.
private:
G4EquationOfMotion *fEquation_Rhs;
const G4int fNoIntegrationVariables; // Number of Variables in integration
const G4int fNoStateVariables; // Number required for FieldTrack
//--- --- For DEBUG --- ---
G4int fNoRHSCalls;
//--- --- ///////// --- ---
// const G4int fNumberOfVariables;
};
#include "G4VFSALIntegrationStepper.icc"
#endif /* G4VFSALIntegrationStepper */
@@ -0,0 +1,83 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VFSALIntegrationStepper.icc 97387 2016-06-02 10:03:42Z gcosmo $
//
inline
G4EquationOfMotion* G4VFSALIntegrationStepper::GetEquationOfMotion()
{
return fEquation_Rhs;
}
inline void
G4VFSALIntegrationStepper::SetEquationOfMotion(G4EquationOfMotion* newEquation)
{
if( newEquation != 0 )
{
fEquation_Rhs= newEquation;
}
}
inline
G4int G4VFSALIntegrationStepper::GetNumberOfVariables() const
{
return fNoIntegrationVariables;
}
inline
G4int G4VFSALIntegrationStepper::GetNumberOfStateVariables() const
{
return fNoStateVariables;
}
inline
void G4VFSALIntegrationStepper::NormaliseTangentVector( G4double vec[6] )
{
G4double drds2 = vec[3]*vec[3]+vec[4]*vec[4]+vec[5]*vec[5];
if( std::fabs(drds2 - 1.0) > 1.e-14 )
{
G4double normx = 1.0 / std::sqrt(drds2);
for(G4int i=3;i<6;i++) { vec[i] *= normx; }
}
}
inline
void G4VFSALIntegrationStepper::NormalisePolarizationVector( G4double vec[12] )
{
G4double drds2 = vec[9]*vec[9]+vec[10]*vec[10]+vec[11]*vec[11];
if( drds2 > 0. )
{
if( std::fabs(drds2 - 1.0) > 1.e-14 )
{
G4double normx = 1.0 / std::sqrt(drds2);
for(G4int i=9;i<12;i++) { vec[i] *= normx; }
}
}
}