From 0e3ad9fef1e26935e4ee54f1dac44329bb87ba14 Mon Sep 17 00:00:00 2001
From: MaNyh <nyhuis@tfd.uni-hannover.de>
Date: Sun, 6 Feb 2022 03:19:24 +0100
Subject: [PATCH] validation implementation

---
 .../case_creation.py                          |   1 +
 .../casesettings.yaml                         |  33 +----
 .../config.schema.yaml                        | 128 ++++++++++++++++--
 .../gwk_compressor_casegeneration/snakedev.py |   6 +
 4 files changed, 127 insertions(+), 41 deletions(-)
 create mode 100644 examples/gwk_compressor_casegeneration/snakedev.py

diff --git a/examples/gwk_compressor_casegeneration/case_creation.py b/examples/gwk_compressor_casegeneration/case_creation.py
index 6afd2caf..b21927a6 100644
--- a/examples/gwk_compressor_casegeneration/case_creation.py
+++ b/examples/gwk_compressor_casegeneration/case_creation.py
@@ -9,6 +9,7 @@ import warnings
 from ntrfc.utils.dictionaries.dict_utils import setInDict
 from ntrfc.utils.dictionaries.dict_utils import nested_dict_pairs_iterator
 
+#todo: at least the next two lines have to be fixed
 TEMPLATEDIR = r"D:\CodingProjects\NTRfC\ntrfc\database\case_templates"
 path_to_sim=r"D:\CodingProjects\NTRfC\examples\gwk_compressor_casegeneration\01_case"
 TEMPLATES = [i for i in os.listdir(TEMPLATEDIR) if os.path.isdir(os.path.join(TEMPLATEDIR, i))]
diff --git a/examples/gwk_compressor_casegeneration/casesettings.yaml b/examples/gwk_compressor_casegeneration/casesettings.yaml
index 076ae935..eb872a6a 100644
--- a/examples/gwk_compressor_casegeneration/casesettings.yaml
+++ b/examples/gwk_compressor_casegeneration/casesettings.yaml
@@ -1,34 +1,5 @@
 case_params:
     case_type: "trace-compressor-cascade-ras"
     parameters:
-        TRACE_CONTROLINPUT : nope
-        MESHNAME: nope
-        OUTFLOW_PRESSURE: nope
-        GLOBAL_TOLERANCE: nope
-        LENGTH_YPER: nope
-        STAGPOINT_ANNOMALLYFIX: nope
-        QUASIUNSTEADYMODEL: nope
-        WAVINESSMODEL: nope
-        VERSION_TWONULLNULLNINE: nope
-        HEATFLUXMODEL: nope
-        PRANDTLTURBULENT: nope
-        ROTATIONAL_EFF: nope
-        TRANSITIONMODEL: nope
-        VGJMODEL: nope
-        ACCURACY_ORDER: nope
-        OUTLET_MFLOW: nope
-        OUTLET_RADIAL_EQUI: nope
-        INLET_TOTAL_PRESSURE: nope
-        VEL_YANGLE: nope
-        ABS_STAGN_TEMP: nope
-        TURBULENTINTENSITY: nope
-        TURBULENTLENGTHSCALE: nope
-        INLET_TEMP: nope
-        INLET_VELX: nope
-        INLET_VELY: nope
-        INLET_VELZ: nope
-        OUTFLOW_TEMP: nope
-        OUTFLOW_PRESSURE: nope
-        OUTFLOW_VELX: nope
-        OUTFLOW_VELY: nope
-        OUTFLOW_VELZ: nope
+        LENGTH_YPER: 0.0765
+
diff --git a/examples/gwk_compressor_casegeneration/config.schema.yaml b/examples/gwk_compressor_casegeneration/config.schema.yaml
index 3e555147..c222b379 100644
--- a/examples/gwk_compressor_casegeneration/config.schema.yaml
+++ b/examples/gwk_compressor_casegeneration/config.schema.yaml
@@ -1,13 +1,121 @@
-$schema : "http://json-schema.org/draft-06/schema#"
-description : Config file for the parPE snakemake optimization workflow
+$schema: "http://json-schema.org/draft-06/schema#"
 
+description: snakemake configuration file
 
-properties :
-    case_params :
-        type : object
-        description : definition of the case and its parameterspace
+type: object
 
-        case_type :
-            type : string
-            description : name of the case-template
-            pattern : trace-compressor-cascade-ras
+properties:
+  case_params:
+    type: object
+    properties:
+      case_type:
+        type: string
+      parameters:
+        type: object
+        properties:
+          TRACE_CONTROLINPUT:
+            type: string
+            default: ""
+          OUTFLOW_PRESSURE:
+            type: number
+            default: 101350
+          GLOBAL_TOLERANCE:
+            type: number
+            default: 0.00000012
+          LENGTH_YPER:
+            type: number
+          STAGPOINT_ANNOMALLYFIX:
+            type: string
+            default: "yes_placeholder"
+          QUASIUNSTEADYMODEL:
+            type: string
+            default: "no_placeholder"
+          STAGPOINT_ANNOMALLYFIX:
+            type: string
+            default: "yes_placeholder"
+          QUASIUNSTEADYMODEL:
+            type: string
+            default: "yes_placeholder"
+          WAVINESSMODEL:
+            type: string
+            default: "no_placeholder"
+          VERSION_TWONULLNULLNINE:
+            type: string
+            default: "no_placeholder"
+          HEATFLUXMODEL:
+            type: string
+            default: "no_placeholder"
+          PRANDTLTURBULENT:
+            type: string
+            default: "no_placeholder"
+          ROTATIONAL_EFF:
+            type: string
+            default: "no_placeholder"
+          TRANSITIONMODEL:
+            type: string
+            default: "no_placeholder"
+          VGJMODEL:
+            type: string
+            default: "no_placeholder"
+          ACCURACY_ORDER:
+            type: number
+            default: 2
+          OUTLET_MFLOW:
+            type: number
+            default: 0.00035
+            min: 0
+          OUTLET_RADIAL_EQUI:
+            type: string
+            default: "no_placeholder"
+          INLET_TOTAL_PRESSURE:
+            type: number
+            default: 283.15
+            min: 0
+          VEL_YANGLE:
+            type: number
+            default: 0
+          ABS_STAGN_TEMP:
+            type: number
+            default: 300
+            min: 0
+          TURBULENTINTENSITY:
+            type: number
+            default: 0.04
+            min: 0
+          TURBULENTLENGTHSCALE:
+            type: number
+            default: 0.002
+            min: 0
+          INLET_TEMP:
+            type: number
+            default: 300
+          INLET_VELX:
+            type: number
+            default: 30
+          INLET_VELY:
+            type: number
+            default: 40
+          INLET_VELZ:
+            type: number
+            default: 0
+          OUTFLOW_TEMP:
+            type: number
+            default: 290
+          OUTFLOW_VELX:
+            type: number
+            default: 40
+          OUTFLOW_VELY:
+            type: number
+            default: 30
+          OUTFLOW_VELZ:
+            type: number
+            default: 0
+        required:
+            - LENGTH_YPER
+
+    required:
+        - case_type
+        - parameters
+
+required:
+    - case_params
diff --git a/examples/gwk_compressor_casegeneration/snakedev.py b/examples/gwk_compressor_casegeneration/snakedev.py
new file mode 100644
index 00000000..cc8520c3
--- /dev/null
+++ b/examples/gwk_compressor_casegeneration/snakedev.py
@@ -0,0 +1,6 @@
+import snakemake
+
+c = snakemake.load_configfile("casesettings.yaml")
+snakemake.utils.validate(c,'config.schema.yaml')
+
+snakemake.snakemake(snakefile="Snakefile",)
-- 
GitLab