thermopy package

Submodules

thermopy.burcat module

Burcat module is intended to give access to the Burcat’s Database [1].

This database contains coefficients for thousands of chemicals to be used in polynomial form. Therefore it allows the user to calculate different thermodynamic properties for various compounds. Some of these properties are: 1. Specific heat capacity at constant pressure 2. Enthalpy 3. Entropy 4. Gibbs energy all of them as functions of temperature for a given compound.

Intended audience from [1]: The database is used by scientists, educators, engineers and students at all levels, dealing primarily with combustion and air pollution, jet engines, rocket propulsion, fireworks, but also by researchers involved in upper atmosphere kinetics, astrophysics, abrasion metallurgy, etc.

This file is deprecated and shall not be maintained. Use the nasa9polynomials instead.

class thermopy.burcat.Compound(cas, description, reference, formula, elements, aggr_state, T_limit_low, T_limit_high, calc_quality, mm, low_coefs, high_coefs, h_formation)[source]

Bases: object

Create chemical compounds.

It is intended to be created via an Elementdb object but you can use it by your own. Take a look at Elementdb class.

description

?? – ?

formula

?? – ?

aggr_state

?? – ?

mm

?? – molar mass of the compound.

h_formation

heat of formation.

Units are in SI on a molar basis.

density_ideal_gas(p, T)[source]

Density in kg/m³.

enthalpy(T)[source]

Computes the sensible enthalpy in J/mol.

enthalpy_engineering(T)[source]
Computes the total enthalpy in J/mol: h = h_formation + integral cp(T) dT.
Useful for heating reacting systems such as:
MgO + Cl2 -> MgCl2 + 0.5 O2 from Tref to 500 K.
deltaH total = (sum (h_form product) -
sum (h_form react)) + sum ( enthalpy(500) * prod)_each_product
enthalpy_massic(T)[source]

Computes the sensible enthalpy in J/kg.

entropy(T)[source]

Computes enthropy in J/mol K.

gibbs_energy(T)[source]

Computes the Gibbs free energy from the sensible enthalpy in J/mol.

heat_capacity(T)[source]

Calculates the specific heat capacity in J/(mol K).

heat_capacity_massic(T)[source]

Computes the specific heat capacity in J/(kg K) for a given temperature.

class thermopy.burcat.Database[source]

Bases: object

Class that reads the Alexander Burcat’s thermochemical database for combustion.

list_compound(cas_or_formula)[source]

Takes a string or a CAS number as input and output all matching results. Helpful for interactive use of the database.

set_compound(formula)[source]

Returns an Element instance given the name of the element.

class thermopy.burcat.Reaction(p, T, reagents, products, rcoefs=None, pcoefs=None)[source]

Bases: thermopy.burcat.Database

Models a simple reaction. Example:

1 N2 + 3 H2 <-> 2 NH3

reaction1 = burcat.Reaction(None, 600, [‘n2 ref element’, ‘h2 ref element’], [‘nh3 anharmonic’], [1, 3], [2])

equilibrium_constant(T=None)[source]

The equilibrium constant: K_eq = exp( - deltaG / (R * T))

thermopy.constants module

Collection of physical constants and conversion factors.

Most constants are in SI units, so you can do print(‘10 mile per minute is’, 10*mile/minute, ‘m/s or’,

10*mile/(minute*knot), ‘knots’)

The list is not meant to be comprehensive, but just a convenient list for everyday use.

thermopy.constants.C2F(C)[source]

Convert Celcius to Fahrenheit

thermopy.constants.C2K(C)[source]

Convert Celcius to Kelvin

thermopy.constants.F2C(F)[source]

Convert Fahrenheit to Celcius

thermopy.constants.F2K(F)[source]

Convert Fahrenheit to Kelvin

thermopy.constants.K2C(K)[source]

Convert Kelvin to Celcius

thermopy.constants.K2F(K)[source]

