Skip to content

Add wolf-sheep-soil-creep tutorial#793

Open
joargu wants to merge 10 commits into
precice:developfrom
joargu:develop
Open

Add wolf-sheep-soil-creep tutorial#793
joargu wants to merge 10 commits into
precice:developfrom
joargu:develop

Conversation

@joargu
Copy link
Copy Markdown

@joargu joargu commented May 25, 2026

Description

Added a new wolf-sheep-soil-creep tutorial coupling Mesa (ABM) and Landlab (PDE) via preCICE.

Checklist

Copy link
Copy Markdown
Member

@MakisH MakisH left a comment

Choose a reason for hiding this comment

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

Hi @joargu! This PR is coming out of the blue for me, but it might be the cleanest PR I have ever reviewed for a new tutorial! 😄

I can run the tutorial on my system, which completes in a few seconds (very good for a tutorial). There are no external adapters used, since the two codes are given (both in Python, both already with requirements.txt). I think this would be a nice tutorial, both to showcase coupling with an ABM code, and to showcase a very different application.

You could also add the two codes in the list of third-party adapters, including contact details. At the moment, I have no idea of the context/contact.

I only have two points where this needs improvement: a bit more description, and a fix in the plotting.

Time-wise, this is also good: We are about to make a new release of the tutorials, and it would be great to have this in there.

Comment thread wolf-sheep-soil-creep/precice-config.xml
Comment thread wolf-sheep-soil-creep/README.md Outdated
Comment thread wolf-sheep-soil-creep/README.md

## Setup

This is an implementation of Landlab's [Wolf-Sheep-Grass Model with Soil Creep](https://landlab.csdms.io/tutorials/agent_based_modeling/wolf_sheep/wolf_sheep_with_soil_creep.html) example, coupled via preCICE. We couple the [Wolf-Sheep model from MESA](https://mesa.readthedocs.io/latest/examples/advanced/wolf_sheep.html) with a soil creep model implemented in Landlab.
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.

Since this tutorial is rather novel for our community, could you please extend this paragraph with a few sentences on the general concept?

cmap="coolwarm_r",
colorbar_label="Depth of soil accumulation (+) or loss (-), m",
)
plt.show()
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.

From these three plt.show(), I am getting:

UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown

and no images are generated. The simplest solution (and the one that would fit automated testing the most) would be to write the images to disk, instead of showing them.

@uekerman uekerman self-requested a review May 26, 2026 09:35
Copy link
Copy Markdown
Member

@uekerman uekerman left a comment

Choose a reason for hiding this comment

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

Thanks, @joargu 🙏
I agree that this is already in pretty good shape. I have not run the case yet, but would like to do so once we fix the plotting issue mentioned above.

Only cosmetics below.

---
title: Wolf-sheep-grass model with soil creep
permalink: tutorials-wolf-sheep-soil-creep.html
keywords: MESA, Landlab, wolf-sheep-grass, soil creep, ABM
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.

Suggested change
keywords: MESA, Landlab, wolf-sheep-grass, soil creep, ABM
keywords: MESA, Landlab, wolf-sheep-grass, soil creep, ABM, agent-based modeling


## Setup

This is an implementation of Landlab's [Wolf-Sheep-Grass Model with Soil Creep](https://landlab.csdms.io/tutorials/agent_based_modeling/wolf_sheep/wolf_sheep_with_soil_creep.html) example, coupled via preCICE. We couple the [Wolf-Sheep model from MESA](https://mesa.readthedocs.io/latest/examples/advanced/wolf_sheep.html) with a soil creep model implemented in Landlab.
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.

Here would also be a good place to explicitly link to the sources (not just the rendering) and mention that they are licensed under MIT.


## Running the simulation

Open two separate terminals and start the soil creep and wolf sheep participant by calling the respective run scripts `run.sh` located in each of the participants' directory. For example:
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.

Suggested change
Open two separate terminals and start the soil creep and wolf sheep participant by calling the respective run scripts `run.sh` located in each of the participants' directory. For example:
Open two separate terminals and start the soil creep and wolf sheep participants by calling the respective run scripts `run.sh` located in each of the participants' directories. For example:


## Post-processing

The Soil-Creep participant generates Python-based visualizations. The following examples were generated by setting rng=42 in the WolfSheepScenario for the wolf-sheep-grass participant.
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.

Suggested change
The Soil-Creep participant generates Python-based visualizations. The following examples were generated by setting rng=42 in the WolfSheepScenario for the wolf-sheep-grass participant.
The Soil-Creep participant generates Python-based visualizations. The following examples were generated by setting `rng=42` in the WolfSheepScenario for the wolf-sheep-grass participant.

and please add this line in the example above. Also for regression testing, this will be important.

Comment on lines +10 to +12
hstar = 0.2
fast_creep = 0.1
slow_creep = 0.001
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.

Could you add some comments here on what these parameters mean?

creep_coef = rmg.add_zeros("creep_coefficient", at="node")

# Create a soil-thickness field
soil = rmg.add_zeros("soil__depth", at="node")
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.

Suggested change
soil = rmg.add_zeros("soil__depth", at="node")
soil = rmg.add_zeros("soil_depth", at="node")

or what is the definition behind using two "_"?


# Run the soil-creep model
prior_elev[:] = elev
diffuser.run_one_step(dt)
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 guess this updates elev? Where could I see more about this?
(a comment could probably be good here)

Comment on lines +12 to +14
# Use dx of Raster Model Grid from Soil Creep for solver_dt calculation
dx = 1.0
fast_creep = 0.1
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.

The dx here also makes sense from the perspective of MESA, right? But the fast_creep doesn't.
Maybe it could be easier to simply hard-code the solver_dt here and comment that we do this to ensure matching time step sizes.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants