Utilities and Base Classes (thermo.utils)

This module contains base classes for temperature T, pressure P, and composition zs dependent properties. These power the various interfaces for each property.

For reporting bugs, adding feature requests, or submitting pull requests, please use the GitHub issue tracker.

Temperature Dependent

class thermo.utils.TDependentProperty(extrapolation, **kwargs)[source]

Class for calculating temperature-dependent chemical properties.

On creation, a TDependentProperty examines all the possible methods implemented for calculating the property, loads whichever coefficients it needs (unless load_data is set to False), examines its input parameters, and selects the method it prefers. This method will continue to be used for all calculations until the method is changed by setting a new method to the to method attribute.

The default list of preferred method orderings is at ranked_methods for all properties; the order can be modified there in-place, and this will take effect on all new TDependentProperty instances created but NOT on existing instances.

All methods have defined criteria for determining if they are valid before calculation, i.e. a minimum and maximum temperature for coefficients to be valid. For constant property values used due to lack of temperature-dependent data, a short range is normally specified as valid.

It is not assumed that a specified method will succeed; for example many expressions are not mathematically valid past the critical point, and in some cases there is no easy way to determine the temperature where a property stops being reasonable.

Accordingly, all properties calculated are checked by a sanity function test_property_validity, which has basic sanity checks. If the property is not reasonable, None is returned.

This framework also supports tabular data, which is interpolated from if specified. Interpolation is cubic-spline based if 5 or more points are given, and linearly interpolated with if few points are given. A transform may be applied so that a property such as vapor pressure can be interpolated non-linearly. These are functions or lambda expressions which are set for the variables interpolation_T, interpolation_property, and interpolation_property_inv.

In order to calculate properties outside of the range of their correlations, a number of extrapolation method are available. Extrapolation is used by default on some properties but not all. The extrapolation methods available are as follows:

  • ‘constant’ - returns the model values as calculated at the temperature limits

  • ‘linear’ - fits the model at its temperature limits to a linear model

  • ‘nolimit’ - attempt to evaluate the model outside of its limits; this will error in most cases and return None

  • ‘AntoineAB’ - fits the model to Antoine’s equation at the temperature limits using only the A and B coefficient

  • ‘DIPPR101_ABC’ - fits the model at its temperature limits to the EQ101 equation

  • ‘Watson’ - fits the model to the Heat of Vaporization model Watson

  • ‘EXP_POLY_LN_TAU2’ - uses the models’s critical temperature and derivative to fit the model linearly in the equation prop=exp(a+blnτ)\text{prop} = \exp(a + b\cdot\ln\tau), so that it is always zero at the critical point; suitable for surface tension.

  • ‘DIPPR106_AB’ - uses the models’s critical temperature and derivative to fit the model linearly in the equation EQ106’s equation at the temperature limits using only the A and B coefficient

  • ‘DIPPR106_ABC’ - uses the models’s critical temperature and first two derivatives to fit the model quadratically in the equation EQ106’s equation at the temperature limits using only the A, B, and C coefficient.

  • ‘Arrhenius’: fits the model at its temperature limits to an Arrhenius linear model in 1/T and log(property) space

It is possible to use different extrapolation methods for the low-temperature and the high-temperature region. Specify the extrapolation parameter with the ‘|’ symbols between the two methods; the first method is used for low-temperature, and the second for the high-temperature.

Attributes
namestr

The name of the property being calculated, [-]

unitsstr

The units of the property, [-]

methodstr

Method used to set a specific property method or to obtain the name of the method in use.

interpolation_Tcallable or None

A function or lambda expression to transform the temperatures of tabular data for interpolation; e.g. ‘lambda self, T: 1./T’

interpolation_T_invcallable or None

A function or lambda expression to invert the transform of temperatures of tabular data for interpolation; e.g. ‘lambda self, x: self.Tc*(1 - x)’

interpolation_propertycallable or None

A function or lambda expression to transform tabular property values prior to interpolation; e.g. ‘lambda self, P: log(P)’

interpolation_property_invcallable or None

A function or property expression to transform interpolated property values from the transform performed by interpolation_property back to their actual form, e.g. ‘lambda self, P: exp(P)’

Tminfloat

Minimum temperature (K) at which the current method can calculate the property.

Tmaxfloat

Maximum temperature (K) at which the current method can calculate the property.

property_minfloat

Lowest value expected for a property while still being valid; this is a criteria used by test_method_validity.

property_maxfloat

Highest value expected for a property while still being valid; this is a criteria used by test_method_validity.

ranked_methodslist

Constant list of ranked methods by default

tabular_datadict

Stores all user-supplied property data for interpolation in format {name: (Ts, properties)}, [-]

tabular_data_interpolatorsdict

Stores all interpolation objects, idexed by name and property transform methods with the format {(name, interpolation_T, interpolation_property, interpolation_property_inv): (extrapolator, spline)}, [-]

all_methodsset

Set of all methods available for a given CASRN and set of properties, [-]

Methods

T_dependent_property(T)

Method to calculate the property with sanity checking and using the selected method.

T_dependent_property_derivative(T[, order])

Method to obtain a derivative of a property with respect to temperature, of a given order.

T_dependent_property_integral(T1, T2)

Method to calculate the integral of a property with respect to temperature, using the selected method.

T_dependent_property_integral_over_T(T1, T2)

Method to calculate the integral of a property over temperature with respect to temperature, using the selected method.

__call__(T)

Convenience method to calculate the property; calls T_dependent_property.

add_correlation(name, model, Tmin, Tmax[, ...])

Method to add a new set of emperical fit equation coefficients to the object and select it for future property calculations (optionally).

add_method(f[, Tmin, Tmax, f_der, f_der2, ...])

Define a new method and select it for future property calculations.

add_tabular_data(Ts, properties[, name, ...])

Method to set tabular data to be used for interpolation.

as_json([cache, option])

Method to create a JSON serialization of the property model which can be stored, and reloaded later.

calculate(T, method)

Method to calculate a property with a specified method, with no validity checking or error handling.

calculate_derivative(T, method[, order])

Method to calculate a derivative of a property with respect to temperature, of a given order using a specified method.

calculate_integral(T1, T2, method)

Method to calculate the integral of a property with respect to temperature, using a specified method.

calculate_integral_over_T(T1, T2, method)

Method to calculate the integral of a property over temperature with respect to temperature, using a specified method.

extrapolate(T, method[, in_range])

Method to perform extrapolation on a given method according to the extrapolation setting.

fit_add_model(name, model, Ts, data, **kwargs)

Method to add a new emperical fit equation to the object by fitting its coefficients to specified data.

fit_data_to_model(Ts, data, model[, ...])

Method to fit T-dependent property data to one of the available model correlations.

from_json(json_repr[, cache])

Method to create a property model from a JSON serialization of another property model.

interpolate(T, name)

Method to perform interpolation on a given tabular data set previously added via add_tabular_data.

plot_T_dependent_property([Tmin, Tmax, ...])

Method to create a plot of the property vs temperature according to either a specified list of methods, or user methods (if set), or all methods.

polynomial_from_method(method[, n, start_n, ...])

Method to fit a T-dependent property to a polynomial.

solve_property(goal)

Method to solve for the temperature at which a property is at a specified value.

test_method_validity(T, method)

Method to test the validity of a specified method for a given temperature.

test_property_validity(prop)

Method to test the validity of a calculated property.

valid_methods([T])

Method to obtain a sorted list of methods that have data available to be used.

T_dependent_property(T)[source]

Method to calculate the property with sanity checking and using the selected method.

In the unlikely event the calculation of the property fails, None is returned.

The calculated result is checked with test_property_validity and None is returned if the calculated value is nonsensical.

Parameters
Tfloat

Temperature at which to calculate the property, [K]

Returns
propfloat

Calculated property, [units]

T_dependent_property_derivative(T, order=1)[source]

Method to obtain a derivative of a property with respect to temperature, of a given order.

Calls calculate_derivative internally to perform the actual calculation.

derivative=d(property)dT\text{derivative} = \frac{d (\text{property})}{d T}
Parameters
Tfloat

Temperature at which to calculate the derivative, [K]

orderint

Order of the derivative, >= 1

Returns
derivativefloat

Calculated derivative property, [units/K^order]

T_dependent_property_integral(T1, T2)[source]

Method to calculate the integral of a property with respect to temperature, using the selected method.

Calls calculate_integral internally to perform the actual calculation.

integral=T1T2property  dT\text{integral} = \int_{T_1}^{T_2} \text{property} \; dT
Parameters
T1float

Lower limit of integration, [K]

T2float

Upper limit of integration, [K]

Returns
integralfloat

Calculated integral of the property over the given range, [units*K]

T_dependent_property_integral_over_T(T1, T2)[source]

Method to calculate the integral of a property over temperature with respect to temperature, using the selected method.

Calls calculate_integral_over_T internally to perform the actual calculation.

integral=T1T2propertyT  dT\text{integral} = \int_{T_1}^{T_2} \frac{\text{property}}{T} \; dT
Parameters
T1float

Lower limit of integration, [K]

T2float

Upper limit of integration, [K]

Returns
integralfloat

Calculated integral of the property over the given range, [units]

T_limits = {}

Dictionary containing method: (Tmin, Tmax) pairs for all methods applicable to the chemical

__call__(T)[source]

Convenience method to calculate the property; calls T_dependent_property. Caches previously calculated value, which is an overhead when calculating many different values of a property. See T_dependent_property for more details as to the calculation procedure.

Parameters
Tfloat

Temperature at which to calculate the property, [K]

Returns
propfloat

Calculated property, [units]

__repr__()[source]

Create and return a string representation of the object. The design of the return string is such that it can be eval’d into itself. This is very convinient for creating tests. Note that several methods are not compatible with the eval’ing principle.

Returns
reprstr

String representation, [-]

add_correlation(name, model, Tmin, Tmax, select=True, **kwargs)[source]

Method to add a new set of emperical fit equation coefficients to the object and select it for future property calculations (optionally).

A number of hardcoded model names are implemented; other models are not supported.

Parameters
namestr

The name of the coefficient set; user specified, [-]

modelstr

A string representing the supported models, [-]

Tminfloat

Minimum temperature to use the method at, [K]

Tmaxfloat

Maximum temperature to use the method at, [K]

kwargsdict

Various keyword arguments accepted by the model, [-]

select: bool

Whether to set the method as the default, [-]

Notes

The correlation models and links to their functions, describing their parameters, are as follows:

add_method(f, Tmin=None, Tmax=None, f_der=None, f_der2=None, f_der3=None, f_int=None, f_int_over_T=None, name=None)[source]

Define a new method and select it for future property calculations.

Parameters
fcallable

Object which calculates the property given the temperature in K, [-]

Tminfloat, optional

Minimum temperature to use the method at, [K]

Tmaxfloat, optional

Maximum temperature to use the method at, [K]

f_dercallable, optional

If specified, should take as an argument the temperature and return the first derivative of the property, [-]

f_der2callable, optional

If specified, should take as an argument the temperature and return the second derivative of the property, [-]

f_der3callable, optional

If specified, should take as an argument the temperature and return the third derivative of the property, [-]

f_intcallable, optional

If specified, should take T1 and T2 and return the integral of the property from T1 to T2, [-]

f_int_over_Tcallable, optional

If specified, should take T1 and T2 and return the integral of the property over T from T1 to T2, [-]

namestr, optional

Name of method.

Notes

Once a custom method has been added to an object, that object can no longer be serialized to json and the TDependentProperty.__repr__ method can no longer be used to reconstruct the object completely.

add_tabular_data(Ts, properties, name=None, check_properties=True)[source]

Method to set tabular data to be used for interpolation. Ts must be in increasing order. If no name is given, data will be assigned the name ‘Tabular data series #x’, where x is the number of previously added tabular data series.

After adding the data, this method becomes the selected method.

Parameters
Tsarray_like

Increasing array of temperatures at which properties are specified, [K]

propertiesarray_like

List of properties at Ts, [units]

namestr, optional

Name assigned to the data

check_propertiesbool

If True, the properties will be checked for validity with test_property_validity and raise an exception if any are not valid

as_json(cache=None, option=0)[source]

Method to create a JSON serialization of the property model which can be stored, and reloaded later.

Parameters
referencesint

How to handle references to other objects; internal parameter, [-]

Returns
json_reprdict

JSON-friendly representation, [-]

calculate(T, method)[source]

Method to calculate a property with a specified method, with no validity checking or error handling. Demo function for testing only; must be implemented according to the methods available for each individual method. Include the interpolation call here.

Parameters
Tfloat

Temperature at which to calculate the property, [K]

methodstr

Method name to use

Returns
propfloat

Calculated property, [units]

calculate_derivative(T, method, order=1)[source]

Method to calculate a derivative of a property with respect to temperature, of a given order using a specified method. Uses SciPy’s derivative function, with a delta of 1E-6 K and a number of points equal to 2*order + 1.

This method can be overwritten by subclasses who may perfer to add analytical methods for some or all methods as this is much faster.

If the calculation does not succeed, returns the actual error encountered.

Parameters
Tfloat

Temperature at which to calculate the derivative, [K]

methodstr

Method for which to find the derivative

orderint

Order of the derivative, >= 1

Returns
derivativefloat

Calculated derivative property, [units/K^order]

calculate_integral(T1, T2, method)[source]

Method to calculate the integral of a property with respect to temperature, using a specified method. Uses SciPy’s quad function to perform the integral, with no options.

This method can be overwritten by subclasses who may perfer to add analytical methods for some or all methods as this is much faster.

If the calculation does not succeed, returns the actual error encountered.

Parameters
T1float

Lower limit of integration, [K]

T2float

Upper limit of integration, [K]

methodstr

Method for which to find the integral

Returns
integralfloat

Calculated integral of the property over the given range, [units*K]

calculate_integral_over_T(T1, T2, method)[source]

Method to calculate the integral of a property over temperature with respect to temperature, using a specified method. Uses SciPy’s quad function to perform the integral, with no options.

This method can be overwritten by subclasses who may perfer to add analytical methods for some or all methods as this is much faster.

If the calculation does not succeed, returns the actual error encountered.

Parameters
T1float

Lower limit of integration, [K]

T2float

Upper limit of integration, [K]

methodstr

Method for which to find the integral

Returns
integralfloat

