Equation of State Sub-Library: Version 0.910
nse_eos.h
00001 /*
00002   -------------------------------------------------------------------
00003   
00004   Copyright (C) 2006-2012, Andrew W. Steiner
00005   
00006   This file is part of O2scl.
00007   
00008   O2scl is free software; you can redistribute it and/or modify
00009   it under the terms of the GNU General Public License as published by
00010   the Free Software Foundation; either version 3 of the License, or
00011   (at your option) any later version.
00012   
00013   O2scl is distributed in the hope that it will be useful,
00014   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016   GNU General Public License for more details.
00017   
00018   You should have received a copy of the GNU General Public License
00019   along with O2scl. If not, see <http://www.gnu.org/licenses/>.
00020 
00021   -------------------------------------------------------------------
00022 */
00023 #ifndef O2SCL_NSE_EOS_H
00024 #define O2SCL_NSE_EOS_H 
00025 
00026 #include <o2scl/classical.h>
00027 #include <o2scl/constants.h>
00028 #include <o2scl/nuclear_dist.h>
00029 #include <o2scl/mm_funct.h>
00030 #include <o2scl/gsl_mroot_hybrids.h>
00031 
00032 #ifndef DOXYGENP
00033 namespace o2scl {
00034 #endif
00035 
00036   /** \brief Equation of state for nuclei in statistical equilibrium
00037 
00038       This class computes the composition of matter in nuclear statistical
00039       equilibrium. The chemical potential of a nucleus X with proton number
00040       \f$ Z_X \f$ and neutron number \f$ N_X \f$ is given by
00041       \f[
00042       \mu_X = N \mu_n + Z \mu_p - E_{\mathrm{bind},X}
00043       \f]
00044       where \f$ \mu_n \f$ and \f$ \mu_p \f$ are the neutron and proton
00045       chemical potentials and \f$ E_{\mathrm{bind},X} \f$ is the binding
00046       energy of the nucleus. 
00047 
00048       The baryon number density and electron fraction are then given 
00049       by
00050       \f[
00051       n_B = n_{X} (N_X + Z_X) \qquad Y_e n_B = n_X Z_X
00052       \f]
00053       where \f$ n_X \f$ is the number density which is determined from
00054       the chemical potential above. 
00055  
00056       This implicitly assumes that the nuclei are non-interacting.
00057 
00058       \future Right now calc_density() needs a very good guess. This 
00059       could be fixed, probably by solving for the log(mu/T) instead 
00060       of mu. 
00061   */
00062   class nse_eos {
00063 
00064 #ifndef DOXYGENP
00065 
00066   protected:
00067     
00068     /// Parameter structure
00069     typedef struct {
00070       double nb, Ye, T;
00071       nuclear_dist *ndp;
00072     } solve_parms;
00073     
00074     /// Function to solve for baryon and charge conservation
00075     int solve_fun(size_t nv, const ovector_base &x, ovector_base &y, 
00076                   solve_parms &pa);
00077     
00078     /// Solver
00079     mroot<mm_funct<> > *root;
00080 
00081     /// Desc
00082     classical cla;
00083 
00084 #endif
00085 
00086   public:
00087 
00088     nse_eos();
00089 
00090     /** \brief Calculate the equation of state as a function of the
00091         chemical potentials
00092 
00093         Given \c mun, \c mup and \c T, this computes the composition
00094         (the individual densities are stored in the distribution \c
00095         nd) the baryon number density \c nb, and the electron fraction
00096         \c Ye. 
00097 
00098         This function does not use the solver.
00099     */
00100     int calc_mu(double mun, double mup, double T,
00101                 double &nb, double &Ye, thermo &th, nuclear_dist &nd);
00102     
00103     /** \brief Calculate the equation of state as a function of the densities
00104 
00105         Given the baryon number density \c nb, and the electron
00106         fraction \c Ye and the temperature \c T, this computes the
00107         composition (the individual densities are stored in the
00108         distribution \c nd) and the chemical potentials are given in
00109         \c mun and \c mup .
00110 
00111         This function uses the solver to self-consistently compute
00112         the chemical potentials. 
00113      */
00114     int calc_density(double nb, double Ye, double T, 
00115                      double &mun, double &mup, thermo &th, nuclear_dist &nd);
00116     
00117     /// Default solver 
00118     gsl_mroot_hybrids<mm_funct<> > def_root;
00119 
00120     /** \brief Set the solver for use in computing the chemical potentials
00121      */
00122     int set_mroot(mroot<mm_funct<> > &rp) {
00123       root=&rp;
00124       return 0;
00125     }
00126 
00127   };
00128 
00129 #ifndef DOXYGENP
00130 }
00131 #endif
00132 
00133 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Friends

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).

Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads.