Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
teqp_fork_old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sven Michael Pohl
teqp_fork_old
Commits
46564b53
Commit
46564b53
authored
3 years ago
by
Ian Bell
Browse files
Options
Downloads
Patches
Plain Diff
An example notebook of obtaining second virials from mutants
parent
74840946
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
notebooks/SecondVirials.ipynb
+120
-0
120 additions, 0 deletions
notebooks/SecondVirials.ipynb
with
120 additions
and
0 deletions
notebooks/SecondVirials.ipynb
0 → 100644
+
120
−
0
View file @
46564b53
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Second virial coefficients for water-based mixtures\n",
"\n",
"No departure term..."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
"import ipywidgets as widgets\n",
"%matplotlib inline\n",
"import timeit\n",
"import pandas\n",
"import matplotlib.pyplot as plt, numpy as np\n",
"import matplotlib as mpl\n",
"mpl.rcParams['figure.dpi']= 100\n",
"import teqp"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-3.1276835541523647e-06"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"names = ['Water','Methane']\n",
"model = teqp.build_multifluid_model(names, '../mycp', '../mycp/dev/mixtures/mixture_binary_pairs.json')\n",
" \n",
"def get_mutant(params):\n",
" \"\"\" Build a teqp-based mutant from the model parameters \"\"\"\n",
" if 'type' not in params:\n",
" raise KeyError('type must be provided')\n",
"\n",
" if params['type'] == 'invariant':\n",
" s = {\n",
" \"0\":{\n",
" \"1\": {\n",
" \"BIP\":{\n",
" \"lambdaT\": params['lambdaT'],\n",
" \"phiT\": params['phiT'],\n",
" \"lambdaV\": params['lambdaV'],\n",
" \"phiV\": params['phiV'],\n",
" \"Fij\": 0.0\n",
" },\n",
" \"departure\":{\n",
" \"type\" : \"Exponential\", \"n\" : [], \"t\" : [], \"d\" : [], \"l\" : []\n",
" }\n",
" }\n",
" }\n",
" }\n",
" return teqp.build_multifluid_mutant_invariant(model, s)\n",
" elif params['type'] == 'GERG':\n",
" s = {\n",
" \"0\":{\n",
" \"1\": {\n",
" \"BIP\":{\n",
" \"betaT\": params['betaT'],\n",
" \"gammaT\": params['gammaT'],\n",
" \"betaV\": params['betaV'],\n",
" \"gammaV\": params['gammaV'],\n",
" \"Fij\": 0.0\n",
" },\n",
" \"departure\":{\n",
" \"type\" : \"Exponential\", \"n\" : [], \"t\" : [], \"d\" : [], \"l\" : []\n",
" }\n",
" }\n",
" }\n",
" }\n",
" return teqp.build_multifluid_mutant(model, s)\n",
" else:\n",
" raise KeyError(\"Bad type for get_mutant\")\n",
"\n",
"mutant = get_mutant({'betaT':1.0,'betaV':1.0,'gammaV':1.0,'gammaT':1.2,\"type\":'GERG'})\n",
"z = np.array([0.3, 0.7])\n",
"teqp.get_B12vir(mutant, 300, z)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
%% 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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment