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
Input phase properties by value differences #4868
Input phase properties by value differences #4868
Conversation
In this PR, I handled the change of the inputting method of properties (e.g. density, viscosity) on phases. Now, the properties could both be assigned by values or by values of differences. @jdannberg and @anne-glerum , thanks for your advice in the discussion. Would you like to take this PR? DescriptionPredating this PR, entries of the phase properties are by the exact values. On the other hand, the implementation of the phase properties is actually calculating the differences between adjacent phases. Based on these values of differences, the implementation will then calculate the values of these properties from the phase-transition functions. In this way, it makes sense to have the interface directly import the values of the differences. TestsTest 1: input_phase_properties_by_jumps: 4 phase transitions in 2 compositionsIn this test, I use the entries of differences in values between adjacent phases, this is controlled by the option of:
The result of this test shows a density change across the 6 sub-regions in the model domain. Here the surface of the domain is on top (y = 100 km) and the temperature field is set to a constant value of 273 K. The left and the right sides are two different compositions. Both of them have two-phase jumps in their sub-domain and would induce a density increase of
Where the values of the differences between adjacent phases are used instead of the exact values on each specific phase. Below is a visualization of the result of density. The viscosity entries, on the other hand, are handled slightly differently. The Prefactors in the flow lows are inputted by the differences in their log10 values. For example, the meaning of "1" in the string below is that the prefactor would increase by 10-fold, and the viscosity would decrease by 10-fold across a phase transition.
The results of the viscosity are shown below. The composition on the left (i.e. the background) decreases in viscosity by 10-fold across each of the two phase-transition. The composition on the right, on the other hand, would remain constant, as only one value is given to the prefactors.: |
This may seem confusing at the first sight. I added a function "parse_map_differences_to_values" in "material_model/utilities.cc" file to deal with the new ways of input - take the inputs of differences and compute the real values. For this, I need to pass an additional entry into the "parse_map_to_double_array" function. I also added two ways of inputting these values: a. by arithmetic or b. by logarithmic. Anyway, write to me if you have any questions. Or we can first discuss it during a user meeting before you review it. Tell me what you think. |
Hi, would anyone jump in and take this review. Thanks for your help. |
Hi @lhy11009 thank you for the PR. We're preparing a new ASPECT release, so the focus lies on PR's with bug fixes at the moment. But we'll make sure to come back to this PR. |
@anne-glerum. By any chance, do we have reviewers available for this PR? No hurry, I am just commenting here in case it's been forgotten. |
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 @lhy11009 , thank you for the PR. It's in good shape. I have four overall remarks & points of discussion:
- The name of the parameter
Define phase properties by exact values instead of differences
is to me less intuitive thanDefine phase properties by differences instead of exact values
. Because, up till now, we have used the exact values. - The parse function can keep
allow_missing_keys
as last argument, so that you don't need to give it as argument each time you call the function. - Do all the phase parameters need the option to be passed as differences? If I remember correctly, we discussed the option for the density and there I think it makes sense. But for friction angles for example, do you see a use case?
- Why did you choose for some parameters to add logarithmically and for some not? This needs comments. Also, should it be user-specified?
tests/visco_plastic_phases_viscosity_jump/solution/solution-00000.0000.vtu
Outdated
Show resolved
Hide resolved
tests/visco_plastic_phases_viscosity_jump/solution/solution-00000.pvtu
Outdated
Show resolved
Hide resolved
@anne-glerum, a gentle reminder, do you have time to review this again? |
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.
@lhy11009, my apologies for the long wait.
There were still some comments open, and I've added some others. Mainly, there is a discrepancy between the name in the prm file Define phase properties by differences instead of exact values
and the parameter name in the code use_values_instead_of_differences
. I think the parameter name in the code should be reversed, this would then have to be changed everywhere (I have not pointed out all the locations).
I also think the 'quotient' difference should be documented better.
@jdannberg I would appreciate you having a look as well, as we three discussed this change.
include/aspect/material_model/equation_of_state/multicomponent_incompressible.h
Outdated
Show resolved
Hide resolved
e0e6d32
to
755ec1c
Compare
Thanks again, @anne-glerum. I have provided a review for every point you addressed. Meanwhile, I added some description of this piece of contribution and of the test I generated with it. Please take a second look when you have time and get back to me. |
@anne-glerum Feel free to point out more issue to address. I also added some description at the start of the PR, as well as a visualization of the test results. I also plan to open up a cookbook for the composition-dependent phase transition after this one is merged. At that point, this approach would be very clear to all users and it would be straight-forward to apply the major phase transitions in the MTZ. |
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 Anne, Sorry for the previous individual comments in the conversation. You must have received a lot of emails. Next time, I know how to use the "file change" for reviewing. Do you still find anything funky in this one?
source/material_model/equation_of_state/multicomponent_incompressible.cc
Outdated
Show resolved
Hide resolved
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 looking good, thanks for the updates! I found one tiny bug, the rest of my comments are edits of the text and its formatting.
doc/modules/changes/20220630_haoyuan
Outdated
by the differences between adjacent phases. If this is the case, | ||
then all the phase properties need to be entered by a value for the first phase | ||
followed by M-1 values for the differences between adjacent phases. | ||
Otherwise, the phase properties are entered by M values, each for a phase. |
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.
Otherwise, the phase properties are entered by M values, each for a phase. | |
Otherwise, the phase properties are entered by M values, one for each phase. |
doc/modules/changes/20220630_haoyuan
Outdated
then all the phase properties need to be entered by a value for the first phase | ||
followed by M-1 values for the differences between adjacent phases. | ||
Otherwise, the phase properties are entered by M values, each for a phase. | ||
Also note that when the option is true, the differences of the log values rather than the differences of the values are used |
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.
Also note that when the option is true, the differences of the log values rather than the differences of the values are used | |
Also note that when the option is true, the differences of the log values rather than | |
the differences of the values are used |
"If this parameter is true, " | ||
"then the input file will use a value for the first phase and M-1 values for the differences between phases " | ||
"to define the material properties (e.g. density)." | ||
"If it is false, the parameter file will use M values, one on each phase to" |
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.
"If it is false, the parameter file will use M values, one on each phase to" | |
"If it is false, the parameter file will use M values, one for each phase to" |
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.
Can you make each line roughly the same length and not too long? This makes it easier to read the code.
"then the input file will use a value for the first phase and M-1 values for the differences between phases " | ||
"to define the material properties (e.g. density). Also note that the differences by log values rather than the" | ||
"differences by values are used for the prefactors in the flow laws." | ||
"If it is false, the parameter file will use M values, one on each phase to" |
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.
"If it is false, the parameter file will use M values, one on each phase to" | |
"If it is false, the parameter file will use M values, one for each phase to" |
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.
Please make every line roughly the same short length (like in line 184 or 186).
std::vector<double> stress_exponents_diffusion_inputs = Utilities::parse_map_to_double_array(prm.get("Stress exponents for diffusion creep"), | ||
list_of_composition_names, | ||
has_background_field, | ||
"Prefactors for diffusion creep", |
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 this is a copy-paste error; shouldn't it be "Stress exponents for diffusion creep" instead of "Prefactors for diffusion creep"?
"then the input file will use a value for the first phase and M-1 values for the differences between phases " | ||
"to define the material properties (e.g. density). Also note that the differences by log values rather than the" | ||
"differences by values are used for the prefactors in the flow laws." | ||
"If it is false, the parameter file will use M values, one on each phase to" |
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.
same here as for the other rheology cc files
"If this parameter is true, " | ||
"then the input file will use a value for the first phase and M-1 values for the differences between phases " | ||
"to define the material properties (e.g. density)." | ||
"If it is false, the parameter file will use M values, one on each phase to" |
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.
same
There is also a conflict in source/utilities.cc that needs to be resolved before this PR can be merged. You can resolve a merge conflict by rebasing to an up to date 'main' branch while on the input_phase_properties branch with |
61a90da
to
1819198
Compare
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 Anne, I have addressed your comments. But unfortunately, the "parse_map_to_double_array" function has been completely rewritten in previous PRs. So I have to change my implementation as well. Can you review this part again? I have marked the points in the code.
* Whether to define the phase properties based | ||
* on the exact values, or the value differences. | ||
*/ | ||
bool use_differences_instead_of_values; |
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 found the function 'parse_map_to_double_array" has been rewritten in previous PRs. So I have to the add this attribute to the class they implemented.
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 would much prefer to have this information outside of the parse
function. The reason is the following:
This function can be used to parse arbitrary maps for any input parameter in ASPECT. We tried very hard to make it this generic. However, this new property is extremely specific and makes not much sense for other properties except the ones in material models. I understand that you need a way to modify the parsing if differences rather than values are expected, but I think this can be achieved in a more natural way (see comments below).
@@ -556,6 +569,7 @@ namespace aspect | |||
MapParsing::Options options(input_field_names, property_name); | |||
options.allow_multiple_values_per_key = allow_multiple_values_per_key; | |||
options.allow_missing_keys = allow_missing_keys; | |||
options.use_differences_instead_of_values = use_differences_instead_of_values; |
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.
So instead of handling the values of inputs, I can only pass this to the instance of this class. This class would then go through the interface of another function and reach the point where the inputs are actually handled (you can follow it in the code).
1819198
to
a31948f
Compare
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 Haoyuan,
Apologies for rewriting the parse_map function in #5055 so you had to redo some of your work, I didnt realize this PR involved changes to that function.
I had a brief look at this PR, and it generally looks in a good shape, but I want to raise the following question first:
Is there an application where you absolutely need this new feature? Can you describe it?
The reason I would like this clarified is that in your description of this PR you say: "... therefore it makes sense to have the interface directly import the values of the differences."
However, this is not exactly what you are doing here. Instead of always importing the differences, you add an additional way to input the values (in fact two, counting the log values as well), because we cannot remove the old way of providing values. As you noticed this adds a lot of complexity to the parsing function, and the fact that the new input is optional also adds an additional input parameter to all places that want to use it. In order to justify this added complexity we would need a reason to add it.
Even if there is an reason: Could there be a structurally easier way to achieve the same result? E.g. if it is more natural for the computation to use differences rather than values, but all of our input is meant for values, could we just compute the differences internally after parsing the values? If this is impossible with the current interface of the function, could we change the interface or make a new interface for the function? One option I have been thinking about during writing #5055 was to have a function return the actual multimap instead of a flattened vector of values. This would allow the calling function to easily compute the differences (or log values) for each phase internally by themselves, without having the user provide them. This way we could also save the additional input parameter, every material model or equation of state could decide for itself if it wants to deal only with values, or only with differences, or a mix of the two for different parameters (hard-coded, instead of chosen by the user).
I apologize that I bring this up now after you have put in all the work to polish this PR. This part of the input parsing has simply grown extremely complex, and I am hesitant to add further complexity to it. Let me know your thoughts, I am happy to help with changing parse_map_to_double_array
if you need additional options (if we decide to move forward in this direction with this PR, I have an idea for how to change the interface to at least not add another option to the function).
parse_map_differences_to_values( const std::vector<double>, | ||
const std::unique_ptr<std::vector<unsigned int>> &, |
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 function is missing names for the input arguments.
* Whether to define the phase properties based | ||
* on the exact values, or the value differences. | ||
*/ | ||
bool use_differences_instead_of_values; |
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 would much prefer to have this information outside of the parse
function. The reason is the following:
This function can be used to parse arbitrary maps for any input parameter in ASPECT. We tried very hard to make it this generic. However, this new property is extremely specific and makes not much sense for other properties except the ones in material models. I understand that you need a way to modify the parsing if differences rather than values are expected, but I think this can be achieved in a more natural way (see comments below).
then all the phase properties need to be entered by a value for the first phase | ||
followed by M-1 values for the differences between adjacent phases. | ||
Otherwise, the phase properties are entered by M values, one for each phase. | ||
Also note that when the option is true, the differences of the log values rather than |
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.
What is the reason for handling the prefactors differently? This needs to be documented in every material model input property that uses the log values rather than the actual values. Is there a functional reason this has to be the log value, or could you use for example the CitcomS notation, where every value is a multiplier to the initial value (i.e. prefactor = base_prefactor * multiplier_for_this_phase). This would seem easier to understand (e.g. I was at first confused that a value of 1 in the input file means change by one order of magnitude, and 0 would mean change nothing).
@@ -0,0 +1,9 @@ | |||
New: The values of the properties of material phases can be entered | |||
by the differences between adjacent phases. If this is 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.
Please leave a note here why this may be needed or a good idea. From the conversation in this PR I gather you have discussed that at some point with @jdannberg or @anne-glerum, but I (and other ASPECT users) were not part of that conversation, and the code itself does not seem to mention it. Without this explanation this looks like a whole lot of complication.
@gassmoeller. Thanks for your comments on the PR. We have discussed the reason to have this implementation is to have it handle a more complex scenario in the phase transitions. The current implementation we have could only handle layered phase transitions. The values entered through that interface has to be layered as the change has to go from phase 1 to 2, then to 3, in the exact order. If, say, phase 1 is transferred to phase 3 directly, then it cannot be achieved with the interface we have. If, on the other hand, we could pass in the value of differences instead, there is a way to do that, the transition from phase 1 to 3 is just another phase transition, where we can assign a clayperon slope and pass in the value differences across this phase transition. |
The idea of this PR is to only change the interface of the parse_map_to_double_array function so that the value exported from it remains the same no matter if the differences or the real values are entered. And originally I thought it wouldn't be a complexity when I was just considering adding up the differences to the base phase. But it turns out every interface on the way has to be changed, which I didn't expect honestly. |
@gassmoeller Anyway, maybe we can involve Magali in the conversation, as she might be able to explain things better than I do, and the three of us could have a short discussion about it? I could send an email around if you say yes. Thanks for your time. |
@gassmoeller. Hi Rene. I was thinking it would not be easy to explain everything here as well as the idea you have got for the implementation, so maybe a short discussion would be the best thing to do. I would vote for a 30 mins discussion. Anyway, get back to me when you have time. Thanks a lot. |
Sure, I am happy to meet. Would you have time during the ASPECT user meeting today? Otherwise we can also meet later, can you set up a when2meet or similar to find a time? I think we can probably clarify the questions in a short time, we should just take care to document the result of our discussion in this PR so that others can see the justification for whatever conclusion we come to. |
@gassmoeller @mibillen In this example, I use 3 phase transitions for the shallower basalt -> eclogite phase transition (yellow -> purple). There are assigned limits on temperature (this other PR), and values inputted by the differences between phases. Here is the prm file for this test: To run this test, you'll need to use my branch: @mibillen also has an idea of how to implement this change otherwise, maybe we could arrange a short meeting on the next user meeting? |
Thanks for providing the example, and yes I am happy to discuss at the next user meeting. However, I have a question about your example: To me it looks like the same behavior should have been possible with the old way of providing densities (as values instead of differences) and the following list of densities:
Please provide an example for why the new way of specifying properties is necessary, i.e. something that would not work with our current input options.. |
As an additional question: It looks like the function |
@gassmoeller , maybe you click the link to the other PR? There the file is different. But the prm I append in the conversation has: Secondly, you mentioned this option in the parse function. You are right about it. My consideration with this PR is to handle everything in the parse function, which would revert the differences to the real values with the new inputs. I was thinking about maintaining a minimum change to the other parts of the code. But now that you mentioned the interfaces of the parse function, we can handle it otherwise. |
@gassmoeller , maybe you click the link to the other PR? There the file is different. But the prm I append in the conversation has: Secondly, you mentioned this option in the parse function. You are right about it. My consideration with this PR is to handle everything in the parse function, which would revert the differences to the real values with the new inputs. I was thinking about maintaining a minimum change to the other parts of the code. But now that you mentioned the interfaces of the parse function, we can handle it otherwise. |
No, you misunderstand me. I have seen that the list of densities you give is the list of densities in your example model. My question is: Why do we need to specify it like this (as differences)? Why would the old way of specifying the densities (as values) not have worked? If you put in the following densities and use the old way of using densities, would you not get the same result?
|
@gassmoeller That's a good question. I guess it was one of our initial considerations. I have tried a couple of times to explain why it doesn't work and it's not so intuitive, it's better to show this with the example you inputted there. Let me try that first. |
But this is just a description, not an explanation. I can see from your figure that inputting the values leads to a different result, but I do not understand why. First, I do not understand why the other two branches of the first phase transition (left and right of the density anomaly around 150-200 km on the x axis) now do not exist. Second, I do not understand how inputting the full values, then computing the difference, then applying the phase function is different from inputting the difference, then applying the phase function. As far as I understand you are saying the following two operations lead to different results:
Did I misunderstand how our phase transitions work? |
Yes, I think it's a good point that we can write it out with the different expressions using the two methods. |
Hi Rene and Magali I am not sure I get the right time for the user meeting. I was in the zoom link but no one showed up. Would we choose another time for discussion? |
Haoyuan - I was in transit during the Aspect meeting this week.
Rene - did Haoyuan’s example calculation help to illustrate the issue that he is trying to resolve with the eclogite transition not being
a simple linear Clapeyron slope, dP/dT, transition like olivine/pyroxene… the phase boundary has 3 different segments depending on temperature (as actually some other phase transitions at the 660 do as well)?
If not, then I think it would be helpful to meet briefly via zoom.
Haoyuan is proposing a change that will work for the special case of the eclogite transitions AND will
also continue to work for the layered case.
I also suggested to him a more minor/backward compatible change to the parsing function to make this work.
I can meet next week any morning between 8-9 am if that would useful.
Magali
… On Mar 15, 2023, at 9:46 AM, lhy11009 ***@***.***> wrote:
Hi Rene and Magali
I am not sure I get the right time for the user meeting. I was in the zoom link but no one showed up. Would we choose another time for discussion?
—
Reply to this email directly, view it on GitHub <#4868 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACS64UTP2A3HFN4GIQU57ILW4HW6PANCNFSM52KNIYDQ>.
You are receiving this because you were mentioned.
____________________
Professor of Geophysics
Chair, EPS Graduate Program
Geophysics Minor Advisor
Department of Earth and Planetary Sciences
Univ. of California, Davis
Davis, CA 95616
2129 Earth & Physical Sciences Bldg.
Office Phone: (530) 752-4169
https://magalibillen.faculty.ucdavis.edu/
Students - need to meet with me? Check available appointment times:
https://calendar.app.google/49asftepWVS1AFvy9
Or e-mail me list of days/times you are available & topic of discussion.
Pronouns: She/her/hers
First Generation College Student: https://firstgen.ucdavis.edu/
|
Haoyuan you were late to the user meeting. California and Florida change to daylight savings time at the same date, so the meeting happened at the same time as usual, but we had already finished when you joined (I only saw the email later). Magali thanks for offering, yes I think it would be good if we could meet this week. Would Thursday 8-9 am Pacific work for both of you? (I can also do Friday if Thursday doesnt work). Let me know. In preparation for this meeting, here are my two major concerns we need to address before we can move forward with this PR:
|
@gassmoeller, the time works for me. Sorry for being late at the meeting, last week was a mess. I was late for two meetings and early for one another depending on where others are. I guess I can better explain your question with a board (or a notebook on PC). |
No worries, time change week is always confusing.
Ok, let's aim for that if it works for Magali as well. |
subsection Material model | ||
set Model name = visco plastic | ||
subsection Visco Plastic | ||
set Phase transition depths = background:50e3|75e3, right:50e3|75e3 |
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.
Please also add a test that changes the plastic parameter angle of friction and cohesion.
Some additional comments:
|
a31948f
to
1121dbd
Compare
|
@gassmoeller Definitely. Thanks for the reminder. |
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.
Describe what you did in this PR and why you did it.
Before your first pull request:
For all pull requests:
For new features/models or changes of existing features: