-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunComposition
More file actions
50 lines (35 loc) · 1.66 KB
/
runComposition
File metadata and controls
50 lines (35 loc) · 1.66 KB
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
#!/bin/bash
rm composition.temp
echo -e "Name \tTotalMol \tH \tB \tC \tO \tF \tN \tP \tS \tCl \tAl \tSi \tP \tZn \tCu \tCo \tTi \tZr \tCr \tNi" >> ./composition.temp
for filename in ~/RASPA/simulations/share/raspa/structures/cif/*.cif
do
#N_C=0; N_O=0; N_N=0; N_H=0;
#Cfrac=0; Nfrac=0; Nfrac=0; Hfrac=0;
symbol=(H B C O F N P S Cl Al Si P Zn Cu Co Ti Zr Cr)
#" H B C O F N P S Cl Al Si P Zn Cu Br Co Ti Zr Cr Ni
mass=(1.00784 10.811 12.0107 15.999 18.998 14.0067 30.973762 32.065 35.453 26.982 28.086 30.974 65.380 63.546 79.904 58.933 47.867 91.224 51.9961 58.6934)
n=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
massfrac=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
#IFS=' ' read -a array <<< "$formula"
TotalMass=0
TotalMol=0
for i in {0..18}
do
n[i]=$(grep -o " ${symbol[i]} " "$filename" | wc -l)
TotalMol=$(echo "${n[i]}+$TotalMol" | bc -l )
#m[i]=$(echo "${mass[i]}*${n[i]}" | bc -l )
#TotalMass=$(echo "${m[i]}+$TotalMass" | bc -l )
#echo "${symbol[i]} ${n[i]} ${massfrac[i]}"
done
COFname=$(basename "$filename" .cif)
echo "$COFname"
echo -ne "\n~$COFname~\t" >> ./composition.temp
echo -ne "$TotalMol\t" >> ./composition.temp
for i in {0..16}
do
molarfrac[i]=$(echo "${n[i]}/$TotalMol" | bc -l )
#massfrac[i]=$(echo "${m[i]}/$TotalMass" | bc -l )
echo -ne "${molarfrac[i]}\t" >> ./composition.temp
#echo -ne "${massfrac[i]}\t" >> ./composition.temp
done
done