Skip to content

Add multiple reactions in particles #453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

AntoniaBerger
Copy link
Collaborator

This pull request introduces a new reaction interface to support multiple reactions per particle type.
The changes include adding a new reaction model (MassActionLawReactionCrossPhase), updating the reaction model factory, and modifying the GeneralRateModel and LumpedRateModelWithPores to handle the new interface. Below are the key changes grouped by theme:

New Reaction Model

  • Added MassActionLawReactionCrossPhase to the build system in CMakeLists.txt and registered it in the ReactionModelFactory. Due to backwards compatibility, the old MAL don't loos any feature.

GeneralRateModel 1D Enhancements

  • Introduced support for multiple reactions per particle type in GeneralRateModel. This includes a new _oldReactionInterface flag to distinguish between the old and new interfaces, and _numReactionsPerParticle to track the number of reactions per particle type. [1] [2]
  • Updated configureModelDiscretization to initialize and configure multiple reactions for each particle type.
  • Enhanced configure to handle the new reaction interface, ensuring proper configuration of multiple reactions. [1] [2]
  • Adjusted memory allocation in threadLocalMemorySize to account for multiple reactions. [1] [2]
  • Modified residualParticle to compute residuals and Jacobians for multiple reactions per particle type.

LumpedRateModelWithPores 1D Enhancements

  • Similar updates as GeneralRateModel to support multiple reactions per particle type, including _oldReactionInterface and _numReactionsPerParticle.
  • Updated configureModelDiscretization and configure methods to handle the new reaction interface.
  • Adjusted threadLocalMemorySize to allocate memory for multiple reactions.

CSTR Enhancements

  • Similar updates as GeneralRateModel to support multiple reactions per particle type, including _oldReactionInterface and _numReactionsPerParticle.
  • Updated configureModelDiscretization and configure methods to handle the new reaction interface.
  • Adjusted threadLocalMemorySize to allocate memory for multiple reactions.

These changes enhance the flexibility of the reaction models, allowing for more complex scenarios with multiple reactions per particle type.

@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.n_cross_phase_reaction = 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.n_reaction_pore= 1
model.root.input.model.unit_000.particle_type_000.pore_reaction_000.type = "MASS_ACTION_LAW"
model.root.input.model.unit_000.particle_type_000.pore_reaction_000.mal_stoich = [-1, 0]
model.root.input.model.unit_000.particle_type_000.pore_reaction_000.mal_kfwd = [1.0]
model.root.input.model.unit_000.particle_type_000.pore_reaction_000.mal_kbwd = [0.5]

To use the same reaction modul for different phases, I gave up the _liquid / _solid description.
I also prefer reaction_cross_phase, reaction_bulk and reaction_solid. Since this is more general and also is valid for CSTR and LRM where there is no particle phase.
For more information, see #92

@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 from 58d2336 to 0982986 Compare August 1, 2025 13:30
@AntoniaBerger AntoniaBerger force-pushed the feature/add_multiple_reactions_partical branch from 9af4e1a to a11c948 Compare August 1, 2025 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

1 participant