Convert Kelvin to Fahrenheit

thermopy.constants.lambda2nu(lambda_)[source]

Convert wavelength to optical frequency

thermopy.constants.nu2lambda(nu)[source]

Convert optical frequency to wavelength

thermopy.iapws module

Calculates water and steam properties.

Classes:

Water: water object.

References: [1] The International Association for the Properties of Water and Steam. Revised Release on the IAPWS Industrial Formulation 1997 for the Thermodynamic Properties of Water and Steam. August 2007.

class thermopy.iapws.Water(p, T, massic_basis=False)[source]

Bases: object

Taken from The International Association for the Properties of Water and Steam. Lucerne, Switzerland. August 2007. Revised Release on the IAPWS Industrial Formulation 1997 for the Thermodynamic Properties of Water and Steam. Reference document: IAPWS-IF97.

All units in SI and default is molar basis.

Tc = 647.096
Tt = 273.16
enthalpy(p=None, T=None)[source]

Returns the enthalpy given p and T in kJ/kg.

entropy(p=None, T=None)[source]

NOT IMPLEMENTED

gibbs_energy(p=None, T=None)[source]

Returns the Gibbs Energy given p and T in kJ/kg.

heat_capacity(p=None, T=None)[source]

Returns the isobaric heat capacity given p and T in kJ/(kg K).

heat_capacity_constant_v(p=None, T=None)[source]

NOT IMPLEMENTED

ht = 0.611783
internal_energy(p=None, T=None)[source]

NOT IMPLEMENTED

pc = 22064000.0
pressure_saturation(T=None)[source]

Yields Psat given a temperature T

pt = 611.657
rhoc = 322
specific_volume(p=None, T=None)[source]

Returns the specific volume in m³/kg

speed_of_sound(p=None, T=None)[source]

NOT IMPLEMENTED

temperature_saturation(p=None)[source]

Yields Tsat given a pressure p.

thermopy.nasa9polynomials module

Enable the NASA 9 term polynomials to create chemical compound objects.

This module allows the user to use the NASA9 term polynomials (abbreviated as NASA 9) to model chemical compounds and reactions. It is worth noting that all the output is stripped of any phyisical unit, that is, results are returned as numpy floats. Therefore to end any form of ambiguity we reinstate that all the results are in SI units using molar basis. It is up to the user to beware of any physical unit conversion concerning his problem.

Classes:

Compound: chemical compound present in the NASA9 term polynomials database.

CompoundIdealGas: chemical compound as an ideal gas present in the NASA9 term polynomials database. It inherits from Compound.

Reaction: model of a chemical reaction.

Example

>>> import thermopy
>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> caf2 = db.set_compound('caf2')
>>> print(caf2.elements)
[('C', 1), ('F', 2)]
>>> print(caf2.inchikey)
WUKWITHWXAAZEY-UHFFFAOYSA-L
>>> print(caf2.enthalpy_of_formation)
-790828.409
>>> print(caf2.heat_capacity(300))
51.2707324499
>>> print(caf2.molecular_weight)
0.0780748064
>>> water = db.set_compound('h2o(l)')
>>> print(water.entropy(300))
69.633703
>>> print(water.elements)
[('H', 2), ('O', 1)]

References: [1] Bonnie J. McBride, Michael J. Zehe, and Sanford Gordon. NASA Glenn Coefficients for Calculating Thermodynamic Properties of Individual Species. September 2002.

class thermopy.nasa9polynomials.Compound(xml_compound)[source]

Bases: object

Chemical compound present in the NASA9 term polynomials database.

It is usually set by nasa9polyniomials.Database.set_compound(‘identifier’). If set this way this method already instantiates either a Compound or a CompoundIdealGas based on the phase of the chemical compound specified by the identifier (see note below).

Note: The default phase for compounds in this database is gas. Thus if instantiating with the name ‘H2O’ one would get steam. For liquid water and ice one would rather look for ‘H2O(L)’ or ‘H2O(cr)’. The same is valid for a lot of compounds expected to be in the condensed form (such as NaCl, Tungsten, etc).

It has all the thermodynamic functions listed in [1] as methods which take temperature as their sole argument. Those were expanded to include gibbs_energy that could be defined by the given functions.

canonical_smiles

str – Canonical SMILES (Simplified molecular-input line-entry system) of the compound.

cas_number

str – CAS (Chemical Abstract Service) number of the compound.

comment

str – Comment found in the xml database. Usually references.

condensed

bool – True if the compound is condensed, False if not.

xml_compounds

list – List containing tuples of two entries. The first is the xml_compound and the second is the proportion of the xml_compound in the molecule. Both values are strings.

enthalpy_of_formation

float – Enthalpy of formation of the compound.

inchikey

str – InChI (International Chemical Identifier) key for the compound.

inp_name

str – Name as per the original ‘inp’ file.

iupac_name

str – IUPAC (International Union of Pure and Applied Chemistry) name of the compound.

molecular_weight

float – Molecular weight of the compound.

reference

str – Reference for the compound. See [1] for details.

enthalpy()[source]

calculates the enthalpy for a Compound object.

entropy()[source]

calculates the entropy for a Compound object.

gibbs_energy()[source]

calculates the Gibbs energy for a Compound object.

heat_capacity()[source]

calculates the heat capacity for a Compound object.

Subclasses:
CompoundIdealGas: chemical compound as an ideal gas present in the NASA9 term polynomials database. It inherits from Compound.

Examples

>>> import thermopy
>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> uf6 = db.set_compound('uf6(cr)')
>>> print(uf6)
hexafluorouranium: UF6(cr)
enthalpy(T)[source]

Calculate molar enthalpy at constant pressure for the compound for a given temperature.

Parameters:T (float) – temperature.
Returns:The molar enthalpy for the compound for a given temperature.
Return type:numpy_float

Examples

>>> import thermopy
>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> magnesium_hydroxide = db.set_compound('Mg(OH)2(cr)')
>>> print(magnesium_hydroxide, '-',
>>> magnesium_hydroxide.enthalpy(500))  # J/mol
Mg(OH)2(cr) - -906097.801815
entropy(T)[source]

Calculate molar entropy at constant pressure for the compound for a given temperature.

Parameters:T (float) – temperature.
Returns:The molar entropy for the compound for a given temperature.
Return type:numpy_float

Examples

>>> import thermopy
>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> argon = db.set_compound('ar')
>>> print(argon, '-', argon.entropy(200))
argon: Ar - 146.546470215
gibbs_energy(T)[source]

Calculate molar Gibbs energy at constant pressure for the compound for a given temperature.

Parameters:T (float) – temperature.
Returns:The molar entropy for the compound for a given temperature.
Return type:numpy_float

Examples

>>> import thermopy
>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> csbr = db.set_compound('csbr(cr)')
>>> print(csbr, '-', csbr.gibbs_energy(273.15))
cesium;bromide: CsBr(cr) - -436504.410044
heat_capacity(T)[source]

Calculate molar heat capacity at constant pressure for standard state.

Parameters:T (float) – temperature.
Returns:The molar heat capacity for the compound for a
Return type:numpy_float

given temperature.

Examples

>>> import thermopy
>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> libr = db.set_compound('LiBr')
>>> print(libr, '-', libr.heat_capacity(2700))
lithium;bromide: LiBr - 39.6593057506
class thermopy.nasa9polynomials.CompoundIdealGas(xml_compound)[source]

Bases: thermopy.nasa9polynomials.Compound

Chemical compound as an ideal gas present in the NASA9 term polynomials database.

It is usually set by nasa9polyniomials.Database.set_compound(‘identifier’). If set this way this method already instantiates either a Compound or a CompoundIdealGas based on the phase of the chemical compound specified by the identifier (see note below).

