-
Notifications
You must be signed in to change notification settings - Fork 4
/
consingint.sh
executable file
·82 lines (66 loc) · 2.33 KB
/
consingint.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
#!/bin/bash
#control.sh
#This script accepts the parameters for the metamaterials simulations as arguments
#and edits the fortran and matlab scripts to have those parameters
#It then compiles the fortran code, uses mv to rename the data files to a convenient name
#and then executes the matlab script to generate the plots
#This script will not loop over ranges of parameters so that it will be easy to call it to get one set
#but it is instead intended that this code can be executed by another loop script to generate ranges of parameters
#Expected usage:
#./control.sh eps2 mu2 eta thetai eps1 mu1 g
#./control.sh 1.0 1.0 5.0 1.0 3 "PI\/4.0" 3.0
echo "Editing Fortran parameters to eps1= $1 , mu1= $2 , eps2= $3 , mu2= $4 , eta= $5 , thetai= $6 , g=$7"
eps1="$1"
mu1="$2"
eps2="$3"
mu2="$4"
eta="$5"
thetai="$6"
g="$7"
#gets filename to put in for dat file saving/loading
striptheta=`echo $thetai | sed 's%\/%d%' `
#echo $striptheta
fname="'data/$striptheta rads $eta eta $g g $eps2 eps2gaussdielecfieldmap.dat'"
stripfname=`echo -n $fname | sed 's% %%g' `
#echo $stripfname
sed -e "s/^eps1=.*/eps1=$1/" \
-e "s/^mu1=.*/mu1=$2/" \
-e "s/^eps2=.*/eps2=($3,0.0)/" \
-e "s/^mu2=.*/mu2=$4/" \
-e "s/^eta=.*/eta=$5/" \
-e "s/^thetai=.*/thetai=$6/" \
-e "s/^ti='.*/ti='$6'/" \
-e "s/^g=.*/g=$7/" \
-e "s%write(filename,20).*%write(filename,20) $stripfname%" \
congaussian1fixed.f90 > congaussian1fixed.tmp
cp congaussian1fixed.tmp congaussian1fixed.f90
echo "Done."
echo "Editing MATLAB parameters..."
#get filename for plots
pname="$striptheta rads $eta eta $g g $eps2 eps2gaussdielecfieldmap.png');"
#echo $pname
strippname=`echo $pname | sed 's% %%g' `
#echo $strippname
sed -e "s/^eps2=.*/eps2=$3;/" \
-e "s/^mu2=.*/mu2=$4;/" \
-e "s/^eta=.*/eta=$5;/" \
-e "s/^thetai=.*/thetai='$6';/" \
-e "s/^g=.*/g=[$7];/" \
-e "s%load(.*%load($stripfname);%" \
-e "s%plots/im_.*%plots/im_$strippname%" \
-e "s%plots/real_.*%plots/real_$strippname%" \
congaussscript.m > congaussscript.tmp
cp congaussscript.tmp congaussscript.m
echo "Done."
echo "Compiling Fortran code..."
gfortran congaussian1fixed.f90 -o a.out &>/dev/null
echo "Done."
echo "Executing Fortran code..."
./a.out &>/dev/null
echo "Done."
echo "Executing MATLAB code..."
matlab -nodisplay -nodesktop -r "congaussscript; quit" &>/dev/null
echo "Done."
#fix matlab messing with terminal
stty echo
echo "Completed."