-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigrate.sh
executable file
·257 lines (214 loc) · 6.46 KB
/
migrate.sh
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#!/bin/bash
#
# This script will be executed when miSpaceExplorer.sh is run.
#
# Compiles and runs equilibrium and migration models and obtains results.
# To restart models automatically if Y2 has not converged when maxSteps
# has been reached, set "neverRestart" to "false" in the notDone
# function at the top of the getValues script.
n=$1
q=$2
m=$3
starMass=$4
jin=$5
planetMass=$6
planetRad=$7
maxSteps=$8
jmax=$9
scriptDir=$(dirname `dirname $(pwd)`)
val="$scriptDir/./getValues $(pwd)"
chmod +x $scriptDir/getValues
####################################################################################################
# RUN EQUILIBRIUM MODEL
echo "Compiling hscf.f..."
cp $scriptDir/hscf.f .
echo "
parameter (jmax = ${jmax},
1 kmax = ${jmax},
2 max = 25000)
c 32x32 wfw(452)
c 64x64 wfw(1030)
c 128x128 wfw(2315)
c 256x256 wfw(5132)
c 512x512 wfw(11279)
c 1024x1024 wfw(24593)
c 2048x2048 wfw(53264)
" > param.h
# ifort -O -mp -r8 -o hscf hscf.f
gfortran -fdefault-real-8 -O2 -o hscf hscf.f
echo "Running equilibrium model..."
echo "1 : 0 = white dwarf 1 = polytrope
0 : 0 = dead start 1 = jump start
${n} -${q} ${jmax} ${jmax} ${jmax} -${jin} 0.0 0.8 ${starMass} : n n' jold kold jout kout log(rho) del starm
" > hscf.in
./hscf < hscf.in
rm param.h hscf hscf.in hscf.f
#plot eqContour
echo "Generating contour plot..."
r=`echo "scale=2; $($val rInOut)/1" | bc`
echo -e "
reset\n
set terminal png\n
set output \"eqContour.png\"\n
set title \"n${n}/q${q}/r-+${r}-j${jin}/M${starMass}/${jmax}\"\n
set contour\n
set cntrparam levels incremental 1.0e-30,$(echo "scale=7; $($val rhomax)/10" | bc),$($val rhomax)\n
set size square\n
set grid\n
set mxtics\n
set mytics\n
set nosurface\n
set view 0,0\n
set data style lines\n
set nokey\n
splot 'fort.47' ti \"fort.47\"\n
" | gnuplot
#
####################################################################################################
# RUN MIGRATION MODEL
if [ $maxSteps -gt 0 ]; then
echo "Compiling migrate.f..."
cp $scriptDir/migrate.f .
echo "
c version: 9 May 2005
parameter (jmax=${jmax},jmax1=jmax+1,jmax2=jmax+2,jmax3=jmax-1,
1 kmax=${jmax},kmax1=kmax+1,kmax2=kmax+2,kmax3=kmax-1,
2 lmax=16,lmax1=lmax/2+1,lmax2=lmax-2,
3 max=25000,jkm1=jmax+kmax-1,neq=8)
c 32x32 wfw(452)
c 64x64 wfw(1030)
c 128x128 wfw(2312)
c 256x256 wfw(5130)
c 512x512 wfw(11276)
c 1024x1024 wfw(24590)
" > param.h
# ifort -O -mp -r8 -o hscf hscf.f
gfortran -fdefault-real-8 -O2 -o migrate migrate.f
echo "Running migration model..."
rerun=0
Time=0
if [ -f fort.11 ] && [ ! -f fort.51 ]; then
mv fort.11 fort.51
fi
###### restart if fort.51 already present
if [ -f fort.51 ]; then
rerun=1
mv fort.51 fort.11
if [ -f fort.22 ]; then
numlines=$(cat fort.22 | wc -l)
ourline=$(( $numlines - $numlines % 100 ))
Time=$(sed -n ${ourline}p fort.22 | cut -c 1-15)
fi
if [ -f fort.23 ]; then
if [ -f fort.23a ]; then
cp fort.23a temp
cat fort.23 >> temp
rm fort.23 fort.23a
mv temp fort.23
fi
cp fort.23 fort.23a
fi
fi
##### create migrate.in file
echo "fort.2
${m} : m
1 : model number
${n},000,.75 : n, 0 to use data file and 100xq otherwise, rin
${q} : q
${planetRad},${planetMass},${starMass},10.0e10 : see below
${maxSteps} : max steps
${rerun},${Time} : 1 to restart,time; mv fort.51 fort.11
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2%
Key:
! background (equilibrium) model location
! azimuthal mode wave number
! background model number in file
! polytropic index, Omega exponent x 100, disk edge / radius of density maxium
! semi-major axis of planet's orbit, planet's mass, stellar mass, growth rate
! 0=dead start, 1= continuation; time at start of run (the restart time)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2%
" > migrate.in
##### execute with migrate.in
./migrate < migrate.in
fi
# remove unnecessary files
rm param.h migrate migrate.in migrate.f
#rm fort.2 fort.15 fort.16 fort.17 fort.30 fort.31 fort.42 fort.52 fort.55 fort.56 fort.57
#rm fort.71 fort.93 anal.dat eta fact1 outfile pulsefile rho.dat wdout
#
####################################################################################################
# GET RESULTS
echo "Getting model results..."
# Combine new fort.23 if restarting
if [ -f fort.23a ]; then
cp fort.23a temp
cat fort.23 >> temp
rm fort.23 fort.23a
mv temp fort.23
fi
##### Generate and save images with gnuplot.
r=`echo "scale=2; $($val rInOut)/1" | bc`
title="m${m}/n${n}/q${q}/r-+${r}-j${jin}/M${starMass}/pr${planetRad}/pm${planetMass}/${jmax}"
#plotit
plotCommand="
reset\n
set terminal png\n
set output \"plotit.png\"\n
set title \"${title}\"\n
set logscale y\n
set autoscale\n
plot 'fort.23' using 1:2 with lines ti \"fort.23\",\
'fort.23' using 1:4 with lines notitle,\
'fort.23' using 1:6 with lines notitle\n
"
echo -e $plotCommand | gnuplot
#plotit2
echo -e "
reset\n
set terminal png\n
set output \"plotit2.png\"\n
set title \"${title}\"\n
set auto\n
plot 'fort.23' using 1:3 with lines ti \"fort.23\",\
'fort.23' using 1:5 with lines notitle,\
'fort.23' using 1:7 with lines notitle\n
" | gnuplot
#torque1
echo -e "
reset\n
set terminal png\n
set output \"torque1.png\"\n
set title \"${title}\"\n
set auto\n
plot 'fort.27' using 1:2 with lines ti \"total_torque\"\n
" | gnuplot
#torque2
echo -e "
reset\n
set terminal png\n
set output \"torque2.png\"\n
set title \"${title}\"\n
set auto\n
plot 'fort.27' using 1:3 with lines ti \"torkp\"\n
" | gnuplot
#torque3
echo -e "
reset\n
set terminal png\n
set output \"torque3.png\"\n
set title \"${title}\"\n
set auto\n
plot 'fort.27' using 1:4 with lines ti \"torksum\"\n
" | gnuplot
#if [ ]; then #BEGIN COMMENTBLOCK
####################################################################################################
# RESTART IF REQUIRED
if [ $($val notDone) ] && [ $maxSteps -gt 0 ]; then
echo -e "\nRestarting..."
qsub -l nodes=1:ppn=1,walltime=168:00:00 -j oe -o output.txt ./$(basename `pwd`)
else
echo -e "\nDone."
fi
#fi #END COMMENTBLOCK
####################################################################################################