Note: The default phase for compounds in this database is gas. Thus if instantiating with the name ‘H2O’ one would get steam. For liquid water and ice one would rather look for ‘H2O(L)’ or ‘H2O(cr)’. The same is valid for a lot of compounds expected to be in the condensed form (such as NaCl, Tungsten, etc).

It adds two extra methods which come from the thermodynamics of Ideal Gases.

Inherits from Compound.

heat_capacity_constant_v()[source]

calculates the heat capacity at a

constant volume for a CompoundIdealGas object.
internal_energy()[source]

calculates

the internal energy for a CompoundIdealGas object.

Examples

>>> # Instantiating a Compound whose condensed attributed is False
>>> # automatically sets it as an Ideal Gas:
>>> import thermopy
>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> co2 = db.set_compound('CO2')
>>> print(co2, type(co2))
carbon dioxide: CO2 <class
'thermopy.nasa9polynomials.CompoundIdealGas'>
heat_capacity_constant_v(T)[source]

Calculate molar heat capacity at constant volume for standard state.

Parameters:T (float) – temperature.
Returns:The molar heat capacity for the compound for a given temperature.
Return type:numpy_float

Examples

>>> import thermopy
>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> xenon = db.set_compound('Xe')
>>> print(xenon, '-', xenon.heat_capacity(298.15))
xenon: Xe - 20.78618
>>> print(xenon, '-', xenon.heat_capacity_constant_v(298.15))
xenon: Xe - 12.471708
>>> print('subtracting both hc:',
...       xenon.heat_capacity(298.15)
...       - xenon.heat_capacity_constant_v(298.15))
subtracting both hc: 8.314472
internal_energy(T)[source]

Calculate molar internal energy at constant pressure for standard state.

Parameters:T (float) – temperature.
Returns:The molar internal energy for the compound for a given temperature.
Return type:numpy_float

Examples

>>> import thermopy
>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> hcn = db.set_compound('hcn')
>>> print(hcn, '-', hcn.internal_energy(500))
formonitrile: HCN - 136809.830971
class thermopy.nasa9polynomials.Database[source]

Bases: object

Nasa 9 term polynomials database (see NASA/TP—2002-211556).

The preferred method for identifying compounds is via usual name followed by an aggregation state if the compound is not a gas. E.g. ‘(L)’, ‘(cr)’, ‘(a)’, ‘(b)’ where ‘(a)’ and ‘(b)’ are for allotropes. Other methods are:

  1. InChIKey.
  2. CAS number.
  3. IUPAC name.

Examples

>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
list_compound(x)[source]

List the compounds for a given input. It is intended to be used in interactive mode.

Parameters:x (str) – identifier for compound being searched.
Returns:list of tuples containing (str, str) being the ‘inp name’ and the IUPAC name respectively.
Return type:list

Examples

>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> for i in db.list_compound('fes'):
...     print(i)
('FeS(a)', 'sulfanylideneiron')
('FeS(b)', 'sulfanylideneiron')
('FeS(c)', 'sulfanylideneiron')
('FeS(L)', 'sulfanylideneiron')
('FeSO4(cr)', 'iron(2+);sulfate')
('FeS2(cr)', 'N/A')

Note

The preferred method for identifying compounds is via usual name followed by an aggregation state if the compound is not a gas. E.g. ‘(L)’, ‘(cr)’, ‘(a)’, ‘(b)’ where ‘(a)’ and ‘(b)’ are for allotropes. Other methods are:

  1. InChIKey.
  2. CAS number.
  3. IUPAC name.
set_compound(x)[source]

Set the compound if there is one entry specified on the database.

It is important to notice that due to the nature of the work of this database, compounds are gases unless explicitly stated otherwise.

Parameters:x (str) – identifier for compound being searched.
Returns:returns a Compound object if the phase is condensed. Returns a CompoundIdealGas otherwise.
Return type:Compound

