Interaction Parameters (thermo.interaction_parameters)

This module contains a small database of interaction parameters. Only two data sets are currently included, both from ChemSep. If you would like to add parameters to this project please make a referenced compilation of values and submit them on GitHub.

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

class thermo.interaction_parameters.InteractionParameterDB[source]

Basic database framework for interaction parameters.

Methods

get_ip_asymmetric_matrix(name, CASs, ip[, T])

Get a table of interaction parameters from a specified source for the specified parameters.

get_ip_automatic(CASs, ip_type, ip)

Get an interaction parameter for the first table containing the value.

get_ip_specific(name, CASs, ip)

Get an interaction parameter from a table.

get_ip_symmetric_matrix(name, CASs, ip[, T])

Get a table of interaction parameters from a specified source for the specified parameters.

get_tables_with_type(ip_type)

Get a list of tables which have a type of a parameter.

has_ip_specific(name, CASs, ip)

Check if a bip exists in a table.

load_json(file, name)

Load a json file from disk containing interaction coefficients.

validate_table(name)

Basic method which checks that all CAS numbers are valid, and that all elements of the data have non-nan values.

get_ip_asymmetric_matrix(name, CASs, ip, T=298.15)[source]

Get a table of interaction parameters from a specified source for the specified parameters.

Parameters
namestr

Name of the data table, [-]

CASsIterable[str]

CAS numbers; they do not need to be sorted, [-]

ipstr

Name of the parameter to retrieve, [-]

Tfloat, optional

Temperature of the system, [-]

Returns
valueslist[list[float]]

Interaction parameters specified by ip, [-]

Examples

>>> from thermo.interaction_parameters import IPDB
>>> IPDB.get_ip_symmetric_matrix(name='ChemSep NRTL', CASs=['64-17-5', '7732-18-5', '67-56-1'], ip='alphaij')
[[0.0, 0.2937, 0.3009], [0.2937, 0.0, 0.2999], [0.3009, 0.2999, 0.0]]
get_ip_automatic(CASs, ip_type, ip)[source]

Get an interaction parameter for the first table containing the value.

Parameters
CASsIterable[str]

CAS numbers; they do not need to be sorted, [-]

ip_typestr

Name of the parameter type, [-]

ipstr

Name of the parameter to retrieve, [-]

Returns
valuefloat

Interaction parameter specified by ip, [-]

Examples

>>> from thermo.interaction_parameters import IPDB
>>> IPDB.get_ip_automatic(CASs=['7727-37-9', '74-84-0'], ip_type='PR kij', ip='kij')
0.0533
get_ip_specific(name, CASs, ip)[source]

Get an interaction parameter from a table. If the specified parameter is missing, the default missing value as defined in the data file is returned instead.

Parameters
namestr

Name of the data table, [-]

CASsIterable[str]

CAS numbers; they do not need to be sorted, [-]

ipstr

Name of the parameter to retrieve, [-]

Returns
valuefloat

Interaction parameter specified by ip, [-]

Examples

Check if nitrogen-ethane as a PR BIP:

>>> from thermo.interaction_parameters import IPDB
>>> IPDB.get_ip_specific('ChemSep PR', ['7727-37-9', '74-84-0'], 'kij')
0.0533
get_ip_symmetric_matrix(name, CASs, ip, T=298.15)[source]

Get a table of interaction parameters from a specified source for the specified parameters. This method assumes symmetric parameters for speed.

Parameters
namestr

Name of the data table, [-]

CASsIterable[str]

CAS numbers; they do not need to be sorted, [-]

ipstr

Name of the parameter to retrieve, [-]

Tfloat, optional

Temperature of the system, [-]

Returns
valueslist[list[float]]

Interaction parameters specified by ip, [-]

Examples

>>> from thermo.interaction_parameters import IPDB
>>> IPDB.get_ip_symmetric_matrix(name='ChemSep PR', CASs=['7727-37-9', '74-84-0', '74-98-6'], ip='kij')
[[0.0, 0.0533, 0.0878], [0.0533, 0.0, 0.0011], [0.0878, 0.0011, 0.0]]
get_tables_with_type(ip_type)[source]

Get a list of tables which have a type of a parameter.

Parameters
ip_typestr

Name of the parameter type, [-]

Returns
table_nameslist[str]

Interaction parameter tables including ip, [-]

Examples

>>> from thermo.interaction_parameters import IPDB
>>> IPDB.get_tables_with_type('PR kij')
['ChemSep PR']
has_ip_specific(name, CASs, ip)[source]

Check if a bip exists in a table.

Parameters
namestr

Name of the data table, [-]

CASsIterable[str]

CAS numbers; they do not need to be sorted, [-]

ipstr

Name of the parameter to retrieve, [-]

Returns
presentbool

Whether or not the data is included in the table, [-]

Examples

Check if nitrogen-ethane as a PR BIP:

>>> from thermo.interaction_parameters import IPDB
>>> IPDB.has_ip_specific('ChemSep PR', ['7727-37-9', '74-84-0'], 'kij')
True
load_json(file, name)[source]

Load a json file from disk containing interaction coefficients.

The format for the file is as follows:

A data key containing a dictionary with a key:

  • CAS1 CAS2str

    The CAS numbers of both components, sorted from small to high as integers; they should have the ‘-’ symbols still in them and have a single space between them; if these are ternary or higher parameters, follow the same format for the other CAS numbers, [-]

  • valuesdict[strvarious]

    All of the values listed in the metadata element necessary keys; they are None if missing.

A metadata key containing:

  • symmetricbool

    Whether or not the interaction coefficients are missing.

  • sourcestr

    Where the data came from.

  • componentsint

    The number of components each interaction parameter is for; 2 for binary, 3 for ternary, etc.

  • necessary keyslist[str]

    Which elements are required in the data.

  • P dependentbool

    Whether or not the interaction parameters are pressure dependent.

  • missingdict[strfloat]

    Values which are missing are returned with these values

  • typeOne of ‘PR kij’, ‘SRK kij’, etc; used to group data but not

    tied into anything else.

  • T dependentbool

    Whether or not the data is T-dependent.

Parameters
filestr

Path to json file on disk which contains interaction coefficients, [-]

namestr

Name that the data read should be referred to by, [-]

validate_table(name)[source]

Basic method which checks that all CAS numbers are valid, and that all elements of the data have non-nan values. Raises an exception if any of the data is missing or is a nan value.

thermo.interaction_parameters.IPDB = <thermo.interaction_parameters.InteractionParameterDB object>

Basic database framework for interaction parameters.

Exmple database with NRTL and PR values from ChemSep. This is lazy-loaded, access it as thermo.interaction_parameters.IPDB.

class thermo.interaction_parameters.ScalarParameterDB[source]

Basic database framework for scalar parameters of various thermodynamic models. The following keys are used:

Peng-Robinson

Twu Volume-translated Peng-Robinson: TwuPRL, TwuPRM, TwuPRN, TwuPRc

Volume-translated Peng-Robinson: PRc

Peng-Robinson-Stryjek-Vera: PRSVkappa1

Peng-Robinson-Stryjek-Vera 2: PRSV2kappa1, PRSV2kappa2, PRSV2kappa3

SRK

Twu Volume-translated Peng-Robinson: TwuSRKL, TwuSRKM, TwuSRKN, TwuSRKc

Volume-translated Peng-Robinson: SRKc

Refinery Soave-Redlich-Kwong: APISRKS1, APISRKS2

MSRK: MSRKM, MSRKN, MSRKc

Predictive Soave-Redlich-Kwong: MCSRKC1, MCSRKC2, MCSRKC3

Excess Gibbs Energy Models

Regular Solution: RegularSolutionV, RegularSolutionSP

Methods

get_parameter_automatic(CAS, parameter)

Get an interaction parameter for the first table containing the value.

get_parameter_specific(name, CAS, parameter)

Get a parameter from a table.

get_parameter_vector(name, CASs, parameter)

Get a list of parameters from a specified source for the specified parameter.

get_tables_with_type(parameter)

Get a list of tables which have a parameter.

has_parameter_specific(name, CAS, parameter)

Check if a parameter exists in a table.

load_json

SPDB

Example scalar parameters for models. This is lazy-loaded, access it as thermo.interaction_parameters.SPDB.