Problem 111 - Infinite loop user G4ClassicalRK4, in Vaccuum
Summary: Infinite loop user G4ClassicalRK4, in Vaccuum
Status: CLOSED REMIND
Alias: None
Product: Geant4
Classification: Unclassified
Component: processes/transportation (show other problems)
Version: 1.1
Hardware: PC Linux
: P2 minor
Assignee: John Apostolakis
URL:
Depends on:
Blocks:
 
Reported: 2000-06-27 10:55 CEST by lebrun
Modified: 2005-08-31 11:33 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description lebrun 2000-06-27 10:55:40 CEST
If one place a small volume in a larger  one, both made of material Vacuum,
nothing determines the step length except the geometry. In this, case *without
 setting User Step Limit,

(detectLog->SetUserLimits(new G4UserLimits(2.0)))

the code falls into a infinite loop, after priting 100 wnaring message about the
step getting to small:

 Warning (G4MagIntegratorDriver): The stepsize for the  next
iteration=3.70591e-14 is too small - in Step number 1.
     Requested step size was 7411.83 .
     Previous  step size was 7411.83 .
     The minimum for the driver is 10
     The integrations has already gone 7.32747e-15

The current patch is to set a user step limit smaller than the volume, which
is not always optimal.

Here is an example source code:

// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: Pr2DetectorConstruction.cc,v 1.1.10.1 1999/12/07 20:47:21
//gunter Exp $
// GEANT4 tag $Name: geant4-01-00 $
//

#include "Pr2DetectorConstruction.hh"

#include "G4Material.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4LogicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "globals.hh"
#include "G4UniformMagField.hh"
#include "G4FieldManager.hh"
#include "G4TransportationManager.hh"
#include "G4UserLimits.hh"
#include "G4EqMagElectricField.hh"
#include "G4ClassicalRK4.hh"
#include "G4SimpleRunge.hh"
#include "Pr2MagneticField.hh"

#include "dataCards.hh"

extern  Pr2GridSpace *AllGridsProton2[10];

Pr2DetectorConstruction::Pr2DetectorConstruction()
{;}

Pr2DetectorConstruction::~Pr2DetectorConstruction()
{;}

G4VPhysicalVolume* Pr2DetectorConstruction::Construct()
{

// Magnetic field
//---------------------------------------------------------------------------

 static G4bool fieldIsInitialized = false;
 if(!fieldIsInitialized)
   {
   int iFOpt =  (int) MyDataCards.fetchValueDouble("FieldOption");
   G4FieldManager* fieldMgr
     = G4TransportationManager::GetTransportationManager()
       ->GetFieldManager();
      Pr2MagneticField* fullEMField  =
                        new  Pr2MagneticField();
      G4EqMagElectricField *fEquationE =
        new G4EqMagElectricField(fullEMField);
      G4MagIntegratorStepper *pStepper = new G4ClassicalRK4 (fEquationE, 6);
//      G4MagIntegratorStepper *pStepper = new G4SimpleRunge (fEquationE, 6);
      fieldMgr->SetDetectorField(fullEMField);
      G4ChordFinder* pChordFinder =
             new G4ChordFinder(fullEMField, 10 * mm , pStepper);
      fieldMgr->SetChordFinder(pChordFinder);

// Testing..

      double point[3];
      double ff[6];
      point[0] = 5.23; point[1] = 8.56; point[2] = 300.;
      cout <<  " Testing at z = 300. \n";
      fullEMField->GetFieldValue( point, ff);
     for (int k=0; k<6; k++)
       cout << " Componnent " << k << " =  " << ff[k] << "\n";
    }
   // double newValue = 1*mm;
   //fieldMgr->GetChordFinder()->SetDeltaChord(newValue);
   fieldIsInitialized = true;
//------------------------------------------------------ materials

  double a;  // atomic mass
  double z;  // atomic number
  double density, pressure, temperature;
  G4String name;

  a = 12.01*g/mole;
  density = 2.265*g/cm3;
  G4Material* Carbon = new G4Material(name="Carbon", z=6., a, density);


  //Vacuum
    density     = universe_mean_density;    //from PhysicalConstants.h
    pressure    = 3.e-18*pascal;
    temperature = 2.73*kelvin;
    G4Material* Vacuum =
            new G4Material(name="Vacuum", z=1., a=1.01*g/mole, density,
                   kStateGas,temperature,pressure);

  //------------------------------------------------------ volumes
  double maxStep = 100.;
  double expHall_x = 500.*mm;
  double expHall_y = expHall_x;
  double expHall_z = 10000.0*mm;
  G4Box* experimentalHall_box
    = new G4Box("expHall_box",expHall_x,expHall_y, expHall_z);
  G4LogicalVolume* experimentalHall_log
    = new G4LogicalVolume(experimentalHall_box,Vacuum,"expHall_log",0,0,0);
  G4VPhysicalVolume* experimentalHall_phys
    = new G4PVPlacement(0,G4ThreeVector(),"expHall",
                        experimentalHall_log,0,false,0);
  experimentalHall_log->SetUserLimits(new G4UserLimits(maxStep));


  //---------------------- mini detector ------------------------

  double outerRad = 50.0*cm;
  double hight = 0.25*cm;
  G4Tubs* detectTube
    = new G4Tubs("Detect_tube",0.,
                 outerRad, hight, 0., 360.);
  G4LogicalVolume* detectLog
    = new G4LogicalVolume(detectTube,Vacuum,"DetectorLog",0,0,0);
//  G4LogicalVolume* detectLog
//    = new G4LogicalVolume(detectTube,Carbon,"DetectorLog",0,0,0);

// Slight offset, 2 cm before the target realy starts.

  G4VPhysicalVolume* det1_phys
    = new G4PVPlacement(0,
             G4ThreeVector(0., 0., - 20.*mm),
             "Detect_1", detectLog,experimentalHall_phys , false, 0);

//   detectLog->SetUserLimits(new G4UserLimits(2.0));

    return experimentalHall_phys;
}
Comment 1 John Apostolakis 2000-06-30 10:29:59 CEST
> The current patch is to set a user step limit smaller than the volume, which
> is not always optimal.

   It is neccessary to set a user step limit.  However it does not need to be
smaller than the volume.  Any reasonable path length will be ok.
Comment 2 John Apostolakis 2005-08-31 11:33:59 CEST
In order to address this issue, a new parameter was added to the field
propagation module to limit the step of particles to a maximum size.

In particular this also addressed the problem for tracks being propagated in a
uniform (or near uniform) field by a helical stepper, in which case the
integration error is nill (or small) and the size of the step could exceed by
large factors the setup size.

The parameter introduced has been documented in the Users Guide for Application
Developers,  in the 4.3.2 under "Parameters that must scale with problem size".