fix(eos): fixed calculation of mean atomic number

This commit is contained in:
2025-06-17 08:12:41 -04:00
parent 9100af3fc5
commit 3961c745e3
4 changed files with 134 additions and 36 deletions

View File

@@ -17,6 +17,8 @@ namespace serif::eos {
q.abar = in.composition.getMeanParticleMass(); // Mean atomic mass in g
q.zbar = in.composition.getMeanAtomicNumber(); // Mean atomic number (dimensionless)
std::cout << "(EOS) abar: " << q.abar << ", zbar: " << q.zbar << std::endl;
helmholtz::HELMEOSOutput tempOutput;
tempOutput = helmholtz::get_helm_EOS(q, *std::get<std::unique_ptr<helmholtz::HELMTable>>(m_reader.getTable()));

View File

@@ -4,6 +4,7 @@
#include "helm.h"
#include <string>
#include "composition.h"
#include <iomanip>
namespace serif::eos {
@@ -17,6 +18,13 @@ namespace serif::eos {
serif::composition::Composition composition; ///< The composition of the system.
double density; ///< The density of the system in cgs (g/cm^3).
double temperature; ///< The temperature of the system in cgs (K).
friend std::ostream& operator<<(std::ostream& os, const EOSInput& input) {
os << "<EOSInput: "
<< "Density: " << input.density << " g/cm^3, "
<< "Temperature: " << input.temperature << " K, "
<< "Composition: " << input.composition << ">";
return os;
}
};
/**
@@ -28,6 +36,12 @@ namespace serif::eos {
* All values are in cgs units unless otherwise specified.
*/
struct EOSParameter {
explicit EOSParameter(std::string name_)
: total(), gas(), radiation(),
dDensity(), dTemperature(),
dMeanAtomicMassNumber(),
dMeanAtomicNumber(),
name(std::move(name_)) {}
double total; ///< Total value of the parameter (gas + radiation) (cgs).
double gas; ///< Gas contribution to the parameter (cgs).
double radiation; ///< Radiation contribution to the parameter (cgs).
@@ -38,6 +52,17 @@ namespace serif::eos {
double dMeanAtomicNumber; ///< Derivative of the total parameter with respect to mean atomic number (Zbar) (cgs units / dimensionless).
std::string name; ///< Name of the parameter (e.g., "Pressure", "Energy", "Entropy").
friend std::ostream& operator<<(std::ostream& os, const EOSParameter& param) {
os << std::setprecision(3) << "<EOSParameter (" << param.name << "): " << param.total << " (gas: " << param.gas
<< ", radiation: " << param.radiation << ") "
<< "d/dRho: " << param.dDensity << ", d/dT: " << param.dTemperature
<< ", d/dAbar: " << param.dMeanAtomicMassNumber
<< ", d/dZbar: " << param.dMeanAtomicNumber << ">";
return os;
}
};
/**
@@ -55,9 +80,9 @@ namespace serif::eos {
double electronChemicalPotential{}; ///< Electron chemical potential (eta_e) in cgs (erg/g).
double neutronExcessFraction{}; ///< Neutron excess fraction (xnefer), dimensionless.
EOSParameter pressure; ///< Pressure output data, including total, gas, radiation, and derivatives.
EOSParameter energy; ///< Internal energy output data, including total, gas, radiation, and derivatives.
EOSParameter entropy; ///< Entropy output data, including total, gas, radiation, and derivatives.
EOSParameter pressure {"pressure"}; ///< Pressure output data, including total, gas, radiation, and derivatives.
EOSParameter energy {"energy"}; ///< Internal energy output data, including total, gas, radiation, and derivatives.
EOSParameter entropy {"entropy"}; ///< Entropy output data, including total, gas, radiation, and derivatives.
/**
* @brief Calculates the temperature susceptibility (chi_T).
@@ -128,6 +153,17 @@ namespace serif::eos {
* @return The EOSFormat enum value (currently only EOSFormat::HELM).
*/
EOSFormat EOSFormat() const;
friend std::ostream& operator<<(std::ostream& os, const EOSOutput& output) {
os << "EOSOutput:\n"
<< "\tElectron Fraction: " << output.electronFraction << "\n"
<< "\tElectron Chemical Potential: " << output.electronChemicalPotential << "\n"
<< "\tNeutron Excess Fraction: " << output.neutronExcessFraction << "\n\t"
<< output.pressure << "\n\t"
<< output.energy << "\n\t"
<< output.entropy;
return os;
}
};
/**