Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use reaction chain in visco plastic model - #7331

Open
lhy11009 wants to merge 1 commit into
geodynamics:mainfrom
lhy11009:visco_plastic_reaction_chain
Open

Use reaction chain in visco plastic model#7331
lhy11009 wants to merge 1 commit into
geodynamics:mainfrom
lhy11009:visco_plastic_reaction_chain

Conversation

@lhy11009

@lhy11009 lhy11009 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Pull Request Checklist. Please read and check each box with an X. Delete any part not applicable. Ask on the forum if you need help with any step.

This is a PR that modified the usage of reaction progress in the Visco Plastic model, with the new reaction chain interface from @buchanankerswell

Before your first pull request:

For all pull requests:

Codex does the actual implementation. I assure that I read all the lines and performed tests myself.

For new features/models or changes of existing features:

  • I have tested my new feature locally to ensure it is correct.
  • I have created a testcase for the new feature/benchmark in the tests/ directory.
  • I have added a changelog entry in the doc/modules/changes directory that will inform other users of my change.

Comment thread tests/phase_kinetics_composition_metastable/statistics

@gassmoeller gassmoeller left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, we should make sure to use the new interface.

One question though: As far as I understand, this for now uses ReactionChain to clamp the reaction progress values, but it does not yet use ReactionChain to actually progress the reaction, do I understand this correctly?

Comment thread source/material_model/visco_plastic.cc Outdated
Comment on lines +504 to +518
const unsigned int n_reaction_progress_fields =
this->introspection().get_number_of_fields_of_type(CompositionalFieldDescription::reaction_progress);

if (n_reaction_progress_fields > 0)
{
reaction_chain.initialize_simulator(this->get_simulator());
reaction_chain.parse_parameters(prm);

AssertThrow(reaction_chain.n_reactions() == n_reaction_progress_fields,
ExcMessage("The number of reactions configured in 'Reaction chain/Kinetic models' must match "
"the number of reaction progress compositional fields."));
AssertThrow(reaction_progress_mapping.size() == n_reaction_progress_fields,
ExcMessage("The number of entries in 'Reaction progress mapping' must match the number of "
"reaction progress compositional fields."));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say unconditionally always initialize and parse the reaction chain parameters, and move the asserts into the parse_parameters function of reaction_chain. This way you will always have a fully functional reaction_chain object, that may just happen to manage 0 reactions. But that is safer than the current state, in which reaction_chain may or may not be initialized.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed. But there are questions. See my other comments

@buchanankerswell

buchanankerswell commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

I like it, we should make sure to use the new interface.

One question though: As far as I understand, this for now uses ReactionChain to clamp the reaction progress values, but it does not yet use ReactionChain to actually progress the reaction, do I understand this correctly?

Just wanted to flag something for your attention @gassmoeller and @lhy11009.

@lhy11009 may or may not have already noticed issue #7287 in this updated visco plastic model. I have two open PRs that ensure:

  1. the ReactionChain doesn't crash the simulation when reaction_progress fields under/overshoot [0, 1] Relax reaction progress tolerance by default (1e20) #7319
  2. that the material model can write the clamped progress back to the solution Add no-op hook to material model interface to clamp reaction progress… buchanankerswell/aspect#1 (e.g., see https://github.com/buchanankerswell/aspect/blob/7978d4d2fbbd310de76b37f72ff8b559afaf00c6/cookbooks/mtz_kinetics/mtz-kinetics.cc#L328-L345)

Together, these PRs solve #7287. I have tested this in cookbook #7119.

I would suggest we merge #7319 and buchanankerswell#1 before going too much further. Otherwise all material models with ReactionChain will run into issue #7287, including this one.

@gassmoeller

Copy link
Copy Markdown
Member

Good point. I wanted to get to your PRs next week. My comment above still applies, but we should figure out the other issues before merging this PR.

@lhy11009

lhy11009 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Thanks to both of you for the heads-up.

I left my comments #7287

This is indeed an important issue to solve. Let me know how I can contribute. @buchanankerswell, would you be able to join the user meeting next Mon to discuss?

On the other hand, it wouldn't change much what we need to do in this PR.

@lhy11009

lhy11009 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

I like it, we should make sure to use the new interface.

One question though: As far as I understand, this for now uses ReactionChain to clamp the reaction progress values, but it does not yet use ReactionChain to actually progress the reaction, do I understand this correctly?

Exactly, that is the case.

In the existing test, I basically assign an initial value to the transition progress field.

My intention is to first connect all the interfaces before using ReactionChain to actually progress the reaction.

@lhy11009
lhy11009 force-pushed the visco_plastic_reaction_chain branch from 22dcdc2 to 2ded8e4 Compare September 5, 2026 18:00
void
ViscoPlastic<dim>::initialize()
{
reaction_chain.initialize();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have put the initialize function here, but the initial_simulator call is in the parse_parameters. Feel free to suggest otherwise.

reaction_progress_mapping = Utilities::string_to_unsigned_int
(Utilities::split_string_list(prm.get ("Reaction progress mapping")));

AssertThrow(reaction_progress_mapping.size() == n_reaction_progress_fields,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I leave this assert here, because this is checking the number of reaction_progress_mapping that is parsed in here.

Patterns::List(Patterns::Selection(ReactionModelPluginList<dim>::get_pattern_of_names()),
1, Patterns::List::max_int_value, "|"),
"",
Patterns::List(Patterns::Anything()),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed the patterns here, to allow 0 kinetic models by default, similar to the "name of fields" entry for the "Composition".

1, Patterns::List::max_int_value, "|"),
"",
Patterns::List(Patterns::Anything()),
"'|'-separated list of registered reaction kinetics model names, one per reaction in the chain. The number of entries "

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, should we change "|" to ","?

const unsigned int n_reaction_progress_fields =
this->introspection().get_number_of_fields_of_type(CompositionalFieldDescription::reaction_progress);

AssertThrow(n_reactions == n_reaction_progress_fields,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I move one of the asserts here. For these assertions to work, things should be parsed in this order: compositions -> reaction chains -> the assigned "mapping" in the material model. Tests passed, so this should be the case.

@lhy11009

lhy11009 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

@gassmoeller, please take another look when available. And check my posts above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants