From 402164adcae1b9613e34afba25275784508f70ce Mon Sep 17 00:00:00 2001
From: Ian Bell <ian.bell@nist.gov>
Date: Thu, 21 Oct 2021 17:41:40 -0400
Subject: [PATCH] Fix superancillary implementation, update check notebook

---
 include/teqp/models/cubics.hpp |  4 ++--
 notebooks/CheckCubics.ipynb    | 42 ++++++++++++++++++++++++++++------
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/include/teqp/models/cubics.hpp b/include/teqp/models/cubics.hpp
index f738b60..d2a8038 100644
--- a/include/teqp/models/cubics.hpp
+++ b/include/teqp/models/cubics.hpp
@@ -77,8 +77,8 @@ public:
         auto b = get_b(T, z);
         auto Ttilde = R(z)*T*b/get_a(T,z);
         return std::make_tuple(
-            CubicSuperAncillary::supercubic(superanc_index, CubicSuperAncillary::RHOL_CODE, Ttilde)*b,
-            CubicSuperAncillary::supercubic(superanc_index, CubicSuperAncillary::RHOV_CODE, Ttilde)*b
+            CubicSuperAncillary::supercubic(superanc_index, CubicSuperAncillary::RHOL_CODE, Ttilde)/b,
+            CubicSuperAncillary::supercubic(superanc_index, CubicSuperAncillary::RHOV_CODE, Ttilde)/b
         );
     }
 
diff --git a/notebooks/CheckCubics.ipynb b/notebooks/CheckCubics.ipynb
index f3d560d..913bb24 100644
--- a/notebooks/CheckCubics.ipynb
+++ b/notebooks/CheckCubics.ipynb
@@ -37,7 +37,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 3,
    "metadata": {},
    "outputs": [
     {
@@ -53,12 +53,13 @@
      "data": {
       "text/plain": [
        "{'Delta1': 2.414213562373095,\n",
+       " 'Delta2': -0.41421356237309515,\n",
        " 'OmegaA': 0.4572355289213822,\n",
        " 'OmegaB': 0.07779607390388846,\n",
        " 'kind': 'Peng-Robinson'}"
       ]
      },
-     "execution_count": 7,
+     "execution_count": 3,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -76,7 +77,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 4,
    "metadata": {},
    "outputs": [
     {
@@ -92,12 +93,13 @@
      "data": {
       "text/plain": [
        "{'Delta1': 1.0,\n",
+       " 'Delta2': 0.0,\n",
        " 'OmegaA': 0.4274802335403417,\n",
        " 'OmegaB': 0.08664034996495766,\n",
        " 'kind': 'Soave-Redlich-Kwong'}"
       ]
      },
-     "execution_count": 6,
+     "execution_count": 4,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -115,10 +117,36 @@
   },
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 5,
    "metadata": {},
-   "outputs": [],
-   "source": []
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "{'Delta1': 2.414213562373095, 'Delta2': -0.41421356237309515, 'OmegaA': 0.4572355289213822, 'OmegaB': 0.07779607390388846, 'kind': 'Peng-Robinson'}\n"
+     ]
+    },
+    {
+     "data": {
+      "text/plain": [
+       "([24221.746187758014, 1030.361868803444],\n",
+       " [24222.536725733073, 1029.779329419418])"
+      ]
+     },
+     "execution_count": 5,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "model = teqp.canonical_PR([Tc_K[0]], [pc_Pa[0]], [acentric[0]])\n",
+    "print(model.get_meta())\n",
+    "[rhoL, rhoV ] = model.superanc_rhoLV(150)\n",
+    "\n",
+    "import CoolProp.CoolProp as CP\n",
+    "[rhoL, rhoV], CP.PropsSI('Dmolar','T',150,'Q',[0,1],'PR::METHANE').tolist()"
+   ]
   }
  ],
  "metadata": {
-- 
GitLab