BioSTEAMDevelopmentGroup / thermosteam

BioSTEAM's Premier Thermodynamic Engine
Other
57 stars 12 forks source link

Creating a custom component #35

Closed dhkblaszyk closed 3 years ago

dhkblaszyk commented 3 years ago

Can one explain how to create a custom component and their properties in thermosteam? Just a basic example will suffice.

yoelcortes commented 3 years ago

Sure, here are a few examples:

Example A: Single phase pseudo-chemical with required properties (e.g., heat capacity and volume) equal to that of water at 298.15 K (more or less)

from thermosteam import *
some_chemical = Chemical('SomeName', 
    search_db=False, # Do not search database
    phase='l', # Only liquid phase
    default=True, # Default missing values
)
assert some_chemical.MW == 1. # Default value
# Defaults are given on a weight basis. 
# Even if you gave a different MW, the default specific heat capacity (by weight) would be the same
assert some_chemical.Cp(298.15) == 4.18  
# This chemical is 100% compatible with thermosteam
# For example, even if no vapor pressure model is available, 
# it assumes the chemical will always remain in given phase during vapor-liquid equilibrium.

Example B: Single phase pseudo-chemical with user-defined properties and default the rest (e.g., surface tension)

from thermosteam import *
Yeast= Chemical('Yeast',
    formula='CH1.61O0.56N0.16',
    search_db=False,
    phase='s',
    rho=1540., 
    default=True,
    Hf=-130412.73, # Heat of formation, useful for energy balances
)
assert Yeast.MW == 24.8342194 # Molecular weight is automatically computed given formula

For more detailed examples, please checkout the documentation, thanks!

yoelcortes commented 3 years ago

Let me know if you have any other questions, it takes a bit of time to get a feel for it