From 46564b53d28261e2e2342f946e45c8bd554342a3 Mon Sep 17 00:00:00 2001
From: Ian Bell <ian.bell@nist.gov>
Date: Tue, 21 Sep 2021 10:31:35 -0600
Subject: [PATCH] An example notebook of obtaining second virials from mutants

---
 notebooks/SecondVirials.ipynb | 120 ++++++++++++++++++++++++++++++++++
 1 file changed, 120 insertions(+)
 create mode 100644 notebooks/SecondVirials.ipynb

diff --git a/notebooks/SecondVirials.ipynb b/notebooks/SecondVirials.ipynb
new file mode 100644
index 0000000..2526cd4
--- /dev/null
+++ b/notebooks/SecondVirials.ipynb
@@ -0,0 +1,120 @@
+{
+ "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
+}
-- 
GitLab