Calculated integral of the property over the given range, [units]

critical_zero = False

Whether or not the property is declining and reaching zero at the critical point. This is used by numerical solvers.

extrapolate(T, method, in_range='error')[source]

Method to perform extrapolation on a given method according to the extrapolation setting.

Parameters
Tfloat

Temperature at which to extrapolate the property, [K]

methodstr

The method to use, [-]

in_rangestr

How to handle inputs which are not outside the temperature limits; set to ‘low’ to use the low T extrapolation, ‘high’ to use the high T extrapolation, ‘nearest’ to use the nearest value, and ‘error’ or anything else to raise an error in those cases, [-]

Returns
propfloat

Calculated property, [units]

property extrapolation

The string setting of the current extrapolation settings. This can be set to a new value to change which extrapolation setting is used.

fit_add_model(name, model, Ts, data, **kwargs)[source]

Method to add a new emperical fit equation to the object by fitting its coefficients to specified data. Once added, the new method is set as the default.

A number of hardcoded model names are implemented; other models are not supported.

This is a wrapper around TDependentProperty.fit_data_to_model and TDependentProperty.add_correlation.

The data is also stored in the object as a tabular method with the name name`+’_data’, through :obj:`TDependentProperty.add_tabular_data.

Parameters
namestr

The name of the coefficient set; user specified, [-]

modelstr

A string representing the supported models, [-]

Tslist[float]

Temperatures of the data points, [K]

datalist[float]

Data points, [units]

kwargsdict

Various keyword arguments accepted by fit_data_to_model, [-]

classmethod fit_data_to_model(Ts, data, model, model_kwargs=None, fit_method='lm', sigma=None, use_numba=False, do_statistics=False, guesses=None, solver_kwargs=None, objective='MeanSquareErr', multiple_tries=False, multiple_tries_max_err=1e-05, multiple_tries_max_objective='MeanRelErr', params_points_max=0, model_selection=None)[source]

Method to fit T-dependent property data to one of the available model correlations.

Parameters
Tslist[float]

Temperatures of the data points, [K]

datalist[float]

Data points, [units]

modelstr

A string representing the supported models, [-]

model_kwargsdict, optional

Various keyword arguments accepted by the model; not necessary for most models. Parameters which are normally fit, can be specified here as well with a constant value and then that fixed value will be used instead of fitting the parameter. [-]

fit_methodstr, optional

The fit method to use; one of {lm, trf, dogbox, differential_evolution}, [-]

sigmaNone or list[float]

Uncertainty parameters used by curve_fit, [-]

use_numbabool, optional

Whether or not to try to use numba to speed up the computation, [-]

do_statisticsbool, optional

Whether or not to compute statistical measures on the outputs, [-]

guessesdict[str: float], optional

Parameter guesses, by name; any number of parameters can be specified, [-]

solver_kwargsdict

Extra parameters to be passed to the solver chosen, [-]

objectivestr

The minimimization criteria; supported by differential_evolution. One of:

  • ‘MeanAbsErr’: Mean absolute error

  • ‘MeanRelErr’: Mean relative error

  • ‘MeanSquareErr’: Mean squared absolute error

  • ‘MeanSquareRelErr’: Mean squared relative error

  • ‘MaxAbsErr’: Maximum absolute error

  • ‘MaxRelErr’: Maximum relative error

  • ‘MaxSquareErr’: Maximum squared absolute error

  • ‘MaxSquareRelErr’: Maximum squared relative error

multiple_triesbool or int

For most solvers, multiple initial guesses are available and the best guess is normally tried. When this is set to True, all guesses are tried until one is found with an error lower than multiple_tries_max_err. If an int is supplied, the best multiple_tries guesses are tried only. [-]

multiple_tries_max_errfloat

Only used when multiple_tries is true; if a solution is found with lower error than this, no further guesses are tried, [-]

multiple_tries_max_objectivestr

The error criteria to use for minimization, [-]

params_points_maxint

When this is 0, a fit can be performed to a correlation with as many points as correlation parameters. If this is 1, a correlation can only be fit with points-1 parameters, and so on, [-]

model_selectionNone or str

One of (None, ‘AICc’, ‘BIC’, or ‘min(BIC, AICc)’). If set fits with different numbers of parameters will be tried (if applicable to the model) and the best statistical fit will be chosen [-]

Returns
coefficientsdict[str: float]

Calculated coefficients, [various]

statisticsdict[str: float]

Statistics, calculated and returned only if do_statistics is True, [-]

classmethod from_json(json_repr, cache=None)[source]

Method to create a property model from a JSON serialization of another property model.

Parameters
json_reprdict

JSON-friendly representation, [-]

Returns
modelTDependentProperty or TPDependentProperty

Newly created object from the json serialization, [-]

Notes

It is important that the input string be in the same format as that created by TDependentProperty.as_json.

interpolate(T, name)[source]

Method to perform interpolation on a given tabular data set previously added via add_tabular_data. This method will create the interpolators the first time it is used on a property set, and store them for quick future use.

Interpolation is cubic-spline based if 5 or more points are available, and linearly interpolated if not. Extrapolation is always performed linearly. This function uses the transforms interpolation_T, interpolation_property, and interpolation_property_inv if set. If any of these are changed after the interpolators were first created, new interpolators are created with the new transforms. All interpolation is performed via the interp1d function.

Parameters
Tfloat

Temperature at which to interpolate the property, [K]

namestr

The name assigned to the tabular data set

Returns
propfloat

Calculated property, [units]

interpolation_T = None
interpolation_T_inv = None
interpolation_property = None
interpolation_property_inv = None
property method

Method used to set a specific property method or to obtain the name of the method in use.

When setting a method, an exception is raised if the method specified isnt’t available for the chemical with the provided information.

If method is None, no calculations can be performed.

Parameters
methodstr

Method to use, [-]

name = 'Property name'
plot_T_dependent_property(Tmin=None, Tmax=None, methods=[], pts=250, only_valid=True, order=0, show=True, tabular_points=True, axes='semilogy')[source]

Method to create a plot of the property vs temperature according to either a specified list of methods, or user methods (if set), or all methods. User-selectable number of points, and temperature range. If only_valid is set,:obj:test_method_validity will be used to check if each temperature in the specified range is valid, and test_property_validity will be used to test the answer, and the method is allowed to fail; only the valid points will be plotted. Otherwise, the result will be calculated and displayed as-is. This will not suceed if the method fails.

Parameters
Tminfloat

Minimum temperature, to begin calculating the property, [K]

Tmaxfloat

Maximum temperature, to stop calculating the property, [K]

methodslist, optional

List of methods to consider

ptsint, optional

A list of points to calculate the property at; if Tmin to Tmax covers a wide range of method validities, only a few points may end up calculated for a given method so this may need to be large

only_validbool

If True, only plot successful methods and calculated properties, and handle errors; if False, attempt calculation without any checking and use methods outside their bounds

showbool

If True, displays the plot; otherwise, returns it

tabular_pointsbool, optional

If True, tabular data will only be shows as the original points; otherwise interpolated values are shown, [-]

polynomial_from_method(method, n=None, start_n=3, max_n=30, eval_pts=100, fit_form='POLY_FIT', fit_method=None)[source]

