Skip to content
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

Fluidity advection 2d #174

Merged
merged 7 commits into from
Mar 25, 2024
Merged
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
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: '3.12'

- name: Install and test
run: |
sudo apt-get update
sudo apt-get install -y libglu1-mesa
sudo apt-get install -y python3-pip
python3 -m pip install --upgrade pip
python3 -m pip install "$PWD[test]"
Expand All @@ -41,7 +42,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: '3.12'

- name: Install and test
run: |
Expand All @@ -61,7 +62,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: '3.12'

- name: Install and test
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: '3.12'

- name: Build
run: |
Expand All @@ -33,7 +33,7 @@ jobs:
python3 -m venv .venv-gh-pages
source .venv-gh-pages/bin/activate
python3 -m pip install "$PWD"[doc,test]
pdoc -t docs/template -o html --math pydrex tests
pdoc -t docs/template -o html --math pydrex !pydrex.mesh tests
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
# If you're changing the branch from main,
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ use `pip install -e "$PWD[dev]"`.

The package metadata and full list of dependencies are specified in [`pyproject.toml`](pyproject.toml).

Optional mesh generation using [gmsh](https://pypi.org/project/gmsh/) is available,
however the `gmsh` module requires the [`glu`](https://gitlab.freedesktop.org/mesa/glu) library
(that may not be installed by default on all systems).

## Test

Some tests can optionally output figures or extended diagnostics when run locally.
Expand Down
18 changes: 18 additions & 0 deletions examples/fluidity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Fluidity examples

Most parameters can be set in the relevant makefiles, except for the number of
grains, which is defined by `(N - 22) / 10` where `N` is the dimension of the
`CPO_` array in the Fluidity `.flml` file. Timestepping options are also set
in the `.flml` file.

To run the example contained in `example_directory`,
ensure that the `envcheck.sh` script is available, and simply run
`make -f example_directory/Makefile`.
To clean previous simulation output use the
`make -f example_directory/Makefile clean` target.

This table lists the corresponding PyDRex tests:

| Fluidity example | PyDRex test |
| --- | --- |
| `advection2d` | `test_simple_shear_2d.TestOlivineA.test_dudz_pathline` |
63 changes: 63 additions & 0 deletions examples/fluidity/advection2d/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Make options to keep what's left of our sanity.
.SHELLFLAGS += -u
.ONESHELL:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
# Path options, SIM_NAME is the name of the .msh and .py files.
SIM_NAME := advection2d
SRC_DIR := advection2d
OUT_DIR := _out
# Initial geometry options (in units of metres), passed to `pydrex-mesh`.
WIDTH := 4e5
DEPTH := 4e5
RESOLUTION := 1e3
# Initial conditions, used to parametrise velocity fields and spawn particles.
# INIT_HORIZ can be a space-delimited array of values (for multiple particles).
STRAIN_RATE := 1e-15
INIT_HORIZ := -1e5
INIT_VERT := 1e5
# Recrystallisation parameters.
STRESS_EXPONENT := 1.5
DEFORMATION_EXPONENT := 3.5
GBM_MOBILITY := 10
GBS_THRESHOLD := 0.3
NUCLEATION_EFFICIENCY := 5

$(OUT_DIR)/fluidity.log-0: $(OUT_DIR)/$(SIM_NAME).flml $(OUT_DIR)/$(SIM_NAME).msh $(OUT_DIR)/$(SIM_NAME).py $(OUT_DIR)/$(SIM_NAME).ini
@echo "********** Running fluidity with verbose logging enabled..."
./envcheck.sh -f
cd $(OUT_DIR) && fluidity -v2 -l $(SIM_NAME).flml

$(OUT_DIR)/$(SIM_NAME).ini: $(OUT_DIR)/$(SIM_NAME).py
@echo "********** Setting up initial conditions and recryst. parameters..."
echo "[initial conditions]" > $@
echo "WIDTH = $(WIDTH)" >> $@
echo "DEPTH = $(DEPTH)" >> $@
echo "RESOLUTION = $(RESOLUTION)" >> $@
echo "STRAIN_RATE = $(STRAIN_RATE)" >> $@
echo "INIT_HORIZ = $(INIT_HORIZ)" >> $@
echo "INIT_VERT = $(INIT_VERT)" >> $@
echo "STRESS_EXPONENT = $(STRESS_EXPONENT)" >> $@
echo "DEFORMATION_EXPONENT = $(DEFORMATION_EXPONENT)" >> $@
echo "GBM_MOBILITY = $(GBM_MOBILITY)" >> $@
echo "GBS_THRESHOLD = $(GBS_THRESHOLD)" >> $@
echo "NUCLEATION_EFFICIENCY = $(NUCLEATION_EFFICIENCY)" >> $@

$(OUT_DIR)/$(SIM_NAME).py: $(SRC_DIR)/$(SIM_NAME).py
@echo "********** Copying python velocity callables..."
mkdir -p $(@D)
cp -f $< $@

$(OUT_DIR)/$(SIM_NAME).flml: $(SRC_DIR)/$(SIM_NAME).flml
@echo "********** Copying serial flml file..."
mkdir -p $(@D)
cp -f $< $@

$(OUT_DIR)/$(SIM_NAME).msh:
@echo "********** Building the mesh file..."
./envcheck.sh -m
pydrex-mesh -k="rectangle" -a xy $(WIDTH),$(DEPTH) $(RESOLUTION) $@

.PHONY: clean
clean:
rm -rf $(OUT_DIR)
Loading
Loading