Maximum number of steps/Total Internal Reflection

Hi All,

I am experiencing a weird issue. I think I have optical photons which are totally internally reflecting/getting trapped in a material. Is there a maximum number of steps at which geant4 stops recording a particle for such a case?

Thank in advance

-Frank

No, but you can follow the wls extended example to do it in your stepping action.

Hi @dsawkey,

Thanks for such a quick reply. I will check out that example. Do you know by chance how geant decides to terminate tracking and/or processing more steps for a particle?

I have reviewed the section 5.1 on tracking, and what a step consists of, but am clear about if there is a fixed number of steps or if the number of steps is determined by the processes that the particle being tracked experiences, e.g. if it is absorbed it would be given the status “fStopAndKill” and no longer is tracked or stepped.

And when you say, “No” do you mean that there is not some variable which can be set to increase the number of steps?

If possible could you explain for example what would happen to a photon that were placed in a volume which it would only totally internally reflect within, not absorbed or transmitted out?

Thank you.

There is no built in limit on the number of steps a track can take. You may implement such a limit yourself, for your particular application. Darren suggested doing in your SteppingAction – just check if track->GetCurrentStepNumber() is larger than whatever limit you want. You could consider doing something more complex, like total track length or something, depending on your particular application.

If you don’t have any absorption set (e.g., absorption length = DBL_MAX), then Geant4 will keep on bouncing that photon around and around and around and around, until your cluster or batch system kills the process for using too much CPU time. Or, if you accumulate a HitsCollection with data on every step, it might kill the process for using too much memory. Not that I’m speaking from personal experience…

1 Like

Hi @mkelsey and @dsawkey,

Another quick question related to the behavior I am observing. I currently am generating optical photons, of energy ~eV, which are start in a scintillating material and are directed toward a surface coupled to the world volume, which is a vacuum. The surface is of a dielectric-dielectric, “ground” type, and so diffuse reflection is expected when the internal statistics allows (the random number generator which sets whether the photon will transmit or reflect via Fresnel equations).

Some runs, the photon will transmit, terminating on the edge of the world box, other times it stops at the interface between the two surfaces. Both materials have absorption lengths on the order of meters, so I don’t think that some form of absorption is happening.

Here is an example of this behavior:

As you can see, in the first set of tracking info, the photon terminates on the world-scent_phys boundary, whereas in the second set the photon transmits into the world and then terminates on the edge of the world. Both photons are identical and so are their starting positions.

The reflectivity of the surface is set to be 0.98, going from the scintillator to the world, and there is no transmittance. With these settings I expect that the photon should be governed by Snell’s law and the Fresnel equations, given the algorithm in “G4OpBoundaryProcess.cc”. Any ideas as to why this may be happening?

Thank you in advance.

-Frank

I’m not sure I understand the question. You seem to be asking, why are some photons absorbed with REFLECTIVITY=0.98. But you know from last week’s discussion that 2% of the photons will be absorbed in this case.

I suggest putting your optical parameters into an OpNovice2 macro. It will tell you what happens to all the photons at the boundary.

As an aside, it’s difficult to read the text in the picture. Why not simply cut & paste the text?

Hi @dsawkey,

Ah yes thanks, realized this after posting, but didn’t remove or edit my comment as I wanted to make sure that I wasn’t also missing something else, which I still think is the case.

I have now removed the reflectivity setting totally, which based on our previous discussion I think the transmittance and reflectivity variables should be defaulted to trans = 0.0 and ref = 1.0, as per the “G4OpBoundaryProcess.cc” script. It is my understanding that the photon should now follow Snell’s law and the Fresnel equations.

The surface of interest is:

G4OpticalSurface *fOpScintAirSurface = new G4OpticalSurface("OpScintAirSurface", glisur, ground, dielectric_dielectric, 0.0);
  new G4LogicalBorderSurface("ScintAirSurface", fPhysicScintCell, fPhysicWorld, fOpScintAirSurface);

Also, the index of refraction for my air volume is 1, and the scintillator is 1.95.

Upon generating optical photons, with an energy of 3 eV, and directing them perpendicular to this surface I find that out of 1k photons, around 20 are terminating in the scintillator when the reflectivity = 1, whereas when the reflectivity was set to 0.98, 60 would terminate in the scintillator.

Is there some other process that I am missing that would cause these photons to terminate at this surface? My expectation is that these photons should either reflect or transmit at the surface.

Thank you again for all of your help!

-Frank

Not that I know of. Likely something is misconfigured in your application or analysis.

Hi @dsawkey,

Upon your advice, I borrowed the ability to read out the process at each surface from OpNovice2. I found that the instances when the photon is terminated in the scintillator it undergoes some total internal reflections and then something referred to as “StepTooSmall” oscillating between the two materials, until finally there are two sequential “StepTooSmall” processes at which time the photon terminates with a fStopAndKill track status.

Do you have any idea what this may be?

Thank you again for all of your help!

-Frank

No. It seems to work for me, although of course I don’t know your exact setup. I can’t debug the process on this information. If you can’t or won’t reproduce the problem with OpNovice2 (or other example), you may need to 1) turn up tracking and optical verbosity 2) step through your application with a debugger.

Hi @dsawkey,

Thank you for all of your time, help and patience.

I implemented my scintillator material in place of the tank material in “OpNovice2” and for the ground surface I had the following result:

############################# ground ##########################################
/opnovice2/surfaceFinish ground
/run/geometryModified
/run/initialize
/opnovice2/surfacePolish 0.2
/run/geometryModified
Surface polish set to: 0.2
/run/beamOn 10000
### Run 2 start.
... open Root analysis file : glisur.root - done
number of event = 10000 User=0.040000s Real=0.039076s Sys=0.000000s

    Run Summary
---------------------------------
Primary particle was: opticalphoton with energy 3 eV .
Material of world: G4_AIR
Material of tank:  G4_WATER

Average number of OpRayleigh per event:   0
Average number of OpAbsorption per event: 1

Surface events (on +X surface, maximum one per photon) this run:
# of primary particles:         10000
OpAbsorption before surface:     6378
Total # of surface events:       3622
Unaccounted for:                    0

Surface events by process:
  Fresnel refraction:            1834
  Fresnel reflection:             306
  Total internal reflection:     1482
 Sum:                            3622
 Unaccounted for:                   0
---------------------------------

Using the same parameters, but now with the tank material as set built in the example, I obtain:

############################# ground ##########################################
/opnovice2/surfaceFinish ground
/run/geometryModified
/run/initialize
/opnovice2/surfacePolish 0.2
/run/geometryModified
Surface polish set to: 0.2
/run/beamOn 10000
### Run 2 start.
... open Root analysis file : glisur.root - done
number of event = 10000 User=0.080000s Real=0.084863s Sys=0.000000s

    Run Summary
---------------------------------
Primary particle was: opticalphoton with energy 3 eV .
Material of world: G4_AIR
Material of tank:  G4_WATER

Average number of OpRayleigh per event:   0
Average number of OpAbsorption per event: 0

Surface events (on +X surface, maximum one per photon) this run:
# of primary particles:         10000
OpAbsorption before surface:      737
Total # of surface events:       9263
Unaccounted for:                    0

Surface events by process:
  Fresnel refraction:            4711
  Fresnel reflection:             799
  Total internal reflection:     3753
 Sum:                            9263
 Unaccounted for:                   0
---------------------------------

I notice in both cases, that there are some photons that undergo “Total Internal Reflection” processes, which are not Fresnel refracted or reflected. Could this be what is happening to the photons in my application which are terminated at the surface? What exactly does this mean in terms of the OpNovice2 application, are the photons which undergo a TIR process at the surface terminated?

Thanks again for all of your help!

-Frank

The TIR photons should continue to propagate.

I notice you have lots of OpAbsorption before the surface. Are you sure the particle is being terminated at the surface? And not OpAbsorbed (which is different from surface absorption) in the material?

Also you could try setting surface polish to 1, i.e. a ground surface that is flat. Maybe something is happening with reflection from facets that are at a large angle.

Hi @dsawkey,

I re-ran OpNovice2 with the “glisur.mac” macro, with your suggestion of a surface polish set to 1, my result was:

############################# ground ##########################################
/opnovice2/surfaceFinish ground
/run/geometryModified
/run/initialize
/opnovice2/surfacePolish 1.0
/run/geometryModified
Surface polish set to: 1
/run/beamOn 10000
### Run 2 start.
... open Root analysis file : glisur.root - done
number of event = 10000 User=0.030000s Real=0.030151s Sys=0.000000s

    Run Summary
---------------------------------
Primary particle was: opticalphoton with energy 3 eV .
Material of world: G4_AIR
Material of tank:  G4_WATER

Average number of OpRayleigh per event:   0
Average number of OpAbsorption per event: 0

Surface events (on +X surface, maximum one per photon) this run:
# of primary particles:         10000
OpAbsorption before surface:     6492
Total # of surface events:       3508
Unaccounted for:                    0

Surface events by process:
  Fresnel refraction:            3133
  Fresnel reflection:             375
 Sum:                            3508
 Unaccounted for:                   0
---------------------------------

I still observed a high number of OpAbsorption, but no total internal reflection, which I assume was due to the facets as you stated.

What is the difference between OpAbsorption and OpAbsorbed? Do you know what would cause there to be such a high number?

Thank you for all of your help and time.

-Frank

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.