Hello Forum,
I observed some unexpected behavior when setting up a simple column model in CADET-Process while trying to use the add_event functionality to change the film diffusion coefficient (k_film) at some time point during the process. I am not sure if this is an issue or if I am just doing something wrong so I just figured I’d ask. An example to illustrate is below.
from CADETProcess.processModel import ComponentSystem
from CADETProcess.processModel import LumpedRateModelWithPores
from CADETProcess.processModel import Inlet, Outlet
from CADETProcess.processModel import FlowSheet
from CADETProcess.processModel import Process
from CADETProcess.simulator import Cadet
component_system = ComponentSystem(['1'])
feed = Inlet(component_system, name='feed')
feed.c = [24,]
column = LumpedRateModelWithPores(component_system, name='column')
column.length = 0.1
column.diameter = 0.016
column.particle_radius = 25e-6
column.bed_porosity = 0.4
column.particle_porosity = 0.93
column.axial_dispersion = 5e-8 # m^2/s
column.film_diffusion = [2.2e-5,]
outlet = Outlet(component_system, name='outlet')
flow_sheet = FlowSheet(component_system)
flow_sheet.add_unit(feed)
flow_sheet.add_unit(column)
flow_sheet.add_unit(outlet)
flow_sheet.add_connection(feed, column)
flow_sheet.add_connection(column, outlet)
flow_sheet.feed.flow_rate = 1e-7
process = Process(flow_sheet, 'fs')
process.cycle_time = 400
simulator = Cadet()
if __name__ == '__main__':
simulation_results = simulator.simulate(process)
_ = simulation_results.solution.outlet.inlet.plot()
However if I try to change k_film at some point in the process when there is only a single component as
process.add_event(
'change_k_film',
'flow_sheet.column.film_diffusion',
[2.5e-5,],
time=100
)
I get this error message:
File ~/opt/anaconda3/envs/CADET-env/lib/python3.9/site-packages/CADETProcess/dynamicEvents/event.py:166 in add_event
evt = Event(name, self, parameter_path, state, time=time, indices=indices)
File ~/opt/anaconda3/envs/CADET-env/lib/python3.9/site-packages/CADETProcess/dynamicEvents/event.py:880 in __init__
self.indices = indices
File ~/opt/anaconda3/envs/CADET-env/lib/python3.9/site-packages/CADETProcess/dynamicEvents/event.py:1022 in indices
raise e
File ~/opt/anaconda3/envs/CADET-env/lib/python3.9/site-packages/CADETProcess/dynamicEvents/event.py:1020 in indices
_ = self.indices
File ~/opt/anaconda3/envs/CADET-env/lib/python3.9/site-packages/CADETProcess/dynamicEvents/event.py:994 in indices
indices = generate_indices(self.parameter_shape, self._indices)
File ~/opt/anaconda3/envs/CADET-env/lib/python3.9/site-packages/CADETProcess/dynamicEvents/section.py:663 in generate_indices
raise ValueError("Scalar parameters cannot have index slices.")
ValueError: Scalar parameters cannot have index slices.
where it looks like the error is just raised because the length of the list used to update k_film is 1. However should that not be the case when there is only one component in the system? When I run this example with two components it seems to work fine.
Thanks in advance for your help