Method to fit a T-dependent property to a polynomial. The degree of the polynomial can be specified with the n parameter, or it will be automatically selected for maximum accuracy.

Parameters
methodstr

Method name to fit, [-]

nint, optional

The degree of the polynomial, if specified

start_nint

If n is not specified, all polynomials of degree start_n to max_n will be tried and the highest-accuracy will be selected; [-]

max_nint

If n is not specified, all polynomials of degree start_n to max_n will be tried and the highest-accuracy will be selected; [-]

eval_ptsint

The number of points to evaluate the fitted functions at to check for accuracy; more is better but slower, [-]

fit_formstr

The shape of the polynomial; options are ‘POLY_FIT’, ‘EXP_POLY_FIT’, ‘EXP_POLY_FIT_LN_TAU’, and ‘POLY_FIT_LN_TAU’ [-]

Returns
coeffslist[float]

Fit coefficients, [-]

Tminfloat

The minimum temperature used for the fitting, [K]

Tmaxfloat

The maximum temperature used for the fitting, [K]

err_avgfloat

Mean error in the evaluated points, [-]

err_stdfloat

Standard deviation of errors in the evaluated points, [-]

min_ratiofloat

Lowest ratio of calc/actual in any found points, [-]

max_ratiofloat

Highest ratio of calc/actual in any found points, [-]

property_max = 10000.0
property_min = 0
ranked_methods = []
solve_property(goal)[source]

Method to solve for the temperature at which a property is at a specified value. T_dependent_property is used to calculate the value of the property as a function of temperature.

Checks the given property value with test_property_validity first and raises an exception if it is not valid.

Parameters
goalfloat

Propoerty value desired, [units]

Returns
Tfloat

Temperature at which the property is the specified value [K]

test_method_validity(T, method)[source]

Method to test the validity of a specified method for a given temperature. Demo function for testing only; must be implemented according to the methods available for each individual method. Include the interpolation check here.

Parameters
Tfloat

Temperature at which to determine the validity of the method, [K]

methodstr

Method name to use

Returns
validitybool

Whether or not a specifid method is valid

classmethod test_property_validity(prop)[source]

Method to test the validity of a calculated property. Normally, this method is used by a given property class, and has maximum and minimum limits controlled by the variables property_min and property_max.

Parameters
propfloat

property to be tested, [units]

Returns
validitybool

Whether or not a specifid method is valid

units = 'Property units'
valid_methods(T=None)[source]

Method to obtain a sorted list of methods that have data available to be used. The methods are ranked in the following order:

  • The currently selected method is first (if one is selected)

  • Other available methods are ranked by the attribute ranked_methods

If T is provided, the methods will be checked against the temperature limits of the correlations as well.

Parameters
Tfloat or None

Temperature at which to test methods, [K]

Returns
sorted_valid_methodslist

Sorted lists of methods valid at T according to test_method_validity, [-]

Temperature and Pressure Dependent

class thermo.utils.TPDependentProperty(extrapolation, **kwargs)[source]

Bases: thermo.utils.t_dependent_property.TDependentProperty

Class for calculating temperature and pressure dependent chemical properties.

On creation, a TPDependentProperty examines all the possible methods implemented for calculating the property, loads whichever coefficients it needs (unless load_data is set to False), examines its input parameters, and selects the method it prefers. This method will continue to be used for all calculations until the method is changed by setting a new method to the to method attribute.

Because many pressure dependent property methods are implemented as a low-pressure correlation and a high-pressure correlation, this class works essentially the same as TDependentProperty but with extra methods that accept pressure as a parameter.

The object also selects the pressure-dependent method it prefers. This method will continue to be used for all pressure-dependent calculations until the pressure-dependent method is changed by setting a new method_P to the to method_P attribute.

The default list of preferred pressure-dependent method orderings is at ranked_methods_P for all properties; the order can be modified there in-place, and this will take effect on all new TPDependentProperty instances created but NOT on existing instances.

Tabular data can be provided as either temperature-dependent or pressure-dependent data. The same extrapolation settings as in TDependentProperty are implemented here for the low-pressure correlations.

In addition to the methods and attributes shown here, all those from TPDependentProperty are also available.

Attributes
method_Pstr

Method used to set or get a specific property method.

methodstr

Method used to set a specific property method or to obtain the name of the method in use.

all_methodsset

All low-pressure methods available, [-]

all_methods_Pset

All pressure-dependent methods available, [-]

Methods

TP_dependent_property(T, P)

Method to calculate the property given a temperature and pressure according to the selected method_P and method.

TP_dependent_property_derivative_P(T, P[, order])

Method to calculate a derivative of a temperature and pressure dependent property with respect to pressure at constant temperature, of a given order, according to the selected method_P.

TP_dependent_property_derivative_T(T, P[, order])

Method to calculate a derivative of a temperature and pressure dependent property with respect to temperature at constant pressure, of a given order, according to the selected method_P.

TP_or_T_dependent_property(T, P)

Method to calculate the property given a temperature and pressure according to the selected method_P and method.

__call__(T, P)

Convenience method to calculate the property; calls TP_dependent_property.

add_method(f[, Tmin, Tmax, f_der, f_der2, ...])

Define a new method and select it for future property calculations.

add_tabular_data(Ts, properties[, name, ...])

Method to set tabular data to be used for interpolation.

add_tabular_data_P(Ts, Ps, properties[, ...])

Method to set tabular data to be used for interpolation.

calculate(T, method)

Method to calculate a property with a specified method, with no validity checking or error handling.

calculate_derivative_P(P, T, method[, order])

Method to calculate a derivative of a temperature and pressure dependent property with respect to pressure at constant temperature, of a given order using a specified method.

calculate_derivative_T(T, P, method[, order])

Method to calculate a derivative of a temperature and pressure dependent property with respect to temperature at constant pressure, of a given order using a specified method.

extrapolate(T, method[, in_range])

Method to perform extrapolation on a given method according to the extrapolation setting.

plot_TP_dependent_property([Tmin, Tmax, ...])

Method to create a plot of the property vs temperature and pressure according to either a specified list of methods, or user methods (if set), or all methods.

plot_isobar(P[, Tmin, Tmax, methods_P, pts, ...])

Method to create a plot of the property vs temperature at a specific pressure according to either a specified list of methods, or user methods (if set), or all methods.

plot_isotherm(T[, Pmin, Pmax, methods_P, ...])

Method to create a plot of the property vs pressure at a specified temperature according to either a specified list of methods, or the user methods (if set), or all methods.

solve_property(goal)

Method to solve for the temperature at which a property is at a specified value.

test_method_validity(T, method)

Method to test the validity of a specified method for a given temperature.

test_property_validity(prop)

Method to test the validity of a calculated property.

valid_methods([T])

Method to obtain a sorted list of methods that have data available to be used.

valid_methods_P([T, P])

Method to obtain a sorted list of high-pressure methods that have data available to be used.

TP_dependent_property(T, P)[source]

Method to calculate the property given a temperature and pressure according to the selected method_P and method. The pressure-dependent method is always used and required to succeed. The result is checked with test_property_validity.

If the method does not succeed, returns None.

Parameters
Tfloat

Temperature at which to calculate the property, [K]

Pfloat

Pressure at which to calculate the property, [Pa]

