-
Notifications
You must be signed in to change notification settings - Fork 242
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
Added reaction and melt output calculations to reactive fluid flow model #5795
Conversation
Hi @jdannberg @naliboff, this PR builds off my other one, so it probably would be best to make sure the other one is wrapped up before doing too much more on this one. I just wanted to get this up! |
Yes, you'll need to rebase to main before we can look at the changes (otherwise it's hard to tell which changes come from this PR and which ones are from the other one). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had some comments on the general structure, and I'll look at the details once we have merged the other PR and this one is rebased.
@@ -377,6 +392,10 @@ namespace aspect | |||
"use polynomials to describe hydration and dehydration reactions for four different " | |||
"rock compositions as defined in Tian et al., 2019, or the Katz et. al. 2003 mantle " | |||
"melting model."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This material model now has a lot of parameters that are not being used when the katz2003 model is selected. The declaration will be overwritten by the ones in ReactionModel::Katz2003MantleMelting<dim>::declare_parameters(prm)
. For example, the default value of the "Reference permeability" will not be used and instead be overwritten by the one from the reaction model. There are two potential solutions
(1) If the computation of the melt outputs is similar, you remove the original parameters here, always call katz2003_model.calculate_fluid_outputs(in, out, reference_T)
, and make any small modifications necessary afterwards. That would be nice because it would also reduce the lines of code.
(2) If that does not work well, you could move the declare and parse parameters function of the ReactionModel::Katz2003MantleMelting into its own section in the parameter file, something like
prm.enter_subsection("Reactive Fluid Transport Model");
{
prm.enter_subsection("Katz 2003 model");
{
This way, they would be separate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm leaning towards the second solution because the Katz2003 model might not be the only melting model ReactiveFluidTransport has, I think I'll end up adding other melting models after the hackathon. Then it might make more sense for each melt model to have its own parameter subsection. Does that sound ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you add tests with graphical output, change the output format to gnuplot rather than vtu and then use the gnuplot file. The reason is that vtu files are binary, so any small change in any number will change the whole file. With the gnuplot format, we can compare the inidividual numbers with numdiff.
4ef9186
to
61d1e34
Compare
Hi @jdannberg and @naliboff, I rebased to main and squashed my commits here, so this PR is ready for comments. Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only have a few small changes to suggest, otherwise this looks good to me! And have you checked that the output of the test is the same as for the rising_melt_blob_freezing test? Because that's what we would expect, right?
"The reference temperature $T_0$. The reference temperature is used " | ||
"in both the density and viscosity formulas. Units: \\si{\\kelvin}."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The reference temperature $T_0$. The reference temperature is used " | |
"in both the density and viscosity formulas. Units: \\si{\\kelvin}."); | |
"The reference temperature $T_0$ for the katz2003 reaction model. The reference temperature is used " | |
"in both the density and viscosity formulas of this model. Units: \\si{\\kelvin}."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a copy of rising_melt_blob_freezing.prm, right? Instead of copying the test, can you include it by adding the line
include $ASPECT_SOURCE_DIR/tests/rising_melt_blob_freezing.prm
and then only including the lines that you changed compared to that test (this way, if something changes, we only have to update it in one test).
And can you also update the documentation? (Something like: "This is like the rising_melt_blob_freezing test, except that it uses the reactive fluid transport material model.")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and you still need to check why the tests are failing, and if those changes are only related to what you changed in the input file (the changes in shear_heating_with_melt looked tiny, but I couldn't tell how much has changed in viscoplastic_melt_fraction, if that was just related to adding the other field) and update the test results.
Hi @jdannberg, thanks for your comments! I'll push the changes up to the PR after doing any changes @naliboff might have, so I don't make too many more commits! My new test has identical results to rising_melt_blob_freezing, except for the solid viscosity, which is what I would expect from using a different solid material in this case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Grant-Block - Nice work!
Only two minor suggestions and a few self-reminder comments for future refactoring.
If possible, can you alter the test in this PR to give the same solid viscosity as the existing rising_melt_blob_freezing
test (this way the tests are identical)? If not, can you make a note of the difference and why it is expected in the test PRM file?
Otherwise, this looks basically ready to go.
{ | ||
// Scale the base model viscosity value based on the porosity. | ||
for (unsigned int q=0; q<out.n_evaluation_points(); ++q) | ||
const unsigned int porosity_idx = this->introspection().compositional_index_for_name("porosity"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not something to modify in this PR, but just a self-reminder that this line of code (and others noted below) will apply to most of the reaction models and we might want to think about ways to avoid duplication in future PRs.
for (unsigned int q=0; q<out.n_evaluation_points(); ++q) | ||
{ | ||
const double porosity = std::max(in.composition[q][porosity_idx],0.0); | ||
out.viscosities[q] *= (1.0 - porosity) * exp(- alpha_phi * porosity); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another line of code we might want to think about generalizing for multiple reaction models in future PRs (again, not a change for this PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@naliboff This is actually slightly different from what the Katz2003 model does. If everything was the same, it would be super easy to combine. But I agree, it would be nice not having to duplicate this.
if (in.composition[q][porosity_idx] + porosity_change < 0) | ||
porosity_change = -in.composition[q][porosity_idx]; | ||
// Fill reaction rate outputs if the model uses operator splitting. | ||
// Specifically, change the porosity (representing the amount of free water) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Specifically, change the porosity (representing the amount of free water) | |
// Specifically, change the porosity (representing the amount of free fluid) |
porosity_change = -in.composition[q][porosity_idx]; | ||
// Fill reaction rate outputs if the model uses operator splitting. | ||
// Specifically, change the porosity (representing the amount of free water) | ||
// based on the water solubility and the water content. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// based on the water solubility and the water content. | |
// based on the fluid solubility and the fluid content. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the above comment are regarding code not introduced in this PR, but I think it would be worth changing it now if I indeed this part of the code is not specific to one of the water-based reaction models (it looks like this is not the case).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
The only test that's not working is the one you added. So if you've made sure any differences between the rising melt blob freezing and viscoplastic melt blob freezing results are due to the different solid viscosity, you can just updated the test case.
for (unsigned int q=0; q<out.n_evaluation_points(); ++q) | ||
{ | ||
const double porosity = std::max(in.composition[q][porosity_idx],0.0); | ||
out.viscosities[q] *= (1.0 - porosity) * exp(- alpha_phi * porosity); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@naliboff This is actually slightly different from what the Katz2003 model does. If everything was the same, it would be super easy to combine. But I agree, it would be nice not having to duplicate this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Grant-Block - This is ready to go from my end as well, aside from one minor comment change in the test prm file and double checking that the change in test output is only due to the change in solid viscosity.
######################################################### | ||
# This is a test for the melting rate functionality, | ||
# in particular the freezing of melt. | ||
# It uses the melt simple model. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# It uses the melt simple model. | |
# It uses the reactive fluid transport material model composited | |
# on top of the visco plastic material model. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @naliboff and @jdannberg, I double checked that the only difference in the output between this and the melt simple version of the test is the solid viscosity, so I applied the updated. Thank you!
/rebuild |
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 uses the KatzMantleMelting module to calculate reaction and melt terms as an option in the reactive_fluid_transport model. A test is included copying a MeltSimple test, but using a visco plastic solid material model.
Before your first pull request:
For all pull requests:
For new features/models or changes of existing features: