xopto / pyxopto

PyXOpto is a collection of python tools for performing Monte Carlo simulations of light propagation in turbid media.
GNU General Public License v3.0
35 stars 8 forks source link

Cylindrical MC - Uniform source off-centre and at an angle. #28

Open l-hemsley opened 1 week ago

l-hemsley commented 1 week ago

When I make a source that is off centre and at an angle to the cylindrical sample, as in;

source = mc.mcsource.UniformBeam([0.5e-3,5.0e-3],position =(-20e-3, 5e-3, 0),direction=(np.cos(2*np.pi*ang/360), np.sin(2*np.pi*ang/360),0))

Looks like this in the x-y plane

image

But the 2D cross section of the beam seems to be tilted - the beam should be symmetrical in the z axis I believe.

image

It looks like the beam is rotated somehow.

Thank you :)

xopto commented 4 days ago

The rotation of non-circular beams in current implementation of the UniformBeam wont be aligned with the coordinate system if the propagation direction is not along the x, y, or z axis.

A solution to this issue is to slightly modify the UniformBeam constructor to take orientation of the beam (the first axis of the ellipse) and rewrite the sampling part of the OpenCL code. Unfortunately, I don't have an example yet but will come back to you later with a snippet.

l-hemsley commented 4 days ago

Thanks for your quick response! I am trying to implement a slit-type uniform input off-axis and off-angle. I was thinking if nothing else works then I can just iterate over the line source though will be time consuming.

xopto commented 3 days ago

In the attached zip file there are two new sources (UniformEllipticBeam in uniformellipticbeam.py and UniformRectangularBeam in uniformrectangularbeam.py) and a slightly modified __init__.py file. Extract/copy the three files into the xopto/mccyl/mcsource directory.

The two new sources take an additional axes parameter that can be used to fix the orientation of the beam in the transverse plane. Note that this is experimental and not fully tested.

mcsources.zip

l-hemsley commented 3 days ago

Thank you I will try it! I also realised I could simply shift the coordinate system... either rotate until the beam until it is centred on y=0 or is paralell to the x axis. This Also seems to work.

image