Expected behavior.
Hello,
I am a bit confused by the behavior I get from CADET when trying to model a bulk reaction in the LRM. Looking at the mathematical model for LRM, I assume I should be able to specify a liquid (bulk) and a solid reaction system. I expect that the LRM will accept designation of a bulk mass action law reaction system, by some kind of parameter specification.
Actual behavior
I am using a Jupyter notebook in Visual Studio Code. I have instantiated a LumpedRateModelWithoutPores named “column”. For “column.” I get suggestions: “bulk_reaction_model” and “particle_reaction_model”. But when trying to specify the bulk reaction system like this:
column.bulk_reaction_model = reaction_system
I get an error message:
CADETProcessError Traceback (most recent call last)
Cell In[9], line 23
19 from CADETProcess.processModel import LumpedRateModelWithoutPores
21 column = LumpedRateModelWithoutPores(component_system, name=‘column’)
—> 23 column.bulk_reaction_model = reaction_system
File e:\Programme\Miniforge3\envs\cadet_workshop\Lib\site-packages\CADETProcess\dataStructure\dataStructure.py:615, in frozen_attributes..frozensetattr(self, key, value)
613 if self._is_frozen and not hasattr(self, key):
614 raise AttributeError(f"{cls.name} object has no attribute {key}")
→ 615 object.setattr(self, key, value)
File e:\Programme\Miniforge3\envs\cadet_workshop\Lib\site-packages\CADETProcess\processModel\unitOperation.py:368, in UnitBaseClass.bulk_reaction_model(self, bulk_reaction_model)
365 raise TypeError(“Expected BulkReactionBase”)
367 if not self.supports_bulk_reaction:
→ 368 raise CADETProcessError(“Unit does not support bulk reactions.”)
369 if bulk_reaction_model.component_system is not self.component_system:
370 raise CADETProcessError(“Component systems do not match.”)
CADETProcessError: Unit does not support bulk reactions.
When trying to specify it in a different way, like in the CADET-Core documentation (Lumped Rate Model Without Pores — CADET):
column.reaction_model = reaction_system
I get:
AttributeError Traceback (most recent call last)
Cell In[10], line 23
19 from CADETProcess.processModel import LumpedRateModelWithoutPores
21 column = LumpedRateModelWithoutPores(component_system, name=‘column’)
—> 23 column.reaction_model = reaction_system
File e:\Programme\Miniforge3\envs\cadet_workshop\Lib\site-packages\CADETProcess\dataStructure\dataStructure.py:614, in frozen_attributes..frozensetattr(self, key, value)
612 def frozensetattr(self: Structure, key: str, value: Any) → None:
613 if self._is_frozen and not hasattr(self, key):
→ 614 raise AttributeError(f"{cls.name} object has no attribute {key}")
615 object.setattr(self, key, value)
AttributeError: UnitBaseClass object has no attribute reaction_model
Although, when I omit a bulk reaction, and just use:
column.particle_reaction_model = reaction_system.to_particle_model()
it seems to work fine. I’ve been able to get bulk and pore phase reactions to work in the LRMP just fine. Is there maybe a bug in the LRM, or am I missing something? How do I make sure I properly model a bulk phase reaction in the LRM?
Versions:
cadet 5.0.4
cadet-process 0.11.1
cadet-python 1.1.0
Thank you.
How to produce bug (including a minimal reproducible example)
from CADETProcess.processModel import ComponentSystem
component_system=ComponentSystem()
component_system.add_component(‘A’)
component_system.add_component(‘B’)
from CADETProcess.processModel import MassActionLaw
reaction_system=MassActionLaw(component_system)
reaction_system.add_reaction(
components=[‘A’,‘B’],
coefficients=[-1,1],
k_fwd=1,
k_bwd=0.5,
)
from CADETProcess.processModel import LumpedRateModelWithoutPores
column = LumpedRateModelWithoutPores(component_system, name=‘column’)
column.bulk_reaction_model = reaction_system