Skip to content

Commit 75ba8e0

Browse files
committed
improved benchmark
1 parent 8c464e0 commit 75ba8e0

3 files changed

Lines changed: 70 additions & 18 deletions

File tree

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
# Configuration A
1+
# Configuration A - Particles in the NVT ensemble
22

3-
Particle in the NVT ensemble.
3+
## Parameters
44

5-
nmb_1= 50 # Define atom number
6-
sig_1 = 3 * ureg.angstrom # Define LJ parameters (sigma)
7-
eps_1 = 0.1 * ureg.kcal/ureg.mol # Define LJ parameters (epsilon)
8-
mss_1 = 10 * ureg.gram/ureg.mol # Define atom mass
9-
L = 20 * ureg.angstrom # Define box size
10-
rc = 2.5 * sig_1 # Define cut_off
11-
T = 300 * ureg.kelvin # Pick the desired temperature
5+
nmb_1= 50 # Define atom number
6+
sig_1 = 3 * ureg.angstrom # Define LJ parameters (sigma)
7+
eps_1 = 0.1 * ureg.kcal/ureg.mol # Define LJ parameters (epsilon)
8+
mss_1 = 10 * ureg.gram/ureg.mol # Define atom mass
9+
L = 20 * ureg.angstrom # Define box size
10+
rc = 2.5 * sig_1 # Define cut_off
11+
T = 300 * ureg.kelvin # Pick the desired temperature
12+
13+
## Measurements
14+
15+
Epot = -3.532 ± 0.021 kcal/mol
16+
press = 298.069 ± 0.832 atm

integration_tests/benchmark/configurationA/nvt.lmp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
variable dump equal 5000
2-
variable thermo equal 5000
3-
variable steps equal 100000
1+
variable dump equal 50000
2+
variable thermo equal 50000
3+
variable steps equal 1000000
4+
variable eqs equal 100000
5+
variable av equal ${dump}/10
46

57
variable nmb_1 equal 50 # Define atom number
68
variable sig_1 equal 3 # Define LJ parameters (sigma)
@@ -34,16 +36,17 @@ timestep 0.25
3436
thermo ${thermo}
3537
dump mydmp all custom ${dump} dump.lammpstrj id type x y z vx vy vz
3638

37-
run ${steps} # equilibration
39+
run ${eqs} # equilibration
3840

3941
variable Epot equal pe
4042
variable Ekin equal ke
4143
variable Etot equal v_Epot+v_Ekin
4244
variable pressure equal press
4345
variable temperature equal temp
44-
fix myat1 all ave/time ${dump} 1 ${dump} v_Epot file Epot.dat
45-
fix myat2 all ave/time ${dump} 1 ${dump} v_Ekin file Ekin.dat
46-
fix myat3 all ave/time ${dump} 1 ${dump} v_Etot file Etot.dat
47-
fix myat4 all ave/time ${dump} 1 ${dump} v_pressure file pressure.dat
48-
fix myat5 all ave/time ${dump} 1 ${dump} v_temperature file temperature.dat
46+
fix myat1 all ave/time 10 ${av} ${dump} v_Epot file Epot.dat
47+
fix myat2 all ave/time 10 ${av} ${dump} v_Ekin file Ekin.dat
48+
fix myat3 all ave/time 10 ${av} ${dump} v_Etot file Etot.dat
49+
fix myat4 all ave/time 10 ${av} ${dump} v_pressure file pressure.dat
50+
fix myat5 all ave/time 10 ${av} ${dump} v_temperature file temperature.dat
51+
4952
run ${steps}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import numpy as np
2+
import re
3+
4+
# Function to calculate the average and standard error of the second column in a data file
5+
def calculate_statistics(filename):
6+
try:
7+
data = np.loadtxt(filename, usecols=1) # Load the second column
8+
mean = np.mean(data)
9+
std_error = np.std(data, ddof=1) / np.sqrt(len(data)) # Standard error of the mean
10+
return mean, std_error
11+
except Exception as e:
12+
print(f"Error reading {filename}: {e}")
13+
return None, None
14+
15+
# Filenames
16+
config_file = "README.md" # Your configuration file
17+
energy_file = "Epot.dat"
18+
pressure_file = "pressure.dat"
19+
20+
# Calculate statistics
21+
average_epot, error_epot = calculate_statistics(energy_file)
22+
average_press, error_press = calculate_statistics(pressure_file)
23+
24+
if average_epot is None or average_press is None:
25+
print("Failed to calculate averages or errors. Exiting.")
26+
exit(1)
27+
28+
# Update the configuration file
29+
try:
30+
with open(config_file, 'r') as file:
31+
config_lines = file.readlines()
32+
33+
with open(config_file, 'w') as file:
34+
for line in config_lines:
35+
if re.match(r"^Epot\s*=", line):
36+
file.write(f"Epot = {average_epot:.3f} ± {error_epot:.3f} kcal/mol\n")
37+
elif re.match(r"^press\s*=", line):
38+
file.write(f"press = {average_press:.3f} ± {error_press:.3f} atm\n")
39+
else:
40+
file.write(line)
41+
42+
print(f"Updated {config_file} with Epot = {average_epot:.3f} ± {error_epot:.3f} kcal/mol and press = {average_press:.3f} ± {error_press:.3f} atm")
43+
except Exception as e:
44+
print(f"Error updating {config_file}: {e}")

0 commit comments

Comments
 (0)