SERiF 0.0.1a
3+1D Stellar Structure and Evolution
Loading...
Searching...
No Matches
EOS.h
Go to the documentation of this file.
1#pragma once
2
3#include "EOSio.h"
4#include "helm.h"
5#include <string>
6#include "composition.h"
7#include <iomanip>
8
9namespace serif::eos {
10
17 struct EOSInput {
19 double density;
20 double temperature;
21 friend std::ostream& operator<<(std::ostream& os, const EOSInput& input) {
22 os << "<EOSInput: "
23 << "Density: " << input.density << " g/cm^3, "
24 << "Temperature: " << input.temperature << " K, "
25 << "Composition: " << input.composition << ">";
26 return os;
27 }
28 };
29
38 struct EOSParameter {
39 explicit EOSParameter(std::string name_)
40 : total(), gas(), radiation(),
44 name(std::move(name_)) {}
45 double total;
46 double gas;
47 double radiation;
48
49 double dDensity;
50 double dTemperature;
53
54 std::string name;
55
56 friend std::ostream& operator<<(std::ostream& os, const EOSParameter& param) {
57 os << std::setprecision(5) << "<EOSParameter (" << param.name << "): " << param.total << " (gas: " << param.gas
58 << ", radiation: " << param.radiation << ") "
59 << "d/dRho: " << param.dDensity << ", d/dT: " << param.dTemperature
60 << ", d/dAbar: " << param.dMeanAtomicMassNumber
61 << ", d/dZbar: " << param.dMeanAtomicNumber << ">";
62 return os;
63 }
64
65
66 };
67
78 struct EOSOutput {
82
83 EOSParameter pressure {"pressure"};
84 EOSParameter energy {"energy"};
85 EOSParameter entropy {"entropy"};
86
100 double chiRho();
107 double soundSpeed();
121 double gamma1();
128 double gamma2();
135 double gamma3();
150
151 friend std::ostream& operator<<(std::ostream& os, const EOSOutput& output) {
152 os << "EOSOutput:\n"
153 << "\tElectron Fraction: " << output.electronFraction << "\n"
154 << "\tElectron Chemical Potential: " << output.electronChemicalPotential << "\n"
155 << "\tNeutron Excess Fraction: " << output.neutronExcessFraction << "\n\t"
156 << output.pressure << "\n\t"
157 << output.energy << "\n\t"
158 << output.entropy;
159 return os;
160 }
161 };
162
216 class EOS {
217 public:
224 explicit EOS(const std::string& filename, EOSFormat format=EOSFormat::HELM);
229 explicit EOS(const EOSio& reader);
233 ~EOS() = default;
234
246 [[nodiscard]] EOSOutput get(const EOSInput& in);
251 [[nodiscard]] EOSFormat getFormat() const;
256 [[nodiscard]] const EOSio& getReader() const;
257 private:
259 };
260}
Manages the composition of elements.
EOSOutput get(const EOSInput &in)
Retrieves thermodynamic properties for the given input conditions.
Definition EOS.cpp:10
EOSio m_reader
The EOS I/O handler responsible for reading and storing EOS table data.
Definition EOS.h:258
EOSFormat getFormat() const
Gets the format of the loaded EOS data.
Definition EOS.cpp:57
~EOS()=default
Default destructor.
const EOSio & getReader() const
Gets a constant reference to the internal EOSio reader.
Definition EOS.cpp:61
EOS(const std::string &filename, EOSFormat format=EOSFormat::HELM)
Constructs an EOS object by loading data from a file.
Definition EOS.cpp:8
Handles the input/output operations for EOS tables.
Definition EOSio.h:57
@ HELM
Helmholtz EOS format.
Definition EOSio.h:30
Input parameters for an EOS calculation.
Definition EOS.h:17
serif::composition::Composition composition
The composition of the system.
Definition EOS.h:18
friend std::ostream & operator<<(std::ostream &os, const EOSInput &input)
Definition EOS.h:21
double density
The density of the system in cgs (g/cm^3).
Definition EOS.h:19
double temperature
The temperature of the system in cgs (K).
Definition EOS.h:20
Output from an EOS calculation.
Definition EOS.h:78
double electronChemicalPotential
Electron chemical potential (eta_e) in cgs (erg/g).
Definition EOS.h:80
EOSParameter entropy
Entropy output data, including total, gas, radiation, and derivatives.
Definition EOS.h:85
double neutronExcessFraction
Neutron excess fraction (xnefer), dimensionless.
Definition EOS.h:81
double chiTemperature()
Calculates the temperature susceptibility (chi_T).
double gamma3()
Calculates the third adiabatic index (Gamma3).
double gamma2()
Calculates the second adiabatic index (Gamma2).
double chiRho()
Calculates the density susceptibility (chi_rho).
double electronFraction
Electron fraction (ye), dimensionless.
Definition EOS.h:79
double soundSpeed()
Calculates the adiabatic sound speed.
EOSParameter pressure
Pressure output data, including total, gas, radiation, and derivatives.
Definition EOS.h:83
double specificHeatCapacityAtConstantPressure()
Calculates the specific heat capacity at constant pressure (c_p).
EOSParameter energy
Internal energy output data, including total, gas, radiation, and derivatives.
Definition EOS.h:84
double specificHeatCapacityAtConstantVolume()
Calculates the specific heat capacity at constant volume (c_v).
friend std::ostream & operator<<(std::ostream &os, const EOSOutput &output)
Definition EOS.h:151
double gamma1()
Calculates the first adiabatic index (Gamma1).
double adiabaticGradient()
Calculates the adiabatic temperature gradient (nabla_ad).
Represents a thermodynamic parameter and its derivatives.
Definition EOS.h:38
double dMeanAtomicNumber
Derivative of the total parameter with respect to mean atomic number (Zbar) (cgs units / dimensionles...
Definition EOS.h:52
double total
Total value of the parameter (gas + radiation) (cgs).
Definition EOS.h:45
double radiation
Radiation contribution to the parameter (cgs).
Definition EOS.h:47
std::string name
Name of the parameter (e.g., "Pressure", "Energy", "Entropy").
Definition EOS.h:54
double dDensity
Derivative of the total parameter with respect to density (cgs units / (g/cm^3)).
Definition EOS.h:49
friend std::ostream & operator<<(std::ostream &os, const EOSParameter &param)
Definition EOS.h:56
double dTemperature
Derivative of the total parameter with respect to temperature (cgs units / K).
Definition EOS.h:50
EOSParameter(std::string name_)
Definition EOS.h:39
double gas
Gas contribution to the parameter (cgs).
Definition EOS.h:46
double dMeanAtomicMassNumber
Derivative of the total parameter with respect to mean atomic mass number (Abar) (cgs units / (g/mol)...
Definition EOS.h:51