Import Geant4 10.7.0 source tree
This commit is contained in:
@@ -37,35 +37,46 @@
|
||||
#include "G4MagIntegratorDriver.hh"
|
||||
// #include "G4ClassicalRK4.hh"
|
||||
// #include "G4CashKarpRKF45.hh"
|
||||
// #include "G4NystromRK4.hh"
|
||||
// #include "G4BogackiShampine23.hh"
|
||||
// #include "G4BogackiShampine45.hh"
|
||||
|
||||
#include "G4DormandPrince745.hh"
|
||||
|
||||
// New FSAL type driver / steppers -----
|
||||
// New templated stepper(s) -- avoid virtual calls to equation rhs
|
||||
#include "G4TDormandPrince45.hh"
|
||||
|
||||
// FSAL type driver / steppers -----
|
||||
#include "G4FSALIntegrationDriver.hh"
|
||||
#include "G4VFSALIntegrationStepper.hh"
|
||||
#include "G4RK547FEq1.hh"
|
||||
// #include "G4RK547FEq2.hh"
|
||||
// #include "G4RK547FEq3.hh"
|
||||
#include "G4NystromRK4.hh"
|
||||
|
||||
// New FSAL type driver / steppers -----
|
||||
#include "G4IntegrationDriver.hh"
|
||||
#include "G4InterpolationDriver.hh"
|
||||
// #include "G4FSALBogackiShampine45.hh"
|
||||
// #include "G4FSALDormandPrince745.hh"
|
||||
|
||||
// Templated type drivers -----
|
||||
#include "G4IntegrationDriver.hh"
|
||||
#include "G4InterpolationDriver.hh"
|
||||
|
||||
#include "G4HelixHeum.hh"
|
||||
#include "G4BFieldIntegrationDriver.hh"
|
||||
|
||||
#include "G4CachedMagneticField.hh"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
static G4bool gVerboseCtor = false; // true;
|
||||
|
||||
// ..........................................................................
|
||||
|
||||
G4ChordFinder::G4ChordFinder(G4VIntegrationDriver* pIntegrationDriver)
|
||||
: fDefaultDeltaChord(0.25 * mm), fIntgrDriver(pIntegrationDriver)
|
||||
{
|
||||
// Simple constructor -- it does not create equation
|
||||
|
||||
if( gVerboseCtor )
|
||||
G4cout << "G4ChordFinder: Simple constructor -- it uses pre-existing driver." << G4endl;
|
||||
|
||||
fDeltaChord = fDefaultDeltaChord; // Parameters
|
||||
}
|
||||
|
||||
@@ -75,45 +86,71 @@ G4ChordFinder::G4ChordFinder(G4VIntegrationDriver* pIntegrationDriver)
|
||||
G4ChordFinder::G4ChordFinder( G4MagneticField* theMagField,
|
||||
G4double stepMinimum,
|
||||
G4MagIntegratorStepper* pItsStepper,
|
||||
G4bool useFSALstepper )
|
||||
G4int stepperDriverId )
|
||||
: fDefaultDeltaChord(0.25 * mm)
|
||||
{
|
||||
// Construct the Chord Finder
|
||||
// by creating in inverse order the Driver, the Stepper and EqRhs ...
|
||||
|
||||
constexpr G4int nVar6 = 6; // Components integrated in Usual Equation of motion
|
||||
|
||||
fDeltaChord = fDefaultDeltaChord; // Parameters
|
||||
|
||||
using NewFsalStepperType = G4RK547FEq1; // or 2 or 3
|
||||
const char* NewFSALStepperName =
|
||||
"G4RK574FEq1> FSAL 4th/5th order 7-stage 'Equilibrium-type' #1.";
|
||||
// stepperDriverId = 2;
|
||||
|
||||
G4bool useFSALstepper= (stepperDriverId == 1);
|
||||
G4bool useTemplatedStepper= (stepperDriverId == 2);
|
||||
G4bool useRegularStepper = (stepperDriverId == 3);
|
||||
// G4bool useBFieldDriver = !useRegularStepper && !useFSALstepper && !useTemplatedStepper;
|
||||
|
||||
// G4bool useRegularStepper = !stepperDriverId != 3) && !useFSALStepper && !useTemplatedStepper;
|
||||
// If it's not 0, 1 or 2 then 'BFieldDriver' which combines DoPri5 (short) and helix is used.
|
||||
|
||||
using EquationType = G4Mag_UsualEqRhs;
|
||||
|
||||
using TemplatedStepperType =
|
||||
G4TDormandPrince45<EquationType,nVar6>; // 5th order embedded method. High efficiency.
|
||||
const char* TemplatedStepperName =
|
||||
"G4TDormandPrince745 (templated Dormand-Prince45, aka DoPri5): 5th/4th Order 7-stage embedded";
|
||||
|
||||
using RegularStepperType =
|
||||
G4DormandPrince745; // 5th order embedded method. High efficiency.
|
||||
G4DormandPrince745; // 5th order embedded method. High efficiency.
|
||||
// G4ClassicalRK4; // The old default
|
||||
// G4CashKarpRKF45; // First embedded method in G4
|
||||
// G4BogackiShampine45; // High efficiency 5th order embedded method
|
||||
// G4NystromRK4; // Nystrom stepper 4th order
|
||||
// G4RK547FEq1; // or 2 or 3
|
||||
const char* RegularStepperName =
|
||||
"G4DormandPrince745 (aka DOPRI5): 5th/4th Order 7-stage embedded stepper";
|
||||
"G4DormandPrince745 (aka DOPRI5): 5th/4th Order 7-stage embedded";
|
||||
// "BogackiShampine 45 (Embedded 5th/4th Order, 7-stage)";
|
||||
// "Nystrom stepper 4th order";
|
||||
|
||||
// Configurable
|
||||
G4bool forceFSALstepper = false; // Choice - true to enable !!
|
||||
G4bool recallFSALflag = useFSALstepper;
|
||||
useFSALstepper = forceFSALstepper || useFSALstepper;
|
||||
|
||||
using NewFsalStepperType = G4DormandPrince745; // Now works -- 2020.10.08
|
||||
// Was G4RK547FEq1; // or 2 or 3
|
||||
const char* NewFSALStepperName =
|
||||
"G4RK574FEq1> FSAL 4th/5th order 7-stage 'Equilibrium-type' #1.";
|
||||
|
||||
#ifdef G4DEBUG_FIELD
|
||||
static G4bool verboseDebug = true;
|
||||
if( verboseDebug )
|
||||
{
|
||||
G4cout << "G4ChordFinder 2nd Constructor called. " << G4endl;
|
||||
G4cout << " Parameters: " << G4endl;
|
||||
G4cout << " useFSAL stepper= " << useFSALstepper
|
||||
<< " (request = " << recallFSALflag
|
||||
<< " force FSAL = " << forceFSALstepper << " )" << G4endl;
|
||||
G4cout << " Arguments: " << G4endl
|
||||
<< " - min step = " << stepMinimum << G4endl
|
||||
<< " - stepper ptr provided : "
|
||||
<< ( pItsStepper==nullptr ? " no " : " yes " ) << G4endl;
|
||||
if( pItsStepper==nullptr )
|
||||
G4cout << " - stepper/driver Id = " << stepperDriverId << " i.e. "
|
||||
<< " useFSAL = " << useFSALstepper
|
||||
<< " , useTemplated = " << useTemplatedStepper
|
||||
<< " , useRegular = " << useRegularStepper
|
||||
<< " , useFSAL = " << useFSALstepper
|
||||
<< G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
// useHigherStepper = forceHigherEffiencyStepper || useHigherStepper;
|
||||
|
||||
G4Mag_EqRhs* pEquation = new G4Mag_UsualEqRhs(theMagField);
|
||||
|
||||
EquationType* pEquation = new G4Mag_UsualEqRhs(theMagField);
|
||||
fEquation = pEquation;
|
||||
|
||||
// G4MagIntegratorStepper* regularStepper = nullptr;
|
||||
@@ -126,41 +163,87 @@ G4ChordFinder::G4ChordFinder( G4MagneticField* theMagField,
|
||||
|
||||
if( pItsStepper != nullptr )
|
||||
{
|
||||
#if 0
|
||||
// G4cout << " G4ChordFinder: Creating G4IntegrationDriver<G4MagIntegratorStepper> with "
|
||||
// << " stepMinimum = " << stepMinimum
|
||||
// << " numVar= " << pItsStepper->GetNumberOfVariables() << G4endl;
|
||||
// Type is not known - so must use old class
|
||||
if( gVerboseCtor )
|
||||
G4cout << " G4ChordFinder: Creating G4IntegrationDriver<G4MagIntegratorStepper> with "
|
||||
<< " stepMinimum = " << stepMinimum
|
||||
<< " numVar= " << pItsStepper->GetNumberOfVariables() << G4endl;
|
||||
// Stepper type is not known - so must use base class G4MagIntegratorStepper
|
||||
fIntgrDriver = new G4IntegrationDriver<G4MagIntegratorStepper>(
|
||||
stepMinimum, pItsStepper, pItsStepper->GetNumberOfVariables());
|
||||
#else
|
||||
G4cout << " G4ChordFinder: Creating G4MagInt_Driver with "
|
||||
<< " stepMinimum = " << stepMinimum
|
||||
<< " numVar= " << pItsStepper->GetNumberOfVariables() << G4endl;
|
||||
fIntgrDriver = new G4MagInt_Driver( stepMinimum, pItsStepper,
|
||||
pItsStepper->GetNumberOfVariables());
|
||||
#endif
|
||||
|
||||
// -- Older:
|
||||
// G4cout << " G4ChordFinder: Creating G4MagInt_Driver with " ...
|
||||
// Type is not known - so must use old class
|
||||
// fIntgrDriver = new G4MagInt_Driver( stepMinimum, pItsStepper,
|
||||
// pItsStepper->GetNumberOfVariables());
|
||||
}
|
||||
else if ( !useFSALstepper )
|
||||
else if ( useTemplatedStepper )
|
||||
{
|
||||
if( gVerboseCtor )
|
||||
G4cout << " G4ChordFinder: Creating Templated Stepper of type> "
|
||||
<< TemplatedStepperName << G4endl;
|
||||
// RegularStepperType* regularStepper = nullptr; // To check the exception
|
||||
auto regularStepper = new RegularStepperType(pEquation);
|
||||
auto templatedStepper = new TemplatedStepperType(pEquation);
|
||||
// *** ******************
|
||||
//
|
||||
// Alternative - for G4NystromRK4:
|
||||
// = new G4NystromRK4(pEquation, 0.1*mm );
|
||||
fRegularStepperOwned = regularStepper;
|
||||
|
||||
if( regularStepper == nullptr )
|
||||
fRegularStepperOwned = templatedStepper;
|
||||
if( templatedStepper == nullptr )
|
||||
{
|
||||
message << "Stepper instantiation FAILED." << G4endl;
|
||||
message << "Templated Stepper instantiation FAILED." << G4endl;
|
||||
message << "G4ChordFinder: Attempted to instantiate "
|
||||
<< RegularStepperName << " type stepper " << G4endl;
|
||||
G4Exception("G4ChordFinder::G4ChordFinder()",
|
||||
"GeomField1001", JustWarning, message);
|
||||
<< TemplatedStepperName << " type stepper " << G4endl;
|
||||
errorInStepperCreation = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
fIntgrDriver = new G4IntegrationDriver<TemplatedStepperType>(
|
||||
stepMinimum, templatedStepper, nVar6 );
|
||||
if( gVerboseCtor )
|
||||
G4cout << " G4ChordFinder: Using G4IntegrationDriver. " << G4endl;
|
||||
}
|
||||
|
||||
}
|
||||
else if ( useRegularStepper ) // Plain stepper -- not double ...
|
||||
{
|
||||
auto regularStepper = new RegularStepperType(pEquation);
|
||||
// *** ******************
|
||||
fRegularStepperOwned = regularStepper;
|
||||
|
||||
if( gVerboseCtor )
|
||||
G4cout << " G4ChordFinder: Creating Driver for regular stepper.";
|
||||
|
||||
if( regularStepper == nullptr )
|
||||
{
|
||||
message << "Regular Stepper instantiation FAILED." << G4endl;
|
||||
message << "G4ChordFinder: Attempted to instantiate "
|
||||
<< RegularStepperName << " type stepper " << G4endl;
|
||||
errorInStepperCreation = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto dp5= dynamic_cast<G4DormandPrince745*>(regularStepper);
|
||||
if( dp5 ) {
|
||||
fIntgrDriver = new G4InterpolationDriver<G4DormandPrince745>(
|
||||
stepMinimum, dp5, nVar6 );
|
||||
if( gVerboseCtor )
|
||||
G4cout << " Using InterpolationDriver<DoPri5> " << G4endl;
|
||||
} else {
|
||||
fIntgrDriver = new G4IntegrationDriver<RegularStepperType>(
|
||||
stepMinimum, regularStepper, nVar6 );
|
||||
if( gVerboseCtor )
|
||||
G4cout << " Using IntegrationDriver<DoPri5> " << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( !useFSALstepper )
|
||||
{
|
||||
auto regularStepper = new G4DormandPrince745(pEquation);
|
||||
// *** ******************
|
||||
//
|
||||
fRegularStepperOwned = regularStepper;
|
||||
|
||||
{
|
||||
using SmallStepDriver = G4InterpolationDriver<G4DormandPrince745>;
|
||||
using LargeStepDriver = G4IntegrationDriver<G4HelixHeum>;
|
||||
@@ -245,9 +328,13 @@ G4ChordFinder::G4ChordFinder( G4MagneticField* theMagField,
|
||||
const std::string BoolName[2]= { "False", "True" };
|
||||
errmsg << " Configuration: (constructor arguments) " << G4endl
|
||||
<< " provided Stepper = " << pItsStepper << G4endl
|
||||
<< " use FSAL stepper = " << BoolName[useFSALstepper]
|
||||
<< " (request = " << BoolName[recallFSALflag]
|
||||
<< " force FSAL = " << BoolName[forceFSALstepper] << " )"
|
||||
<< " stepper/driver Id = " << stepperDriverId << " i.e. "
|
||||
<< " useTemplated = " << BoolName[useTemplatedStepper]
|
||||
<< " useRegular = " << BoolName[useRegularStepper]
|
||||
<< " useFSAL = " << BoolName[useFSALstepper]
|
||||
<< " using combo BField Driver = " <<
|
||||
BoolName[ ! (useFSALstepper||useTemplatedStepper
|
||||
|| useRegularStepper ) ]
|
||||
<< G4endl;
|
||||
errmsg << message.str();
|
||||
errmsg << "Aborting.";
|
||||
|
||||
@@ -57,6 +57,13 @@
|
||||
|
||||
using namespace field_utils;
|
||||
|
||||
const G4String G4DormandPrince745::gStepperType =
|
||||
G4String("G4DormandPrince745: 5th order");
|
||||
|
||||
const G4String G4DormandPrince745::gStepperDescription= G4String(
|
||||
"Embedeed 5th order Runge-Kutta stepper - 7 stages, FSAL, Interpolating.");
|
||||
|
||||
|
||||
G4DormandPrince745::G4DormandPrince745(G4EquationOfMotion* equation,
|
||||
G4int noIntegrationVariables)
|
||||
: G4MagIntegratorStepper(equation, noIntegrationVariables)
|
||||
@@ -71,7 +78,7 @@ void G4DormandPrince745::Stepper(const G4double yInput[],
|
||||
G4double dydxOutput[])
|
||||
{
|
||||
Stepper(yInput, dydx, hstep, yOutput, yError);
|
||||
copy(dydxOutput, ak7);
|
||||
field_utils::copy(dydxOutput, ak7);
|
||||
}
|
||||
|
||||
// Stepper
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
// Author: J.Apostolakis, CERN - 15.01.1997
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include <cassert>
|
||||
#include "G4MagIntegratorStepper.hh"
|
||||
|
||||
// Constructor for stepper abstract base class.
|
||||
@@ -43,4 +44,9 @@ G4MagIntegratorStepper( G4EquationOfMotion* Equation,
|
||||
fNoStateVariables(std::max(num_state_vars,8)),
|
||||
fIsFSAL(isFSAL)
|
||||
{
|
||||
if( Equation == nullptr ) {
|
||||
G4Exception( "G4MagIntegratorStepper::G4MagIntegratorStepper", "GeomField0003",
|
||||
FatalErrorInArgument, "Must have non-null equation." );
|
||||
}
|
||||
assert( Equation != nullptr );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user