Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions wolf-sheep-soil-creep/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Wolf-sheep-grass model with soil creep
permalink: tutorials-wolf-sheep-soil-creep.html
aliases:
- /tutorials-wolf-sheep-soil-creep.html
keywords: MESA, Landlab, wolf-sheep-grass, soil creep, ABM, agent-based modeling
keywords: MESA, Landlab, FEniCSx, wolf-sheep-grass, soil creep, ABM, agent-based modeling
summary: Example of bi-directional ABM-PDE coupling via preCICE.
---

Expand Down Expand Up @@ -31,6 +31,10 @@ Soil-Creep PDE participant:

* Landlab. Numerical modeling of Earth surface dynamics. For more information, have a look at the [Landlab documentation](https://landlab.csdms.io/index.html).

* Standalone reimplementation of the Landlab participant, tailored to this example.

* FEniCSx. For more information, have a look at the [FEniCSx adapter](https://precice.org/adapter-fenicsx.html).

Wolf-Sheep-Grass ABM participant:

* MESA. Agent-based modeling (or ABM) framework. For more information have a look at the [MESA documentation](https://mesa.readthedocs.io/latest/index.html)
Expand All @@ -44,6 +48,20 @@ cd soil-creep-landlab
./run.sh
```

or

```bash
cd soil-creep-simplified-landlab
./run.sh
```

or

```bash
cd soil-creep-fenicsx
./run.sh
```

and

```bash
Expand All @@ -53,7 +71,7 @@ cd wolf-sheep-grass-mesa

## Post-processing

The soil-creep participant generates Python-based visualizations, which are written to `soil-creep-landlab/output`. 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, which are written to `soil-creep-landlab/output` or `soil-creep-fenicsx/output`, depending on which participant is used. The following examples were generated by Landlab with `rng=42` in the `WolfSheepScenario` for the wolf-sheep-grass participant.

![erosion/deposition patterns](images/tutorials-wolf-sheep-soil-creep-erosion_deposition_patterns.png)
![soil thickness](images/tutorials-wolf-sheep-soil-creep-soil_thickness.png)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 13 additions & 21 deletions wolf-sheep-soil-creep/precice-config.xml
Original file line number Diff line number Diff line change
@@ -1,69 +1,61 @@
<?xml version="1.0" encoding="UTF-8" ?>
<precice-configuration>

<log>
<sink
filter="%Severity% > debug"
format="---[precice] %ColorizedSeverity% %Message%"
enabled="true" />
</log>


<data:scalar name="Grass" />
<data:scalar name="Soil" />

<mesh name="Wolf-Sheep-Grass-Mesh" dimensions="2">
<use-data name="Grass" />
<use-data name="Soil" />
</mesh>

<mesh name="Soil-Creep-Mesh" dimensions="2">
<use-data name="Grass" />
</mesh>

<mesh name="Soil-Grass-Mesh" dimensions="2">
<use-data name="Soil" />
</mesh>

<mesh name="Soil-Depth-Mesh" dimensions="2">
<use-data name="Soil" />
</mesh>

<participant name="Wolf-Sheep-Grass">
<receive-mesh name="Soil-Depth-Mesh" from="Soil-Creep" />
<receive-mesh name="Soil-Creep-Mesh" from="Soil-Creep" />
<provide-mesh name="Wolf-Sheep-Grass-Mesh" />
<provide-mesh name="Soil-Grass-Mesh" />
<write-data name="Grass" mesh="Wolf-Sheep-Grass-Mesh" />
<read-data name="Soil" mesh="Soil-Grass-Mesh" />
<read-data name="Soil" mesh="Wolf-Sheep-Grass-Mesh" />
<mapping:nearest-neighbor
direction="read"
from="Soil-Depth-Mesh"
to="Soil-Grass-Mesh"
from="Soil-Creep-Mesh"
to="Wolf-Sheep-Grass-Mesh"
constraint="consistent" />
</participant>

<participant name="Soil-Creep">
<receive-mesh name="Wolf-Sheep-Grass-Mesh" from="Wolf-Sheep-Grass" />
<provide-mesh name="Soil-Creep-Mesh" />
<provide-mesh name="Soil-Depth-Mesh" />
<read-data name="Grass" mesh="Soil-Creep-Mesh" />
<write-data name="Soil" mesh="Soil-Depth-Mesh" />
<write-data name="Soil" mesh="Soil-Creep-Mesh" />
<mapping:nearest-neighbor
direction="read"
from="Wolf-Sheep-Grass-Mesh"
to="Soil-Creep-Mesh"
constraint="consistent" />
</participant>


<m2n:sockets acceptor="Wolf-Sheep-Grass" connector="Soil-Creep" exchange-directory=".." />


<coupling-scheme:serial-explicit>
<participants first="Soil-Creep" second="Wolf-Sheep-Grass" />
<time-window-size value="2" />
<max-time value="100" />
<exchange
data="Grass"
mesh="Wolf-Sheep-Grass-Mesh"
from="Wolf-Sheep-Grass"
to="Soil-Creep"
initialize="true" />
<exchange data="Soil" mesh="Soil-Depth-Mesh" from="Soil-Creep" to="Wolf-Sheep-Grass" />
<exchange data="Grass" mesh="Wolf-Sheep-Grass-Mesh" from="Wolf-Sheep-Grass" to="Soil-Creep" initialize="true"/>
<exchange data="Soil" mesh="Soil-Creep-Mesh" from="Soil-Creep" to="Wolf-Sheep-Grass" />
</coupling-scheme:serial-explicit>

</precice-configuration>
11 changes: 11 additions & 0 deletions wolf-sheep-soil-creep/soil-creep-fenicsx/clean.sh
Comment thread
joargu marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env sh
set -e -u

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"

rm -rfv ./output/

. ../../tools/cleaning-tools.sh

clean_fenicsx .
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"participant_name": "Soil-Creep",
"precice_config_file_path": "../precice-config.xml",
"interfaces": [
{
"mesh_name": "Soil-Creep-Mesh",
"write_data": [
{
"name": "Soil"
}
],
"read_data": [
{
"name": "Grass"
}
]
}
]
}
4 changes: 4 additions & 0 deletions wolf-sheep-soil-creep/soil-creep-fenicsx/requirements.txt
Comment thread
joargu marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
numpy >1, <2
fenicsxprecice~=1.0
matplotlib>=3,<4
pyprecice~=3.0
23 changes: 23 additions & 0 deletions wolf-sheep-soil-creep/soil-creep-fenicsx/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e -u

. ../../tools/log.sh

exec > >(tee --append "$LOGFILE") 2>&1

if [ ! -v PRECICE_TUTORIALS_NO_VENV ]; then

if [ ! -d ".venv" ]; then
python3 -m venv --system-site-packages .venv
source .venv/bin/activate
pip install -r requirements.txt && pip freeze > pip-installed-packages.log
else
source .venv/bin/activate
fi

fi

mkdir -p output
python3 soil_creep.py

close_log
Loading
Loading