Is it safe to change LargestAcceptableStep in the stepping action?

Dear colleagues,

I am wondering if it is safe, that it to say if it produces the expected behavior if I change the LargestAcceptableStep (of the global PropagatorInField) during the Stepping Action (i.e. the LargestAcceptableStep is changed from time to time during the simulation time depending on some characteristics of the steps). Knowing that the particle is propagating in a magnetic field. By “expected behaviour” I mean that it really applies to the maximum step to the track without producing problems. I also expect this to work only for charged particles (i.e. affected by the field)

Just to get a better idea on my question, here is how it is implemented in the code:
#include “G4TransportationManager.hh”
#include “G4PropagatorInField.hh”
void SteppingAction::UserSteppingAction(const G4Step *aStep) {

…calculate variable_value depending on the characteristics of the step…



Thanks in advance for the help.
Best regards,

Dear David,

I do not see a problem with changing this value in the SteppingAction (or other user actions.) Of course it will affect only future steps and all future steps, until you change its value again.

There may be a way to make similar changes, though, that could be automatically reset. If you create and register your own class derived from FieldManager and implement the method
ConfigureForTrack( const G4Track * );
you could also change this parameter there. The idea for creating this functionality is to enable a user to configure parameters that matter for the field propagation – it is a small stretch to change the PropagatorInField’s LargestAcceptableStep value.

ok, thank you very much :slight_smile: