diff --git a/modules/optimization/examples/bimaterial/pest.pst b/modules/optimization/examples/bimaterial/pest.pst new file mode 100644 index 000000000000..58231058ceb6 --- /dev/null +++ b/modules/optimization/examples/bimaterial/pest.pst @@ -0,0 +1,27 @@ +pcf +* control data +restart estimation + 2 4 1 0 1 + 1 1 single point 1 0 0 + 10.0 2.0 0.3 0.03 10 + 5.0 5.0 0.001 + 0.1 + 100 0.01 4 3 0.01 3 + 0 0 0 +* parameter groups + p relative 0.01 0.0 switch 2.0 parabolic +* parameter data +ppktop none factor 2.0 0.1 20 p 1 0 1 +ppkbot none factor 2.0 0.1 20 p 1 0 1 +* observation groups + obsgroup +* observation data +TTOPMID 0.138 1.0 obsgroup +TBOTMID 0.040 1.0 obsgroup +TBOTLEF 0.022 1.0 obsgroup +TBOTRIG 0.022 1.0 obsgroup +* model command line + ./run_model.py +* model input/output + pest_params.tpl pest_params.csv + pest_instruction.ins pest_to_read.txt diff --git a/modules/optimization/examples/bimaterial/pest_instruction.ins b/modules/optimization/examples/bimaterial/pest_instruction.ins new file mode 100644 index 000000000000..d137c337da21 --- /dev/null +++ b/modules/optimization/examples/bimaterial/pest_instruction.ins @@ -0,0 +1,6 @@ +pif @ +@Data@ +l1 [TTOPMID]1:25 +l1 [TBOTMID]1:25 +l1 [TBOTLEF]1:25 +l1 [TBOTRIG]1:25 diff --git a/modules/optimization/examples/bimaterial/pest_params.tpl b/modules/optimization/examples/bimaterial/pest_params.tpl new file mode 100644 index 000000000000..dacb9421f19f --- /dev/null +++ b/modules/optimization/examples/bimaterial/pest_params.tpl @@ -0,0 +1,4 @@ +ptf @ +# This file was written by PEST +# The following numbers are top diffisivity and bottom diffusivity +@ppktop @,@ppkbot @ diff --git a/modules/optimization/examples/bimaterial/run_model.py b/modules/optimization/examples/bimaterial/run_model.py new file mode 100755 index 000000000000..95f6e37d4be3 --- /dev/null +++ b/modules/optimization/examples/bimaterial/run_model.py @@ -0,0 +1,24 @@ +#!/usr/bin/python3 +import subprocess + +# because PEST operates on files, we have to get the diffusivities from the PEST file pest_params.csv +with open("pest_params.csv", "r") as f: + ktop, kbot = f.readlines()[-1].strip().split(",") + +# then feed them to model.i +subprocess.call(['../../isopod-opt', '-i', 'model.i', 'Outputs/csv=true', 'Materials/mat_top/prop_values=' + ktop, 'Materials/mat_bottom/prop_values=' + kbot]) + +# Now format the output as required by pest_instruction.ins +with open("model_out.csv", "r") as f: + tme, T_bottom_left, T_bottom_mid, T_bottom_right, T_top, d_bot, d_top = f.readlines()[-1].strip().split(",") +with open("pest_to_read.txt", "w") as f: + f.write("Data\n") + f.write(" " + T_top + " \n") + f.write(" " + T_bottom_mid + " \n") + f.write(" " + T_bottom_left + " \n") + f.write(" " + T_bottom_right + " \n") + + + + +