tardis.energy_input.util module

tardis.energy_input.util.angle_aberration_gamma(direction_vector, position_vector, time)[source]

Angle aberration formula for photons in 3D

Parameters:
direction_vectorarray
position_vectorarray
timefloat
Returns:
array

New direction after aberration

tardis.energy_input.util.compton_theta_distribution(energy, sample_resolution=100)[source]

Calculates the cumulative distribution function of theta angles for Compton Scattering

Parameters:
energyfloat
sample_resolutionint
Returns:
theta_anglesOne dimensional Numpy array, dtype float
norm_theta_distributionOne dimensional Numpy array, dtype float
tardis.energy_input.util.convert_half_life_to_astropy_units(half_life_string)[source]

Converts input half-life to use astropy units

Parameters:
half_life_stringstr

Half-life as a string

Returns:
astropy Quantity

Half-life in seconds

tardis.energy_input.util.doppler_factor_3d(direction_vector, position_vector, time)[source]

Doppler shift for photons in 3D

Parameters:
direction_vectorarray
position_vectorarray
timefloat
Returns:
float

Doppler factor

tardis.energy_input.util.euler_rodrigues(theta, direction)[source]

Calculates the Euler-Rodrigues rotation matrix

Parameters:
thetafloat

angle of rotation in radians

directionOne dimensional Numpy array, dtype float

x, y, z direction vector

Returns:
rotation matrixTwo dimensional Numpy array, dtype float
tardis.energy_input.util.get_index(value, array)[source]

Get the index that places a value at array[i] < array <= vec[i+1]

Parameters:
valuefloat

Value to locate

arrayarray

Array to search

Returns:
int

Index

tardis.energy_input.util.get_perpendicular_vector(original_direction)[source]

Computes a random vector which is perpendicular to the input vector

Parameters:
original_directionarray
Returns:
numpy.ndarray

Perpendicular vector to the input

tardis.energy_input.util.get_random_phi_photon()[source]

Get a random phi direction between 0 and 2 * pi

Returns:
float

Random phi direction

tardis.energy_input.util.get_random_theta_photon()[source]

Get a random theta direction between 0 and pi

Returns:
float

Random theta direction

tardis.energy_input.util.get_random_unit_vector()[source]

Generate a random unit vector

Returns:
array: random unit vector
tardis.energy_input.util.klein_nishina(energy, theta_C)[source]

Calculates the Klein-Nishina equation

https://en.wikipedia.org/wiki/Klein%E2%80%93Nishina_formula

\[\]

rac{r_e}{2} [1 + kappa (1 - cos heta_C)]^{-2} left( 1 + cos^2 heta_C + rac{kappa^2 (1 - cos heta_C)^2}{1 + kappa(1 - cos heta_C)} ight)

where \(\kappa = E / (m_e c^2)\)

Parameters:
energyfloat

Packet energy

theta_Cfloat

Compton angle

Returns:
float

Klein-Nishina solution

tardis.energy_input.util.normalize_vector(vector)[source]

Normalizes a vector in Cartesian coordinates

Parameters:
vectorOne-dimensional Numpy Array, dtype float

Input vector

Returns:
One-dimensional Numpy Array, dtype float

Normalized vector

tardis.energy_input.util.solve_quadratic_equation(position, direction, radius)[source]

Solves the quadratic equation for the distance to the shell boundary

Parameters:
positionarray
directionarray
radiusfloat
Returns:
solution_1float
solution_2float
tardis.energy_input.util.solve_quadratic_equation_expanding(position, direction, time, radius)[source]

Solves the quadratic equation for the distance to an expanding shell boundary

Parameters:
positionarray
directionarray
timefloat
radiusfloat
Returns:
solution_1float
solution_2float
tardis.energy_input.util.spherical_to_cartesian(r, theta, phi)[source]

Converts spherical coordinates to Cartesian

Parameters:
rfloat64

Radius

thetafloat64

Theta angle in radians

phifloat64

Phi angle in radians

Returns:
array

x, y, z coordinates