Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MonteCarlo Tissues GetDistanceToBoundary logic in error #136

Closed
hayakawa16 opened this issue Mar 20, 2024 · 2 comments · Fixed by #137
Closed

MonteCarlo Tissues GetDistanceToBoundary logic in error #136

hayakawa16 opened this issue Mar 20, 2024 · 2 comments · Fixed by #137
Assignees

Comments

@hayakawa16
Copy link
Member

In Vts/MonteCarlo/Tissues, the method GetDistanceToBoundary should determine the distance to the closest tissue region boundary using the photon current position and direction, independent of hitting it (not using photon.S, track length, but possibly using a projection of S).

The projected distance needs to be correct so that MonteCarloSimulation MoveToBoundaryCheck processes correctly.

Problem definitely occurs in MultiConcentricInclusionTissue but plan to check all other tissues.

@hayakawa16 hayakawa16 self-assigned this Mar 20, 2024
@hayakawa16
Copy link
Member Author

While making corrections to MultiConcentricInclusionTissue GetDistanceToBoundary and writing unit tests, I decided to beef up
other unit tests for this class, in particular for GetRefractedDirection. I determined the Direction when refracting between n=1.0 and n=1.4 both ways. I used a flat layer plane to determine refracted Direction from test incident Directions. Then put the photon on top or bottom of cylinder with same incident Directions. Since on top or bottom, the plane determined from the surface normal will be flat like the layer and the direction of the normal will be outward like the layer. I used the validation values
from the layer tests for the cylinder tests.

From these unit tests I found that GetRefractedDirection algorithm was in error. I had previously used the reference: Bram de Greve "Reflections and Refractions in Ray Tracing" dated 11/13/2006. However after much trial and error, determined that the algorithm was missing something. The missing code was found in
https://stackoverflow.com/questions/26087106/refraction-in-raytracing
After applying this code my unit tests for the cylinder GetRefractedDirection passed.

If @janakarana feels these modifications solve the handling of air-(tissue cylinder layers of varying n)-air, I will start a PR.

@dcuccia
Copy link
Contributor

dcuccia commented Mar 27, 2024

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants