Ray tracing - how to numerically integrate the equation of the ray

AI Thread Summary
In a continuous isotropic medium with a variable refractive index n, the ray path is described by a specific differential equation. The user has implemented a code to calculate this ray path but found qualitative consistency without quantitative accuracy, suspecting an error in their integration method. They seek assistance with algorithm suggestions, relevant literature, or source code for integration. A response highlights the importance of ensuring that the unit vector dr/ds maintains a length of one throughout the path and suggests exploring higher-order Runge-Kutta methods if simpler approaches fail. The discussion emphasizes the need for precise integration techniques in modeling ray paths in variable refractive index media.
carlos-carlos
Messages
10
Reaction score
0
In a continuous isotropic medium having refractive index n, (not constant)
the ray path can be described by the following equation

d/ds(n dr/ds)) = grad (n)

with an obvious meaning of the symbols (for they who can help me!).

I wrote a code to calculate the ray path. I found result qualitatively consistent but not quantitatively. I think that the integration procedure I used is wrong (I used a simple one,
that I set up on my own).

Can anybody help me?
Can anybody suggest me a paper or book where to read an algorithm?
Has anybody a source code to integrate it? (I would need just the core instructions).

Thanks Bye
 
Physics news on Phys.org
Just to make sure, the equation you are actually integrating over is the following, correct?

\frac{d}{ds}\frac{dr}{ds} = \nabla n - \left(\nabla n \cdot \frac{dr}{ds}\right)\frac{dr}{ds}

Note that dr/ds is just a unit vector you want as function of s, and the above equation maintains unit length of the vector.

So the thing you should check in your code is if ||dr/ds|| = 1 all the way along the path. If not, you either have an error in the method or the code.

Now, not knowing specifically the kind of function you have for n(r), it's a little hard to say how advanced a method you should be using, but if brute force forward Euler is not working for you, try one of the higher order Runge Kutta methods.
 
Thread 'Question about pressure of a liquid'
I am looking at pressure in liquids and I am testing my idea. The vertical tube is 100m, the contraption is filled with water. The vertical tube is very thin(maybe 1mm^2 cross section). The area of the base is ~100m^2. Will he top half be launched in the air if suddenly it cracked?- assuming its light enough. I want to test my idea that if I had a thin long ruber tube that I lifted up, then the pressure at "red lines" will be high and that the $force = pressure * area$ would be massive...
I feel it should be solvable we just need to find a perfect pattern, and there will be a general pattern since the forces acting are based on a single function, so..... you can't actually say it is unsolvable right? Cause imaging 3 bodies actually existed somwhere in this universe then nature isn't gonna wait till we predict it! And yea I have checked in many places that tiny changes cause large changes so it becomes chaos........ but still I just can't accept that it is impossible to solve...
Back
Top