geodynamics / aspect

A parallel, extensible finite element code to simulate convection in both 2D and 3D models.
https://aspect.geodynamics.org/
Other
227 stars 237 forks source link

Discrete phase funcion #6131

Open lhy11009 opened 2 weeks ago

lhy11009 commented 2 weeks ago

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.

Headline

I added a new class of phase function that handles discrete phase transitions by looking up the most dominant phases in a lookup table.

This is now ready for a review. @gassmoeller technically advises me in the PR. @ryanstoner1, I borrowed some of the ideas from your previous PR. I want to thank both of your perspectives. I also want to keep @mibillen posted on the progress of this work. This is really cool idea. To those who are interested, this PR would add a flexible utility to look up phase indicators in the material data files and use a distinct set of rheologic parameters. The new class we defined here only requires a small tweak in the material model itself, and thus would be portable to material models other than the visco plastic model.

Before your first pull request:

For all pull requests:

For new features/models or changes of existing features:

lhy11009 commented 2 weeks ago

Implementation Overview

Tests

Test visco_plastic_phase_discrete

I've added a new test called visco_plastic_phase_discrete, where I use a small lookup table to conduct the test. This lookup table includes four points, with the dominant phase index assigned a value of 0 for the two low-pressure points and a value of 1 for the high-pressure points. For the rheologic parameters, I’m using diffusion creep, assigning a weaker rheology to phase 1. The results I’ve generated include pressure (P), temperature (T), and the resulting viscosity. The change in viscosity occurs around (P = 2 \times 10^{10}), which lies between the two pressure values (0 and ($4 \times 10^{10}$)) specified in the lookup table.

combine_images

lhy11009 commented 2 weeks ago

Test visco_plastic_phase_discrete_comp

I’ve also included a test case visco_plastic_phases_discrete_comp for the second composition, where I assigned a viscosity of ($1 \times 10^{24}$) Pa·s to the phase 0 of the second composition and ($1 \times 10^{14}$) Pa·s to the phase 1 of the same composition.

discrete_phase_2nd_visc

Test visco_plastic_phase_discrete_comp_invert

Furthermore, I've tested invert the phase lookup, such that we look for index 0 as the most abundant phase and assign it a smaller viscosity. This demonstrates the flexibility of the implementation: arbitrary phases can be assigned distinct rheology as long as they are marked in the look-up table in the first place.

discrete_phase_2nd_visc_invert

lhy11009 commented 2 weeks ago

Test visco_plastic_phase_discrete_mixed

This approach is followed by another test visco_plastic_phases_discrete_mixed, assigning a 0.5, 0.5 compositional fraction to the background and the "spharz" composition to facilitate compositional mixing. The results of the mixing are shown in the attached figure. Note that the range of values differs from the previous plot.

In the region of phase 0, the background composition has a viscosity of ($1 \times 10^{20}$) Pa·s, while the "spharz" composition has a viscosity of ($1 \times 10^{24}$) Pa·s, resulting in a mixed viscosity of around ($2 \times 10^{20}$) Pa·s. In contrast, in the region of phase 1, the background composition has a viscosity of ($1 \times 10^{18}$) Pa·s, while the "spharz" composition has a viscosity of ($1 \times 10^{14}$) Pa·s, leading to a mixed viscosity of ($2 \times 10^{14}$) Pa·s.

discrete_phase_mix_visc

lhy11009 commented 2 weeks ago

Some related PR ideas

lhy11009 commented 1 week ago

Hi @gassmoeller, Thank you for your comments to make it in better shape. I have now addressed these comments, so you can start another review.

gassmoeller commented 1 week ago

Could you check why the tests are failing?

lhy11009 commented 1 week ago

Hi Rene (@gassmoeller ), can you take a look at the issue in "no_unity-build" test. Building on my local PC is fine. Moreover, this issue is from the reference to the functions in the newly defined PhaseFunctionDiscrete class. If it raises issue there, I am confused why the link to the previous PhaseFunction class is established in the first place.

gassmoeller commented 1 week ago

I'll try to get to the review tomorrow, but about the test failures: It looks like you are missing an explicit instantiation of your new template class. Check the bottom of material_models/utilities.cc and what we do in line 1543 for PhaseFunction. You can check if it works on your local machine if you rerun cmake with -DASPECT_UNITY_BUILD=OFF and then recompile aspect.

lhy11009 commented 6 days ago

Thanks, Rene, for a lot of insightful review points. Especially about the unique_ptr, I think this time I have a feel for that. The time I changed to unique_ptr, I had to go over a few bugs already. In a way, this forces me to be careful. Here, I leave 3 open conversations for you to respond to double-check.

Let me know what you think of them.

gassmoeller commented 3 days ago

Is this ready for another look or do you plan to make more changes first?

lhy11009 commented 2 days ago

Rene, it's really for another look. Sorry, I forgot to put the comments in the end.