-
Notifications
You must be signed in to change notification settings - Fork 4
/
make_minerals.sh
124 lines (91 loc) · 5.92 KB
/
make_minerals.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
#!/bin/bash
#####################################################################
################# September 2019 @ajay #####################
#####################################################################
##### This script extracts stable minerals from full material #####
##### files generated by opting in GENERATOR. #####
##### Plotting part is independent using python scripsts #####
##### automate it -> @ajay6763 #####
#####################################################################
#####################################################################
#Name T(K) P(bar) V,J/bar H,J gamma T Ks,bar Gs,bar v0,km/s vp,km/s vs,km/s vp/vs rho,kg/m3 unused cp,J/#K alpha,1/K beta,1/bar S,J/K n,mol N,g Ks_T,bar/K Gs_T,bar/K Ks_P Gs_P v0_T vp_T vs_T v0_P vp_P #vs_P wt % vol % mol % SIO2 AL2O3 FEO MGO CAO NA2O
if [ -d "./Phase_diagrams" ]; then
### Take action if $DIR exists ###
echo
echo "You have a Phase_diagram it will be overwritten"
else
### Control will jump here if $DIR does NOT exists ###
mkdir ./Phase_diagrams
fi
echo "Enter the output file from conversions:"
ls *.txt
read infile
cp $infile ./Phase_diagrams
#################################
#reading material files code name
echo "Enter material the full material file name (e.g., DMM_HP_FULL) "
echo "Following are the full property material files in your model directory."
ls ./databases/*_FULL
echo " "
read mat_file
#echo "Enter the prefix codes (e.g. 90,99) of full material files from above seperated by space: "
#read -a mat_list
######################################
### looping through all material files
### and looking up for stable phase and mineral assemblages in full property files
#for i in ${mat_list[@]}
#do
echo "Searching for your stable minerals in ......"
echo $mat_file
#cat post_processing_output.dat|awk -v a="$i" '{if ($8 == a) print $0}' > ./Phase_diagrams/$i"_profile"
####
## Findinf minimum and maximum T P
#P_min=`cat "./Phase_diagrams/"$i"_profile"|awk '{print $4}'|minmax -C |awk '{print $1}'`
#P_max=`cat "./Phase_diagrams/"$i"_profile"|awk '{print $4}'|minmax -C |awk '{print $2}'`
#T_min=`cat "./Phase_diagrams/"$i"_profile"|awk '{print $3}'|minmax -C |awk '{print $1}'`
#T_max=`cat "./Phase_diagrams/"$i"_profile"|awk '{print $3}'|minmax -C |awk '{print $2}'`
P_min=1438.8 #10000000
P_max=137148.0 #1000000000
T_min=579.805 #1200
T_max=1809.455 #1300
#echo "Min P = " $P_min " Max P= " $P_max
#echo "Min T = " $T_min " Max T= " $T_max
#grep 'O(HP)' "$i"_FULL|awk '{print $2-273,$3*100000,$32,$33}'|awk -v min="$P_min" -v max="$P_max" '{if($2 >= min && $2<= max) print $0}' > O_"$i"_FULL.txt
#grep 'O(HP)' "$i"_FULL|awk '{print $2-273,$3*100000,$32,$33}'|awk -v Tmin="$T_min" -v Tmax="$T_max" -v Pmin="$P_min" -v Pmax="$P_max" '{if($1 >= Tmin && $1<= Tmax && $2 >= Pmin && $2<= Pmax) print $0}' > O_"$i"_FULL.txt
#T P Vp Vs Vp/Vs density wt% vol%
echo ""
echo "Searching for your Plagioclase ......"
echo $mat_file
grep 'Pl(h)' ./databases/$mat_file|awk '{print $2+273,$3,$10,$11,$12,$13,$31,$32,$33}'| awk -v min="$P_min" -v max="$P_max" '{if($2 >= min && $2<= max) print $0}'|awk -v min="$T_min" -v max="$T_max" '{if($1 >= min && $1<= max) print $0}' > ./Phase_diagrams/Ph.txt
echo ""
echo "Searching for your Spinel ......"
echo $mat_file
grep 'Sp(HP)' ./databases/$mat_file|awk '{print $2+273,$3,$10,$11,$12,$13,$31,$32,$33}'| awk -v min="$P_min" -v max="$P_max" '{if($2 >= min && $2<= max) print $0}'|awk -v min="$T_min" -v max="$T_max" '{if($1 >= min && $1<= max) print $0}' > ./Phase_diagrams/Sp.txt
echo ""
echo "Searching for your Garnet ......"
echo $mat_file
grep 'Gt(stx8)' ./databases/$mat_file|awk '{print $2+273,$3,$10,$11,$12,$13,$31,$32,$33}'| awk -v min="$P_min" -v max="$P_max" '{if($2 >= min && $2<= max) print $0}' |awk -v min="$T_min" -v max="$T_max" '{if($1 >= min && $1 <= max) print $0}'> ./Phase_diagrams/Gt.txt
echo ""
echo "Searching for your Orthopyroxene ......"
echo $mat_file
grep 'Opx(HP)' ./databases/$mat_file|awk '{print $2+273,$3,$10,$11,$12,$13,$31,$32,$33}'| awk -v min="$P_min" -v max="$P_max" '{if($2 >= min && $2<= max) print $0}' |awk -v min="$T_min" -v max="$T_max" '{if($1 >= min && $1<= max) print $0}' > ./Phase_diagrams/Opx.txt
echo ""
echo "Searching for your Clinopyroxene ......"
echo $mat_file
grep 'Cpx(HP)' ./databases/$mat_file|awk '{print $2+273,$3,$10,$11,$12,$13,$31,$32,$33}'| awk -v min="$P_min" -v max="$P_max" '{if($2 >= min && $2<= max) print $0}' |awk -v min="$T_min" -v max="$T_max" '{if($1 >= min && $1<= max) print $0}'> ./Phase_diagrams/Cpx.txt
echo ""
echo "Searching for your Olivine ......"
echo $mat_file
grep 'O(HP)' ./databases/$mat_file|awk '{print $2+273,$3,$10,$11,$12,$13,$31,$32,$33}'|awk -v min="$P_min" -v max="$P_max" '{if($2 >= min && $2<= max) print $0}'|awk -v min="$T_min" -v max="$T_max" '{if($1 >= min && $1<= max) print $0}' > ./Phase_diagrams/Ol.txt
echo ""
echo "Searching for your C2/c(stx) ......"
echo $mat_file
grep 'C2_c(jca)' ./databases/$mat_file|awk '{print $2+273,$3,$10,$11,$12,$13,$31,$32,$33}'|awk -v min="$P_min" -v max="$P_max" '{if($2 >= min && $2<= max) print $0}'|awk -v min="$T_min" -v max="$T_max" '{if($1 >= min && $1<= max) print $0}' > ./Phase_diagrams/C2c.txt
echo ""
echo "Searching for your Wadselyte ......"
echo $mat_file
grep 'Wad(stx8)' ./databases/$mat_file|awk '{print $2+273,$3,$10,$11,$12,$13,$31,$32,$33}'|awk -v min="$P_min" -v max="$P_max" '{if($2 >= min && $2<= max) print $0}'|awk -v min="$T_min" -v max="$T_max" '{if($1 >= min && $1<= max) print $0}' > ./Phase_diagrams/Wad.txt
echo " "
echo " "
echo "Your beautiful mantle minerals are in Phase_diagram folder and are ready to be plotted :)"
echo "Use the provided jupyter-notebook phase_diagram.ipynb."