-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from mdcourse/improve-benchmark-with-LAMMPS
improved benchmark
- Loading branch information
Showing
4 changed files
with
72 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
# Configuration A | ||
# Configuration A - Particles in the NVT ensemble | ||
|
||
Particle in the NVT ensemble. | ||
## Parameters | ||
|
||
nmb_1= 50 # Define atom number | ||
sig_1 = 3 * ureg.angstrom # Define LJ parameters (sigma) | ||
eps_1 = 0.1 * ureg.kcal/ureg.mol # Define LJ parameters (epsilon) | ||
mss_1 = 10 * ureg.gram/ureg.mol # Define atom mass | ||
L = 20 * ureg.angstrom # Define box size | ||
rc = 2.5 * sig_1 # Define cut_off | ||
T = 300 * ureg.kelvin # Pick the desired temperature | ||
nmb_1= 50 # Define atom number | ||
sig_1 = 3 * ureg.angstrom # Define LJ parameters (sigma) | ||
eps_1 = 0.1 * ureg.kcal/ureg.mol # Define LJ parameters (epsilon) | ||
mss_1 = 10 * ureg.gram/ureg.mol # Define atom mass | ||
L = 20 * ureg.angstrom # Define box size | ||
rc = 2.5 * sig_1 # Define cut_off | ||
T = 300 * ureg.kelvin # Pick the desired temperature | ||
|
||
## Measurements | ||
|
||
Epot = -3.532 ± 0.021 kcal/mol | ||
press = 298.069 ± 0.832 atm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
integration_tests/benchmark/configurationA/update_README.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import numpy as np | ||
import re | ||
|
||
# Function to calculate the average and standard error of the second column in a data file | ||
def calculate_statistics(filename): | ||
try: | ||
data = np.loadtxt(filename, usecols=1) # Load the second column | ||
mean = np.mean(data) | ||
std_error = np.std(data, ddof=1) / np.sqrt(len(data)) # Standard error of the mean | ||
return mean, std_error | ||
except Exception as e: | ||
print(f"Error reading {filename}: {e}") | ||
return None, None | ||
|
||
# Filenames | ||
config_file = "README.md" # Your configuration file | ||
energy_file = "Epot.dat" | ||
pressure_file = "pressure.dat" | ||
|
||
# Calculate statistics | ||
average_epot, error_epot = calculate_statistics(energy_file) | ||
average_press, error_press = calculate_statistics(pressure_file) | ||
|
||
if average_epot is None or average_press is None: | ||
print("Failed to calculate averages or errors. Exiting.") | ||
exit(1) | ||
|
||
# Update the configuration file | ||
try: | ||
with open(config_file, 'r') as file: | ||
config_lines = file.readlines() | ||
|
||
with open(config_file, 'w') as file: | ||
for line in config_lines: | ||
if re.match(r"^Epot\s*=", line): | ||
file.write(f"Epot = {average_epot:.3f} ± {error_epot:.3f} kcal/mol\n") | ||
elif re.match(r"^press\s*=", line): | ||
file.write(f"press = {average_press:.3f} ± {error_press:.3f} atm\n") | ||
else: | ||
file.write(line) | ||
|
||
print(f"Updated {config_file} with Epot = {average_epot:.3f} ± {error_epot:.3f} kcal/mol and press = {average_press:.3f} ± {error_press:.3f} atm") | ||
except Exception as e: | ||
print(f"Error updating {config_file}: {e}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters