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)
201 if(
GetIT(track)->GetTrackingInfo()->IsLeadingStep())
205 G4bool makeException =
true;
213 exceptionDescription <<
"ComputeStep is called while the track has"
214 "the minimum interaction time";
215 exceptionDescription <<
" so it should not recompute a timeStep ";
216 G4Exception(
"G4DNABrownianTransportation::ComputeStep",
218 exceptionDescription);
222 State(fGeometryLimitedStep) =
false;
235 G4double sqrt_Dt = sqrt(diffCoeff*timeStep);
237 G4double x = G4RandGauss::shoot(0,sqrt_2Dt);
238 G4double y = G4RandGauss::shoot(0,sqrt_2Dt);
239 G4double z = G4RandGauss::shoot(0,sqrt_2Dt);
241 if(
State(fTimeStepReachedLimit)==
true)
244 State(fGeometryLimitedStep) =
true;
246 spaceStep =
State(fEndPointDistance);
251 spaceStep = sqrt(x*x + y*y + z*z);
253 if(spaceStep >=
State(fEndPointDistance))
257 State(fGeometryLimitedStep) =
true;
272 <<
"G4ITBrownianTransportation::ComputeStep() : "
273 <<
"Step was limited to boundary"
279 if(
State(fRandomNumber)>=0)
300 spaceStep = invErfc*2*sqrt_Dt;
302 if(
State(fTimeStepReachedLimit)==
false)
305 State(fGeometryLimitedStep) =
false;
326 G4double min_randomNumber = Erfc(
State(fEndPointDistance)/2*sqrt_Dt);
329 spaceStep = invErfc*2*sqrt_Dt;
330 if(spaceStep >=
State(fEndPointDistance))
333 State(fGeometryLimitedStep) =
true;
336 else if(
State(fTimeStepReachedLimit)==
false)
339 State(fGeometryLimitedStep) =
false;
346 State(fGeometryLimitedStep) =
true;
348 spaceStep =
State(fEndPointDistance);
365 State(fTransportEndPosition)= spaceStep*
373 State(fGeometryLimitedStep) =
false;
386 State(fTransportEndPosition) = nextPosition;
393 State(fGeometryLimitedStep) =
false;
398 State(fEndGlobalTimeComputed) =
true;
405 <<
"G4ITBrownianTransportation::ComputeStep() : "
406 <<
" trackID : " << track.
GetTrackID() <<
" : Molecule name: "
411 <<
"Final position:" <<
G4BestUnit(
State(fTransportEndPosition),
"Length")
415 <<
"Final magnitude:" <<
G4BestUnit(
State(fTransportEndPosition).mag(),
"Length")
417 <<
"Diffusion length : "
419 <<
" within time step : " <<
G4BestUnit(timeStep,
"Time")
421 <<
"State(fTimeStepReachedLimit)= " <<
State(fTimeStepReachedLimit) <<
G4endl
422 <<
"State(fGeometryLimitedStep)=" <<
State(fGeometryLimitedStep) <<
G4endl
423 <<
"End point distance was: " <<
G4BestUnit(
State(fEndPointDistance),
"Length")
448 <<
" trackID : " << track.
GetTrackID() <<
" Molecule name: "
450 G4cout <<
"Diffusion length : "
453 <<
"\t Current global time : "
466 MemStat mem_first = MemoryUsage();
474 <<
"G4DNABrownianTransportation::Diffusion :" << setw(8)
476 <<
"\t" <<
" Global Time = "
497 if (waterDensity == 0.0)
511 G4cout <<
"A track is outside water material : trackID = "
527 MemStat mem_intermediaire = MemoryUsage();
528 mem_diff = mem_intermediaire-mem_first;
529 G4cout <<
"\t\t\t >> || MEM || In G4DNABrownianTransportation::Diffusion "
530 "after dealing with waterDensity for "<< track.
GetTrackID()
531 <<
", diff is : " << mem_diff <<
G4endl;
535 State(fMomentumChanged) =
true;
539 mem_intermediaire = MemoryUsage();
540 mem_diff = mem_intermediaire-mem_first;
541 G4cout <<
"\t\t\t >> || MEM || In G4DNABrownianTransportation::"
542 "After proposing new direction to fParticleChange for "
578 G4cout <<
" G4DNABrownianTransportation::AlongStepGetPhysicalInteractionLength - track ID: "
587 track, previousStepSize, currentMinimumStep, currentSafety,
590 if(geometryStepLength==0)
593 if(
State(fGeometryLimitedStep))
599 State(fCurrentTouchableHandle)->GetHistory());
611 State(fCurrentTouchableHandle) = newTouchable;
626 track, previousStepSize, currentMinimumStep, currentSafety,
643 geometryStepLength = distanceToBoundary;
681 if(diffusionCoefficient <= 0)
683 State(fGeometryLimitedStep) =
false;
690 State(fComputeLastPosition) =
false;
691 State(fTimeStepReachedLimit) =
false;
693 if (
State(fGeometryLimitedStep))
703 State(theInteractionTimeLeft) = (geometryStepLength * geometryStepLength)
704 / (diffusionCoefficient);
708 State(theInteractionTimeLeft) = (currentSafety * currentSafety)
709 / (diffusionCoefficient);
716 State(fComputeLastPosition) =
true;
723 State(theInteractionTimeLeft) = 1 / (4 * diffusionCoefficient)
724 * pow(geometryStepLength / InvErfc(
State(fRandomNumber)),2);
726 State(fTransportEndPosition) = geometryStepLength*
738 if (
State(theInteractionTimeLeft) < minTimeStepAllowed)
740 State(theInteractionTimeLeft) = minTimeStepAllowed;
741 State(fTimeStepReachedLimit) =
true;
742 State(fComputeLastPosition) =
true;
748 State(fTimeStepReachedLimit) =
true;
752 State(fComputeLastPosition) =
true;
756 State(fCandidateEndGlobalTime) =
759 State(fEndGlobalTimeComputed) =
true;
761 State(fPathLengthWasCorrected) =
false;
766 geometryStepLength = 2
767 * sqrt(diffusionCoefficient *
State(theInteractionTimeLeft))
769 State(fPathLengthWasCorrected) =
true;
771 State(fTransportEndPosition) = geometryStepLength*
780 <<
"G4DNABrownianTransportation::AlongStepGetPhysicalInteractionLength = "
792 return geometryStepLength;
804 MemStat mem_first, mem_second, mem_diff;
808 mem_first = MemoryUsage();
811 if (
GetIT(track)->GetTrackingInfo()->IsLeadingStep()
812 &&
State(fComputeLastPosition)
813 &&
State(fGeometryLimitedStep)
825 GetDiffusionCoefficient();
827 G4double sqrt_2Dt= sqrt(2 * diffusionCoefficient *
State(theInteractionTimeLeft));
828 G4double x = G4RandGauss::shoot(0, sqrt_2Dt);
829 G4double y = G4RandGauss::shoot(0, sqrt_2Dt);
830 G4double z = G4RandGauss::shoot(0, sqrt_2Dt);
834 spaceStep =
State(fEndPointDistance);
835 State(fGeometryLimitedStep) =
true;
839 spaceStep = sqrt(x * x + y * y + z * z);
841 if(spaceStep >=
State(fEndPointDistance))
843 State(fGeometryLimitedStep) =
true;
847 && spaceStep >=
State(fEndPointDistance))
849 spaceStep =
State(fEndPointDistance);
854 State(fGeometryLimitedStep) =
false;
874 State(fTransportEndPosition) = nextPosition;
882 <<
"G4DNABrownianTransportation::AlongStepDoIt: "
883 "GeometryLimitedStep = "
884 <<
State(fGeometryLimitedStep)
897 MemStat mem_intermediaire = MemoryUsage();
898 mem_diff = mem_intermediaire-mem_first;
899 G4cout <<
"\t\t\t >> || MEM || After calling G4ITTransportation::"
900 "AlongStepDoIt for "<< track.
GetTrackID() <<
", diff is : "
948 mem_intermediaire = MemoryUsage();
949 mem_diff = mem_intermediaire-mem_first;
950 G4cout <<
"\t\t\t >> || MEM || After calling G4DNABrownianTransportation::"
951 "Diffusion for "<< track.
GetTrackID() <<
", diff is : "
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()
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
void Diffusion(const G4Track &track)
G4VUserBrownianAction * fpUserBrownianAction
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
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)
virtual G4double GetDistanceToBoundary(const G4Track &)=0
virtual void Transport(G4ThreeVector &, G4Track *pTrack=nullptr)=0
G4bool fTimeStepReachedLimit
G4bool fPathLengthWasCorrected
G4bool fComputeLastPosition