Skip to content

st4sd/flow-simulator-experiment

Repository files navigation

Flow Simulator Experiments

This ST4SD experiment runs flow simulations in a capillary network, including the geometry modification effects caused by erosion, precipitation, dissolution and deposition.

Run simulations using the Docker backend of ST4SD

Prerequisites

  1. A recent version of python 3 - python 3.7+
  2. A container runtime like docker and podman
  3. The git command-line utility

Running Simulations Coupled with the Geometry Modification Module

You can try out the Geometry Modification Module experiment on your laptop by:

  1. creating a python virtual environment, activating it, and installing the python module st4sd-runtime-core[deploy]
  2. cloning this repository
  3. creating simulations-data folder to be used as an application dependency
  4. launching the experiment

For example, if you are using docker you can run :

: Download virtual experiment
git clone https://github.com/st4sd/flow-simulator-experiment.git
cd flow-simulator-experiment

: Setup ST4SD Core
python3 -m venv --copies venv
. venv/bin/activate
python3 -m pip install "st4sd-runtime-core[develop]"

: Run a Geometry Modification Module Experiment
cat <<EOF >variables.yaml
global:
  s3Folder: "my_simulation_folder"
  centerlinesFile: "centerlines"
  csvFile: "my_cases_file.csv"
  numberOfCases: 3
  binaryImage: "binary_image"
EOF
time elaunch.py -l 40 --platform docker \
    -s simulations-data:simulations-data:copy \
    -a variables.yaml --manifest manifest.yaml conf/flowir_package_gmm.yaml

: See outputs of experiment
output_dir=$(ls -td flowir_package_gmm*.instance | head -1)
results_dir=${output_dir}stages/stage2/AggregateGMMResults/
echo The outputs of the experiment are in ${results_dir}
ls -lth ${results_dir}

Note: The above should take just a couple of minutes from start to finish.

If you are using podman as your container runtime, you should configure it like this before running the experiment:

podman machine set --rootful

before running

podman machine start

Also, include

--dockerExecutableOverride=`which podman` 

to the command line arguments like so:

time elaunch.py -l 40 --platform docker --dockerExecutableOverride=`which podman` \
    -s simulations-data:simulations-data:copy \
    -a variables.yaml --manifest manifest.yaml conf/flowir_package_gmm.yaml

Running Static Simulations

  1. Create a new folder inside simulations-data with a centerlines.json file.
  2. To create the variables.yaml file, run the following command replacing the values if needed:
cat <<EOF >variables.yaml
global:
  numberOfNetworks: 30
  s3Folder: "my_simulation_folder"
  sampleFileName: "centerlines.json"
  voxelSize_m: 2.25e-6
  capillaryLength_m: 4.5e-5
  sampleSize_m: 3.0e-4
  dynamicViscosity_Pas: 1.002e-3
  temperature_K: 340.0
  absolutePressure_Pa: 101325.0
  pressureGradient_Pa: 10132.5
EOF
  1. Run elaunch.py command replacing the path to your simulations-data folder. If you are using docker, run:
time elaunch.py -l 40 --platform docker \
    -s simulations-data:simulations-data:copy \
    -a variables.yaml --manifest manifest.yaml conf/flowir_package_static.yaml

If you are using podman, run:

time elaunch.py -l 40 --platform docker --dockerExecutableOverride=`which podman` \
    -s simulations-data:simulations-data:copy \
    -a variables.yaml --manifest manifest.yaml conf/flowir_package_static.yaml

Running Dynamic Simulations

  1. Create a new folder inside simulations-data with a centerlines.tar file (see instructions about this file below). It is possible to use centerlines.tar files generated by previous executions of static simulations. To use the centerlines.tar from the latest execution and copy it to simulation-data/my_simulation_folder, run:
output_dir=$(ls -td flowir_package_static-*.instance | head -1)
cp "${output_dir}/stages/stage2/AggregateStaticResults/centerlines.tar" "simulations-data/my_simulation_folder/centerlines.tar"
  1. To create the variables.yaml file, run the following command replacing the values if needed:
cat <<EOF >variables.yaml
global:
  numberOfCenterlines: 30
  s3Folder: "my_simulation_folder"
  voxelSize_m: 2.25e-6
  capillaryLength_m: 4.5e-5
  sampleSize_m: 3.0e-4
  contactAngle_deg: 0.0
  linearMK: 0.0
  interfacialTension_Nm: 0.04
  temperature_K: 400.0
  absolutePressure_Pa: 10000000.0
  pressureGradient_Pa_m: 10e6
  dynamicViscosityWater_Pas: 0.000260196
  dynamicCiscosityCO2_Pas: 3.26e-5
  initialTime_s: 0.0
  finalTime_s: 0.05
  timeStepSize_s: 0.001
EOF
  1. Run elaunch.py command replacing the path to your simulations-data folder. If you are using docker, run:
time elaunch.py --platform docker \
    -s simulations-data:simulations-data:copy \
    -a variables.yaml --manifest manifest.yaml conf/flowir_package_dynamic.yaml

If you are using podman, run:

time elaunch.py --platform docker --dockerExecutableOverride=`which podman` \
    -s simulations-data:simulations-data:copy \
    -a variables.yaml --manifest manifest.yaml conf/flowir_package_dynamic.yaml

Centerlines files

To perform dynamic simulations it is required to provide the centerlines to be used. They should be all in a single compressed file named centerlines.tar and each centerline must follow the following name convenction:

  • centerlines
    • centerlines_0000.json
    • centerlines_0001.json
    • centerlines_0002.json
    • ...

About

Capillary network experiments with ST4SD

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages