CADET-Python provides a file-based Python interface for CADET-Core, which must be installed separately. For this, please refer to the installation instructions and the CADET-Core repository.
The CADET-Python package simplifies access by mapping to the CADET interface, with all dataset names in lowercase.
To install CADET-Python, use:
pip install cadet-python
The package includes two primary classes:
CADET
: The main class to configure and run simulations.H5
: A general-purpose HDF5 interface.
To set a simulation parameter, such as the column porosity for column 1.
Referring to this path in the CADET interface:
/input/model/unit_001/COL_POROSITY
In CADET-Python, this is now set as:
from cadet import Cadet
# Initialize simulation
sim = Cadet()
# Set column porosity for unit 001
sim.root.input.model.unit_001.col_porosity = 0.33
Before running, save the simulation configuration to a file:
sim.filename = "/path/to/your/file.hdf5"
sim.save()
To execute the simulation, specify the path to CADET-Core. On Windows, set the path to cadet-cli.exe
:
sim.cadet_path = '/path/to/cadet-cli'
Run the simulation and load the output data with:
print(sim.run())
sim.load()
If you have a pre-simulated file, you can read it directly:
# Initialize a new simulation object
sim = Cadet()
# Set the filename for the existing simulation data
sim.filename = "/path/to/your/file.hdf5"
sim.load()
At this point, any data in the file can be accessed.