particle beam direction change over its path

Hi Experts,

I have a beam starts that changes its direction twice on its path.
It starts at Z0 with a zero angle from upstream to downstream of a tunnel then it changes direction in XY-pane at an angle of theta1 at Z1 first, then theta 2 in XZ-plane at Z2. How do I set these three angles of my beam on its path for my simulation? I’ve tried to set those three angles using the “if” statement in source_newgen.f. Unfortunately, it did not function.

Dear @melike.abliz,

It is not clear exactly what you want to do, some more details would be useful. Could you please share a drawing of what you want to do, detail better which quantities you want to estimate, and also share your source routine?