0
$\begingroup$

This is a continuation development of another post by @Dr. Wolfgang Hintze and deserves credit for the code work presented here. My modification was to include simple mapping to allow compare the behavior of the photon propagation under different anisotropy and number of photons trajectories respectively.

My problem is with the mapping in the number of trajectories.

    (*https://mathematica.stackexchange.com/questions/76404/how-to-set-up-\
    a-simple-monte-carlo-simulation/76406*)

    ClearAll["Global`*"]

    (*Let me give a model solution which can easily be adapted.2 dimensions

    Consider a photon which moves in the x-y-plane,starting at time t=0 \
    in the origin {0,0} and moving towards the positive x-axis.At each \
    tick of the clock,corresponding to a constant distance 1 travelled by \
    the photon,the photon will experience a scattering event which leads \
    to a deviation of the original direction by an angle "a".The angle \
    "a" is a random variable with a certain given distibution dist.We ask \
    for the random trajectory of the photon after a given number n of \
    scattering events.We would like to see several of those trajectories \
    in one picture.For simplicity,I assume that the angle distribution is \
    a symmetric NormaDistribution[0,s] with a given width s.*)

    dist[s_] = NormalDistribution[0, s];

    (*The scattering angle is then*)
    a[s_] := RandomVariate[dist[s]]

    (*A sample of angles is*)
    Array[a[1] &, 10^3];

    (*We need to cumulate these angeles because the new one gives the \
    deviation with respect to the current one:*)
    Accumulate[%];

    (*Now the x-y-coordinates of each subtrajectory of one tick of the \
    clock are*)
    {Cos[#], Sin[#]} & /@ %;

    (*This again needs to be cumulated in order to get the coordinates of \
    the trajectory:*)
    Accumulate[%];
(*Putting everything together gives us a trajectory by*)

tr[s_, n_] := 
 Accumulate[{Cos[#], Sin[#]} & /@ (Accumulate[Array[a[s] &, n]])]
(*Plotting a bunch of k=11 trajectories,each of length n=100 with a \
width s of the normal Distribution*)

With[{s = 1/10^#, n = 100, k = 15}, 
   ListLinePlot[Table[tr[s, n], {k}]]] & /@ {-2, -1, 1, 2, 3}
(*With[{s=0.45,n=#,k=11},ListLinePlot[Table[tr[s,n],{k}]]]&/@{4,15,60}\
*)

With[{s = 0.45, n = #, k = 11}, 
   ListLinePlot[Table[tr[s, n], {k}]]] & /@ {4, 15, 60}
(*150304 plot_k_trajectories.jpg*)

My output is

enter image description here

Why the photons trajectories are not starting from the same point location?

enter image description here

$\endgroup$
  • 1
    $\begingroup$ Rather than using Accumulate and computing the coordinates, how about using AnglePath? $\endgroup$ – Rohit Namjoshi Jul 20 '19 at 22:19
  • $\begingroup$ @Rohit Namjoshi how this make a difference in that I am not starting at the single point? $\endgroup$ – Jose Enrique Calderon Jul 21 '19 at 0:26
  • $\begingroup$ Looks like the starting point is not fixed, but given by {Cos[a], Sin[a]} where a is the first random angle. $\endgroup$ – MelaGo Jul 21 '19 at 2:28
  • 1
    $\begingroup$ You can include the zero time-point (0,0) with tr[s_, n_] := Join[{{0, 0}}, Accumulate[{Cos[#], Sin[#]} & /@ (Accumulate[Array[a[s] &, n]])]] $\endgroup$ – MelaGo Jul 21 '19 at 2:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.