Example

>>> # Someone is looking for the element gallium but is not certain
>>> # how to instantiate it. One would first list the compounds:
>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> for i in db.list_compound('gallium'):
...     print(i)
...
('Ga', 'gallium')
('Ga+', 'gallium')
('GaBr', 'bromogallium')
('GaBr2', 'dibromogallium')
('GaCl', 'chlorogallium')
('GaCl2', 'gallium;dichloride')
('GaF2', 'difluorogallium')
('GaI2', 'diiodogallium')
('GaO', 'oxogallium')
('GaOH', 'gallium;hydroxide')
('Ga2Cl4', 'gallium;gallium;tetrachloride')
('Ga2O', 'gallium;oxygen(2-)')
('Ga(cr)', 'gallium')
('Ga(L)', 'gallium')
('Ga2O3(cr)', 'digallium;oxygen(2-)')
('Ga2O3(L)', 'digallium;oxygen(2-)')
>>> gallium = db.set_compound('Ga')
>>> print(gallium)
gallium: Ga

Note

The preferred method for identifying compounds is via usual name followed by an aggregation state if the compound is not a gas. E.g. ‘(L)’, ‘(cr)’, ‘(a)’, ‘(b)’ where ‘(a)’ and ‘(b)’ are for allotropes. Other methods are:

  1. InChIKey.
  2. CAS number.
  3. IUPAC name.
class thermopy.nasa9polynomials.Reaction(T, reactants, products, reactants_coefficients, product_coefficients)[source]

Bases: object

Model of a chemical reaction.

Model of a chemical reaction using the NASA9 Compounds.

Inherits from object.

enthalpy_reaction()[source]

enthalpy of the reaction.

entropy_reaction()[source]

entropy of the reaction.

gibbs_energy_reaction()[source]

Gibbs energy of the reaction.

equilibrium_constant()[source]

equilibrium constant of the reaction.

Examples

>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> na = db.set_compound('na(cr)')
>>> # being careful to initilize solid compounds
>>> water = db.set_compound('h2o(l)')
>>> # being careful to initilize liquid compounds
>>> sodium_hydroxide = db.set_compound('naoh(a)')
>>> # being careful to initilize solid compounds
>>> hydrogen = db.set_compound('h2')
>>> reacts = (na, water)
>>> prods = (sodium_hydroxide, hydrogen)
>>> reacts_coefs = (2, 2)
>>> prods_coefs = (2, 1)
>>> reaction1 = nasa9.Reaction(300, reacts, prods, reacts_coefs,
>>> prods_coefs)
>>> print(reaction1)
<reaction> +2 Na(cr) +2 H2O(L)  -> +2 NaOH(a) +1 H2
>>> print(reaction1.entropy_reaction())
149.097547531
>>> print(reaction1.enthalpy_reaction())
-279857.367433

Notes

The Reaction class does not check for imbalances of the reaction (yet).

enthalpy_reaction(T=None)[source]

Calculate the enthalpy of the reaction at the standard state.

Parameters:T (float) – temperature.
Returns:The enthalpy of the reaction for a given temperature.
Return type:numpy_float

Examples

>>> import thermopy
>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> nitric_acid = db.set_compound('hno3')
>>> # the liquid phase is not present in the database
>>> naoh = db.set_compound('naoh(a)')
>>> sodium_nitrate = db.set_compound('nano3(a)')
>>> water = db.set_compound('h2o(l)')
>>> reagents = (nitric_acid, naoh)
>>> products = (sodium_nitrate, water)
>>> reactants_stoichometry = (1, 1)
>>> prodcuts_stoichometry = (1, 1)
>>> reaction1 = nasa9.Reaction(
...     298,
...     reagents,
...     products,
...     reactants_stoichometry,
...     prodcuts_stoichometry
...     )
>>> print(reaction1, reaction1.enthalpy_reaction())
<reaction> +1 HNO3 +1 NaOH(a)  -> +1 NaNO3(a) +1 H2O(L)
-193773.133358
entropy_reaction(T=None)[source]

Calculate the entropy of the reaction at the standard state.

Parameters:T (float) – temperature.
Returns:The entropy of the reaction for a given temperature.
Return type:numpy_float

Examples

>>> import thermopy
>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> nitric_acid = db.set_compound('hno3')
>>> # the liquid phase is not present in the database
>>> naoh = db.set_compound('naoh(a)')
>>> sodium_nitrate = db.set_compound('nano3(a)')
>>> water = db.set_compound('h2o(l)')
>>> reagents = (nitric_acid, naoh)
>>> products = (sodium_nitrate, water)
>>> reactants_stoichometry = (1, 1)
>>> prodcuts_stoichometry = (1, 1)
>>> reaction1 = nasa9.Reaction(
...     298,
...     reagents,
...     products,
...     reactants_stoichometry,
...     prodcuts_stoichometry
...     )
>>> print(reaction1, reaction1.entropy_reaction())
<reaction> +1 HNO3 +1 NaOH(a)  -> +1 NaNO3(a) +1 H2O(L)
-145.797754143
equilibrium_constant(T=None)[source]

Calculate the equilibrium constant of the reaction at the standard state.

Definition: K = exp(- deltaG / (R T))

Parameters:T (float) – temperature.
Returns:The Gibbs energy of the reaction for a given temperature.
Return type:numpy_float

Examples

>>> import thermopy
>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> pcl5 = db.set_compound('pcl5')
>>> pcl3 = db.set_compound('pcl3')
>>> chlorine = db.set_compound('cl2')
>>> reagents = (pcl5,)
>>> products = (pcl3, chlorine)
>>> reactants_stoichometry = (1,)
>>> prodcuts_stoichometry = (1, 1)
>>> reaction1 = nasa9.Reaction(
...     500,
...     reagents,
...     products,
...     reactants_stoichometry,
...     prodcuts_stoichometry
...     )
>>> print(reaction1, reaction1.equilibrium_constant())
<reaction> +1 PCl5  -> +1 PCl3 +1 Cl2  6.39431126134e-13
gibbs_energy_reaction(T=None)[source]

Calculate the Gibbs energy of the reaction at the standard state.

Parameters:T (float) – temperature.
Returns:The Gibbs energy of the reaction for a given temperature.
Return type:numpy_float

Examples

>>> import thermopy
>>> from thermopy import nasa9polynomials as nasa9
>>> db = nasa9.Database()
>>> pcl5 = db.set_compound('pcl5')
>>> pcl3 = db.set_compound('pcl3')
>>> chlorine = db.set_compound('cl2')
>>> reagents = (pcl5,)
>>> products = (pcl3, chlorine)
>>> reactants_stoichometry = (1,)
>>> prodcuts_stoichometry = (1, 1)
>>> reaction1 = nasa9.Reaction(
...     298,
...     reagents,
...     products,
...     reactants_stoichometry,
...     prodcuts_stoichometry
...     )
>>> print(reaction1, reaction1.gibbs_energy_reaction())
<reaction> +1 PCl5  -> +1 PCl3 +1 Cl2  103038.712535

thermopy.units module

Units conversion module.

Classes:

Temperature: temperature object.

Pressure: pressure object.

Enthalpy: enthalpy object.

Length: length object.

Massflow: mass flow object.

Massflowrate: massflowrate object.

Energy: energy object.

class thermopy.units.Energy(data)[source]

Bases: float

Energy in J, Btu, cal, kWh

Btu

Property of Btu unit.

cal

Property of cal unit.

kWh

Property of KWh unit.

unit(units='J')[source]

Set unit for energy.

class thermopy.units.Enthalpy(data)[source]

Bases: float

Class that models an enthalpy measure with conversion utilities

Supported units are

  • Joule per kg (default)
  • Kilojoule per kg (kJkg)
  • Kilocalorie per kg (kcalkg)
  • BTU per pound (Btulb)
>>> h = Enthalpy(1000)
>>> h.kJkg
1.0
>>> h.kcalkg
0.2390057361376...
>>> h.Btulb
0.42992261392949266
Btulb

Property of Btulb pressure unit.

kJkg

Property of KJkg pressure unit.

kcalkg

Property of kcalkg pressure unit.

unit(units='si')[source]

Set unit for Enthalpy.

class thermopy.units.Length(data)[source]

Bases: float

Class that models a length measure with conversion utilities

Supported units are

  • meter (default)
  • millimeter (mm)
  • inch (inch)
  • foot (ft)
>>> l = Length(1).unit('inch')
>>> round(l.mm, 1)
25.4
>>> l.ft
0.0833333333333...
>>> round(l, 4)
0.0254
ft

Property of feet unit.

inch

Property of inch unit.

mm

Property of mm unit.

unit(units='m')[source]

Set unit for length.

class thermopy.units.Massflow(data)[source]

Bases: float

Class that models a mass flow measure with conversion utilities

Supported units are

  • kg per second (default)
  • kg per hour (kgh)
  • pounds per second (lbs)
  • pounds per hour (lbh)
kgh

Property of kgh unit.

lbh

Property of lbh unit.

lbs

Property of lbs unit.

unit(units='kgs')[source]

Set unit for massflow.

class thermopy.units.Massflowrate(data)[source]

Bases: float

Class that models a mass flow measure with conversion utilities

Supported units are

  • (default)
  • (Btu)
Btu

Property of Btu unit.

unit(units='default')[source]

Set unit for massflowrate.

class thermopy.units.Pressure(data)[source]

Bases: float

Class that models a Pressure measure with conversion utilities

Suported units are

  • Pascal (Pa)
  • Mega Pascal (MPa)
  • Bar (bar)
  • Pound per square inch (psi)
  • Atmosphere (atm)
  • Millimeters of water column (mmwc)
  • Torricelli (torr)

Normal instantiation is pressure in Pa. How much is an athmosphere?

>>> p = Pressure(1.0).unit('atm')
>>> p
101325.0
>>> p.torr
760.0
>>> p.mmwc
10285.839999999998
>>> p.psi
14.69594877551345
MPa

Property of MPa pressure unit.

atm

Property of atm pressure unit.

bar

Property of bar pressure unit.

mmwc

Property of mmwc pressure unit.

psi

Property of psi pressure unit.

torr

Property of torr pressure unit.

unit(units='Pa')[source]

Set unit for pressure.

class thermopy.units.Temperature(data)[source]

Bases: float

Class that models a temperature measure with conversion utilities

Supported units are

  • Kelvin
  • Celsius
  • Fahrenheit

Normal instantiation is a temperature in Kelvin

>>> T = Temperature(100)
>>> T
100.0

But you can instantiate and specify if unit is Celsius or Fahrenheit

>>> T = Temperature(100).unit('F')
>>> T
310.92777777777775

Unit conversion is as easy as it gets.

>>> T.C
37.777777777777...
>>> T.F
99.999999999999...

You can compute with temperatures because inherits from the float built-in

>>> T1 = Temperature(200)
>>> T2 = Temperature(0).unit('C')
>>> round(T1+T2, 2)
473.15

If you don’t want to use the class’ attribute you can use the function getattr to get a value using the unit code.

>>> getattr(T,'C')
37.77777777777...
C

Property of Celsius temperature unit.

F

Property of Fahrenheit temperature unit.

unit(units='K')[source]

Set unit for temperature.

Module contents

Modules:
Burcat: burcat thermodynamic database. Constants: physical constants database. Iapws: water and steam thermodynamic database. Nasa9polynomials: nasa 9 term polynomials database. Units: units conversion database.