Esempio n. 1
0
positions = np.array([[-0.6, -0.6, 0.0], [0.6, -0.5, 0.0], [-0.6, 0.6, 0.0],
                      [0.6, 0.6, 0.0]])
part = particles.PointParticles(len(positions))
part.x = positions
part.t = 1
part.mass = np.array([3.0, 3.0, 2.0, 3.0])
dt = 0.005
evol = integrator.Andersen(dt, 100, 0.5)

# We should initalize this in a much better way (see #3)
x0 = np.array([-0.7] * 3)
xf = np.array([0.7] * 3)
b = box.Box(x0, xf, t='Fixed')

#lj = interaction.LennardJones([1, 1], 5.4, 1.0, 1.0, "None")
lj = interaction.Morse([1, 1], 5.4, 1.0, 1.0, "None")
pp = []
kk = []
tt = []
for t in np.arange(0, 2, dt):
    part.x, part.v = evol.first_step(part.x, part.v, part.a)
    part.x, part.v = b.wrap_boundary(part.x, part.v)
    part.f, e = lj.forces(part.x, part.v, part.t)
    part.x, part.v = evol.last_step(part.x, part.v, part.a)
    tt.append(t)
    pp.append(e)
    k = 0
    for vv, m in zip(part.v, part.mass):
        k += np.dot(vv, vv) * m
    k /= 2
    kk.append(k)
Esempio n. 2
0
part = particles.PointParticles(nparticles)
part.x = positions_ini
part.v = velocities_ini
part.t = 1
part.mass = masses_ini

evol = integrator.Andersen(dt, temperature_ini, 10.)

# We should initalize this in a much better way (see #3)
x0 = np.array([-scale] * 3)
xf = np.array([scale] * 3)
b = box.Box(x0, xf, t='Periodic')

#lj = interaction.LennardJones([1, 1], 5.4, 1.0, 1.0, "Displace")
lj = interaction.Morse([1, 1], 5.4, 1.0, 1.0, 1.0, "Displace")

pp = []
kk = []
tt = []

fig = plt.figure(figsize=plt.figaspect(0.4))
ax1 = fig.add_subplot(121, projection='3d')
ax1.hold(False)
ax2 = fig.add_subplot(122)

for t in np.arange(0, t_end, dt):
    part.x, part.v = evol.first_step(part.x, part.v, part.a)
    part.x, part.v = b.wrap_boundary(part.x, part.v)
    part.f, e = lj.forces(part.x, part.v, part.t)
    part.x, part.v = evol.last_step(part.x, part.v, part.a)
Esempio n. 3
0
 def test_morse_forces_diff(self):
   mor = interaction.Morse(5.4, 1.0, 1.0, 2.5, "None")
   f, e = mor.forces(self.four_by3, self.four_by3, pairs=np.array([[0, 2], [0, 3], [1, 2], [1, 3]], dtype=np.int64))
   force_by_hand = np.array([[31.2076957, 0.0, 0.0], [2.13912211, 0.0, 0.0],
                             [-2.13912211-31.2076957, 0.0, 0.0], [0.0, 0.0, 0.0]])
   np.testing.assert_array_almost_equal(f, force_by_hand)
Esempio n. 4
0
 def test_create_morse(self):
   interaction.Morse(5.4, 1.0, 1.0, 2.0, "None")
Esempio n. 5
0
 def test_morse_forces_equal(self):
   mor = interaction.Morse(5.4, 1.0, 1.0, 2.5, "None")
   f, e = mor.forces(self.four_by3, self.four_by3)
   force_by_hand = np.array([[0.0, 0.0, 0.0], [31.2076957+2.13912211, 0.0, 0.0],
                             [-31.2076957-2.13912211, 0.0, 0.0], [0.0, 0.0, 0.0]])
   np.testing.assert_array_almost_equal(f, force_by_hand)