Beam

class nexus.Beam(polarization=0, mixing_angle=0, canting_angle=0, profile='g', fwhm=0, id='')

Constructor for the Beam class. Default values set a linear polarization along \(\sigma\).

See Eq. (9), [Sturhahn2000], however, the canting angle given in Nexus is multiplied by 2 to give a polarization of \(\pi\) at 90 degree.

Changed in version 2.0.0

The default method sets a unpolarized beam.

All parameters are now such that it corresponds to standard values of optical theory. The mixing angle now corresponds to the ellpticity angle of the ellipse of the coherent Jones vector.

Parameters:
  • polarization (float or Var) –

    Degree of polarization, 0 to 1.

    Changed in version 2.0.0: fitable since version 2.0.0

  • mixing_angle (float or Var) –

    Mixing angle (deg). Defines the contribution of independent polarization components of the coherent Jones vector. The definition is such that circular left polarized light carries a spin angular momentum of \(+\hbar\).

    • 0 degree linear polarization.

    • +90 degree circular left polarization. +45 deg since version 2.0.0.

    • -90 degree circular right polarization. -45 deg since version 2.0.0.

    Changed in version 2.0.0: fitable since version 2.0.0

    value is halved compared to version 1 to obtain the same beam properties.

  • canting_angle (float or Var) –

    Canting angle of the beam with respect to sigma direction (deg).

    Changed in version 2.0.0: fitable since version 2.0.0

  • profile (string) –

    Profile of the beam for grazing incidence scattering. The beam profile is only considered in the methods Reflectivity, Transmission, NuclearReflectivity and NuclearReflectivityEnergy.

    • g - Gaussian profile.

    • r - Rectangular profile.

    • n - No beam profile correction.

    Changed in version 1.0.2: Rectangular beam profile correction wrong prior to version 1.0.2

  • fwhm (float or Var) – Full width half maximum of the beam in the scattering plane of grazing scattering geometry (mm). Only needed for grazing incidence geometry.

  • id (string) – User identifier.

polarization

Degree of polarization, 0 to 1.

Added in version 2.0.0.

Type:

Var

mixing_angle

Mixing angle (deg). Defines the contribution of independent polarization components of the coherent Jones vector. The definition is such that circular left polarized light carries a spin angular momentum of \(+\hbar\).

Added in version 2.0.0.

  • 0 degree linear polarization.

  • +45 degree circular left polarization.

  • -45 degree circular right polarization.

Type:

Var

canting_angle

Canting angle of the beam with respect to sigma direction (deg).

Added in version 2.0.0.

Type:

Var

matrix

2x2 complex Jones matrix of the beam.

Type:

ndarray

jones_vector

Jones vector for a fully coherent beam, 2-element vector. Can only be set via :attr:` or special methods with fully polarized beam properties.

Type:

ndarray

profile

Profile of the beam for grazing incidence scattering. The beam profile is only considered in the methods Reflectivity, Transmission, NuclearReflectivity and NuclearReflectivityEnergy.

  • g - Gaussian profile.

  • r - Rectangular profile.

  • n - No beam profile correction.

Changed in version 1.0.2: Rectangular beam profile correction wrong prior to version 1.0.2

Type:

string

fwhm

Full width half maximum (FWHM) of the beam in the scattering plane of grazing scattering geometry (mm). Only needed for grazing incidence geometry.

Type:

Var

id

User identifier.

Type:

string

CircularLeft()

Set the beam to circular left polarized light.

CircularRight()

Set the beam to circular right polarized light.

Coherence()

Calculates the coherence of the beam [Born]

\[|\mu| = | \frac{J_{\sigma \pi}}{\sqrt(J_{\sigma \sigma}) \sqrt(J_{\pi \pi})} |\]

It is a measure of the correlation between the \(E\)-vector components.

If nan is returned one \(E\)-vector component is zero.

Returns:

Degree of coherence between \(E_{\sigma}\) and \(E_{\pi}\).

Return type:

float

ComplexCoherence()

Calculates the complex coherence (or correlation between \(E_{\sigma}\) and \(E_{\pi}\)) of the beam [Born]

\[\mu = \frac{J_{\sigma \pi}}{\sqrt(J_{\sigma \sigma}) \sqrt(J_{\pi \pi})}\]

It is a measure of the correlation between the \(E\)-vector components.

If nan is returned one \(E\)-vector component is zero.

Returns:

Complex coherence between \(E_{\sigma}\) and \(E_{\pi}\).

Return type:

complex

LinearPi()

Set the beam to \(\pi\) polarized light.

LinearSigma()

Set the beam to \(\sigma\) polarized light.

MatrixFromJonesVector()

Get the coherency matrix after you have set a valid Jones vector.

Returns:

coherency matrix.

Return type:

ndarray

PhaseDifference()

Calculates the phase difference between \(E_{\sigma}\) and \(E_{\pi}\) [Born]

If nan is returned one \(E\)-vector component is zero.

Returns:

Phase difference between \(E_{\sigma}\) and \(E_{\pi}\).

Return type:

float

Polarization()

Calculates the degree of polarization [Born]

\[P = \frac{I_{pol}}{I_{tot}} = \sqrt{1 - \frac{4|\mathbf{J}|}{(J_{\sigma \sigma} + J_{\pi \pi})^2}}\]
Returns:

Degree of polarization. 0 to 1.

Return type:

float

Rotate(angle)

Rotate the beam by the given angle. Jones vector and matrix are rotated.

..versionremoved:: 2.0.0

Parameters:

angle (float) – angle of rotation (degree).

SetCoherencyMatrix(matrix)

Set the coherency matrix. The Jones vector is invalid in this case. To set a fully coherent beam use SetJonesVector or a specific method.

Removed in version 2.0.0.

Parameters:

matrix (ndarray) – 2x2 complex coherency matrix.

SetJonesVector(jones_vector, angle=0.0)

Set the Jones vector.

Changed in version 2.0.0: Only sets the Jones vector since version 2.0.0.

Parameters:
  • jones_vector (ndarray) – Two element Jones vector.

  • angle (float) – Rotation angle of Jones vector with respect to \(\sigma\) (deg).

Unpolarized()

Set the beam to unpolarized radiation.

ValidJonesVector()

Checks a valid Jones vector is set.

Returns:

True or False.

Return type:

bool

Different ways to define a Beam.

# initialize beam, standard is fully sigma polarized
beam = nx.Beam()

# set beam to pi polarization
beam.LinearPi()

print(beam.matrix)

# set beam to unpolarized
beam.Unpolarized()

print(beam)
# set beam to sigma polarization via initialization parameters
# Rectangular beam profile, beam with 1 mm height
beam = nx.Beam(polarization = 1, mixing_angle = 0, profile = "r", fwhm = 1)
# set beam along pi polarization via initialization parameters
beam = nx.Beam(polarization = 1, mixing_angle = 0, canting_angle = 90)
beam = nx.Beam()
# set coherency matrix for unpolarized detection
beam.SetCoherencyMatrix(np.array([[1,0], [0, 1]], dtype=complex))
beam = nx.Beam()
# set Jones vector for fully sigma polarized beam
beam.SetJonesVector(np.array([1,0], dtype=complex))

print(beam.jones_vector)
print(beam.matrix)
# circularly right polarized beam
beam = nx.Beam(polarization = 1, mixing_angle = -90)

print(beam.Polarization())
print(beam.Coherence())
beam = nx.Beam()
# linear polarization at 45 deg rotation
beam.SetJonesVector(np.array([1, 0], dtype=complex), 45)