SERiF 0.0.1a
3+1D Stellar Structure and Evolution
Loading...
Searching...
No Matches
EOS.cpp
Go to the documentation of this file.
1#include "EOS.h"
2#include "EOSio.h"
3#include "helm.h"
4#include <string>
5
6namespace serif::eos {
7 EOS::EOS(const EOSio& reader) : m_reader(reader) {}
8 EOS::EOS(const std::string& filename, const EOSFormat format) : m_reader(EOSio(filename, format)) {}
9
11 EOSOutput output;
12 if (getFormat() == EOSFormat::HELM) {
14 q.T = in.temperature; // Temperature in K
15 q.rho = in.density; // Density in g/cm^3
16
17 q.abar = in.composition.getMeanParticleMass(); // Mean atomic mass in g
18 q.zbar = in.composition.getMeanAtomicNumber(); // Mean atomic number (dimensionless)
19
20 helmholtz::HELMEOSOutput tempOutput;
21 tempOutput = helmholtz::get_helm_EOS(q, *std::get<std::unique_ptr<helmholtz::HELMTable>>(m_reader.getTable()));
22
23 output.electronFraction = tempOutput.ye;
24 output.electronChemicalPotential = tempOutput.etaele;
25 output.neutronExcessFraction = tempOutput.xnefer;
26
27 // --- Pressure Variables ---
28 output.pressure.total = tempOutput.ptot;
29 output.pressure.gas = tempOutput.pgas;
30 output.pressure.radiation = tempOutput.ptot;
31 output.pressure.dDensity = tempOutput.dpresdd;
32 output.pressure.dTemperature = tempOutput.dpresdt;
33 output.pressure.dMeanAtomicMassNumber = tempOutput.dpresda;
34 output.pressure.dMeanAtomicNumber = tempOutput.dpresdz;
35
36 // --- Energy Variables ---
37 output.energy.total = tempOutput.etot;
38 output.energy.gas = tempOutput.egas;
39 output.energy.radiation = tempOutput.erad;
40 output.energy.dDensity = tempOutput.denerdd;
41 output.energy.dTemperature = tempOutput.denerdt;
42 output.energy.dMeanAtomicMassNumber = tempOutput.denerda;
43 output.energy.dMeanAtomicNumber = tempOutput.denerdz;
44
45 // --- Entropy Variables ---
46 output.entropy.total = tempOutput.stot;
47 output.entropy.gas = tempOutput.sgas;
48 output.entropy.radiation = tempOutput.srad;
49 output.entropy.dDensity = tempOutput.dentrdd;
50 output.entropy.dTemperature = tempOutput.dentrdt;
51 output.entropy.dMeanAtomicMassNumber = tempOutput.dentrda;
52 output.entropy.dMeanAtomicNumber = tempOutput.dentrdz;
53 }
54 return output;
55 }
56
58 return m_reader.getFormat();
59 }
60
61 const EOSio& EOS::getReader() const {
62 return m_reader;
63 }
64}
double getMeanAtomicNumber() const
Compute the mean atomic mass number of the composition.
double getMeanParticleMass() const
Compute the mean particle mass of the composition.
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
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
serif::eos::helmholtz::HELMEOSOutput get_helm_EOS(serif::eos::helmholtz::HELMEOSInput &q, const serif::eos::helmholtz::HELMTable &table)
Calculate the Helmholtz EOS components.
Definition helm.cpp:243
@ 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
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 electronFraction
Electron fraction (ye), dimensionless.
Definition EOS.h:79
EOSParameter pressure
Pressure output data, including total, gas, radiation, and derivatives.
Definition EOS.h:83
EOSParameter energy
Internal energy output data, including total, gas, radiation, and derivatives.
Definition EOS.h:84
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
double dDensity
Derivative of the total parameter with respect to density (cgs units / (g/cm^3)).
Definition EOS.h:49
double dTemperature
Derivative of the total parameter with respect to temperature (cgs units / K).
Definition EOS.h:50
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
Structure to hold the input parameters for the EOS calculation.
Definition helm.h:176
double abar
Mean atomic mass.
Definition helm.h:179
double zbar
Mean atomic number.
Definition helm.h:180