Returns
propfloat

Calculated property, [units]

TP_dependent_property_derivative_P(T, P, order=1)[source]

Method to calculate a derivative of a temperature and pressure dependent property with respect to pressure at constant temperature, of a given order, according to the selected method_P.

Calls calculate_derivative_P internally to perform the actual calculation.

derivative=d(property)dPT\text{derivative} = \frac{d (\text{property})}{d P}|_{T}
Parameters
Tfloat

Temperature at which to calculate the derivative, [K]

Pfloat

Pressure at which to calculate the derivative, [Pa]

orderint

Order of the derivative, >= 1

Returns
dprop_dP_Tfloat

Calculated derivative property, [units/Pa^order]

TP_dependent_property_derivative_T(T, P, order=1)[source]

Method to calculate a derivative of a temperature and pressure dependent property with respect to temperature at constant pressure, of a given order, according to the selected method_P.

Calls calculate_derivative_T internally to perform the actual calculation.

derivative=d(property)dTP\text{derivative} = \frac{d (\text{property})}{d T}|_{P}
Parameters
Tfloat

Temperature at which to calculate the derivative, [K]

Pfloat

Pressure at which to calculate the derivative, [Pa]

orderint

Order of the derivative, >= 1

Returns
dprop_dT_Pfloat

Calculated derivative property, [units/K^order]

TP_or_T_dependent_property(T, P)[source]

Method to calculate the property given a temperature and pressure according to the selected method_P and method. The pressure-dependent method is always tried. The result is checked with test_property_validity.

If the pressure-dependent method does not succeed, the low-pressure method is tried and its result is returned.

Warning

It can seem like a good idea to switch between a low-pressure and a high-pressure method if the high pressure method is not working, however it can cause discontinuities and prevent numerical methods from converging

Parameters
Tfloat

Temperature at which to calculate the property, [K]

Pfloat

Pressure at which to calculate the property, [Pa]

Returns
propfloat

Calculated property, [units]

T_limits = {}

Dictionary containing method: (Tmin, Tmax) pairs for all methods applicable to the chemical

__call__(T, P)[source]

Convenience method to calculate the property; calls TP_dependent_property. Caches previously calculated value, which is an overhead when calculating many different values of a property. See TP_dependent_property for more details as to the calculation procedure.

Parameters
Tfloat

Temperature at which to calculate the property, [K]

Pfloat

Pressure at which to calculate the property, [Pa]

Returns
propfloat

Calculated property, [units]

add_method(f, Tmin=None, Tmax=None, f_der=None, f_der2=None, f_der3=None, f_int=None, f_int_over_T=None, name=None)

Define a new method and select it for future property calculations.

Parameters
fcallable

Object which calculates the property given the temperature in K, [-]

Tminfloat, optional

Minimum temperature to use the method at, [K]

Tmaxfloat, optional

Maximum temperature to use the method at, [K]

f_dercallable, optional

If specified, should take as an argument the temperature and return the first derivative of the property, [-]

f_der2callable, optional

If specified, should take as an argument the temperature and return the second derivative of the property, [-]

f_der3callable, optional

If specified, should take as an argument the temperature and return the third derivative of the property, [-]

f_intcallable, optional

If specified, should take T1 and T2 and return the integral of the property from T1 to T2, [-]

f_int_over_Tcallable, optional

If specified, should take T1 and T2 and return the integral of the property over T from T1 to T2, [-]

namestr, optional

Name of method.

Notes

Once a custom method has been added to an object, that object can no longer be serialized to json and the TDependentProperty.__repr__ method can no longer be used to reconstruct the object completely.

add_tabular_data(Ts, properties, name=None, check_properties=True)

Method to set tabular data to be used for interpolation. Ts must be in increasing order. If no name is given, data will be assigned the name ‘Tabular data series #x’, where x is the number of previously added tabular data series.

After adding the data, this method becomes the selected method.

Parameters
Tsarray_like

Increasing array of temperatures at which properties are specified, [K]

propertiesarray_like

List of properties at Ts, [units]

namestr, optional

Name assigned to the data

check_propertiesbool

If True, the properties will be checked for validity with test_property_validity and raise an exception if any are not valid

add_tabular_data_P(Ts, Ps, properties, name=None, check_properties=True)[source]

Method to set tabular data to be used for interpolation. Ts and Ps must be in increasing order. If no name is given, data will be assigned the name ‘Tabular data series #x’, where x is the number of previously added tabular data series.

After adding the data, this method becomes the selected high-pressure method.

Parameters
Tsarray_like

Increasing array of temperatures at which properties are specified, [K]

Psarray_like

Increasing array of pressures at which properties are specified, [Pa]

propertiesarray_like

List of properties at Ts and Ps; the data should be indexed [P][T], [units]

namestr, optional

Name assigned to the data

check_propertiesbool

If True, the properties will be checked for validity with test_property_validity and raise an exception if any are not valid

calculate(T, method)

Method to calculate a property with a specified method, with no validity checking or error handling. Demo function for testing only; must be implemented according to the methods available for each individual method. Include the interpolation call here.

Parameters
Tfloat

Temperature at which to calculate the property, [K]

methodstr

Method name to use

Returns
propfloat

Calculated property, [units]

calculate_derivative_P(P, T, method, order=1)[source]

Method to calculate a derivative of a temperature and pressure dependent property with respect to pressure at constant temperature, of a given order using a specified method. Uses SciPy’s derivative function, with a delta of 0.01 Pa and a number of points equal to 2*order + 1.

This method can be overwritten by subclasses who may perfer to add analytical methods for some or all methods as this is much faster.

If the calculation does not succeed, returns the actual error encountered.

Parameters
Pfloat

Pressure at which to calculate the derivative, [Pa]

Tfloat

Temperature at which to calculate the derivative, [K]

methodstr

Method for which to find the derivative

orderint

Order of the derivative, >= 1

Returns
dprop_dP_Tfloat

Calculated derivative property at constant temperature, [units/Pa^order]

calculate_derivative_T(T, P, method, order=1)[source]

Method to calculate a derivative of a temperature and pressure dependent property with respect to temperature at constant pressure, of a given order using a specified method. Uses SciPy’s derivative function, with a delta of 1E-6 K and a number of points equal to 2*order + 1.

This method can be overwritten by subclasses who may perfer to add analytical methods for some or all methods as this is much faster.

If the calculation does not succeed, returns the actual error encountered.

Parameters
Tfloat

Temperature at which to calculate the derivative, [K]

Pfloat

Pressure at which to calculate the derivative, [Pa]

methodstr

Method for which to find the derivative

orderint

Order of the derivative, >= 1

Returns
dprop_dT_Pfloat

Calculated derivative property at constant pressure, [units/K^order]

extrapolate(T, method, in_range='error')

Method to perform extrapolation on a given method according to the extrapolation setting.

Parameters
Tfloat

Temperature at which to extrapolate the property, [K]

methodstr

The method to use, [-]

in_rangestr

How to handle inputs which are not outside the temperature limits; set to ‘low’ to use the low T extrapolation, ‘high’ to use the high T extrapolation, ‘nearest’ to use the nearest value, and ‘error’ or anything else to raise an error in those cases, [-]

Returns
propfloat

Calculated property, [units]

property extrapolation

