inscar package

Module contents

INcoherent SCAtter Radar spectrum.

class inscar.SpectrumCalculation

Bases: object

Class containing the calculation of the power density spectrum.

calculate_spectrum()

Calculate a spectrum based on the given parameters and calculation methods.

Returns:

The frequency axis in the first position and the spectrum values along the axis in the second position.

Return type:

Tuple[np.ndarray, np.ndarray]

Raises:

ValueError – If any of the needed attribute objects are not set.

set_calculate_f_function(f_func)

Set what function to use to calculate the \(F\) function.

Parameters:

f_func (Callable[[Particle, Integrand], np.ndarray]) – A function that take a particle and an integrand function as input, and that calculates the \(F\) function based on these, returning a numpy array. By default, the integrate function from the numba_integration module is used.

Return type:

None

set_electron(electron)

Set the electron particles to use.

Parameters:

electron (Particle) – An instance of the Particle class, representing electrons.

Return type:

None

set_electron_integration_function(function)

Set the electron integration method to use.

Parameters:

function (Integrand) – An object of type Integrand, representing the electrons.

Return type:

None

set_ion(ion)

Set the ion particles to use.

Parameters:

ion (Particle) – An instance of the Particle class, representing ions.

Return type:

None

set_ion_integration_function(function)

Set the ion integration method to use.

Parameters:

function (Integrand) – An object of type Integrand, representing the ions.

Return type:

None

set_params(params)

Set the plasma parameters.

Parameters:

params (Parameters) – An instance of the Parameters class.

Return type:

None

set_susceptibility_function(func)

Set what function to use to calculate the susceptibility function.

Parameters:

func (Callable[[Particle, Integrand], float]) – A function that take a particle and an integrand function as input, and that calculates the susceptibility function based on these, returning a single float.

Return type:

None

Submodules

inscar.config module

Objects used to configure the physical parameters of the system.

class inscar.config.Parameters(radar_frequency=430000000.0, frequency_range=(-2000000.0, 2000000.0), frequency_size=10001, frequency_exp=1, magnetic_field_strength=3.5e-05, aspect_angle=45)

Bases: object

Object used to configure the physical parameters of the system.

See also

Particle

Examples

>>> from inscar import config

Setting aspect angle to 45 degrees.

>>> p = config.Parameters(aspect_angle=45)
>>> print(f"p.aspect_angle = {p.aspect_angle:.4f}")
p.aspect_angle = 0.7854

It’s automatically converted to radians! Similarly, setting radar frequency to 430 MHz will automatically update radar wave number:

>>> print(f"p.radar_wavenumber = {p.radar_wavenumber:.4f}")
p.radar_wavenumber = -18.0243
>>> # Changing radar frequency...
>>> p.radar_frequency = 430e5
>>> print(f"p.radar_wavenumber = {p.radar_wavenumber:.4f}")
p.radar_wavenumber = -1.8024

Setting aspect angle to 360.5 degrees.

>>> p.aspect_angle = 360.5
>>> print(f"p.aspect_angle = {p.aspect_angle:.4f}")
p.aspect_angle = 6.2919
Parameters:
  • radar_frequency (float)

  • frequency_range (tuple)

  • frequency_size (int)

  • frequency_exp (int)

  • magnetic_field_strength (float)

  • aspect_angle (int | float)

property angular_frequency: ndarray

Return the angular frequency used for the power spectrum.

aspect_angle: int | float
frequency_exp: int
frequency_range: tuple
frequency_size: int
property linear_frequency: ndarray

Return the linear frequency used for the power spectrum.

magnetic_field_strength: float
radar_frequency: float
property radar_wavenumber: float

Return the radar wave number.

class inscar.config.Particle(gordeyev_upper_lim=0.00015, gordeyev_size=80001, gordeyev_exp=3, velocity_upper_lim=6000000.0, velocity_size=40001, velocity_exp=3, temperature=5000, collision_frequency=0, mass=9.1093837015e-31, number_density=200000000000.0, kappa=20)

Bases: object

Object used to configure the physical parameters of a particle.

See also

Parameters

Parameters:
  • gordeyev_upper_lim (float | int)

  • gordeyev_size (int)

  • gordeyev_exp (int)

  • velocity_upper_lim (float | int)

  • velocity_size (int)

  • velocity_exp (int)

  • temperature (float)

  • collision_frequency (float)

  • mass (float)

  • number_density (float)

  • kappa (float)

collision_frequency: float
property gordeyev_axis: ndarray

Return the axis for the Gordeyev integral.

gordeyev_exp: int
gordeyev_size: int
gordeyev_upper_lim: float | int
kappa: float
mass: float
number_density: float
temperature: float
property velocity_axis: ndarray

Return the axis for the velocity integral.

velocity_exp: int
velocity_size: int
velocity_upper_lim: float | int
inscar.config.is_nonnegative(_, attribute, value)

Verify that a value is non-negative.

inscar.config.is_odd(_, attribute, value)

Verify that a value is odd.

inscar.config.is_positive(_, attribute, value)

Verify that a value is positive.

inscar.config.is_range_tuple(_, attribute, value)

Verify that a value is a tuple of two numbers.

inscar.config.to_radians(value)

Convert degrees to radians.

Return type:

float

inscar.integrand_functions module

Script containing the integrands used in the Gordeyev integral.

class inscar.integrand_functions.IntKappa

Bases: Integrand

Implementation of the integrand of the Gordeyev integral.

Notes

This implementation is for the kappa distribution described by Mace [1].

References

initialize(params, particle)

Initialize the integration.

Parameters:
Return type:

None

integrand()

Return the integrand that goes into the Gordeyev integral.

Return type:

ndarray

property the_type: str

Return the type of the VDF that is being used.

class inscar.integrand_functions.IntLong

Bases: Integrand

Implementation of the integrand of the Gordeyev integral.

Notes

This implementation is for the integral for the isotropic distribution from Mace [4].

References

initialize(params, particle)

Initialize the integration.

Parameters:
Return type:

None

integrand()

Return the integrand that goes into the Gordeyev integral.

Return type:

ndarray

set_vdf(vdf)

Assign a new VDF that is used in the integration.

Return type:

None

property the_type: str

Return the type of the VDF that is being used.

class inscar.integrand_functions.IntMaxwell

Bases: Integrand

Implementation of the integrand of the Gordeyev integral.

Notes

This implementation is for the integral for the Maxwellian distribution from e.g. Hagfors [2] or Mace [3].

References

initialize(params, particle)

Initialize the integration.

Parameters:
Return type:

None

integrand()

Return the integrand that goes into the Gordeyev integral.

Return type:

ndarray

property the_type: str

Return the type of the VDF that is being used.

class inscar.integrand_functions.Integrand

Bases: ABC

Base class for an integrand object.

Parameters:

ABC (ABC) – Abstract base class

abstract initialize(params, particle)

Initialise the kappa integrand object.

Parameters:
Return type:

None

abstract integrand()

Return the np.ndarray that is used as the integrand.

Return type:

ndarray

abstract property the_type: str

Return the type of the integrand implementation.

inscar.numba_integration module

Implementation of integrals using numba for parallelization.

inscar.numba_integration.inner_int(w, x, function)

Calculate the Gordeyev integral of the F function.

Parameters:
  • w (np.ndarray) – Angular frequency array.

  • x (np.ndarray) – The axis of the \(F\) function.

  • function (np.ndarray) – Function to integrate over.

Returns:

The integrated function.

Return type:

np.ndarray

inscar.numba_integration.integrate(params, particle, integrand, the_type, char_vel=None)

Calculate the Gordeyev integral for each frequency.

This locates the Gordeyev axis of the particle object, and for each frequency calculates the Gordeyev integral corresponding to it, returning an array of the same length as the frequency array.

Parameters:
  • params (Parameters) – Parameters object with simulation parameters.

  • particle (Particle) – Particle object with particle parameters.

  • integrand (np.ndarray) – Function to integrate over.

  • the_type (str) – Defines which type of Integrand class that is used.

  • char_vel (float, optional) – Characteristic velocity of the particle.

Returns:

The integral evaluated along the whole Gordeyev frequency axis of the particle.

Return type:

np.ndarray

Notes

The \(F\) function here refers to the equation found in Hagfors [6]:

\[\begin{split}\begin{aligned} F_{\mathrm{e}}(\boldsymbol{k}, \omega) =1-\left(i\frac{X(\omega)}{X_{\mathrm{e}}}+\Lambda_{\mathrm{e}}\right)\int_0^{\infty}\exp\left \{-iy\frac{X(\omega)}{X_{\mathrm{e}}}-y\Lambda_{\mathrm{e}}\right.\\ \left.-\frac{1}{2X_{\mathrm{e}}^2}\left[\sin^2\theta(1-\cos y)+\frac{1}{2}y^2\cos^2\theta\right]\right \}\textnormal{d}y \end{aligned}\end{split}\]

References

inscar.numba_integration.integrate_velocity(y, v, f, k_r, theta, w_c)

Calculate the velocity integral.

Parameters:
  • y (np.ndarray) – The axis in frequency space.

  • v (np.ndarray) – The axis in velocity space.

  • f (np.ndarray) – The function to integrate.

  • k_r (float) – The radar wavenumber.

  • theta (float) – The radar aspect angle.

  • w_c (float) – The gyro frequency.

Returns:

The integrated function.

Return type:

np.ndarray

inscar.numba_integration.p(y, k_r, theta, w_c)

Calculate the \(p\) function.

Parameters:
  • y (np.ndarray) – Parameter from Gordeyev integral

  • k_r (float) – The radar wave number.

  • theta (float) – The radar aspect angle.

  • w_c (float) – The gyro frequency.

Returns:

Value of the \(p\) function

Return type:

np.ndarray

Notes

Implementation of the \(p\) function from Mace [7].

References

inscar.numba_integration.trapz(y, x)

Pure python version of trapezoid rule.

Parameters:
  • y (np.ndarray) – Function to integrate over.

  • x (np.ndarray) – The axis to integrate along.

Returns:

The value of the integral.

Return type:

float

inscar.spectrum_calculation module

Calculate the power density spectrum and other plasma parameters.

class inscar.spectrum_calculation.SpectrumCalculation

Bases: object

Class containing the calculation of the power density spectrum.

calculate_spectrum()

Calculate a spectrum based on the given parameters and calculation methods.

Returns:

The frequency axis in the first position and the spectrum values along the axis in the second position.

Return type:

Tuple[np.ndarray, np.ndarray]

Raises:

ValueError – If any of the needed attribute objects are not set.

set_calculate_f_function(f_func)

Set what function to use to calculate the \(F\) function.

Parameters:

f_func (Callable[[Particle, Integrand], np.ndarray]) – A function that take a particle and an integrand function as input, and that calculates the \(F\) function based on these, returning a numpy array. By default, the integrate function from the numba_integration module is used.

Return type:

None

set_electron(electron)

Set the electron particles to use.

Parameters:

electron (Particle) – An instance of the Particle class, representing electrons.

Return type:

None

set_electron_integration_function(function)

Set the electron integration method to use.

Parameters:

function (Integrand) – An object of type Integrand, representing the electrons.

Return type:

None

set_ion(ion)

Set the ion particles to use.

Parameters:

ion (Particle) – An instance of the Particle class, representing ions.

Return type:

None

set_ion_integration_function(function)

Set the ion integration method to use.

Parameters:

function (Integrand) – An object of type Integrand, representing the ions.

Return type:

None

set_params(params)

Set the plasma parameters.

Parameters:

params (Parameters) – An instance of the Parameters class.

Return type:

None

set_susceptibility_function(func)

Set what function to use to calculate the susceptibility function.

Parameters:

func (Callable[[Particle, Integrand], float]) – A function that take a particle and an integrand function as input, and that calculates the susceptibility function based on these, returning a single float.

Return type:

None

inscar.spectrum_calculation.get_debye_length(number_density, electron_temperature, ion_temperature=None, kappa=None, char_vel=None)

Calculate the Debye length.

Parameters:
  • number_density (float) – The number density of the plasma.

  • electron_temperature (float) – The electron temperature.

  • ion_temperature (float, optional) – The ion temperature.

  • kappa (float, optional) – Kappa parameter.

  • char_vel (float, optional) – Characteristic velocity.

Returns:

float – Debye length.

Return type:

float

inscar.vdfs module

Velocity distribution function to be used by the integrand class a_vdf.

One of the integrands available for use in the Gordeyev integral.

class inscar.vdfs.Vdf

Bases: ABC

Base class for a VDF object.

Parameters:

ABC – Abstract base class that all Vdf objects inherit from

abstract f_0()

Return the values along the velocity axis of a VDF.

Returns:

1D array with the VDF values at the sampled points

Return type:

np.ndarray

abstract normalize()

Calculate the normalization for the VDF.

Return type:

None

class inscar.vdfs.VdfKappa(params, particle)

Bases: Vdf

Create an object that make kappa distribution functions.

Notes

Kappa VDF used in Gordeyev paper by Mace [5].

References

Parameters:
f_0()

Return the values along the velocity axis of a VDF.

Return type:

ndarray

normalize()

Normalize the distribution function.

Return type:

None

class inscar.vdfs.VdfMaxwell(params, particle)

Bases: Vdf

Create an object that make Maxwellian distribution functions.

Parameters:
  • VDF (ABC) – Abstract base class to make VDF objects

  • params (Parameters)

  • particle (Particle)

f_0()

Return the values along the velocity axis of a VDF.

Return type:

ndarray

normalize()

Normalize the distribution function.

Return type:

None

inscar.experimental package