- functor(f=None, var=None, units=None)#
Decorate a function of temperature, or both temperature and pressure to have an attribute, functor, that serves to create its functor counterpart.
f – Same function, but with an attribute functor that can create its Functor counterpart.
- Return type:
The functor decorator checks the signature of the function to find the names of the parameters that should be stored as data.
Create a functor of temperature that returns the vapor pressure in Pascal:
>>> # Describe the return value with `var`. >>> # Thermosteam's chemical units of measure are always assumed. >>> import thermosteam as tmo >>> @tmo.functor(var='Psat') ... def Antoine(T, a, b, c): ... return 10.0**(a - b / (T + c)) >>> Antoine(T=373.15, a=10.116, b=1687.5, c=-42.98) # functional 101157.148 >>> f = Antoine.functor(a=10.116, b=1687.5, c=-42.98) # as functor object >>> f.show() Functor: Antoine(T, P=None) -> Psat [Pa] a: 10.116 b: 1687.5 c: -42.98 >>> f(T=373.15) 101157.148
All functors are saved in the functors module:
>>> tmo.functors.Antoine <class 'thermosteam.functors.Antoine'>