Skip to content
Snippets Groups Projects
Commit 46564b53 authored by Ian Bell's avatar Ian Bell
Browse files

An example notebook of obtaining second virials from mutants

parent 74840946
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
# Second virial coefficients for water-based mixtures
No departure term...
%% Cell type:code id: tags:
``` python
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
%matplotlib inline
import timeit
import pandas
import matplotlib.pyplot as plt, numpy as np
import matplotlib as mpl
mpl.rcParams['figure.dpi']= 100
import teqp
```
%% Cell type:code id: tags:
``` python
names = ['Water','Methane']
model = teqp.build_multifluid_model(names, '../mycp', '../mycp/dev/mixtures/mixture_binary_pairs.json')
def get_mutant(params):
""" Build a teqp-based mutant from the model parameters """
if 'type' not in params:
raise KeyError('type must be provided')
if params['type'] == 'invariant':
s = {
"0":{
"1": {
"BIP":{
"lambdaT": params['lambdaT'],
"phiT": params['phiT'],
"lambdaV": params['lambdaV'],
"phiV": params['phiV'],
"Fij": 0.0
},
"departure":{
"type" : "Exponential", "n" : [], "t" : [], "d" : [], "l" : []
}
}
}
}
return teqp.build_multifluid_mutant_invariant(model, s)
elif params['type'] == 'GERG':
s = {
"0":{
"1": {
"BIP":{
"betaT": params['betaT'],
"gammaT": params['gammaT'],
"betaV": params['betaV'],
"gammaV": params['gammaV'],
"Fij": 0.0
},
"departure":{
"type" : "Exponential", "n" : [], "t" : [], "d" : [], "l" : []
}
}
}
}
return teqp.build_multifluid_mutant(model, s)
else:
raise KeyError("Bad type for get_mutant")
mutant = get_mutant({'betaT':1.0,'betaV':1.0,'gammaV':1.0,'gammaT':1.2,"type":'GERG'})
z = np.array([0.3, 0.7])
teqp.get_B12vir(mutant, 300, z)
```
%% Output
-3.1276835541523647e-06
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment