Equation of state for nuclei in statistical equilibrium. More...
#include <eos_nse.h>
This class computes the composition of matter in nuclear statistical equilibrium. The chemical potential of a nucleus X with proton number and neutron number
is given by
where and
are the neutron and proton chemical potentials and
is the binding energy of the nucleus. The chemical potentials are assumed to be in units of
.
The baryon number density and electron fraction are then given by
where is the number density which is determined from the chemical potential above.
The nuclei in specified in the parameter named nd
, must have their proton number, neutron number, mass number, binding energy, and spin degeracy already specified. This class implicitly assumes that the nuclei are non-interacting and that the values of part::inc_rest_mass
are false. The chemical potential arguments also do not include the rest mass. The nuclear rest mass is presumed to be .
The function calc_density() attempts to solve for the neutron and proton chemical potentials given the neutron and proton densities. However, this is relatively difficult. At low enough temperatures, is a staircase-like function with alernating regions which are very flat and or nearly vertical. For this reason, derivative-based methods often fail without extremely good guesses. The current method of solution combines make_guess(), density_min() and direct_solve() in order to obtain the solution.
Note also that calc_density() will fail if there are no nuclei in the distribution which equal, or surround the requested value of determined from
nn
and np
.
Public Types | |
typedef boost::numeric::ublas::vector< double > | ubvector |
Protected Member Functions | |
int | solve_fun (size_t nv, const ubvector &x, ubvector &y, double nn, double np, double T, std::vector< o2scl::nucleus > &nd) |
Function to solve to match neutron and proton densities. | |
double | minimize_fun (size_t nv, const ubvector &x, double T, double nn, double np, o2scl::thermo &th, std::vector< o2scl::nucleus > &nd) |
Function to minimize to match neutron and proton densities. | |
Protected Attributes | |
mroot * | mroot_ptr |
Solver. | |
mmin_base * | mmin_ptr |
Minimizer. | |
classical | cla |
Compute particle properties assuming classical thermodynamics. | |
Basic usage | |
int | verbose |
Verbosity parameter (default 1) | |
bool | err_nonconv |
If true, call the error handler if calc_density() does not converge (default true) | |
void | calc_mu (double mun, double mup, double T, double &nn, double &np, thermo &th, std::vector< nucleus > &nd) |
Calculate the equation of state as a function of the chemical potentials. More... | |
int | calc_density (double nn, double np, double T, double &mun, double &mup, thermo &th, std::vector< nucleus > &nd) |
Calculate the equation of state as a function of the densities. More... | |
Tools for fixing chemical potentials from the densities | |
size_t | make_guess_iters |
The maximum number of iterations for make_guess() (default 60) | |
double | make_guess_init_step |
The initial stepsize for the chemical potentials relative to the temperature (default ![]() | |
int | make_guess (double &mun, double &mup, double T, thermo &th, std::vector< nucleus > &nd, double nn_min=1.0e-20, double nn_max=1.0e8, double np_min=1.0e-20, double np_max=1.0e8, bool err_on_fail=true) |
Find values for the chemical potentials which ensure that the densities are within a fixed range. More... | |
int | direct_solve (double nn, double np, double T, double &mun, double &mup, thermo &th, std::vector< nucleus > &nd) |
Obtain chemical potentials from densities directly using a solver. More... | |
int | density_min (double nn, double np, double T, double &mun, double &mup, thermo &th, std::vector< nucleus > &nd) |
Obtain chemical potentials from densities using a minimizer. More... | |
Numerical methods | |
mroot_hybrids | def_mroot |
Default solver. | |
mmin_simp2 | def_mmin |
Default minimizer. | |
void | set_mroot (mroot<> &rp) |
Set the solver for use in direct_solve() | |
void | set_mmin (mmin_base<> &mp) |
Set the minimizer for use in density_min() | |
int o2scl::eos_nse::calc_density | ( | double | nn, |
double | np, | ||
double | T, | ||
double & | mun, | ||
double & | mup, | ||
thermo & | th, | ||
std::vector< nucleus > & | nd | ||
) |
Given the neutron number density nn
in , the proton number density
np
and the temperature T
in , this computes the composition (the individual densities are stored in the distribution
nd
) and the chemical potentials are given in mun
and mup
. The nuclei in nd
must have their proton number, neutron number, atomic number, binding energy, and spin degeracy already specified.
This function uses make_guess(), direct_solve(), and density_min(), to self-consistently compute the chemical potentials.
void o2scl::eos_nse::calc_mu | ( | double | mun, |
double | mup, | ||
double | T, | ||
double & | nn, | ||
double & | np, | ||
thermo & | th, | ||
std::vector< nucleus > & | nd | ||
) |
Given mun
, mup
and T
, this computes the composition (the individual densities are stored in the distribution nd
), the neutron number density nn
, and the proton number density np
. Note that the densities can be infinite if the chemical potentials are sufficiently large.
This function does not use the solver or the minimizer.
int o2scl::eos_nse::density_min | ( | double | nn, |
double | np, | ||
double | T, | ||
double & | mun, | ||
double & | mup, | ||
thermo & | th, | ||
std::vector< nucleus > & | nd | ||
) |
This function often requires extremely good guesses for the chemical potentials, especially at low temperatures. By default, this calls the minimizer five times, as this seems to improve convergence using the default minimizer. By default, the value of o2scl::mmin_base::err_nonconv is set to false for def_mmin .
int o2scl::eos_nse::direct_solve | ( | double | nn, |
double | np, | ||
double | T, | ||
double & | mun, | ||
double & | mup, | ||
thermo & | th, | ||
std::vector< nucleus > & | nd | ||
) |
This function often requires extremely good guesses for the chemical potentials, especially at low temperatures.
int o2scl::eos_nse::make_guess | ( | double & | mun, |
double & | mup, | ||
double | T, | ||
thermo & | th, | ||
std::vector< nucleus > & | nd, | ||
double | nn_min = 1.0e-20 , |
||
double | nn_max = 1.0e8 , |
||
double | np_min = 1.0e-20 , |
||
double | np_max = 1.0e8 , |
||
bool | err_on_fail = true |
||
) |
This function improves initial guesses for the chemical potentials in order to ensure the densities are within a specified range. It can sometimes even succeed when the chemical potentials are so far off as to make the densities infinite or zero. This function is used by calc_density() to improve the initial guesses for the chemical potentials if necessary.
The algorithm can fail in several different ways. This is particularly likely if the density range specified by nn_min
, nn_max
, np_min
, and np_max
is small. This function ignores the value of err_nonconv, and throws an exception on failure only if err_on_fail
is true (which is the default).
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).