wnstatmech package

A package of python routines to handle thermodynamics of fermions and bosons.

wnstatmech.base module

This is the base module for the package.

class wnstatmech.base.Particle(name, rest_mass_mev, multiplicity, charge)[source]

Bases: object

A class for base particles.

Args:

name (str): The name of the particle.

rest_mass_mev (float): The rest mass energy of the particle (in MeV).

multiplicity (int): The multiplicity of the internal degrees of freedom of the particle (typically 2 times the spin plus one).

charge (int): The charge of the particle.

get_gamma(temperature)[source]

A method to return the rest mass energy of the particle divided by kT.

Args:

temperature (float): The temperature in K at which to compute the quanitity.

Returns:

A (float) with the rest mass energy of the particle in cgs units.

get_properties()[source]

A method to return the particle properties.

Returns:

A (dict) the particles basic properties.

get_rest_mass_cgs()[source]

A method to return the rest mass energy of the particle in cgs units.

Returns:

A (float) with the rest mass energy of the particle in cgs units.

update_function(quantity, func)[source]

A method to update the functions for the particle.

Args:

quantity (str): The name of the quantity.

func: A user-defined function to return the value of the quantity for some or all sets of conditions. The function must take two arguments. The second is T, the temperature in Kelvin, and the second is the alpha, the chemical potential (less the rest mass) divided by kT. Other data can be bound to the integrand function. The function must return the value of the quantity for the input conditions, or None, if the conditions are not appropriate.

update_integrand(quantity, integrand_fn)[source]

A method to update an integrand for the particle.

Args:

quantity (str): The name of the quantity.

integrand_fn (float): The integrand corresponding to the quantity. The integrand function must take three arguments. The first is the scaled energy x, the second is T, the temperature in Kelvin, and the third is the alpha, the chemical potential (less the rest mass) divided by kT. Other data can be bound to the integrand function.

wnstatmech.boson module

This is the module that handles bosons.

class wnstatmech.boson.Boson(name, rest_mass_mev, multiplicity, charge)[source]

Bases: Particle

A class for boson.

Args:

name (str): The name of the boson.

rest_mass_mev (float): The rest mass energy of the boson (in MeV).

multiplicity (int): The multiplicity of the internal degrees of freedom of the boson (typically 2 times the spin plus one).

charge (int): The charge of the boson.

compute_chemical_potential(temperature, number_density)[source]

Routine to compute the chemical potential (less the rest mass) divided by kT.

Args:

temperature (float): The temperature (in K) at which to compute the chemical potential.

number_density (float): The number density (in per cc) at which to compute the chemical potential.

Returns:

A float giving the chemical potential (less the rest mass) divided by kT.

compute_quantity(quantity, temperature, alpha)[source]

Routine to compute a thermodynamic quantity for the boson.

Args:

quantity (str): The name of the quantity to compute.

temperature (float): The temperature (in K) at which to compute the quantity.

alpha (float): The chemical potential (less the rest mass) divided by kT at which to compute the quantity.

Returns:

A float giving the quantity in cgs units.

compute_temperature_derivative(quantity, temperature, number_density)[source]

Routine to compute the temperature derivative of a thermodynamic quantity for the boson at fixed number density.

Args:

quantity (str): The name of the quantity to compute.

temperature (float): The temperature (in K) at which to compute the derivative.

number_density (float): The fixed number density at which to compute the derivative.

Returns:

A float giving the temperature derivative of the quantity in cgs units.

default_energy_density_function(temperature, alpha)[source]

The default energy density function to treat case of zero-rest-mass boson.

Args:

temperature (float): The temperature (in K) at which to compute the function.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the boson energy density in cgs units for the given input for the case when the rest mass and chemical potential are zero. When they are not zero, the routine returns None so that other routines will compute the function by integration.

default_energy_density_integrand(x, temperature, alpha)[source]

The default energy density integrand.

Args:

x (float): The argument of the integrand.

temperature (float): The temperature (in K) at which to compute the integrand.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the energy density integrand for the boson in cgs units for the given input.

default_entropy_density_function(temperature, alpha)[source]

The default entropy density function to treat case of zero-rest-mass boson.

Args:

temperature (float): The temperature (in K) at which to compute the function.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the boson entropy density in cgs units for the given input for the case when the rest mass and chemical potential are zero. When they are not zero, the routine returns None so that other routines will compute the function by integration.

default_entropy_density_integrand(x, temperature, alpha)[source]

The default entropy density integrand.

Args:

x (float): The argument of the integrand.

temperature (float): The temperature (in K) at which to compute the integrand.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the entropy density integrand for the boson in cgs units for the given input.

default_internal_energy_density_function(temperature, alpha)[source]

The default internal energy function to treat case of zero-rest-mass boson.

Args:

temperature (float): The temperature (in K) at which to compute the function.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the boson internal energy density in cgs units for the given input for the case when the rest mass and chemical potential are zero. When they are not zero, the routine returns None so that other routines will compute the function by integration.

default_internal_energy_density_integrand(x, temperature, alpha)[source]

The default internal energy density integrand.

Args:

x (float): The argument of the integrand.

temperature (float): The temperature (in K) at which to compute the integrand.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the internal energy density integrand for the boson in cgs units for the given input.

default_number_density_function(temperature, alpha)[source]

The default number density function to treat case of zero-rest-mass boson.

Args:

temperature (float): The temperature (in K) at which to compute the function.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the boson number density in cgs units for the given input for the case when the rest mass and chemical potential are zero. When they are not zero, the routine returns None so that other routines will compute the function by integration.

default_number_density_integrand(x, temperature, alpha)[source]

The default number density integrand.

Args:

x (float): The argument of the integrand.

temperature (float): The temperature (in K) at which to compute the integrand.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the number density integrand in cgs units for the given input.

default_pressure_function(temperature, alpha)[source]

The default pressure function to treat case of zero-rest-mass boson.

Args:

temperature (float): The temperature (in K) at which to compute the function.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the boson pressure in cgs units for the given input for the case when the rest mass and chemical potential are zero. When they are not zero, the routine returns None so that other routines will compute the function by integration.

default_pressure_integrand(x, temperature, alpha)[source]

The default pressure integrand.

Args:

x (float): The argument of the integrand.

temperature (float): The temperature (in K) at which to compute the integrand.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the pressure integrand for the boson in cgs units for the given input.

wnstatmech.boson.create_photon()[source]

Convenience routine for creating a photon.

Returns:

A photon as a wnstatmech.boson.Boson object.

wnstatmech.fermion module

This is the module that handles fermions.

class wnstatmech.fermion.Fermion(name, rest_mass_mev, multiplicity, charge)[source]

Bases: Particle

A class for fermions.

Args:

name (str): The name of the fermion.

rest_mass_mev (float): The rest mass energy of the fermion (in MeV).

multiplicity (int): The multiplicity of the internal degrees of freedom of the fermion (typically 2 times the spin plus one).

charge (int): The charge of the fermion.

compute_chemical_potential(temperature, number_density)[source]

Routine to compute the chemical potential (less the rest mass) divided by kT.

Args:

temperature (float): The temperature (in K) at which to compute the chemical potential.

number_density (float): The number density (in per cc) at which to compute the chemical potential.

Returns:

A float giving the chemical potential (less the rest mass) divided by kT.

compute_quantity(quantity, temperature, alpha)[source]

Routine to compute a thermodynamic quantity for the fermion.

Args:

quantity (str): The name of the quantity to compute.

temperature (float): The temperature (in K) at which to compute the quantity.

alpha (float): The chemical potential (less the rest mass) divided by kT at which to compute the quantity.

Returns:

A float giving the quantity in cgs units. The routine will first try to compute the quantity with a function, if set. If the function is not set for the quantity, or if the conditions in the function are not met by the input, the routine will integrate the associated integrand.

compute_temperature_derivative(quantity, temperature, number_density)[source]

Routine to compute the temperature derivative of a thermodynamic quantity for the fermion at fixed number density.

Args:

quantity (str): The name of the quantity to compute.

temperature (float): The temperature (in K) at which to compute the derivative.

number_density (float): The fixed number density at which to compute the derivative.

Returns:

A float giving the temperature derivative of the quantity in cgs units.

default_energy_density_integrand(x, temperature, alpha)[source]

The default energy density integrand.

Args:

x (float): The argument of the integrand.

temperature (float): The temperature (in K) at which to compute the integrand.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the energy density integrand for the fermions (plus anti-fermions) in cgs units for the given input.

default_entropy_density_integrand(x, temperature, alpha)[source]

The default entropy density integrand.

Args:

x (float): The argument of the integrand.

temperature (float): The temperature (in K) at which to compute the integrand.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the entropy density integrand for the fermions (plus anti-fermions) in cgs units for the given input.

default_internal_energy_density_integrand(x, temperature, alpha)[source]

The default internal energy density integrand.

Args:

x (float): The argument of the integrand.

temperature (float): The temperature (in K) at which to compute the integrand.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the internal energy density integrand for the fermions (plus anti-fermions) in cgs units for the given input.

default_number_density_function(temperature, alpha)[source]

The default number density function to treat case of zero-rest-mass fermion.

Args:

temperature (float): The temperature (in K) at which to compute the function.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the net number density (fermions minus anti-fermions) in cgs units for the given input for the case when the rest mass is zero. When it is not zero, the routine returns None so that other routines will compute the number density by integration.

default_number_density_integrand(x, temperature, alpha)[source]

The default number density integrand.

Args:

x (float): The argument of the integrand.

temperature (float): The temperature (in K) at which to compute the integrand.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the net number density integrand (fermions minus anti-fermions) in cgs units for the given input.

default_pressure_integrand(x, temperature, alpha)[source]

The default pressure integrand.

Args:

x (float): The argument of the integrand.

temperature (float): The temperature (in K) at which to compute the integrand.

alpha (float): The chemical potential (less the rest mass) divided by kT.

Returns:

A float giving the pressure integrand for the fermions (plus anti-fermions) in cgs units for the given input.

wnstatmech.fermion.create_electron()[source]

Convenience routine for creating an electron.

Returns:

An electron as a wnstatmech.fermion.Fermion object.