Skip to content

Conversation

AntoniaBerger
Copy link
Collaborator

@AntoniaBerger AntoniaBerger commented Jul 11, 2025

This pull request introduces improvements to the reaction modeling infrastructure in the codebase, primarily by integrating a new ReactionSystem abstraction that supports multiple reaction types (liquid, solid, cross-phase) and refactoring the configuration and residual calculation logic to use this new system. The changes also update various model classes to utilize the new reaction interface and extend support for cross-phase reactions.

Reaction system integration and refactoring:

  • Added the ReactionSystem abstraction to GeneralRateModel, LumpedRateModelWithPores, and LumpedRateModelWithoutPores, replacing direct use of _dynReactionBulk and related vectors, and providing helper methods for reaction offsets and management. (src/libcadet/model/GeneralRateModel.hpp [1] src/libcadet/model/LumpedRateModelWithPores.hpp [2] src/libcadet/model/LumpedRateModelWithoutPores.hpp [3]
  • Refactored configuration logic in LumpedRateModelWithoutPores to support multiple reaction types (liquid, solid, cross_phase) using the new ReactionSystem, and updated workspace management accordingly. (src/libcadet/model/LumpedRateModelWithoutPores.cpp [1] [2] [3]
  • Updated the residual and Jacobian calculation logic to use the new reaction system, supporting multiple reactions per type and properly handling cross-phase, liquid, and solid reactions in the computation. (src/libcadet/model/LumpedRateModelWithoutPores.cpp [1] [2]

API and interface updates:

  • Changed calls from residualLiquidAdd and analyticJacobianLiquidAdd to the more general residualFluxAdd and analyticJacobianAdd in several model implementations, reflecting the new interface. (src/libcadet/model/GeneralRateModel2D.cpp [1] src/libcadet/model/GeneralRateModelDG.cpp [2] [3] src/libcadet/model/LumpedRateModelWithPoresDG.cpp [4] [5] src/libcadet/model/LumpedRateModelWithPoresDG2D.cpp [6]

Support for cross-phase reactions:

  • Registered and integrated MassActionLawReactionCrossPhase as a new reaction type, with corresponding registration in the factory and inclusion in the build system. (src/libcadet/CMakeLists.txt [1] src/libcadet/ReactionModelFactory.cpp [2] [3]

Include and dependency updates:

  • Added necessary includes for ReactionSystem in model header files to support the new abstraction. (src/libcadet/model/GeneralRateModel.hpp [1] src/libcadet/model/LumpedRateModelWithPores.hpp [2] src/libcadet/model/LumpedRateModelWithoutPores.hpp [3]

@AntoniaBerger
Copy link
Collaborator Author

AntoniaBerger commented Jul 11, 2025

The new suggested user interface for cross phase reactions will be similar to the interface for bulk reactions:

model.root.input.model.unit_000.particle_type_000.nreac_cross_phase= 1
model.root.input.model.unit_000.particle_type_000.cross_phase_reaction_000.type = "MASS_ACTION_LAW_CROSS_PHASE"
model.root.input.model.unit_000.particle_type_000.cross_phase_reaction_000.mal_stoich_liquid = [-1, 0]
model.root.input.model.unit_000.particle_type_000.cross_phase_reaction_000.mal_stoich_solid = [0, 1]
model.root.input.model.unit_000.particle_type_000.cross_phase_reaction_000.mal_kfwd_liquid = [1.0]
model.root.input.model.unit_000.particle_type_000.cross_phase_reaction_000.mal_kbwd_solid = [0.5]

Up to discussion is still, how we want to continue with parameters like MAL_EXPONENTS_LIQUID_FWD_MODSOLID.

And for reactions located only in the pore (liquid) phase I purpose:


model.root.input.model.unit_000.particle_type_000.nreac_liquid= 1
model.root.input.model.unit_000.particle_type_000.liquid_reaction_000.type = "MASS_ACTION_LAW"
model.root.input.model.unit_000.particle_type_000.liquid_reaction_000.mal_stoich = [-1, 0]
model.root.input.model.unit_000.particle_type_000.liquid_reaction_000.mal_kfwd = [1.0]
model.root.input.model.unit_000.particle_type_000.liquid_reaction_000.mal_kbwd = [0.5]

To use the same reaction modul for different phases, I gave up the _liquid / _solid description.
For more information about the general plan see #92
For more and about the documentation files.

@AntoniaBerger AntoniaBerger marked this pull request as draft July 11, 2025 13:58
@AntoniaBerger AntoniaBerger self-assigned this Jul 11, 2025
@AntoniaBerger AntoniaBerger changed the title Add multiple reactions for cross phase reactions. Add multiple reactions in particles Jul 14, 2025
@AntoniaBerger AntoniaBerger force-pushed the feature/add_multiple_reactions_partical branch from 90d36ca to 58d2336 Compare July 24, 2025 12:28
@AntoniaBerger AntoniaBerger force-pushed the feature/add_multiple_reactions_partical branch 2 times, most recently from 9af4e1a to a11c948 Compare August 1, 2025 13:43
@jbreue16
Copy link
Contributor

Should we have a different field in the LRM, ie liquid_reaction_000 instead of bulk ? i think this is more descriptive and breaking the interface compared to other unit operations is actually good as it emphasizes that the phase considered int he model is indeed something else.

Also, do we want the names to start with reaction_ or with the description, followed by _reaction ? I dont mind either way but both ways were wrote down in two different comments above.

@AntoniaBerger
Copy link
Collaborator Author

Should we have a different field in the LRM, ie liquid_reaction_000 instead of bulk ? i think this is more descriptive and breaking the interface compared to other unit operations is actually good as it emphasizes that the phase considered int he model is indeed something else.

I agree, it is the most precise name.

Also, do we want the names to start with reaction_ or with the description, followed by _reaction ? I dont mind either way but both ways were wrote down in two different comments above.

I switched it to phase reaction_xxx because, in my opinion, it is more fluid. I need to update the comment, though.

@AntoniaBerger AntoniaBerger force-pushed the feature/add_multiple_reactions_partical branch from 0cdfa20 to e579e7d Compare September 2, 2025 15:14
@AntoniaBerger AntoniaBerger force-pushed the feature/add_multiple_reactions_partical branch from ad0254f to 87f491a Compare September 12, 2025 14:01
delete old interface

delete old interface grm

delete old interface

delete old interface from lrmp

delete old interface cstr and mct

Change bulk reaction to liquid reaction in interface

update reaction interface index
@AntoniaBerger AntoniaBerger force-pushed the feature/add_multiple_reactions_partical branch from 7591f4c to 9ae9247 Compare September 18, 2025 13:03
@AntoniaBerger AntoniaBerger force-pushed the feature/add_multiple_reactions_partical branch from 2386902 to 0d6c8c4 Compare September 18, 2025 13:42
@AntoniaBerger
Copy link
Collaborator Author

This will PR will be continued in #491

@github-project-automation github-project-automation bot moved this from Todo to Done in CADET Repositories Sep 30, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Sep 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants