Skip to content

Commit a893d21

Browse files
committed
added configuration B
1 parent 136f100 commit a893d21

4 files changed

Lines changed: 101 additions & 2 deletions

File tree

integration_tests/benchmark/configurationA/nvt.lmp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ atom_style atomic
1818
pair_style lj/cut ${rc}
1919
boundary p p p
2020

21-
#read_data twoparticle.data
22-
2321
variable L2 equal ${L}/2
2422
region myreg block -${L2} ${L2} -${L2} ${L2} -${L2} ${L2}
2523
create_box 1 myreg
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Configuration B - Particles in the GCMC ensemble
2+
3+
## Parameters
4+
5+
nmb_1 = 50 # Define inital 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+
mu = - 4 * ureg.kcal/ureg.mol # Pick the desired chemical potential
13+
14+
## Measurements
15+
16+
density = 0.014 ± 0.000 g/cm3
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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
6+
7+
variable nmb_1 equal 50 # Define atom number
8+
variable sig_1 equal 3 # Define LJ parameters (sigma)
9+
variable eps_1 equal 0.1 # Define LJ parameters (epsilon)
10+
variable mss_1 equal 10 # Define atom mass
11+
variable L equal 20 # Define box size
12+
variable rc equal 2.5*${sig_1} # Define cut_off (angstrom)
13+
variable T equal 300 # Pick the desired temperature (kelvin)
14+
variable mu equal -4
15+
16+
# main parameters
17+
units real
18+
dimension 3
19+
atom_style atomic
20+
pair_style lj/cut ${rc}
21+
boundary p p p
22+
23+
variable L2 equal ${L}/2
24+
region myreg block -${L2} ${L2} -${L2} ${L2} -${L2} ${L2}
25+
create_box 1 myreg
26+
create_atoms 1 random ${nmb_1} 14141 myreg
27+
28+
mass 1 ${mss_1}
29+
pair_coeff 1 1 ${eps_1} ${sig_1}
30+
31+
timestep 0.1
32+
fix mygcmc all gcmc 1 1 0 1 29494 ${T} ${mu} 0.01
33+
34+
thermo ${thermo}
35+
dump mydmp all custom ${dump} dump.lammpstrj id type x y z vx vy vz
36+
37+
run ${eqs} # equilibration
38+
39+
variable atom atom "type==1"
40+
group atom dynamic all var atom
41+
variable n_atom equal count(atom)
42+
variable density equal v_n_atom/vol
43+
fix myat1 all ave/time 10 ${av} ${dump} v_density file density.dat
44+
45+
run ${steps}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
density_file = "density.dat"
18+
19+
# Calculate statistics
20+
average_density, error_density = calculate_statistics(density_file)
21+
22+
if average_density is None or error_density is None:
23+
print("Failed to calculate averages or errors. Exiting.")
24+
exit(1)
25+
26+
# Update the configuration file
27+
try:
28+
with open(config_file, 'r') as file:
29+
config_lines = file.readlines()
30+
31+
with open(config_file, 'w') as file:
32+
for line in config_lines:
33+
if re.match(r"^Epot\s*=", line):
34+
file.write(f"density = {average_density:.3f} ± {error_density:.3f} g/cm3\n")
35+
else:
36+
file.write(line)
37+
38+
print(f"Updated {config_file} with density = {average_density:.3f} ± {error_density:.3f} g/cm3")
39+
except Exception as e:
40+
print(f"Error updating {config_file}: {e}")

0 commit comments

Comments
 (0)