Skip to content

Commit

Permalink
PEST version of bimaterial example added (idaholab#22220)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilkAndy authored and dschwen committed Oct 18, 2022
1 parent 98bc9a5 commit 19083ca
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
27 changes: 27 additions & 0 deletions modules/optimization/examples/bimaterial/pest.pst
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions modules/optimization/examples/bimaterial/pest_instruction.ins
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pif @
@Data@
l1 [TTOPMID]1:25
l1 [TBOTMID]1:25
l1 [TBOTLEF]1:25
l1 [TBOTRIG]1:25
4 changes: 4 additions & 0 deletions modules/optimization/examples/bimaterial/pest_params.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ptf @
# This file was written by PEST
# The following numbers are top diffisivity and bottom diffusivity
@ppktop @,@ppkbot @
24 changes: 24 additions & 0 deletions modules/optimization/examples/bimaterial/run_model.py
Original file line number Diff line number Diff line change
@@ -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")





0 comments on commit 19083ca

Please sign in to comment.