Skip to content

[Feature] Ability to set initial accumulated plastic strain#41

Merged
sgeotech merged 4 commits into
UniMainzGeo:masterfrom
mitchellmcm27:mitchellmcm27/feature-initial_aps
Sep 17, 2025
Merged

[Feature] Ability to set initial accumulated plastic strain#41
sgeotech merged 4 commits into
UniMainzGeo:masterfrom
mitchellmcm27:mitchellmcm27/feature-initial_aps

Conversation

@mitchellmcm27
Copy link
Copy Markdown
Contributor

@mitchellmcm27 mitchellmcm27 commented Aug 27, 2025

Motivation

I want to add the ability to set the initial APS, similar to how we can set the initial temperature and phases on the domain. Although pretty simple, this feature involves coordinated PRs in LaMEM, LaMEM.jl and GeophysicalModelGenerator.jl (see below). The changes are meant to be fully backwards compatible. I am leaving this as a draft as I want to get some feedback on the approach.

Summary of changes

LaMEM.jl (JuliaGeodynamics/LaMEM.jl#92)

  • adds APS as a property of Grid and passes it to CartData
  • adds ability to plot plast_strain as a cross-section (name matches Paraview field)
  • adds out_ptr_APS option to include APS on passive tracers (defaults to 0)

GeophysicalModelGenerator.jl (JuliaGeodynamics/GeophysicalModelGenerator.jl#184)

  • writes APS from Grid as an additional property in the marker binary file (defaults to 0 if not given)
  • increments the file header to enable backwards compatibility

LaMEM (this PR)

  • sets initial APS, if present, from marker binary file
  • interprets the file header (previously ignored) as a version number to maintain backwards compatibility
  • outputs APS as a field on markers
  • optionally outputs APS as a field on passive tracers (defaults to no APS output)
  • confirmed all tests pass locally

Outstanding questions

There is some averaging of initial APS that seems to be related to projecting from grid, to markers, back to grid, e.g., setting random values between 0 and 1 gives a result where the values are between ~0.4 and 0.6. I think it has something to do with APS being a deviatoric variable. Is there a way to work around this? Does it even matter given that the markers retain values between 0 and 1 (see below)?

Should I write a test for this, and which repository would be best for that?

Is this something that can eventually be merged into all 3 repositories?

Example & screenshots

Using the code

using Random
Random.seed!(2222)
model.Grid.APS .= 0.0
is_crust = model.Grid.Grid.Z .< 0 .&& model.Grid.Grid.Z .> -50.0
model.Grid.APS[is_crust] = rand(Float64, size(model.Grid.APS[is_crust]))

Cross section of initial conditions with initial APS is set to 0-1 in the crust:
image

Model3D.vts where APS is still between 0 and 1. Note: this mesh is not uniform, so the smearing at the edges is correct:

plast_strain_vts

output.pvd at t=0 where APS is now ~0.4 to 0.6:
plast_strain_pvd

Markers after 1 time step with APS output (values between 0 and 1):
plast_strain_mark

Passive tracers with APS output:
plast_strain_ptr

@boriskaus
Copy link
Copy Markdown
Contributor

Thanks, this is a very useful contribution that we in fact discussed not long ago!
Few remarks:

  • Yes, please add tests for reading marker files with and without APS. Please add that to LaMEM itself, so we can test it directly in this repo
  • Part of the issue with interpolating back and forth appears to be that you have lots of variation in APS on the markers within a single cell, which will indeed be smoothend by interpolation. Why don't you try generating random variations on properyies within individual cells (taking the grid solurtiion into account) and set only one value of APS within a single cell? I imagine that this will reduce the issue.
  • Sure, we can merge this in all repo's. We should start with the main LaMEM, though (this repo). We will have to build new binaries (so create a new LaMEM_jll) before this has an affect on LaMEM.jl.
  • @sgeotech should have a detailed look at the code. To me, the changes seem sufficiently minor to warant adding this to LaMEM/master before the upcoming big release is merged.

@sgeotech
Copy link
Copy Markdown
Collaborator

Thanks for this interesting contribution. We indeed discussed implementing just that a couple of days ago. The codes look good, but unfortunately I'm fully booked until mid September, because of GeoMod. I will look at the PR just after the conference. Thanks again!

@mitchellmcm27
Copy link
Copy Markdown
Contributor Author

Tests added to the best of my ability. Note that running the tests also produces PVD output that can be inspected (but is gitignored).
Thanks for the quick and supportive responses!

@sgeotech sgeotech marked this pull request as ready for review September 17, 2025 14:14
@sgeotech sgeotech merged commit fc41177 into UniMainzGeo:master Sep 17, 2025
2 checks passed
@sgeotech
Copy link
Copy Markdown
Collaborator

Hi Mitchell,

Thanks again for your valuable contribution. There is a little issue. I accidentally overlooked two rather big binary files with markers in your pull request and merged them into master. After realizing my mistake I purged them form the repository history using the filter-repo script and temporarily deactivated the associated test. Would it be possible to modify this test such that these files are generated on the fly? That would be really great.

Thanks,
Anton

@mitchellmcm27
Copy link
Copy Markdown
Contributor Author

No problem! I created a new PR for that.

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