The string setting of the current extrapolation settings. This can be set to a new value to change which extrapolation setting is used.

interpolation_T = None
interpolation_T_inv = None
interpolation_property = None
interpolation_property_inv = None
property method

Method used to set a specific property method or to obtain the name of the method in use.

When setting a method, an exception is raised if the method specified isnt’t available for the chemical with the provided information.

If method is None, no calculations can be performed.

Parameters
methodstr

Method to use, [-]

property method_P

Method used to set or get a specific property method.

An exception is raised if the method specified isnt’t available for the chemical with the provided information.

Parameters
methodstr or list

Methods by name to be considered or preferred

name = 'Property name'
plot_TP_dependent_property(Tmin=None, Tmax=None, Pmin=None, Pmax=None, methods_P=[], pts=15, only_valid=True)[source]

Method to create a plot of the property vs temperature and pressure according to either a specified list of methods, or user methods (if set), or all methods. User-selectable number of points for each variable. If only_valid is set,:obj:test_method_validity_P will be used to check if each condition in the specified range is valid, and test_property_validity will be used to test the answer, and the method is allowed to fail; only the valid points will be plotted. Otherwise, the result will be calculated and displayed as-is. This will not suceed if the any method fails for any point.

Parameters
Tminfloat

Minimum temperature, to begin calculating the property, [K]

Tmaxfloat

Maximum temperature, to stop calculating the property, [K]

Pminfloat

Minimum pressure, to begin calculating the property, [Pa]

Pmaxfloat

Maximum pressure, to stop calculating the property, [Pa]

methods_Plist, optional

List of methods to plot

ptsint, optional

A list of points to calculate the property at for both temperature and pressure; pts^2 points will be calculated.

only_validbool

If True, only plot successful methods and calculated properties, and handle errors; if False, attempt calculation without any checking and use methods outside their bounds

plot_isobar(P, Tmin=None, Tmax=None, methods_P=[], pts=50, only_valid=True, show=True)[source]

Method to create a plot of the property vs temperature at a specific pressure according to either a specified list of methods, or user methods (if set), or all methods. User-selectable number of points, and temperature range. If only_valid is set,:obj:test_method_validity_P will be used to check if each condition in the specified range is valid, and test_property_validity will be used to test the answer, and the method is allowed to fail; only the valid points will be plotted. Otherwise, the result will be calculated and displayed as-is. This will not suceed if the method fails.

Parameters
Pfloat

Pressure for the isobar, [Pa]

Tminfloat

Minimum temperature, to begin calculating the property, [K]

Tmaxfloat

Maximum temperature, to stop calculating the property, [K]

methods_Plist, optional

List of methods to consider

ptsint, optional

A list of points to calculate the property at; if Tmin to Tmax covers a wide range of method validities, only a few points may end up calculated for a given method so this may need to be large

only_validbool

If True, only plot successful methods and calculated properties, and handle errors; if False, attempt calculation without any checking and use methods outside their bounds

plot_isotherm(T, Pmin=None, Pmax=None, methods_P=[], pts=50, only_valid=True, show=True)[source]

Method to create a plot of the property vs pressure at a specified temperature according to either a specified list of methods, or the user methods (if set), or all methods. User-selectable number of points, and pressure range. If only_valid is set, test_method_validity_P will be used to check if each condition in the specified range is valid, and test_property_validity will be used to test the answer, and the method is allowed to fail; only the valid points will be plotted. Otherwise, the result will be calculated and displayed as-is. This will not suceed if the method fails.

Parameters
Tfloat

Temperature at which to create the plot, [K]

Pminfloat

Minimum pressure, to begin calculating the property, [Pa]

Pmaxfloat

Maximum pressure, to stop calculating the property, [Pa]

methods_Plist, optional

List of methods to consider

ptsint, optional

A list of points to calculate the property at; if Pmin to Pmax covers a wide range of method validities, only a few points may end up calculated for a given method so this may need to be large

only_validbool

If True, only plot successful methods and calculated properties, and handle errors; if False, attempt calculation without any checking and use methods outside their bounds

showbool

If True, displays the plot; otherwise, returns it

property_max = 10000.0
property_min = 0
ranked_methods = []
solve_property(goal)

Method to solve for the temperature at which a property is at a specified value. T_dependent_property is used to calculate the value of the property as a function of temperature.

Checks the given property value with test_property_validity first and raises an exception if it is not valid.

Parameters
goalfloat

Propoerty value desired, [units]

Returns
Tfloat

Temperature at which the property is the specified value [K]

test_method_validity(T, method)

Method to test the validity of a specified method for a given temperature. Demo function for testing only; must be implemented according to the methods available for each individual method. Include the interpolation check here.

Parameters
Tfloat

Temperature at which to determine the validity of the method, [K]

methodstr

Method name to use

Returns
validitybool

Whether or not a specifid method is valid

classmethod test_property_validity(prop)

Method to test the validity of a calculated property. Normally, this method is used by a given property class, and has maximum and minimum limits controlled by the variables property_min and property_max.

Parameters
propfloat

property to be tested, [units]

Returns
validitybool

Whether or not a specifid method is valid

units = 'Property units'
valid_methods(T=None)

Method to obtain a sorted list of methods that have data available to be used. The methods are ranked in the following order:

  • The currently selected method is first (if one is selected)

  • Other available methods are ranked by the attribute ranked_methods

If T is provided, the methods will be checked against the temperature limits of the correlations as well.

Parameters
Tfloat or None

Temperature at which to test methods, [K]

Returns
sorted_valid_methodslist

Sorted lists of methods valid at T according to test_method_validity, [-]

valid_methods_P(T=None, P=None)[source]

Method to obtain a sorted list of high-pressure methods that have data available to be used. The methods are ranked in the following order:

  • The currently selected method_P is first (if one is selected)

  • Other available pressure-depenent methods are ranked by the attribute ranked_methods_P

If T and P are provided, the methods will be checked against the temperature and pressure limits of the correlations as well.

Parameters
Tfloat

Temperature at which to test methods, [K]

Pfloat

Pressure at which to test methods, [Pa]

Returns
sorted_valid_methods_Plist

Sorted lists of methods valid at T and P according to test_method_validity_P

Temperature, Pressure, and Composition Dependent

class thermo.utils.MixtureProperty(**kwargs)[source]

Bases: object

Attributes
correct_pressure_pure

Method to set the pressure-dependence of the model; if set to False, only temperature dependence is used, and if True, temperature and pressure dependence are used.

method

Method to set the T, P, and composition dependent property method desired.

prop_cached

Methods

__call__(T, P[, zs, ws])

Convenience method to calculate the property; calls mixture_property.

as_json([cache, option])

Method to create a JSON serialization of the mixture property which can be stored, and reloaded later.

calculate_derivative_P(P, T, zs, ws, method)

Method to calculate a derivative of a mixture property with respect to pressure at constant temperature and composition of a given order using a specified method.

calculate_derivative_T(T, P, zs, ws, method)

Method to calculate a derivative of a mixture property with respect to temperature at constant pressure and composition of a given order using a specified method.

excess_property(T, P[, zs, ws])

Method to calculate the excess property with sanity checking and without specifying a specific method.

from_json(json_repr[, cache])

