From d5ad467226dca620d9117331debb04ba17c1e451 Mon Sep 17 00:00:00 2001
From: Ian Bell <ian.bell@nist.gov>
Date: Thu, 3 Nov 2022 20:19:08 -0400
Subject: [PATCH] And the updated setup.py to go along

---
 setup.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index 1ea918b..e4ab9b8 100644
--- a/setup.py
+++ b/setup.py
@@ -83,13 +83,63 @@ class CMakeBuild(build_ext):
 init_template  = r'''import os
 
 # Bring all entities from the extension module into this namespace
-from .teqp import * 
+from .teqp import *
+from .teqp import _make_model
 
 def get_datapath():
     """Get the absolute path to the folder containing the root of multi-fluid data"""
     return os.path.abspath(os.path.dirname(__file__)+"/fluiddata")
 
 from .teqp import __version__
+
+# for factory_function in ['_make_vdW1']:
+
+def tolist(a):
+    if isinstance(a, list):
+        return a
+    else:
+        try:
+            return a.tolist()
+        except:
+            return a
+        
+def make_vdW1(a, b):
+    AS = _make_model({"kind": "vdW1", "model": {"a": a, "b": b}})
+    attach_model_specific_methods(AS)
+    return AS
+    
+def vdWEOS1(*args):
+    return make_vdW1(*args)
+    
+def make_model(*args):
+    AS = _make_model(*args)
+    attach_model_specific_methods(AS)
+    return AS
+    
+def canonical_PR(Tc_K, pc_Pa, acentric, kmat=[]):
+    j = {
+        "kind": "PR",
+        "model": {
+            "Tcrit / K": tolist(Tc_K),
+            "pcrit / Pa": tolist(pc_Pa),
+            "acentric": tolist(acentric),
+            "kmat": tolist(kmat)
+        }
+    }
+    return make_model(j)
+    
+def canonical_SRK(Tc_K, pc_Pa, acentric, kmat=[]):
+    j = {
+        "kind": "SRK",
+        "model": {
+            "Tcrit / K": tolist(Tc_K),
+            "pcrit / Pa": tolist(pc_Pa),
+            "acentric": tolist(acentric),
+            "kmat": tolist(kmat)
+        }
+    }
+    return make_model(j)
+
 '''
 
 def prepare():
@@ -132,4 +182,4 @@ finally:
 
 toc = timeit.default_timer()
 
-print('elapsed:', toc-tic, 'seconds')
\ No newline at end of file
+print('elapsed:', toc-tic, 'seconds')
-- 
GitLab