diff --git a/.gitignore b/.gitignore index 3d9f5db..9add661 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ /ron.py /CADET.egg-info /dist +/build/lib/cadet +/cadet/__pycache__ diff --git a/CADETPython.egg-info/PKG-INFO b/CADETPython.egg-info/PKG-INFO new file mode 100644 index 0000000..1afa5e0 --- /dev/null +++ b/CADETPython.egg-info/PKG-INFO @@ -0,0 +1,55 @@ +Metadata-Version: 2.1 +Name: CADETPython +Version: 0.2 +Summary: CADET is a python interface to the CADET chromatography simulator +Home-page: https://github.com/modsim/CADET-Python +Author: William Heymann +Author-email: w.heymann@fz-juelich.de +License: UNKNOWN +Description: CADET python is a file based python interface for CADET + CADET still must be downloaded and built from https://github.com/modsim/CADET + + CADET python almost exactly maps to the documented CADET interface except that all dataset names + are lowercase. This simplifies useing the interface. + + This package includes the Cadet class and H5 class. H5 can be used as a simple generic HDF5 interface. + + As an example look at setting column porosity for column 1. From the CADET manual the path for this is + /input/model/unit_001/COL_POROSITY + + In the python interface this becomes + + sim = Cadet() + sim.root.input.model.unit_001.col_porosity = 0.33 + + Once the simulation has been created it must be saved before it can be run + + sim.filename = "/path/to/where/you/want/the/file.hdf5" + sim.save() + + #Next the path to cadet needs to be set before a simulation can be run, if running on windows you need the path to cadet-cli.exe + + sim.cadet_path = '/path/to/cadet-cli' + + #next run the simulation + + print(sim.run()) + + #load the data + sim.load() + + + At this point any data can be read + + If you have a file you want to read that has already been simulated this is also easy to do + + sim = Cadet() + sim.filename = "/path/to/where/you/want/the/file.hdf5" + sim.load() + +Platform: UNKNOWN +Classifier: Programming Language :: Python :: 3 +Classifier: License :: OSI Approved :: BSD License +Classifier: Operating System :: OS Independent +Requires-Python: >=3.6 +Description-Content-Type: text/markdown diff --git a/CADETPython.egg-info/SOURCES.txt b/CADETPython.egg-info/SOURCES.txt new file mode 100644 index 0000000..90cbadf --- /dev/null +++ b/CADETPython.egg-info/SOURCES.txt @@ -0,0 +1,10 @@ +README.md +setup.cfg +setup.py +CADETPython.egg-info/PKG-INFO +CADETPython.egg-info/SOURCES.txt +CADETPython.egg-info/dependency_links.txt +CADETPython.egg-info/requires.txt +CADETPython.egg-info/top_level.txt +cadet/__init__.py +cadet/cadet.py \ No newline at end of file diff --git a/CADETPython.egg-info/dependency_links.txt b/CADETPython.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/CADETPython.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/CADETPython.egg-info/requires.txt b/CADETPython.egg-info/requires.txt new file mode 100644 index 0000000..ee94725 --- /dev/null +++ b/CADETPython.egg-info/requires.txt @@ -0,0 +1,3 @@ +addict +numpy +h5py diff --git a/CADETPython.egg-info/top_level.txt b/CADETPython.egg-info/top_level.txt new file mode 100644 index 0000000..0adfc8b --- /dev/null +++ b/CADETPython.egg-info/top_level.txt @@ -0,0 +1 @@ +cadet diff --git a/cadet/cadet.py b/cadet/cadet.py index b89729f..afdcfb0 100644 --- a/cadet/cadet.py +++ b/cadet/cadet.py @@ -91,24 +91,30 @@ def inverse_transform(self, x): def run(self, timeout = None, check=None): if self.filename is not None: - data = subprocess.run([self.cadet_path, self.filename], timeout = timeout, check=check, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + data = subprocess.run([self.cadet_path, self.filename], timeout = timeout, check=check, capture_output=True) self.return_information = data return data else: print("Filename must be set before run can be used") def recursively_load( h5file, path, func, paths): - - ans = {} - for key_original in h5file[path].keys(): - key = func(key_original) - local_path = path + key - if paths is None or (paths is not None and local_path in paths): + ans = Dict() + if paths is not None: + for path in paths: + item = h5file[path] + if isinstance(item, h5py._hl.dataset.Dataset): + ans[path[1:]] = item[()] + elif isinstance(item, h5py._hl.group.Group): + ans[path[1:]] = recursively_load(h5file, path + '/', func, None) + else: + for key_original in h5file[path].keys(): + key = func(key_original) + local_path = path + key item = h5file[path][key_original] if isinstance(item, h5py._hl.dataset.Dataset): ans[key] = item[()] elif isinstance(item, h5py._hl.group.Group): - ans[key] = recursively_load(h5file, local_path + '/', func, paths) + ans[key] = recursively_load(h5file, local_path + '/', func, None) return ans def recursively_save( h5file, path, dic, func): diff --git a/examples/SMB.py b/examples/SMB.py index ea81809..df13e12 100644 --- a/examples/SMB.py +++ b/examples/SMB.py @@ -6,16 +6,17 @@ import math from cadet import Cadet -Cadet.cadet_path = "C:/Users/kosh_000/cadet_build/CADET-dev/MS_SMKL_RELEASE/bin/cadet-cli.exe" +#Cadet.cadet_path = "C:/Users/kosh_000/cadet_build/CADET-dev/MS_SMKL_RELEASE/bin/cadet-cli.exe" +Cadet.cadet_path = "C:/Users/kosh_000/cadet_build/CADET/VCPKG/bin/cadet-cli.exe" #use to render results import matplotlib.pyplot as plt #number of columns in a cycle -cycle_size = 4 +cycle_size = 8 #number of cycles -cycles = 7 +cycles = 4 #number of times flows have to be expanded for a 4-zone model repeat_size = int(cycle_size/4) @@ -121,7 +122,7 @@ def createSimulation(simulation): col.ncomp = 2 col.cross_section_area = math.pi * (0.02**2)/4.0 col.col_dispersion = 3.8148e-20 - col.col_length = 0.25 + col.col_length = 0.25/repeat_size col.col_porosity = 0.83 col.init_c = [0.0, 0.0] col.init_q = [0.0, 0.0] diff --git a/setup.py b/setup.py index af0510b..04ecac3 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="CADET", - version="0.2", + version="0.3", author="William Heymann", author_email="w.heymann@fz-juelich.de", description="CADET is a python interface to the CADET chromatography simulator",