Method to create a MixtureProperty from a JSON serialization of another MixtureProperty.

mixture_property(T, P[, zs, ws])

Method to calculate the property with sanity checking and without specifying a specific method.

partial_property(T, P, i[, zs, ws])

Method to calculate the partial molar property with sanity checking and without specifying a specific method for the specified compound index and composition.

plot_isobar(P[, zs, ws, Tmin, Tmax, ...])

Method to create a plot of the property vs temperature at a specific pressure and composition according to either a specified list of methods, or the selected method.

plot_isotherm(T[, zs, ws, Pmin, Pmax, ...])

Method to create a plot of the property vs pressure at a specified temperature and composition according to either a specified list of methods, or the set method.

plot_property([zs, ws, Tmin, Tmax, Pmin, ...])

Method to create a plot of the property vs temperature and pressure according to either a specified list of methods, or the selected method.

property_derivative_P(T, P[, zs, ws, order])

Method to calculate a derivative of a mixture property with respect to pressure at constant temperature and composition, of a given order.

property_derivative_T(T, P[, zs, ws, order])

Method to calculate a derivative of a mixture property with respect to temperature at constant pressure and composition, of a given order.

test_method_validity(T, P, zs, ws, method)

Method to test the validity of a specified method for the given conditions.

test_property_validity(prop)

Method to test the validity of a calculated property.

add_excess_correlation

calculate

calculate_excess_property

calculate_pures

calculate_pures_P

calculate_pures_corrected

plot_binary

plot_isobaric_isothermal

pure_objs

RAISE_PROPERTY_CALCULATION_ERROR = False
TP_zs_ws_cached = (None, None, None, None)
Tmax

Maximum temperature at which no method can calculate the property above.

Tmin

Minimum temperature at which no method can calculate the property under.

add_excess_correlation(name, model, **kwargs)[source]
all_methods

Set of all methods available for a given set of information; filled by load_all_methods.

as_json(cache=None, option=0)[source]

Method to create a JSON serialization of the mixture property which can be stored, and reloaded later.

Parameters
referencesint

How to handle references to other objects; internal parameter, [-]

Returns
json_reprdict

JSON-friendly representation, [-]

calculate(T, P, zs, ws, method)[source]
calculate_derivative_P(P, T, zs, ws, method, order=1)[source]

Method to calculate a derivative of a mixture property with respect to pressure at constant temperature and composition of a given order using a specified method. Uses SciPy’s derivative function, with a delta of 0.01 Pa and a number of points equal to 2*order + 1.

This method can be overwritten by subclasses who may perfer to add analytical methods for some or all methods as this is much faster.

If the calculation does not succeed, returns the actual error encountered.

Parameters
Pfloat

Pressure at which to calculate the derivative, [Pa]

Tfloat

Temperature at which to calculate the derivative, [K]

zslist[float]

Mole fractions of all species in the mixture, [-]

wslist[float]

Weight fractions of all species in the mixture, [-]

methodstr

Method for which to find the derivative

orderint

Order of the derivative, >= 1

Returns
d_prop_d_P_at_Tfloat

Calculated derivative property at constant temperature, [units/Pa^order]

calculate_derivative_T(T, P, zs, ws, method, order=1)[source]

Method to calculate a derivative of a mixture property with respect to temperature at constant pressure and composition of a given order using a specified method. Uses SciPy’s derivative function, with a delta of 1E-6 K and a number of points equal to 2*order + 1.

This method can be overwritten by subclasses who may perfer to add analytical methods for some or all methods as this is much faster.

If the calculation does not succeed, returns the actual error encountered.

Parameters
Tfloat

Temperature at which to calculate the derivative, [K]

Pfloat

Pressure at which to calculate the derivative, [Pa]

zslist[float]

Mole fractions of all species in the mixture, [-]

wslist[float]

Weight fractions of all species in the mixture, [-]

methodstr

Method for which to find the derivative

orderint

Order of the derivative, >= 1

Returns
d_prop_d_T_at_Pfloat

Calculated derivative property at constant pressure, [units/K^order]

calculate_excess_property(T, P, zs, ws, method)[source]
calculate_pures(T, objs=None)[source]
calculate_pures_P(T, P, fallback=False, objs=None)[source]
calculate_pures_corrected(T, P, fallback=False, objs=None)[source]
property correct_pressure_pure

Method to set the pressure-dependence of the model; if set to False, only temperature dependence is used, and if True, temperature and pressure dependence are used.

excess_property(T, P, zs=None, ws=None)[source]

Method to calculate the excess property with sanity checking and without specifying a specific method. This requires the calculation of the property as a function of composition at the limiting concentration of each component. One or both of zs and ws are required.

mE=mmixing=mimi,purezim^E = m_{mixing} = m - \sum_i m_{i, pure}\cdot z_i
Parameters
Tfloat

Temperature at which to calculate the excess property, [K]

Pfloat

Pressure at which to calculate the excess property, [Pa]

zslist[float], optional

Mole fractions of all species in the mixture, [-]

wslist[float], optional

Weight fractions of all species in the mixture, [-]

Returns
excess_propfloat

Calculated excess property, [units]

classmethod from_json(json_repr, cache=None)[source]

Method to create a MixtureProperty from a JSON serialization of another MixtureProperty.

Parameters
json_reprdict

JSON-friendly representation, [-]

Returns
constantsMixtureProperty

Newly created object from the json serialization, [-]

Notes

It is important that the input string be in the same format as that created by MixtureProperty.as_json.

json_version = 1
property method

Method to set the T, P, and composition dependent property method desired. See the all_methods attribute for a list of methods valid for the specified chemicals and inputs.

mixture_correlations

Dictionary containing lookups for coefficient-based mixture excess models.

mixture_property(T, P, zs=None, ws=None)[source]

Method to calculate the property with sanity checking and without specifying a specific method. valid_methods is used to obtain a sorted list of methods to try. Methods are then tried in order until one succeeds. The methods are allowed to fail, and their results are checked with test_property_validity. On success, the used method is stored in the variable method.

If method is set, this method is first checked for validity with test_method_validity for the specified temperature, and if it is valid, it is then used to calculate the property. The result is checked for validity, and returned if it is valid. If either of the checks fail, the function retrieves a full list of valid methods with valid_methods and attempts them as described above.

If no methods are found which succeed, returns None. One or both of zs and ws are required.

Parameters
Tfloat

Temperature at which to calculate the property, [K]

Pfloat

Pressure at which to calculate the property, [Pa]

zslist[float], optional

Mole fractions of all species in the mixture, [-]

wslist[float], optional

Weight fractions of all species in the mixture, [-]

Returns
propfloat

Calculated property, [units]

name = 'Test'
non_json_attributes = ['TP_zs_ws_cached', 'prop_cached']
obj_references = ()
partial_property(T, P, i, zs=None, ws=None)[source]

Method to calculate the partial molar property with sanity checking and without specifying a specific method for the specified compound index and composition.

mˉi=((nTm)ni)T,P,nji\bar m_i = \left( \frac{\partial (n_T m)} {\partial n_i} \right)_{T, P, n_{j\ne i}}
Parameters
Tfloat

Temperature at which to calculate the partial property, [K]

Pfloat

Pressure at which to calculate the partial property, [Pa]

iint

Compound index, [-]

zslist[float], optional

Mole fractions of all species in the mixture, [-]

wslist[float], optional

Weight fractions of all species in the mixture, [-]

Returns
partial_propfloat

Calculated partial property, [units]

plot_binary(P=None, T=None, pts=30, Tmin=None, Tmax=None, Pmin=100000.0, Pmax=1000000.0, methods=[], only_valid=True)[source]
plot_isobar(P, zs=None, ws=None, Tmin=None, Tmax=None, methods=[], pts=50, only_valid=True)[source]

Method to create a plot of the property vs temperature at a specific pressure and composition according to either a specified list of methods, or the selected method. User-selectable number of points, and temperature range. If only_valid is set,:obj:test_method_validity will be used to check if each condition in the specified range is valid, and test_property_validity will be used to test the answer, and the method is allowed to fail; only the valid points will be plotted. Otherwise, the result will be calculated and displayed as-is. This will not suceed if the method fails. One or both of zs and ws are required.

Parameters
Pfloat

Pressure for the isobar, [Pa]

zslist[float], optional

Mole fractions of all species in the mixture, [-]

wslist[float], optional

Weight fractions of all species in the mixture, [-]

Tminfloat

Minimum temperature, to begin calculating the property, [K]

Tmaxfloat

Maximum temperature, to stop calculating the property, [K]

methodslist, optional

List of methods to consider

ptsint, optional

A list of points to calculate the property at; if Tmin to Tmax covers a wide range of method validities, only a few points may end up calculated for a given method so this may need to be large

only_validbool

If True, only plot successful methods and calculated properties, and handle errors; if False, attempt calculation without any checking and use methods outside their bounds

plot_isobaric_isothermal(T, P, methods=[], pts=50, only_valid=True, plot='property')[source]
plot_isotherm(T, zs=None, ws=None, Pmin=None, Pmax=None, methods=[], pts=50, only_valid=True)[source]

Method to create a plot of the property vs pressure at a specified temperature and composition according to either a specified list of methods, or the set method. User-selectable number of points, and pressure range. If only_valid is set, test_method_validity will be used to check if each condition in the specified range is valid, and test_property_validity will be used to test the answer, and the method is allowed to fail; only the valid points will be plotted. Otherwise, the result will be calculated and displayed as-is. This will not suceed if the method fails. One or both of zs and ws are required.

Parameters
Tfloat

Temperature at which to create the plot, [K]

zslist[float], optional

Mole fractions of all species in the mixture, [-]

wslist[float], optional

Weight fractions of all species in the mixture, [-]

Pminfloat

Minimum pressure, to begin calculating the property, [Pa]

Pmaxfloat

Maximum pressure, to stop calculating the property, [Pa]

methodslist, optional

List of methods to consider

ptsint, optional

A list of points to calculate the property at; if Pmin to Pmax covers a wide range of method validities, only a few points may end up calculated for a given method so this may need to be large

only_validbool

If True, only plot successful methods and calculated properties, and handle errors; if False, attempt calculation without any checking and use methods outside their bounds

plot_property(zs=None, ws=None, Tmin=None, Tmax=None, Pmin=100000.0, Pmax=1000000.0, methods=[], pts=15, only_valid=True)[source]

Method to create a plot of the property vs temperature and pressure according to either a specified list of methods, or the selected method. User-selectable number of points for each variable. If only_valid is set,:obj:test_method_validity will be used to check if each condition in the specified range is valid, and test_property_validity will be used to test the answer, and the method is allowed to fail; only the valid points will be plotted. Otherwise, the result will be calculated and displayed as-is. This will not suceed if the any method fails for any point. One or both of zs and ws are required.

Parameters
zslist[float], optional

Mole fractions of all species in the mixture, [-]

wslist[float], optional

Weight fractions of all species in the mixture, [-]

Tminfloat

Minimum temperature, to begin calculating the property, [K]

Tmaxfloat

Maximum temperature, to stop calculating the property, [K]

Pminfloat

Minimum pressure, to begin calculating the property, [Pa]

Pmaxfloat

Maximum pressure, to stop calculating the property, [Pa]

methodslist, optional

List of methods to consider

ptsint, optional

A list of points to calculate the property at for both temperature and pressure; pts^2 points will be calculated.

only_validbool

If True, only plot successful methods and calculated properties, and handle errors; if False, attempt calculation without any checking and use methods outside their bounds

prop_cached = None
property_derivative_P(T, P, zs=None, ws=None, order=1)[source]

Method to calculate a derivative of a mixture property with respect to pressure at constant temperature and composition, of a given order. Methods found valid by valid_methods are attempted until a method succeeds. If no methods are valid and succeed, None is returned.

Calls calculate_derivative_P internally to perform the actual calculation.

derivative=d(property)dPT,z\text{derivative} = \frac{d (\text{property})}{d P}|_{T, z}
Parameters
Tfloat

Temperature at which to calculate the derivative, [K]

Pfloat

Pressure at which to calculate the derivative, [Pa]

zslist[float], optional

Mole fractions of all species in the mixture, [-]

wslist[float], optional

Weight fractions of all species in the mixture, [-]

orderint

Order of the derivative, >= 1

Returns
d_prop_d_P_at_Tfloat

Calculated derivative property, [units/Pa^order]

property_derivative_T(T, P, zs=None, ws=None, order=1)[source]

Method to calculate a derivative of a mixture property with respect to temperature at constant pressure and composition, of a given order. Methods found valid by valid_methods are attempted until a method succeeds. If no methods are valid and succeed, None is returned.

Calls calculate_derivative_T internally to perform the actual calculation.

derivative=d(property)dTP,z\text{derivative} = \frac{d (\text{property})}{d T}|_{P, z}

One or both of zs and ws are required.

Parameters
Tfloat

Temperature at which to calculate the derivative, [K]

Pfloat

Pressure at which to calculate the derivative, [Pa]

zslist[float], optional

Mole fractions of all species in the mixture, [-]

wslist[float], optional

Weight fractions of all species in the mixture, [-]

orderint

Order of the derivative, >= 1

Returns
d_prop_d_T_at_Pfloat

Calculated derivative property, [units/K^order]

property_max = 10.0
property_min = 0.0
pure_objs()[source]
pure_reference_types = ()
pure_references = ()
ranked_methods = []
skip_method_validity_check = False

Flag to disable checking the validity of the method at the specified conditions. Saves a little time.

skip_prop_validity_check = False

Flag to disable checking the output of the value. Saves a little time.

test_method_validity(T, P, zs, ws, method)[source]

Method to test the validity of a specified method for the given conditions.

Parameters
Tfloat

Temperature at which to check method validity, [K]

Pfloat

Pressure at which to check method validity, [Pa]

zslist[float]

Mole fractions of all species in the mixture, [-]

wslist[float]

Weight fractions of all species in the mixture, [-]

methodstr

Method name to use

Returns
validitybool

Whether or not a specifid method is valid

classmethod test_property_validity(prop)[source]

Method to test the validity of a calculated property. Normally, this method is used by a given property class, and has maximum and minimum limits controlled by the variables property_min and property_max.

Parameters
propfloat

property to be tested, [units]

Returns
validitybool

Whether or not a specifid method is valid

units = 'test units'
vectorized = False