chemicals_wrapper#
- chemicals_wrapper(phase, f, **kwargs)[source]#
Wrapper function for calling models in the
chemicals
package- Parameters:
phase (dict) – The OpenPNM Species object for which this model should calculate values. This object should ideally have all the necessary chemical properties in its
params
attribute, although this is optional as discussed below in relation tokwargs
.f (function) – The handle of the function to apply, such as
chemicals.viscosity.Letsou_Stiel
.kwargs – By default this function will use
openpnm.models.phase.default_argmap
to determine which names onphase
correspond to each argument required byf
. For instance,default_argmap['Tc'] = 'param.critical_temperature'
so any functions that needTc
will receivephase['param.critical_temperature']
. Some models only require the normal thermodynamic parameters, likeT
,Tc
, andPc
, so in many cases no additional arguments are needed beyond whats in the default argument map. However, other models require values that are themselves calcualted by another model, likeCvm
, or perhaps a list of constants likea0
,a1
, etc. It is necessary to provide these as keyword arguments, and they will be included indefault_argmap
as new entries or overwriting existing ones. Somu='pore.blah'
will passphase['pore.blah']
to themu
argument off
. Any arguments ending with ans
are assumed to refer to the individual properties of pure components in a mixture. Somus
means fetch the viscosity of each component as a list, like[1.3e-5, 1.9e-5]
. This function will trim the trailings
off any argument name before checking thedefault_argmap
so that the normal pure component values can be looked up.
Notes
This wrapper works with both pure and mixture phases, but the mixture models are very slow due to the way
chemicals
vectorizes code. For pure species it allows the computation of values at many different conditions in a vectorized way. The means that the conditions in each pore, such as temperature, pressure, etc can be passed and iterpreted as a list of conditions. For mixture models, however, the vectorization is done over the compositions, at a fixed condition. This means that we must do a pure-python for-loop (ie. slow) for each individual pore. As such, we have re-implemented several of the most useful mixing models offered bychemicals
inOpenPNM
, and include unit tests to ensure both implementations agree.