get_species_references function to fluid_system added to show data references
This commit is contained in:
parent
14d6f5a7fb
commit
a2744b7b01
|
@ -14,9 +14,9 @@ FloatArray = NDArray[NDFloat]
|
||||||
|
|
||||||
_T = TypeVar('_T', 'fluid', 'elements')
|
_T = TypeVar('_T', 'fluid', 'elements')
|
||||||
|
|
||||||
data = pkgutil.get_data(__name__, 'data/therm_data.bin')
|
_data = pkgutil.get_data(__name__, 'data/therm_data.bin')
|
||||||
assert data is not None, 'Could not load thermodynamic data'
|
assert _data is not None, 'Could not load thermodynamic data'
|
||||||
species_db = db_reader(data)
|
_species_db = db_reader(_data)
|
||||||
|
|
||||||
kB = 1.380649e-23 # J/K
|
kB = 1.380649e-23 # J/K
|
||||||
NA = 6.02214076e23 # 1/mol
|
NA = 6.02214076e23 # 1/mol
|
||||||
|
@ -86,10 +86,10 @@ def species(pattern: str = '*', element_names: str | list[str] = [], use_regex:
|
||||||
pattern = '^' + pattern + '(,.*)?$'
|
pattern = '^' + pattern + '(,.*)?$'
|
||||||
|
|
||||||
if element_names == []:
|
if element_names == []:
|
||||||
return [sn for sn in species_db.names if re.fullmatch(pattern, sn)]
|
return [sn for sn in _species_db.names if re.fullmatch(pattern, sn)]
|
||||||
else:
|
else:
|
||||||
return [
|
return [
|
||||||
s.name for s in species_db
|
s.name for s in _species_db
|
||||||
if re.fullmatch(pattern, s.name) and
|
if re.fullmatch(pattern, s.name) and
|
||||||
(len(elements) == 0 or set(s.composition.keys()).issubset(elements))]
|
(len(elements) == 0 or set(s.composition.keys()).issubset(elements))]
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ class fluid_system:
|
||||||
element_compositions: list[dict[str, int]] = list()
|
element_compositions: list[dict[str, int]] = list()
|
||||||
|
|
||||||
for i, s in enumerate(species):
|
for i, s in enumerate(species):
|
||||||
species_data = species_db.read(s)
|
species_data = _species_db.read(s)
|
||||||
if not species_data:
|
if not species_data:
|
||||||
raise Exception(f'Species {s} not found')
|
raise Exception(f'Species {s} not found')
|
||||||
element_compositions.append(species_data.composition)
|
element_compositions.append(species_data.composition)
|
||||||
|
@ -240,6 +240,14 @@ class fluid_system:
|
||||||
Array of gibbs free energy divided by RT (dimensionless)
|
Array of gibbs free energy divided by RT (dimensionless)
|
||||||
"""
|
"""
|
||||||
return lookup(self._g_rt_array, t, self._t_offset)
|
return lookup(self._g_rt_array, t, self._t_offset)
|
||||||
|
|
||||||
|
def get_species_references(self) -> str:
|
||||||
|
"""Get a string with the references for all fluids of the fluid system
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
String with the references
|
||||||
|
"""
|
||||||
|
return '\n'.join([f'{s:<12}: {_species_db[s].ref_string}' for s in self.species])
|
||||||
|
|
||||||
def __add__(self, other: 'fluid_system') -> 'fluid_system':
|
def __add__(self, other: 'fluid_system') -> 'fluid_system':
|
||||||
assert isinstance(other, self.__class__)
|
assert isinstance(other, self.__class__)
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
import gaspype as gp
|
||||||
|
|
||||||
|
def test_fluid_references():
|
||||||
|
fs = gp.fluid_system('Cl, CH4, H2O, C2H6, C3H8')
|
||||||
|
|
||||||
|
reference_string = """Cl : Hf:Cox,1989. Moore,1971. Moore,1970a. Gordon,1999. [g 7/97]
|
||||||
|
CH4 : Gurvich,1991 pt1 p44 pt2 p36. [g 8/99]
|
||||||
|
H2O : Hf:Cox,1989. Woolley,1987. TRC(10/88) tuv25. [g 8/89]
|
||||||
|
C2H6 : Ethane. Pamidimukkala,1982. [g 7/00]
|
||||||
|
C3H8 : Hf:TRC(10/85) w1350. Chao,1973. [g 2/00]"""
|
||||||
|
|
||||||
|
assert reference_string == fs.get_species_references(), 'fs.get_species_references() == ' + fs.get_species_references()
|
Loading…
Reference in New Issue