65#define State(theXInfo) (GetState<G4ITBrownianState>()->theXInfo)
75#define RED "\033[0;31m"
76#define LIGHT_RED "\33[1;31m"
77#define GREEN "\033[32;40m"
78#define GREEN_ON_BLUE "\033[1;32;44m"
79#define RESET_COLOR "\033[0m"
84#define GREEN_ON_BLUE ""
117#define State(theXInfo) (GetState<G4ITTransportationState>()->theXInfo)
165 if(
this == &rhs)
return *
this;
222 if(
GetIT(track)->GetTrackingInfo()->IsLeadingStep())
226 G4bool makeException =
true;
234 exceptionDescription <<
"ComputeStep is called while the track has"
235 "the minimum interaction time";
236 exceptionDescription <<
" so it should not recompute a timeStep ";
237 G4Exception(
"G4DNABrownianTransportation::ComputeStep",
239 exceptionDescription);
243 State(fGeometryLimitedStep) =
false;
256 G4double sqrt_Dt = sqrt(diffCoeff*timeStep);
259 if(
State(fTimeStepReachedLimit)==
true)
262 State(fGeometryLimitedStep) =
true;
264 spaceStep =
State(fEndPointDistance);
273 spaceStep = sqrt(x*x + y*y + z*z);
275 if(spaceStep >=
State(fEndPointDistance))
279 State(fGeometryLimitedStep) =
true;
294 <<
"G4ITBrownianTransportation::ComputeStep() : "
295 <<
"Step was limited to boundary"
301 if(
State(fRandomNumber)>=0)
322 spaceStep = invErfc*2*sqrt_Dt;
324 if(
State(fTimeStepReachedLimit)==
false)
327 State(fGeometryLimitedStep) =
false;
351 spaceStep = invErfc*2*sqrt_Dt;
352 if(spaceStep >=
State(fEndPointDistance))
355 State(fGeometryLimitedStep) =
true;
358 else if(
State(fTimeStepReachedLimit)==
false)
361 State(fGeometryLimitedStep) =
false;
368 State(fGeometryLimitedStep) =
true;
370 spaceStep =
State(fEndPointDistance);
387 State(fTransportEndPosition)= spaceStep*
395 State(fGeometryLimitedStep) =
false;
406 State(fGeometryLimitedStep) =
false;
411 State(fEndGlobalTimeComputed) =
true;
418 <<
"G4ITBrownianTransportation::ComputeStep() : "
419 <<
" trackID : " << track.
GetTrackID() <<
" : Molecule name: "
424 <<
"Final position:" <<
G4BestUnit(
State(fTransportEndPosition),
"Length")
428 <<
"Final magnitude:" <<
G4BestUnit(
State(fTransportEndPosition).mag(),
"Length")
430 <<
"Diffusion length : "
432 <<
" within time step : " <<
G4BestUnit(timeStep,
"Time")
434 <<
"State(fTimeStepReachedLimit)= " <<
State(fTimeStepReachedLimit) <<
G4endl
435 <<
"State(fGeometryLimitedStep)=" <<
State(fGeometryLimitedStep) <<
G4endl
436 <<
"End point distance was: " <<
G4BestUnit(
State(fEndPointDistance),
"Length")
461 <<
" trackID : " << track.
GetTrackID() <<
" Molecule name: "
463 G4cout <<
"Diffusion length : "
466 <<
"\t Current global time : "
487 <<
"G4DNABrownianTransportation::Diffusion :" << setw(8)
489 <<
"\t" <<
" Global Time = "
510 if (waterDensity == 0.0)
524 G4cout <<
"A track is outside water material : trackID = "
541 mem_diff = mem_intermediaire-mem_first;
542 G4cout <<
"\t\t\t >> || MEM || In G4DNABrownianTransportation::Diffusion "
543 "after dealing with waterDensity for "<< track.
GetTrackID()
544 <<
", diff is : " << mem_diff <<
G4endl;
548 State(fMomentumChanged) =
true;
553 mem_diff = mem_intermediaire-mem_first;
554 G4cout <<
"\t\t\t >> || MEM || In G4DNABrownianTransportation::"
555 "After proposing new direction to fParticleChange for "
591 G4cout <<
" G4DNABrownianTransportation::AlongStepGetPhysicalInteractionLength - track ID: "
600 track, previousStepSize, currentMinimumStep, currentSafety,
603 if(geometryStepLength==0)
606 if(
State(fGeometryLimitedStep))
612 State(fCurrentTouchableHandle)->GetHistory());
624 State(fCurrentTouchableHandle) = newTouchable;
639 track, previousStepSize, currentMinimumStep, currentSafety,
684 if(diffusionCoefficient <= 0)
686 State(fGeometryLimitedStep) =
false;
693 State(fComputeLastPosition) =
false;
694 State(fTimeStepReachedLimit) =
false;
696 if (
State(fGeometryLimitedStep))
707 / (diffusionCoefficient);
712 / (diffusionCoefficient);
719 State(fComputeLastPosition) =
true;
727 * pow(geometryStepLength /
InvErfc(
State(fRandomNumber)),2);
729 State(fTransportEndPosition) = geometryStepLength*
744 State(fTimeStepReachedLimit) =
true;
745 State(fComputeLastPosition) =
true;
751 State(fTimeStepReachedLimit) =
true;
755 State(fComputeLastPosition) =
true;
759 State(fCandidateEndGlobalTime) =
762 State(fEndGlobalTimeComputed) =
true;
764 State(fPathLengthWasCorrected) =
false;
769 geometryStepLength = 2
772 State(fPathLengthWasCorrected) =
true;
774 State(fTransportEndPosition) = geometryStepLength*
783 <<
"G4DNABrownianTransportation::AlongStepGetPhysicalInteractionLength = "
795 return geometryStepLength;
807 MemStat mem_first, mem_second, mem_diff;
814 if (
GetIT(track)->GetTrackingInfo()->IsLeadingStep()
815 &&
State(fComputeLastPosition)
816 &&
State(fGeometryLimitedStep)
830 spaceStep =
State(fEndPointDistance);
831 State(fGeometryLimitedStep) =
true;
836 GetDiffusionCoefficient();
843 spaceStep = sqrt(x * x + y * y + z * z);
845 if(spaceStep >=
State(fEndPointDistance))
847 State(fGeometryLimitedStep) =
true;
851 && spaceStep >=
State(fEndPointDistance))
853 spaceStep =
State(fEndPointDistance);
858 State(fGeometryLimitedStep) =
false;
874 <<
"G4DNABrownianTransportation::AlongStepDoIt: "
875 "GeometryLimitedStep = "
876 <<
State(fGeometryLimitedStep)
890 mem_diff = mem_intermediaire-mem_first;
891 G4cout <<
"\t\t\t >> || MEM || After calling G4ITTransportation::"
892 "AlongStepDoIt for "<< track.
GetTrackID() <<
", diff is : "
941 mem_diff = mem_intermediaire-mem_first;
942 G4cout <<
"\t\t\t >> || MEM || After calling G4DNABrownianTransportation::"
943 "Diffusion for "<< track.
GetTrackID() <<
", diff is : "
static G4double InvErf(G4double x)
static G4double Erfc(G4double x)
static G4double InvErfc(G4double x)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4IT * GetIT(const G4Track *track)
@ fLowEnergyBrownianTransportation
G4Molecule * GetMolecule(const G4Track &track)
G4ThreeVector G4RandomDirection()
static constexpr double picosecond
G4GLOB_DLL std::ostream G4cout
static double erf(double x)
static double inverseErf(double t)
virtual void Transport(const G4Track &, G4ParticleChangeForTransport &)=0
virtual void ComputeStep(const G4Track &, const G4Step &, const G4double, G4double &)
virtual G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &)
G4BrownianAction * fpBrownianAction
G4DNABrownianTransportation & operator=(const G4DNABrownianTransportation &)
void Diffusion(const G4Track &track)
G4bool fUseSchedulerMinTimeSteps
G4DNABrownianTransportation(const G4String &aName="DNABrownianTransportation", G4int verbosityLevel=0)
const std::vector< G4double > * fpWaterDensity
G4double ComputeGeomLimit(const G4Track &track, G4double &presafety, G4double limit)
virtual void StartTracking(G4Track *aTrack)
virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track &, G4double, G4double, G4double &, G4GPILSelection *)
virtual G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &)
G4double fInternalMinTimeStep
G4bool fUseMaximumTimeBeforeReachingBoundary
virtual ~G4DNABrownianTransportation()
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
static G4DNAMolecularMaterial * Instance()
G4VPhysicalVolume * GetWorldVolume()
G4double CheckNextStep(const G4ThreeVector &position, const G4ThreeVector &direction, const G4double currentMaxStep, G4double &newSafety)
G4ParticleChangeForTransport fParticleChange
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
void SetInstantiateProcessState(G4bool flag)
virtual G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &stepData)
virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track &track, G4double, G4double currentMinimumStep, G4double ¤tSafety, G4GPILSelection *selection)
G4ITSafetyHelper * fpSafetyHelper
G4ITNavigator * fLinearNavigator
virtual G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &)
virtual void StartTracking(G4Track *aTrack)
G4TrackingInformation * GetTrackingInfo()
virtual const G4String & GetName() const =0
G4double GetTemperature() const
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
const G4String & GetName() const
G4double GetDiffusionCoefficient() const
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static G4NistManager * Instance()
void SetMomentumChanged(G4bool b)
void ProposeEnergy(G4double finalEnergy)
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
const G4String & GetParticleName() const
G4double GetGlobalTime() const
const G4VProcess * GetProcessDefinedStep() const
const G4ThreeVector & GetPosition() const
G4double GetDeltaTime() const
G4StepPoint * GetPreStepPoint() const
G4double GetStepLength() const
G4StepPoint * GetPostStepPoint() const
virtual void LoadTrackState(G4TrackStateManager &manager)
virtual void ResetTrackState()
G4VPhysicalVolume * GetVolume() const
const G4ThreeVector & GetPosition() const
G4double GetGlobalTime() const
G4int GetCurrentStepNumber() const
G4Material * GetMaterial() const
const G4ThreeVector & GetMomentumDirection() const
G4double GetStepLength() const
const G4Step * GetStep() const
G4bool ProposesTimeStep() const
G4double * theInteractionTimeLeft
G4shared_ptr< G4ProcessState > fpState
void ProposeTrackStatus(G4TrackStatus status)
const G4String & GetName() const
void SetProcessSubType(G4int)
G4int GetProcessSubType() const
const G4String & GetProcessName() const
static G4VScheduler * Instance()
virtual double GetLimitingTimeStep() const
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
virtual void UpdateYourself(G4VPhysicalVolume *pPhysVol, const G4NavigationHistory *history=nullptr)
ThreeVector shoot(const G4int Ap, const G4int Af)
G4bool fTimeStepReachedLimit
G4bool fPathLengthWasCorrected
G4bool fComputeLastPosition