forked from JMSkelton/ModeMap
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLoopTemperatures.sh
executable file
·60 lines (37 loc) · 1.46 KB
/
LoopTemperatures.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
#!/bin/bash
# Wrapping the loop body in a function saves typing (!).
function Run()
{
temp=${1}
# This script can take a long time to run -> print a "status message" to show that something is happening.
echo "Running: T = ${temp} K"
# Modify input.dat to overwrite the temperature.
# Note that this code assumes the layout of the example input file (i.e. with the temperature appearing on line 22).
head -21 "input.dat" > "input_temp.dat"
echo "${temp}" >> "input_temp.dat"
tail +23 "input.dat" >> "input_temp.dat"
mv "input_temp.dat" "input.dat"
# Run the solver.
../schrodinger-solve1d-anharmonic.exe > out.dat
# Extract the effective (renormalised) harmonic frequency.
freq=`grep "Omega" "out.dat" | tail -n 3 | head -n 1 | awk '{print $3}'`
# Append the temperature and effective frequency to "t-vs-omega.dat".
echo "${temp} ${freq}" >> "t-vs-omega.dat"
# Merge the output into "full-out.dat"
echo "Temperature: ${temp} K" >> "full-out.dat"
echo "" >> "full-out.dat"
cat "out.dat" >> "full-out.dat"
echo "" >> "full-out.dat"
}
# Set up an output file to hold the calculated effective frequencies.
echo "# T [K] Frequency [THz]" > "t-vs-omega.dat"
# We want to calculate the frequencies at low temperature over a fine temperature range...
for (( i=0; i<50; i++ ))
do
Run ${i}
done
# ... but the frequencies at higher temperatures can be calculated over a coarser range.
for (( i=5; i<=100; i++ ))
do
Run $(($i * 10))
done