Skip to content

Commit 40934c2

Browse files
author
dtyagi
committed
edits to the docs. more edits to come in the next push.
1 parent 604a78c commit 40934c2

File tree

11 files changed

+149
-118
lines changed

11 files changed

+149
-118
lines changed

.github/workflows/run-benchmark.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
--reporter metadata4ing \
5454
--report-metadata4ing-paramscript parameter_extractor.py \
5555
--report-metadata4ing-filename metadata4ing_provenance
56-
unzip metadata4ing_provenance -d reporter_data
56+
unzip metadata4ing_provenance -d snakemake_provenance
5757
5858
- name: run_linear-elastic-plate-with-hole-benchmarks_nextflow
5959
shell: bash -l {0}
@@ -66,7 +66,7 @@ jobs:
6666
with:
6767
name: snakemake_results_linear-elastic-plate-with-hole
6868
path: |
69-
benchmarks/linear-elastic-plate-with-hole/reporter_data/
69+
benchmarks/linear-elastic-plate-with-hole/snakemake_provenance/
7070
7171
- name: Archive Linear Elastic plate with a hole benchmark data for nextflow
7272
uses: actions/upload-artifact@v4

benchmarks/linear-elastic-plate-with-hole/Snakefile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ rule summary:
4141
input:
4242
# the summary is performed for all configurations saved into a single file
4343
# (snakemake_results/linear-elastic-plate-with-hole/fenics/summary.json)
44-
script = "summarise_results.py",
44+
script = "summarize_results.py",
4545
parameters = expand("{param}", param=[configuration_to_parameter_file[c] for c in configurations]),
4646
mesh = expand(f"{result_dir}/mesh/mesh_{{configuration}}.msh", configuration=configurations),
4747
metrics = lambda wildcards: expand(
@@ -65,4 +65,20 @@ rule summary:
6565
--input_solution_field_data {input.solution_field_data} \
6666
--input_benchmark {benchmark} \
6767
--output_summary_json {output.summary_json}
68-
"""
68+
"""
69+
70+
"""
71+
Steps to add a new simulation tool to the workflow:
72+
73+
1. Write the tool-specific workflow & scripts and store them in the benchmarks/linear-elastic-plate-with-hole/tool_name/.
74+
2. Add the tool name to "tools" workflow_config.json (generated here using generate_config.py)
75+
76+
------------------------------------------------------------------------------------------------------------------------
77+
"rule all" defines the final target of the workflow. Knowing the final target, the snakemake determines
78+
the dependency chain automatically.
79+
80+
Wildcards in the rule definitions allow to generalize the rules for multiple configurations and tools.
81+
They act like placeholders (variables) in filenames or paths that get automatically filled in by Snakemake.
82+
83+
Information on snakemake rules: https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html
84+
"""

benchmarks/linear-elastic-plate-with-hole/plateWithHoleSolution.py renamed to benchmarks/linear-elastic-plate-with-hole/analytical_solution.py

File renamed without changes.

benchmarks/linear-elastic-plate-with-hole/fenics/run_fenics_simulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# Add parent directory to sys.path
1616
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
17-
from plateWithHoleSolution import PlateWithHoleSolution
17+
from analytical_solution import PlateWithHoleSolution
1818

1919

2020
def run_fenics_simulation(

benchmarks/linear-elastic-plate-with-hole/kratos/create_kratos_input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77
# Ensure the parent directory is in the path to import PlateWithHoleSolution
88
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
9-
from plateWithHoleSolution import PlateWithHoleSolution
9+
from analytical_solution import PlateWithHoleSolution
1010

1111
def create_kratos_input(
1212
parameter_file: str,

benchmarks/linear-elastic-plate-with-hole/main.nf

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ workflow {
137137

138138
//Summarizing results
139139
def ch_benchmark = Channel.value(params.benchmark)
140-
def ch_summarise_python_script = Channel.value(file('summarise_results.py'))
141-
summary(ch_summarise_python_script, \
140+
def ch_summarize_python_script = Channel.value(file('summarize_results.py'))
141+
summary(ch_summarize_python_script, \
142142
input_summary_configuration, \
143143
input_summary_parameter_file, \
144144
input_summary_mesh, \
@@ -148,10 +148,22 @@ workflow {
148148
ch_tools)
149149

150150
}
151+
/*
152+
Steps to add a new simulation tool to the workflow:
151153
152-
// Steps to perform to add a new simulation tool to the workflow:
153-
// 1. Add the tool name to "tools" workflow_config.json (generated here using generate_config.py)
154-
// 2. Include the tool-specific workflow script at the top of this file.
155-
// 3. Create an input channel for the new tool (e.g. see the definition of input_fenics_workflow)
156-
// 4. Invoke the new tool-specific workflow (similar to fenics_workflow) & using its output, prepare inputs for the summary process.
157-
// 5. Concatenate the prepared inputs to form the final input channels for the summary process.
154+
1. Write the tool-specific workflow & scripts and store them in the benchmarks/linear-elastic-plate-with-hole/tool_name/.
155+
2. Add the tool name to "tools" workflow_config.json (generated here using generate_config.py)
156+
3. Include the tool-specific workflow script at the top of this file.
157+
4. Create an input channel for the new tool (e.g. see the definition of input_fenics_workflow)
158+
5. Invoke the new tool-specific workflow (similar to fenics_workflow) & using its output, prepare inputs for the summary process.
159+
6. Concatenate the prepared inputs to form the final input channels for the summary process.
160+
161+
---------------------------------------------------------------------------------------------------------------------------------
162+
163+
Remark: Care should be taken to track the entries in the I/O channels, as the process output for a given configuration
164+
may not arrive in the same order as the inputs were sent. When reusing channel entries after process execution, outputs should
165+
be matched with their corresponding inputs using a common key.
166+
167+
Information on channel operations: https://www.nextflow.io/docs/latest/reference/operator.html
168+
Information on channels: https://training.nextflow.io/2.2/basic_training/channels/
169+
*/

benchmarks/linear-elastic-plate-with-hole/summarise_results.py renamed to benchmarks/linear-elastic-plate-with-hole/summarize_results.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ def create_summary(configurations: list[str],
99
benchmark: str,
1010
summary_json: str) -> None:
1111

12+
"""
13+
Create a summary JSON file containing simulation results and metadata.
14+
15+
Args:
16+
configurations: List of configuration names
17+
parameter_files: List of paths to parameter JSON files
18+
mesh_files: List of paths to mesh files
19+
solution_metrics: List of paths to metrics JSON files
20+
solution_field_data: List of paths to solution field data files
21+
benchmark: Name of the benchmark
22+
summary_json: Output path for the summary JSON file
23+
"""
24+
25+
1226
all_summaries = []
1327
for idx, config in enumerate(configurations):
1428
print(idx, config)

docs/benchmark_addition_guide.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
# A Guide to add a Benchmark Problem
22

3-
The platform uses a hierarchical workflow system that incorporates:
4-
5-
- Multiple simulation tools (e.g., FEniCS, Kratos) for solving a problem.
6-
- Standardized I/O streams to the simulation tools.
7-
- Multiple parameter configurations per benchmark.
8-
- Automated mesh generation.
9-
<!-- Provenance tracking and metadata collection -->
10-
11-
This guide outlines the algorithm needed to add a benchmark problem.
3+
The steps are as follows:
124

135
1. **Create a folder for the problem**
146

@@ -30,10 +22,15 @@ This guide outlines the algorithm needed to add a benchmark problem.
3022
- Develop a workflow script connecting the I/O scripts, simulation code and environment.yml files.
3123
3224
3. **Create the mesh generation script**
33-
- Write `create_mesh.py` inside `benchmarks/problem_name/` to define the domain geometry.
34-
- Provide user-modifiable inputs via a JSON input interface, cf. `benchmarks/linear-elastic-plate-with-hole/create_mesh.py`.
25+
26+
**With mesh generation**
27+
- Create `create_mesh.py` inside `benchmarks/problem_name/` to define the domain geometry.
28+
- In the file, provide the interface for the user-adjustable inputs related to geometry, mesh and numerical solver. These inputs are passed to the script via `parameter_*.json`.
3529
- If required, include an environment file for the mesh generation script in the same directory.
3630
31+
**Pre-existing meshes**
32+
- Provide the path to the mesh(es) location directly to the sub-workflow of the simulation tool. `parameter_*.json` will only contain the material parameters in this case.
33+
3734
4. **Define parameter configurations**
3835
3936
For each parameter configuration run using simulation tools, create a JSON file in `benchmarks/problem/` specifying parameters related to the domain geometry, mesh information, and constitutive model parameters, cf. `benchmarks/linear-elastic-plate-with-hole/parameters_*.json`.

docs/introduction.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
The platform uses a hierarchical workflow system that incorporates:
2+
3+
- Multiple simulation tools (e.g., FEniCS, Kratos) for solving a problem.
4+
- Standardized I/O streams to the simulation tools.
5+
- Multiple parameter configurations per benchmark.
6+
- Automated mesh generation.
7+
8+
# Workflow
9+
10+
The workflow has a hierarchical structure. The common tasks like mesh generation and results' summary creation are done by the top-level workflow. The top-level workflow interacts with the sub-workflows which are tool-specific. The sub-workflows are responsible for running the scripts containing simulation code and pre/post-processing scripts necessary for processing the mesh files or the simulation output.
11+
12+
The benchmark `linear-elastic-plate-with-hole` is implemented with nextflow and snakemake packages. For this benchmark, the structure of the snakemake workflow is exemplified below:
13+
14+
```
15+
linear-elastic-plate-with-hole/Snakefile
16+
17+
├── calls ──> fenics/Snakefile
18+
│ └── executes ──> run_fenics_simulation.py
19+
20+
└── calls ──> kratos/Snakefile
21+
├── executes ──> msh_to_mdpa.py
22+
├── executes ──> create_kratos_input.py
23+
├── executes ──> run_kratos_simulation.py
24+
└── executes ──> postprocess_results.py
25+
```
26+
27+
# Terminologies
28+
29+
### Parameter JSON File
30+
31+
A `parameter_*.json` file defines all the user-adjustable parameters for mesh generation, material properties, boundary conditions, and solver settings for finite element simulations. Each parameter file represents a unique configuration of these parameters that will be processed by the workflow system.
32+
33+
Cf. `benchmarks/linear-elastic-plate-with-hole/parameters_1.json`
34+
35+
```json
36+
{
37+
"configuration": "1",
38+
}
39+
```
40+
41+
The keyword `"configuration"` is a unique identifier for the provided parameter set. It is used in output file naming and workflow tracking and must be unique across all parameter files.
42+
43+
### Configuration Generator
44+
45+
`generate_config.py` file writes a configuration file for the workflow managers (snakemake or nextflow) extracting the configuration information from `parameter_*.json` files. The keywords for simulation tools to run the configurations on are also specified by the user in this file.
46+
47+
Cf. `benchmarks/linear-elastic-plate-with-hole/generate_config.py`
48+
49+
50+
### Mesh Generation
51+
<!--[create_mesh.py](https://github.com/BAMresearch/NFDI4IngModelValidationPlatform/blob/main/benchmarks/linear-elastic-plate-with-hole/create_mesh.py) -->
52+
53+
The `create_mesh.py` file contains the code for mesh generation. In case the mesh(es) are already available, the file is not needed. In the `linear-elastic-plate-with-hole` example the file:
54+
55+
1. receives inputs from `\parameter_*.json` and output `.msh` files.
56+
2. Uses `pint` library for unit conversion.
57+
3. Uses `gmsh` library for mesh generation.
58+
59+
Cf. `benchmarks/linear-elastic-plate-with-hole/create_mesh.py`
60+
61+
### Summarize File
62+
`summarize_results.py` creates a JSON file containing the solution metrics and their corresponding parameter configurations after simulation runs of a benchmark.
63+
64+
Cf. `benchmarks/linear-elastic-plate-with-hole/summarize_results.py`
65+
66+
67+
### Environment Files
68+
The environment files are YML files which configures the environment for running a script. They contain a list of software libraries that build up an environment.
69+
70+
71+
72+
73+
74+
75+
76+
77+
78+
79+
80+
81+
82+
83+
84+

docs/parameter_json_description.md

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)