Monte Carlo, Euler and Quaternions Jessica C. Ramella-Roman II Escuela de Optica Biomedica, Puebla, 2011 Stokes vector reference • Yesterday, Meridian plane – Three steps – “Rotate” to scattering plane • Rotational matrix – Scatter • Scattering matrix – “Rotate” to a new plane • Rotational matrix II Escuela de Optica Biomedica, Puebla, 2011 Today Monte Carlo • Reference frame is a triplet of unit vectors • Rotation are about an axis and follow a specific order http://www.grc.nasa.gov/WWW/K-12/airplane II Escuela de Optica Biomedica, Puebla, 2011 Today Monte Carlo • Reference frame is a triplet of unit vectors • Rotation of the frame is done in two steps. II Escuela de Optica Biomedica, Puebla, 2011 Euler and Quaternion • The only difference between today programs is the way we handle these rotations • Euler angles rotation Quaternions algebra II Escuela de Optica Biomedica, Puebla, 2011 Euler Monte Carlo • The photon polarization reference frame is tracked at any time via a triplet of unit vectors that are rotated by an azimuth and scattering angle according to a predefined order • Introduced by Bartel et al. (*) * S. Bartel, A. Hielsher, “Monte Carlo simulations of the diffuse backscattering Mueller matrix for highly scattering media,” Applied Optics, Vol. 39, No. 10; (2000). II Escuela de Optica Biomedica, Puebla, 2011 Euler matrices • Euler's rotation theorem: any rotation may be described using three angles. • And three rotation matrices – About z axis – About x’ axis – About z’ axis Drawings, Wolfram, Mathworld II Escuela de Optica Biomedica, Puebla, 2011 Euler cnt. • We only need TWO vectors and TWO rotations • Two unit vectors v and u v [vx , vy , vz ] [ 0,1,0] u [ux , uy , u z ] [0,0,1] • The third unit vector is defined by the cross product of v and u and is calculated only when a photon reaches a boundary. II Escuela de Optica Biomedica, Puebla, 2011 Euler cnt. • Advantage – Stokes vector is rotated only once for each scattering event instead of twice as in the meridian plane method. – Simple to implement and visualize • Drawback – – Gimbal lock - makes the rotation fail for angles exactly equal to 90˚ (rare event). II Escuela de Optica Biomedica, Puebla, 2011 Monte Carlo flow chart II Escuela de Optica Biomedica, Puebla, 2011 Launch • The two unit vector v and u v [vx , vy , vz ] [ 0,1,0] u [ux , uy , u z ] [0,0,1] • v and u define the starting Stokes vector reference plane. • The unit vector u represents the direction of photon propagation. II Escuela de Optica Biomedica, Puebla, 2011 Move • The photon is moved a distance Ds, the new coordinates of the photon are x x ux Ds y y u y Ds z z uz Ds II Escuela de Optica Biomedica, Puebla, 2011 Drop • Reduction of photon weight (W) • According to material albedo • albedo = ms/(ms+ ma) • absorbed = W*(1-albedo) II Escuela de Optica Biomedica, Puebla, 2011 Scatter • The rejection method establishes the scattering angle q and azimuth angle f. • The Stokes vector must be rotated by an angle f into the scattering plane before scattering can occur. II Escuela de Optica Biomedica, Puebla, 2011 Referencing to scattering plane • Done as in meridian plane Monte Carlo • Multiply the Stokes vector by matrix R 1 0 0 0 cos(2f ) sin(2f ) R f 0 sin(2f ) cos(2f ) 0 0 0 0 0 0 1 S out R f S in II Escuela de Optica Biomedica, Puebla, 2011 Scatter cnt • The interaction with a spherical particle is achieved by multiplying the Stokes vector with a scattering matrix M(q) s11( q ) s12 ( q ) 0 0 s ( q ) s11( q ) 0 0 M q 12 0 0 s33 ( q ) s34 ( q ) 0 0 s ( q ) s ( q ) 34 33 S out M q S in II Escuela de Optica Biomedica, Puebla, 2011 M(q) elements • s11 , s12 , s33 , s34 calculated with Mie theory 2 2 1 s11( q ) [ S2 ( q ) S1( q ) ] 2 2 2 1 s12 ( q ) [ S2 ( q ) S1( q ) ] 2 1 s33 ( q ) [ S2* ( q )S1( q ) S2 ( q )S1* ( q )] 2 i s34 ( q ) [ S2* ( q )S1( q ) S2 ( q )S1* ( q )] 2 • Expressed as • S1, S2* – Mie scattering *http://omlc.ogi.edu/calc/mie_calc.html C. Bohren and D. R. Huffman, Absorption and scattering of light by small particles, (Wiley Science Paperback Series,1998). II Escuela de Optica Biomedica, Puebla, 2011 Reference frame • After scattering the Stokes vector the reference coordinate system v u must be updated. • The two rotations, for the angles f and q can be obtained using Euler’s rotational matrices. II Escuela de Optica Biomedica, Puebla, 2011 Rotational matrix ROT • Rodrigues’s rotational matrix ROT • Accomplishes the general case of rotating any vector by an angle y about an axis K k x k x v c k y k x v k z s k z k x v k ys ROT ( K ,y ) k x k y v k z s k y k y v c k y k z v k x s k x k z v k y s k y k z v k x s k z k z v c • Where K is the rotational axis, • c=cos(y), s=sin(y) and v=1-cos(y). II Escuela de Optica Biomedica, Puebla, 2011 Vector rotation • First the unit vector v is rotated about the vector u by an angle f • Multiply v by the rotational matrix ROT(u,f); u remains unchanged II Escuela de Optica Biomedica, Puebla, 2011 Vector rotation • Second u is rotated about the newly generated v by an angle q. • This is done multiplying the unit vector u by the rotational matrix ROT(v,q). II Escuela de Optica Biomedica, Puebla, 2011 Update of direction cosines • This is done as in standard Monte Carlo • q and f If |uz| ≈ 1 ^ u x sin( q ) cos( f ) ^ u y sin( q ) sin( f ) ^ u z cos( q ) uz uz II Escuela de Optica Biomedica, Puebla, 2011 Update of direction cosines If |uz| ≠ 1 ^ ux 1 1 u2 sin(q )( ux u y cos(f ) u y sin(f )) ux cos(q ) z ^ uy 1 1 u2 sin(q )( ux u z cos(f ) ux sin(f )) u y cos(q ) z ^ u z 1 u2 sin(q ) cos(f )( u y u z cos(f ) ux sin(f )) u z cos(q ) z II Escuela de Optica Biomedica, Puebla, 2011 Photon life • The life of a photon ends when the photon passes through a boundary or when its weight W value falls below a threshold. • Roulette is used to terminate the photon packet when W Wth. – Gives the photon packet one chance of surviving – If the photon packet does not survive the roulette, the photon weight is reduced to zero and the photon is terminated. II Escuela de Optica Biomedica, Puebla, 2011 Boundaries • Two final rotations of the Stokes vector are necessary to put the photon status of polarization in the detector reference frame. • This will be achieved with matrix multiplication of two rotational matrix by stokes vector S final R( y )R( )S II Escuela de Optica Biomedica, Puebla, 2011 Boundaries – R() • w is reconstructed as the cross product of v and u. w vu • An angle is needed to rotate the Stokes vector into a scattering plane II Escuela de Optica Biomedica, Puebla, 2011 Boundaries – R() 0 when vz 0 and uz 0 vz tan ( ) in all other cases wz 1 • This is the ONLY reason we need the vector u, v, and w II Escuela de Optica Biomedica, Puebla, 2011 Boundaries – R() • This rotation is about the direction of propagation of the photon, i.e. the axis u • Resulting position of v II Escuela de Optica Biomedica, Puebla, 2011 Boundaries – R(y) • A second rotation of an angle y about the Z axis • Put the photon reference frame in the detector reference frame II Escuela de Optica Biomedica, Puebla, 2011 Boundaries – R(y) • Transmission uy 1 y tan ( ux ) • Reflection y tan 1( uy ux ) II Escuela de Optica Biomedica, Puebla, 2011 Boundaries End • Stokes vector in the detector frame of reference S final R( y )R( )S • We need vector u, v, and w to obtain these angles II Escuela de Optica Biomedica, Puebla, 2011 Quaternion Monte Carlo • Quaternion Monte Carlo simply uses Quaternion Algebra to handle vector rotation. • Advantage – Stokes vector is rotated only once for each scattering event instead of twice as in the meridian plane method. – No issue with Gimbal lock – Optimized for computer simulations II Escuela de Optica Biomedica, Puebla, 2011 Quaternions • A quaternion is a 4-tuple of real numbers; it is an element of R4. q qo ,q1 ,q2 ,q3 • Quaternion can also be defined as the sum of a scalar part q0 and a vector part Q in R3 of the form q q0 Q q0 iq1 jq2 kq3 II Escuela de Optica Biomedica, Puebla, 2011 Quaternions cnt. • The vector part Q is the rotational axis and the scalar part is the angle of rotation. • Multiplication of a vector t by the quaternion is equivalent to rotating the vector t around the vector Q of an angle q0. II Escuela de Optica Biomedica, Puebla, 2011 Vector rotation • First the unit vector v is rotated about the vector u by an angle f II Escuela de Optica Biomedica, Puebla, 2011 Rotation - f • The first rotation is about the vector u by an angle f. • This is done generating the quaternion qf qf f u f iux juy kuz • And then using the quaternion operator • q∗ vq on the vector v • q∗ is the complex conjugate of q II Escuela de Optica Biomedica, Puebla, 2011 Vector rotation • Second u is rotated about the newly generated v by an angle q. II Escuela de Optica Biomedica, Puebla, 2011 Rotation - q • The second rotation is about the vector v by an angle q. • This is done generating the quaternion qq qf q v f ivx jv y kvz • And then using the quaternion operator • qq*uqq on the vector u II Escuela de Optica Biomedica, Puebla, 2011 Rotations • These steps are repeated for every scattering event. • At the boundaries the last aligning rotations are the same as in Euler Monte Carlo. II Escuela de Optica Biomedica, Puebla, 2011 Testing • Comparison with Evans Code • In 1991 Evans designed an adding doubling code that can calculate both the radiance and flux of a polarized light beam exiting the atmosphere • plane parallel slab of thickness L = 4/µs, • absorption coefficient µa=0, • unpolarized incident beam • wavelength l = 0.632 nm. II Escuela de Optica Biomedica, Puebla, 2011 Evans - Reflectance mode Diameter (nm) Evans This code Evans This code I I Q Q 10 0.6883 0.6886 -0.1041 -0.1042 100 0.6769 0.6769 -0.1015 -0.1009 1000 0.4479 0.4484 0.0499 0.0499 2000 0.2930 0.2931 0.0089 0.0088 Incident I=[1 0 0 0] Reflectance mode, comparison between Evans adding-doubling code and the meridian plane Monte Carlo program. The results do not include the final rotation for a single detector. II Escuela de Optica Biomedica, Puebla, 2011 Evans – Transmission mode Diameter (nm) Evans This code Evans This code I I Q Q 10 0.33126 0.31133 -0.01228 -0.01233 100 0.32301 0.32305 -0.12844 -0.12770 1000 0.55201 0.55152 0.02340 0.02348 2000 0.70698 0.70689 0.01197 0.01205 Incident I=[1 0 0 0] Transmission mode, comparison between Evans adding doubling code and the meridian plane Monte Carlo program. The results are not corrected for a single detector II Escuela de Optica Biomedica, Puebla, 2011 How to run the code • Download the code • http://faculty.cua.edu/ramella/MonteCarlo/in dex.html II Escuela de Optica Biomedica, Puebla, 2011 How to run the code • Download the code • http://faculty.cua.edu/ramella/MonteCarlo/in dex.html II Escuela de Optica Biomedica, Puebla, 2011 Download the code Programs II Escuela de Optica Biomedica, Puebla, 2011 Make Command line Compilation/linking step II Escuela de Optica Biomedica, Puebla, 2011 Run Command line This program will run a full Mueller matrix Monte Carlo launching four vectors [1 1 0 0] H 0 degree polarized [1 -1 0 0] V 90 degrees polarized [1 0 1 0] P 45 degrees polarized [1 0 0 1] R –Right circular II Escuela de Optica Biomedica, Puebla, 2011 Memory usage • Intel (64-bit) – Macbook pro 2.3Ghz I7 8GB RAM • Real mem 860 KB • Virtual mem 17 MB II Escuela de Optica Biomedica, Puebla, 2011 Output is a set of Stokes vector images for each launched Stokes vector outHI -> Horizontal incident polarization and I portion of the Stokes vector outHQ -> Horizontal incident polarization and Q portion of the Stokes vector out II Escuela de Optica Biomedica, Puebla, 2011 Inside the code GNU Licence II Escuela de Optica Biomedica, Puebla, 2011 Modifiable parameters II Escuela de Optica Biomedica, Puebla, 2011 Image related parameters II Escuela de Optica Biomedica, Puebla, 2011 Stokes vector launch II Escuela de Optica Biomedica, Puebla, 2011 Launch terms Initial position Initial orientation Initial Stokes vector II Escuela de Optica Biomedica, Puebla, 2011 We can use the three Monte Carlo programs to understand how polarized light travels into scattering media II Escuela de Optica Biomedica, Puebla, 2011 Light transfer –mono disperse particles II Escuela de Optica Biomedica, Puebla, 2011 Light transfer –mono disperse particles • Experimental results – black circles • Monte Carlo – black square • Diameter 482 nm, • Wavelength was 543 nm. • nsphere =1.59 II Escuela de Optica Biomedica, Puebla, 2011 Light transfer –mono disperse particles • Experimental results – black circles • Monte Carlo – black square • Diameter 308 nm, • Wavelength was 543 nm. • nsphere =1.59 II Escuela de Optica Biomedica, Puebla, 2011 Poly-disperse solutions • Gamma distribution of particles N (r ) ar exp(br ) II Escuela de Optica Biomedica, Puebla, 2011 Poly-disperse solutions Comparison with Evans Incident I=[1 0 0 0] Results from a slab in reflectance II Escuela de Optica Biomedica, Puebla, 2011 Poly-disperse solutions -DLP II Escuela de Optica Biomedica, Puebla, 2011 Map of polarized light distribution d II Escuela de Optica Biomedica, Puebla, 2011 Map of polarized light distribution d II Escuela de Optica Biomedica, Puebla, 2011 Map of polarized light distribution d II Escuela de Optica Biomedica, Puebla, 2011 d d d y x D = 0.01 µm µs = 0.89 cm-1 l = 0.543µm d x y II Escuela de Optica Biomedica, Puebla, 2011 d d y x D = 0.01µm µs = 0.89 cm-1 l = 0.543µm y y II Escuela de Optica Biomedica, Puebla, 2011 d d d y x D = 0.48 µm µs = 0.89 cm-1 l = 0.543µm d x y II Escuela de Optica Biomedica, Puebla, 2011 d d y x D = 0.48 µm µs = 0.89 cm-1 l = 0.543µm y y II Escuela de Optica Biomedica, Puebla, 2011 D = 0.01 µm µs = 0.89 cm-1 l = 0.543µm Isosurface Pol= 0.5 d x y II Escuela de Optica Biomedica, Puebla, 2011 D = 0.48 µm µs = 0.89 cm-1 l = 0.543µm Isosurface Pol = 0.9 d x y II Escuela de Optica Biomedica, Puebla, 2011 Poincaré sphere analysis, Ellipticity I E 2x E y2 Im() Q E 2x E y2 I cos(2)cos(2f ) U 2E x E y cos() I cos(2)sin( 2f ) V 2E x E y sin( ) I sin( 2) +i -1 +1 Re() -i tan( f ) itan( ) 1 itan( )tan( f ) II Escuela de Optica Biomedica, Puebla, 2011 Ellipticity l = 543nm 2 scattering events 19 scattering events 0.01µm II Escuela de Optica Biomedica, Puebla, 2011 10 µm Particle effect on polarization Small spheres • Depolarize faster • Less forward directed • Turn incident polarized light into another linear state Large spheres • Depolarize slower – Large g effect • More forward directed • Turn incident polarized light into elliptical states II Escuela de Optica Biomedica, Puebla, 2011