Skip to content

Commit 536e62d

Browse files
Merge pull request #9 from mdcourse/implement-metropolis-paper
started implementing metropolis1953
2 parents da0b521 + 878345a commit 536e62d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

docs/source/chapters/chapter1.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Copy the following lines into *potentials.py*:
7676

7777
.. code-block:: python
7878
79+
import numpy as np
80+
7981
def potentials(potential_type, epsilon, sigma, r, derivative=False):
8082
if potential_type == "Lennard-Jones":
8183
if derivative:
@@ -84,9 +86,11 @@ Copy the following lines into *potentials.py*:
8486
return 4 * epsilon * ((sigma / r) ** 12 - (sigma / r) ** 6)
8587
elif potential_type == "Hard-Sphere":
8688
if derivative:
87-
raise ValueError("Derivative is not defined for Hard-Sphere potential.")
89+
# Derivative is not defined for Hard-Sphere potential.
90+
# --> return 0
91+
return np.zeros(len(r))
8892
else:
89-
return 1000 if r < sigma else 0
93+
return np.where(r > sigma, 0, 1000)
9094
else:
9195
raise ValueError(f"Unknown potential type: {potential_type}")
9296

docs/source/chapters/chapter4.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ following *run()* method to the *MinimizeEnergy* class:
146146
# First, meevaluate the initial energy and max force
147147
self.update_neighbor_lists() # Rebuild neighbor list, if necessary
148148
self.update_cross_coefficients() # Recalculate the cross coefficients, if necessary
149-
if self.step == 0: # At the first step, Epot/MaxF do not exists yet, calculate them both
150-
init_Epot = self.compute_potential()
151-
forces, init_MaxF = self.compute_force()
149+
# Compute Epot/MaxF/force
150+
init_Epot = self.compute_potential()
151+
forces, init_MaxF = self.compute_force()
152152
# Save the current atom positions
153153
init_positions = copy.deepcopy(self.atoms_positions)
154154
# Move the atoms in the opposite direction of the maximum force

docs/source/chapters/chapter5.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ a LAMMPS dump format, and can be read by molecular dynamics softwares like VMD.
143143
f.write("ITEM: NUMBER OF ATOMS\n")
144144
f.write(str(code.total_number_atoms) + "\n")
145145
f.write("ITEM: BOX BOUNDS pp pp pp\n")
146-
for dim in np.arange(code.dimensions):
146+
for dim in np.arange(3):
147147
f.write(str(box_boundaries[dim][0]) + " "
148148
+ str(box_boundaries[dim][1]) + "\n")
149149
cpt = 1

0 commit comments

Comments
 (0)