Issues after CADET-Process Installation

Expected behavior.

Hey all,

I am currently trying to migrate to CADET-Process.
I expected the appended script to work without issues because it has worked on another computer (On which we haven’t used CADET before)
Installation was done in a fresh environment and the error occured on multiple computers that previously had cadet 4.3.0 running.
Thanks in advance for any help!

Actual behavior

The error I get on these Computers is:

C:\Users\ak46oqoz\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\cadet\cadet.py:510: FutureWarning: Cadet.run_load() will be removed in a future release. Please use Cadet.run_simulation()
  warnings.warn(
There was an exception in simulate_n_cycles
Traceback (most recent call last):
  File "C:\Users\ak46oqoz\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\CADETProcess\log.py", line 172, in wrapper
    return function(*args, **kwargs)
  File "C:\Users\ak46oqoz\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\CADETProcess\simulator\simulator.py", line 308, in simulate_n_cycles
    return self.run(process, **kwargs)
           ~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ak46oqoz\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\CADETProcess\simulator\cadetAdapter.py", line 133, in wrapper
    results = func(self, process, *args, **kwargs)
  File "C:\Users\ak46oqoz\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\CADETProcess\simulator\cadetAdapter.py", line 233, in run
    return_information = cadet.run_load(timeout=self.timeout)
  File "C:\Users\ak46oqoz\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\cadet\cadet.py", line 515, in run_load
    return_information = self.run_simulation(timeout=timeout, clear=clear)
  File "C:\Users\ak46oqoz\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\cadet\cadet.py", line 539, in run_simulation
    return_information = self.cadet_runner.run(
        simulation=self,
        timeout=timeout
    )
  File "C:\Users\ak46oqoz\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\cadet\runner.py", line 162, in run
    error_message=data.stderr.decode('utf-8'),
                  ~~~~~~~~~~~~~~~~~~^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 100: invalid start byte
---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
File c:\users\ak46oqoz\faubox\promotion\abschlussarbeiten\müller\linear_isotherm.py:147
    144 from CADETProcess.simulator import Cadet
    146 process_simulator = Cadet()
--> 147 simulation_results = process_simulator.simulate(process)
    149 signal=simulation_results.solution.column.outlet.solution
    150 time=simulation_results.solution.column.outlet.time

File ~\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\CADETProcess\simulator\simulator.py:252, in SimulatorBase.simulate(self, process, previous_results, **kwargs)
    249     raise CADETProcessError("Process is not configured correctly.")
    251 if not self.evaluate_stationarity:
--> 252     results = self.simulate_n_cycles(
    253         process, self.n_cycles, previous_results, **kwargs
    254     )
    255 else:
    256     results = self.simulate_to_stationarity(
    257         process, previous_results, **kwargs
    258     )

File ~\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\CADETProcess\log.py:150, in log_time.<locals>.log_time_decorator.<locals>.wrapper(*args, **kwargs)
    147 @wraps(function)
    148 def wrapper(*args, **kwargs):
    149     start = time.time()
--> 150     result = function(*args, **kwargs)
    151     elapsed = time.time() - start
    152     logger = get_logger(logger_name, level=None)

File ~\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\CADETProcess\log.py:201, in log_results.<locals>.log_results_decorator.<locals>.wrapper(*args, **kwargs)
    197 logger = get_logger(logger_name, level=None)
    199 logger.debug('{} was called with {}, {}'.format(
    200         function, *args, **kwargs))
--> 201 results = function(*args, **kwargs)
    202 logger.debug(f'Results: {results}')
    204 return results

File ~\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\CADETProcess\log.py:180, in log_exceptions.<locals>.log_exception_decorator.<locals>.wrapper(*args, **kwargs)
    177 logger.exception(err)
    179 # re-raise the exception
--> 180 raise e

File ~\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\CADETProcess\log.py:172, in log_exceptions.<locals>.log_exception_decorator.<locals>.wrapper(*args, **kwargs)
    170 logger = get_logger(logger_name, level=None)
    171 try:
--> 172     return function(*args, **kwargs)
    173 except Exception as e:
    174     # log the exception
    175     err = "There was an exception in "

File ~\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\CADETProcess\simulator\simulator.py:308, in SimulatorBase.simulate_n_cycles(self, process, n_cyc, previous_results, **kwargs)
    305 if previous_results is not None:
    306     self.set_state_from_results(process, previous_results)
--> 308 return self.run(process, **kwargs)
    310 self.n_cycles = n_cyc_orig

File ~\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\CADETProcess\simulator\cadetAdapter.py:133, in Cadet.locks_process.<locals>.wrapper(self, process, *args, **kwargs)
    130     process.lock = True
    131     locked_process = True
--> 133 results = func(self, process, *args, **kwargs)
    135 if locked_process:
    136     process.lock = False

File ~\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\CADETProcess\simulator\cadetAdapter.py:233, in Cadet.run(self, process, cadet, file_path)
    231 try:
    232     start = time.time()
--> 233     return_information = cadet.run_load(timeout=self.timeout)
    234     elapsed = time.time() - start
    235 except TimeoutExpired:

File ~\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\cadet\cadet.py:515, in Cadet.run_load(self, timeout, clear)
    495 """
    496 Run the CADET simulation and load the results.
    497 
   (...)
    508     Information about the simulation run.
    509 """
    510 warnings.warn(
    511     "Cadet.run_load() will be removed in a future release. "
    512     "Please use Cadet.run_simulation()",
    513     category=FutureWarning
    514 )
--> 515 return_information = self.run_simulation(timeout=timeout, clear=clear)
    517 return return_information

File ~\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\cadet\cadet.py:539, in Cadet.run_simulation(self, timeout, clear)
    519 def run_simulation(
    520         self,
    521         timeout: Optional[int] = None,
    522         clear: bool = True
    523 ) -> ReturnInformation:
    524     """
    525     Run the CADET simulation and load the results.
    526 
   (...)
    537         Information about the simulation run.
    538     """
--> 539     return_information = self.cadet_runner.run(
    540         simulation=self,
    541         timeout=timeout
    542     )
    544     if return_information.return_code == 0:
    545         self.cadet_runner.load_results(self)

File ~\AppData\Local\anaconda3\envs\CADET_Process_env\Lib\site-packages\cadet\runner.py:162, in CadetCLIRunner.run(self, simulation, timeout)
    152     raise ValueError("Filename must be set before run can be used")
    154 data = subprocess.run(
    155     [self.cadet_path, str(simulation.filename)],
    156     timeout=timeout,
    157     capture_output=True
    158 )
    160 return_info = ReturnInformation(
    161     return_code=data.returncode,
--> 162     error_message=data.stderr.decode('utf-8'),
    163     log=data.stdout.decode('utf-8')
    164 )
    166 return return_info

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 100: invalid start byte

How to produce bug (including a minimal reproducible example)

When executing the following script I run into this error, but only on the computers that had a older CADET version installed (specifically cadet 4.3.0):

from CADETProcess.processModel import ComponentSystem
from CADETProcess.processModel import Inlet
from CADETProcess.processModel import Linear
from CADETProcess.processModel import LumpedRateModelWithoutPores
from CADETProcess.processModel import Outlet
from CADETProcess.processModel import FlowSheet
from CADETProcess.processModel import Process
from CADETProcess.simulator import Cadet

component_system = ComponentSystem(1)
c_inj_hom=1
Q = 0.7/(60*1e6) #feed flow m^3/s

inlet = Inlet(component_system, name='inlet')
inlet.flow_rate = Q  # m^3 / s
inlet.c = c_inj_hom  # mol / m^3

binding_model = Linear(component_system, n_binding_sites=1, name='linear')
binding_model.is_kinetic = False
binding_model.adsorption_rate = [1]  # m^3 / (mol * s)   (mobile phase)
binding_model.desorption_rate = [1]  # 1 / s (desorption)

column = LumpedRateModelWithoutPores(component_system, name='column')
column.binding_model = binding_model
NTP=7351    #determined
column.length = 0.1  # m
column.diameter = 0.0046  # m
column.total_porosity = 0.61  # total porosity of system
column.set_axial_dispersion_from_NTP(NTP, Q)
column.c = [0]
column.q = [0]

outlet = Outlet(component_system, name='outlet')
                                    
flow_sheet = FlowSheet(component_system)
flow_sheet.add_unit(inlet)
flow_sheet.add_unit(column)
flow_sheet.add_unit(outlet, product_outlet=True)
flow_sheet.add_connection(inlet, column)
flow_sheet.add_connection(column, outlet)

process = Process(flow_sheet, 'Process')
process.cycle_time = 10000

process_simulator = Cadet()
simulation_results = process_simulator.simulate(process)

File produced by conda env export > environment.yml

environment.yml (11.7 KB)

1 Like

Hi Jan, thanks for reporting the issue,

I tried to run it locally but unfortunately, I cannot reproduce the issue on Ubuntu 24.04. Maybe it’s a Windows issue?

If we can’t reproduce it, this would be a good topic for our next office hours.

2 Likes

Hi Jan,

Unfortunately, I wasn’t able to reproduce your issue on Windows either.

Could you please try running CADET-Process in a fresh environment and see if the error persists?

Here’s a minimal example environment you can use:

name: CADET_Process
channels:
  - conda-forge
dependencies:
  - python=3.13.2
  - pip
  - pip:
      - CADET-Process
      - CADET-Python

It’s possible that another package is interfering, so isolating it in a clean setup might help.

All the best,
Hannah

1 Like