Problem 1275

Summary: The velocity is wrong in optical photon propagation
Product: Geant4 Reporter: gum
Component: trackAssignee: kurasige
Status: RESOLVED FIXED    
Severity: major CC: kurasige
Priority: P5    
Version: other   
Hardware: All   
OS: All   
Attachments: macro to run novice example N06
op-V09-05-00 fixed version of G4OpBoundaryProcess::DoIt

Description gum 2012-01-09 02:44:12 CET
Created attachment 143 [details]
macro to run novice example N06

Version 9.5

A G4 user reported this bug:

http://hypernews.slac.stanford.edu/HyperNews/geant4/get/opticalphotons/420.html

Looks like in 9.5:

mat=fpTouchable->GetVolume()->GetLogicalVolume()->GetMaterial();
groupvel = mat->GetMaterialPropertiesTable()->GetProperty("GROUPVEL");
velocity = groupvel->Value(current_momentum);

in G4Track::CalculateVelocityForOpticalPhoton() calculates the velocity
of the PreStepPoint and not, as expected, that of the PostStepPoint.
Thus, the velocity after refraction is wrong.

But it gets worse!

G4ParticleChange::UpdateStepForPostStep

has this line in it:

if (!isVelocityChanged)theVelocityChange =
pStep->GetTrack()->CalculateVelocity();

what this means is that every other type of optical photon step also
triggers CalculateVelocityForOpticalPhoton.

That includes the zero-step-length reallocation step. It too triggers
CalculateVelocityForOpticalPhoton. This now calculates and sets the
velocity of the outside medium.

The attached macro shows this for vanilla /examples/novice/N06
Comment 1 kurasige 2012-01-09 06:34:04 CET
 
  Thank you for reporting the bug.

  I looked over the problem.
  First, fpTouuchable in G4Track is updated only at the beginning of the Step though the touchable handle to the next volume is proposed in the PostStepDoIt of G4Transportation. So, we should use the touchable handle of PostStepPoint in 
  G4Track::CalculateVelocityForOpticalPhoton()
So, use GetNextMaterial() instead of GetMaterial().
  
track-V09-02-05 is the bug fixed tag.

As for the problem that every optical photon step triggers CalculateVelocityForOpticalPhoton, I think that it is not serious because caching mechanism works.
The line
>if (!isVelocityChanged)theVelocityChange = 
> pStep->GetTrack()->CalculateVelocity();
is necessary for processes other than optical.
But, I'll continue to think about better solution.

Regards,
	Hisaya
Comment 2 gum 2012-01-24 22:41:48 CET
Created attachment 149 [details]
op-V09-05-00 fixed version of G4OpBoundaryProcess::DoIt
Comment 3 gum 2012-01-24 22:43:29 CET
The tag: op-V09-05-00 fixes this problem. G4OpBoundaryProcess::DoIt calls
aParticleChange.ProposeVelocity(aTrack.GetVelocity()) at every invocation, so
that the variable - isVelocityChanged = true - in G4ParticleChange and hence
theVelocityChange = pStep->GetTrack()->CalculateVelocity() is not requested.
Moreover, for FresnelRefraction the process calculates the finalVelocity
locally from Material2->GetMaterialPropertiesTable()->GetProperty("GROUPVEL")
instead of calling G4Track::CalculateVelocityForOpticalPhoton().

Please, replace the attached file with the one in your 9.5 installation. My
hope is that this fix makes it into patch01 for 9.5.

Again, thank you for reporting this bug and my appologies.