Magnet field: exception from G4magInt_Driver stepsize underflow


I would like to understand what the origin of this exception is:

-------- WWWW ------- G4Exception-START -------- WWWW -------

*** G4Exception : GeomField1001
issued by : G4MagInt_Driver::OneGoodStep()
Stepsize underflow in Stepper !

  • Step’s start x=27365.9 and end x= 27365.9 are equal !!
    Due to step-size= 1.13848e-12. Note that input step was 0.013671
    *** This is just a warning message. ***
    -------- WWWW -------- G4Exception-END --------- WWWW -------

At this x there is no detector and there should not be any field as it is out of the world volume, which is 6m. A user defined magnetic field is used. The field is applied via

G4Mag_SpinEqRhs *equation = new G4Mag_SpinEqRhs(MagneticField::GetInstance());
G4MagIntegratorStepper stepper = new G4ClassicalRK4(equation, 12); // 12: mag field
G4MagInt_Driver driver = new G4MagInt_Driver
mm, stepper, stepper->GetNumberOfVariables());
finder = new G4ChordFinder(driver);
fFieldManager = new G4FieldManager(MagneticField::GetInstance());
fFieldManager->SetDeltaOneStep(1e-10); // improved tracking precision

Do you have any idea how to debug this?

Thank you very much in advance,

Dear Simone,

Some observations: the “x” value mentioned is badly labelled. It refers to the distance along the trajectory from the start of the current physical step.

I observe that the accuracy that you are requesting is very high compared with our typical accuracies. In particular the basic 4th order G4ClassicalRK4 integration method which you have chosen will not be efficient for accuracies above 1.0e-4 or so.

Higher order RK methods are found to be more efficient for higher accuracies - see for example the textbook E. Hairer S. P. Norsett G. Wanner “Solving Ordinary Differential Equations I”, section II.6 “Explicit RK-methods of higher order”.

So I would suggest to try higher order integration methods if you need high accuracy, starting with the now default G4DormandPrince745 5th order method, and experimenting with the higher order methods including G4DormandPrinceRK56 and G4DormandPrinceRK78.

I suggest to also add the following line in the printout code for the G4Exception:

        message << " Relative Error^2 are pos/mom/spin = " << errpos_sq
                << " / " << errmom_sq << " / " << errspin_sq ;

just above the line

              "GeomField1001", JustWarning, message);

which will help to show which component is causing the underflow.

Dear John,

thank you very much for your reply and your suggestions! By changing the integration method to G4DormandPrince745, the exceptions went away!

Best regards,

Glad to hear that it solved your issue.