-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimulator_script_cluster
executable file
·106 lines (97 loc) · 4.36 KB
/
simulator_script_cluster
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
# Sample simulator to Dakota system call script
# See Advanced Simulation Code Interfaces chapter in Users Manual
# $1 is params.in FROM Dakota
# $2 is results.out returned to Dakota
# Script sets up all the cases needed within the UQ case. Based in Askervein hill 1983, TU03b campaign measurements.
# Only 180 degres of wind direction are considered, so only 2 test cases are needed to set up the run, depending on a limiting angle (thetaLimit).
# This scripts computes all the variables and sets the cases automatically to be launched in a cluster using the script named "LaunchSimulationUQ".
# Local variable definition:
NCORES=8
thetaLimit=210;
Href=10;
vkconstant=0.41;
# --------------
# PRE-PROCESSING
# --------------
# Incorporate the parameters from DAKOTA into the template, writing ros.in
# Use the following line if SNL's APREPRO utility is used instead of DPrePro.
# ../aprepro -c '*' -q --nowarning ros.template ros.in
dprepro $1 ABLConditions.template ABLConditions.in
# --------
# ANALYSIS
# --------
# choose the type of case depending on the wind direction
pi=`echo "4*a(1)" |bc -l`
cp ../templatedir/initialConditions.template initialConditions.in
a=$(grep 'AngleIn' ABLConditions.in | awk ' {print substr($2, 0, length($2))}');
theta=$(echo ${a} | awk '{ print sprintf("%.9f", $1); }');
a1=$(grep 'AngleRef' ABLConditions.in | awk ' {print substr($2, 0, length($2))}');
thetaRef=$(echo ${a1} | awk '{ print sprintf("%.9f", $1); }');
b=$(grep 'Uref' ABLConditions.in | awk ' {print substr($2, 0, length($2)-1)}')
U=$(echo ${b} | awk '{ print sprintf("%.2f", $1); }');
Ucomp1=`echo "c(($thetaRef-$theta)*pi/180)*$U" | bc -l`
Ucomp2=`echo "s(($thetaRef-$theta)*pi/180)*$U" | bc -l`
if [ $(echo " ${theta} > $thetaLimit" | bc) -eq 1 ]; then
cp -r ../casebase1/* .;
else
cp -r ../casebase2/* .;
fi
c=$(grep 'z0' ABLConditions.in | awk ' {print substr($3, 0, length($3)-1)}')
z0=$(echo ${c} | awk '{ print sprintf("%.15f", $1); }');
uStar=`echo "$U*$vkconstant/l(($Href+$z0)/$z0)" | bc -l`
tke=`echo "$uStar*$uStar/0.3" | bc -l`
eps=`echo "$uStar*$uStar*$uStar/($vkconstant*($Href+$z0))" | bc -l`
sed 's/tkeInitial/'${tke}'/g' initialConditions.template > initialConditions.1
sed 's/epsInitial/'${eps}'/g' initialConditions.1 > initialConditions.in
sed 's/tkeInitial/'${tke}'/g' ABLConditions.in > ABLConditions.1
sed 's/Ucomp1/'${Ucomp1}'/g' ABLConditions.1 > ABLConditions.2
sed 's/Ucomp2/'${Ucomp2}'/g' ABLConditions.2 > ABLConditions.3
mv ABLConditions.3 ABLConditions.in
cp initialConditions.in 0/include/initialConditions
cp ABLConditions.in 0/include/ABLConditions
rm initialConditions.1
rm ABLConditions.1 ABCconditions.2
#------------------------------------------
#
# WRITE THE SCRIPT TO RUN OPENFOAM
#
#-------------------------------------------
echo "#!/bin/bash" >> cluster_submissiono.pbs
echo "#PBS -N workdir$num " >> cluster_submissiono.pbs
echo "#PBS -e openfoam1.err " >> cluster_submissiono.pbs
echo "#PBS -o openfoam1.out " >> cluster_submissiono.pbs
echo "#PBS -m aeb " >> cluster_submissiono.pbs
echo "#PBS -M gsclara@stanford.edu " >> cluster_submissiono.pbs # giving the right name to the job to keep track of the simulations
echo "#PBS -l nodes=1:ppn=24 " >> cluster_submissiono.pbs
echo "#PBS -l walltime=08:00:00 " >> cluster_submissiono.pbs
echo "#PBS -V " >> cluster_submissiono.pbs
echo "#PBS -q medium " >> cluster_submissiono.pbs
echo "module load gnu/4.9.2 " >> cluster_submissiono.pbs
echo "module load openmpi/1.10.2-gnu-4.9.2 " >> cluster_submissiono.pbs
echo "source /your/installation/folder/OpenFOAM/OpenFOAM-4.0/etc/bashrc" >> cluster_submissiono.pbs
echo "cd $workdir" >> cluster_submissiono.pbs
echo "decomposePar >log.preRun " >> cluster_submissiono.pbs
echo "mpirun -np 24 scalarTransportBoundedSimpleFoam -parallel >log.run " >> cluster_submissiono.pbs
echo "wait" >> cluster_submissiono.pbs
#------------------------------------------
#
# LAUCH OPENFOAM
#
#-------------------------------------------
chmod a+x cluster_submissiono.pbs
# ---------------------------
# OUTPUT FILE POST PROCESSING
# ---------------------------
# Need to write a results file so DAKOTA will proceed with the next
# job generation:
echo "1" > temp.txt # give dummy values to dakota
for i in {1..113};do
echo "1" >> temp.txt
done
mv temp.txt $2
# -------------
# CLEANUP
# -------------
# Do not want to cleanup in this case!
echo "case $num ready to be lauch"