Skip to content

The vector returned by Beam.direction(x, y, z) does not depend on coordinates #414

@vsnever

Description

@vsnever

I was working on updating the MSE model and found that the calculation of the direction of the beam at a point, which is used as a direction of beam bulk velocity in the BeamEmissionLine and BeamCXLine models, is rather strange:

cpdef Vector3D direction(self, double x, double y, double z):
"""
Calculates the beam direction vector at a point in space.
Note the values of the beam outside of the beam envelope should be
treated with caution.
:param x: x coordinate in meters.
:param y: y coordinate in meters.
:param z: z coordinate in meters.
:return: Direction vector.
"""
# if behind the beam just return the beam axis (for want of a better value)
if z <= 0:
return self.BEAM_AXIS
# calculate direction from divergence
cdef double dx = tan(DEGREES_TO_RADIANS * self._divergence_x)
cdef double dy = tan(DEGREES_TO_RADIANS * self._divergence_y)
return new_vector3d(dx, dy, 1.0).normalise()

The vector returned by this function is independent of the given x, y coordinates and always points in the same direction, determined by the beam's divergence angles.

I think that if the model takes into account beam divergence, then at least the polar angle should be taken into account:

        # calculate direction from divergence
        cdef double phi = atan2(y, x)
        cdef double dx = cos(phi) * tan(DEGREES_TO_RADIANS * self._divergence_x)
        cdef double dy = sin(phi) * tan(DEGREES_TO_RADIANS * self._divergence_y)
        return new_vector3d(dx, dy, 1.0).normalise()

However, I'm not an NBI expert, so I'm asking for advice here. @Mateasek, what do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions