-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add pyiron based example * Add conda_subprocess as dependency * remove empty lines * Update source path * Add Readme * rename functions * Update exemplary_workflow/pyiron/README.md Co-authored-by: Philipp Diercks <55233917+pdiercks@users.noreply.github.com> * Add explanation about storage in the README * Use f-strings to call executables --------- Co-authored-by: Philipp Diercks <55233917+pdiercks@users.noreply.github.com>
- Loading branch information
1 parent
3c6ff77
commit 652d7c3
Showing
3 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# pyiron | ||
This directory contains an implementation of the exemplary workflow with [pyiron](https://pyiron.org/) or more specifically the [pyiron_base](https://pyiron-base.readthedocs.io) workflow manager. | ||
|
||
## Installation | ||
For more detailed information we refer to the official [documentation](https://pyiron-base.readthedocs.io/en/latest/installation.html). | ||
The recommended way of installing `pyiron_base` is via conda, because it also enables `pyiron_base` to handle software dependencies of your workflow using the [conda_subprocess](https://github.com/pyiron/conda_subprocess) package. | ||
|
||
You can then install `pyiron_base` with | ||
```sh | ||
mamba create -c conda-forge -n pyiron_base pyiron_base=0.7.11 conda_subprocess=0.0.1 | ||
``` | ||
|
||
## Running the exemplary workflow | ||
The workflow can be run with | ||
```sh | ||
python workflow.py | ||
``` | ||
The final output `paper.pdf` created using the `tectonic` package is then stored in the working direcrtory of last workflow step: | ||
```sh | ||
./workflow/tectonic_hdf5/tectonic/paper.pdf | ||
``` | ||
This is a general feature of the `pyiron_base` workflow manager, each step of the workflow - called job - is executed in a separate working directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import os | ||
from pyiron_base import Project | ||
|
||
# input parameter | ||
domain_size = 2.0 | ||
|
||
# create pyiron project | ||
pr = Project("workflow") | ||
|
||
# create conda environments for the proprocessing, processing and postprocessing stage | ||
for k, v in { | ||
"preprocessing": "../source/envs/preprocessing.yaml", | ||
"processing": "../source/envs/processing.yaml", | ||
"postprocessing": "../source/envs/postprocessing.yaml" | ||
}.items(): | ||
pr.conda_environment.create(env_name=k, env_file=v) | ||
|
||
|
||
# Preprocessing | ||
## generate mesh | ||
gmsh = pr.wrap_executable( | ||
job_name="gmsh", | ||
executable_str=f"gmsh -2 -setnumber domain_size {domain_size} unit_square.geo -o square.msh", | ||
conda_environment_path=pr.conda_environment.preprocessing, | ||
input_file_lst=["../source/unit_square.geo"], | ||
execute_job=True, | ||
) | ||
|
||
## convert mesh to xdmf | ||
meshio = pr.wrap_executable( | ||
job_name="meshio", | ||
executable_str="meshio convert square.msh square.xdmf", | ||
conda_environment_path=pr.conda_environment.preprocessing, | ||
input_file_lst=[gmsh.files.square_msh], | ||
execute_job=True, | ||
) | ||
|
||
|
||
# Processing | ||
## poisson | ||
def collect_output_poisson(working_directory): | ||
with open(os.path.join(working_directory, "numdofs.txt"), "r") as f: | ||
return {"numdofs": int(f.read())} | ||
|
||
poisson = pr.wrap_executable( | ||
job_name="poisson", | ||
executable_str="python poisson.py --mesh square.xdmf --degree 2 --outputfile poisson.pvd --num-dofs numdofs.txt", | ||
collect_output_funct=collect_output_poisson, | ||
conda_environment_path=pr.conda_environment.processing, | ||
input_file_lst=["../source/poisson.py", meshio.files.square_xdmf, meshio.files.square_h5], | ||
execute_job=True, | ||
) | ||
|
||
|
||
# Postprocessing | ||
## plot over line | ||
pvbatch = pr.wrap_executable( | ||
job_name="pvbatch", | ||
executable_str="pvbatch postprocessing.py poisson.pvd plotoverline.csv", | ||
conda_environment_path=pr.conda_environment.postprocessing, | ||
input_file_lst=["../source/postprocessing.py", poisson.files.poisson_pvd, poisson.files.poisson000000_vtu], | ||
execute_job=True, | ||
) | ||
|
||
## substitute macros | ||
macros = pr.wrap_executable( | ||
job_name="macros", | ||
executable_str=f"python prepare_paper_macros.py --macro-template-file macros.tex.template --plot-data-path plotoverline.csv --domain-size {domain_size} --num-dofs {poisson.output['numdofs']} --output-macro-file macros.tex", | ||
conda_environment_path=pr.conda_environment.postprocessing, | ||
input_file_lst=["../source/macros.tex.template", "../source/prepare_paper_macros.py", pvbatch.files.plotoverline_csv], | ||
execute_job=True, | ||
) | ||
|
||
## compile paper | ||
tectonic = pr.wrap_executable( | ||
job_name="tectonic", | ||
executable_str="tectonic paper.tex", | ||
conda_environment_path=pr.conda_environment.postprocessing, | ||
input_file_lst=["../source/paper.tex", macros.files.macros_tex, pvbatch.files.plotoverline_csv], | ||
execute_job=True, | ||
) |