FlatGrating

class marxs.optics.FlatGrating(**kwargs)[source] [edit on github]

Bases: FlatOpticalElement

Flat grating

The grating is assumed to be geometrically thin, i.e. all photons enter on the face of the grating, not through the sides.

Parameters:
dfloat or callable

grating constant in mm. If d is callable, then it will be called as d(intercoos), where intercoos is a (N, 2) array holding the positions where photons hit the gratings in the local coordinate system. This can be used to simulate manufacturing uncertainties or intentional grating period variation. The callable has to return a vector of lengths N that contains the grating constant for each photon in mm.

order_selectorcallable

A function or callable object that accepts arrays of photon energy, polarization and the blaze angle as input and returns arrays for grating order (integer) and probability (float). The probabiliy expresses the chance that the photon passes the grating and is not absorbed, e.g. if the probability that a photon at energy E ends up in order=[-2, -1, 0, 1, 2] is [0, 0, .5, .3, .0] , then the returned probability for all photons should be 0.8.

transmissionbool

Set to True for a transmission grating and to False for a reflection grating. (Default: True ) Warning: Reflection gratings have not yet been tested

groove_anglefloat

Angle between the local z axis and the direction of the grooves in radian. (Default: 0.)

Define a new MARXS element.

Attributes Summary

blaze_name

Column name for blaze angle.

loc_coos_name

name for output columns that contain the interaction point in local coordinates.

order_name

Column name for diffraction order.

Methods Summary

blaze_angle_modifier(intercoos)

Modify blaze angle

d(intercoos)

Method that returns the grating constant at given positions.

diffract_photons(photons, intersect, ...)

Vectorized implementation

e_groove_coos(intercoos)

Get coordiante orthonormal coordinate system along groove direction.

order_sign_convention(p, e_perp_groove)

Set sign convention for grating orders.

specific_process_photons(photons, intersect, ...)

Attributes Documentation

blaze_name = 'blaze'

Column name for blaze angle.

loc_coos_name = ['grat_y', 'grat_z']

name for output columns that contain the interaction point in local coordinates.

order_name = 'order'

Column name for diffraction order.

Methods Documentation

blaze_angle_modifier(intercoos)[source] [edit on github]

Modify blaze angle

In diffract_photons the blaze angle is calculated relative to the surface of the grating. In cases where that number has to be modified (e.g. when the grating bars are not perpendicular to the surface) the blaze angle can be modified by overriding this function.

d(intercoos)[source] [edit on github]

Method that returns the grating constant at given positions.

For a grating with constant grating constant, this will just return the number input as d when the element was initialized. For gratings where the grating constant varies with position on the facet, this calculates the appropriate number for every position.

diffract_photons(photons, intersect, interpos, intercoos)[source] [edit on github]

Vectorized implementation

e_groove_coos(intercoos)[source] [edit on github]

Get coordiante orthonormal coordinate system along groove direction.

Parameters:
intercoosnumpy.ndarray of shape (N, 2)

coordinates in the coordiante system of the geometry (e.g. (x, y), or (r, phi)).

Returns:
e_groove, e_perp_groove, nnumpy.ndarray of shape (N, 4)

Vectors pointing along the groove direction (parallel to the surface), perpendicular to the groove direction (parallel to surface), and normal to surface.

order_sign_convention(p, e_perp_groove)[source] [edit on github]

Set sign convention for grating orders.

This sets the following, somewhat arbitrary convention: Positive grating orders will are displaced along the local \(\hat e_z\) vector, negative orders in the opposite direction. If the grating is rotated by \(-\pi\) the physical situation is the same, but the sign of the grating order will be reversed. In this sense, the convention chosen is arbitrarily. However, it has some practical advantages: The implementation is fast and all photons passing through the grating in the same diffraction order are displaced in the same way. (Contrary to the convention in CATGrating.) order_sign_convention has to be a callable that accepts an array of eukledian direction vectors as input and returns +1, -1, or an array filled with -1 or +1.

Parameters:
pnp.array

Array of Eucleadian direction vectors

e_perp_groovenp.array

Array of local groove directions at the positions where the photons hit

specific_process_photons(photons, intersect, interpos, intercoos)[source] [edit on github]