-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollectSimPerformance
More file actions
127 lines (98 loc) · 4.69 KB
/
collectSimPerformance
File metadata and controls
127 lines (98 loc) · 4.69 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
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
#!/bin/bash
# Set the working folder
working_folder="/home/s2216474/toSiSeMatDatastore/thomas"
# Create the performances subfolder if it doesn't exist
performances_folder="$working_folder/performances"
mkdir -p "$performances_folder"
# Initialize variables for the total number of steps
total_steps=0
output_file="concatenated_output.txt"
# Function to extract data from each simulation folder
process_simulation_folder() {
simulation_folder="$1"
cof="$2"
adsorbate="$3"
simulation="$4"
# Generate the XY data file name based on the current COF, adsorbate, and simulation
xy_file="$performances_folder/${cof}_${adsorbate}_${simulation}_data.dat"
# Empty the output and XY data files if they already exist
> $output_file
> $xy_file
# Concatenate all files matching the pattern into one output file
#cat qstat"$simulation_folder"/Output*/*/o* >> "$output_file"
#find "$simulation_folder"/Output*/ -type f -name "o*" -printf '%T@ %p\n' | sort -n | cut -d' ' -f2- | xargs cat >> "$output_file"
for dir in $(ls "$simulation_folder" | grep '^Output_' | sed 's/Output_//' | sort -t_ -k1.7,1.10n -k1.4,1.5n -k1.1,1.2n -k2,2n | sed 's/^/Output_/'); do
cat "$simulation_folder/$dir"/*/o* >> "$output_file"
echo "$dir"
done
# Extract the total number of steps
steps=$(grep -oP 'Current cycle: \d+ out of \d+' "$output_file" | awk '{print $5}' | tail -1)
total_steps=$((total_steps + steps))
# Initialize variables to hold the data
cycle=""
total_energy=""
adsads_energy=""
host_adsorbate_energy=""
stp_per_g=""
mg_per_g=""
molecules=""
read_data=yes
# Read through the output file line by line
while IFS= read -r line; do
# Check if the line contains the cycle information
if [[ $line == "Current cycle: "* ]]; then
# If we have already collected data for a previous cycle, save it
if [[ -n $cycle && -n $total_energy && -n $adsads_energy && -n $host_adsorbate_energy && -n $stp_per_g && -n $mg_per_g ]]; then
echo "$cycle $total_energy $adsads_energy $host_adsorbate_energy $molecules $stp_per_g $mg_per_g" >> "$xy_file"
#echo "$cycle $total_energy $adsads_energy $host_adsorbate_energy $molecules $stp_per_g $mg_per_g"
read_data=yes
fi
# Reset variables for the new cycle
cycle=$(echo $line | awk '{print $3}')
total_energy="NaN"
adsads_energy="NaN"
host_adsorbate_energy="NaN"
stp_per_g="NaN"
mg_per_g="NaN"
molecules="NaN"
elif [[ $line =~ "excess adsorption: " ]]; then
read_data=no
elif [[ $line =~ "current number of integer" ]]; then
molecules=$(echo $line | awk '{print $9}')
# Check if the line contains the value corresponding to cm^3 STP/g
elif [[ $line =~ "3 STP" && $read_data =~ "yes" ]]; then
stp_per_g=$(echo $line | awk '{print $1}')
# Check if the line contains the value corresponding to mg/g
elif [[ $line =~ "mg/g" && $read_data =~ "yes" ]]; then
mg_per_g=$(echo $line | awk '{print $11}')
# Check if the line contains the total potential energy
elif [[ $line =~ "Current total potential energy: " ]]; then
total_energy=$(echo $line | awk '{print $5}')
# Check if the line contains the Host-Host energy
elif [[ $line =~ "Current Adsorbate-Adsorbate energy: " ]]; then
adsads_energy=$(echo $line | awk '{print $4}')
# Check if the line contains the Host-Adsorbate energy
elif [[ $line =~ "Current Host-Adsorbate energy: " ]]; then
host_adsorbate_energy=$(echo $line | awk '{print $4}')
fi
done < "$output_file"
# After the loop, save the last cycle's data if it exists
if [[ -n $cycle && -n $total_energy && -n $adsads_energy && -n $host_adsorbate_energy && -n $stp_per_g && -n $mg_per_g ]]; then
echo "$cycle $total_energy $adsads_energy $host_adsorbate_energy $molecules $stp_per_g $mg_per_g" >> "$xy_file"
fi
total_steps= $(more $xy_file | wc -l)
# Print the total number of steps for this simulation
echo "Total number of steps for $cof $adsorbate $simulation: $total_steps"
}
# Loop through each COF, adsorbate, and simulation directory
for cof in $working_folder/*ddec; do
for adsorbate in $cof/*; do
for simulation in $adsorbate/*; do
# Extract folder names
cof_name=$(basename "$cof")
adsorbate_name=$(basename "$adsorbate")
simulation_name=$(basename "$simulation")
process_simulation_folder "$simulation" "$cof_name" "$adsorbate_name" "$simulation_name"
done
done
done