Пример #1
0
def step_vv(x, v, f, dt, xup):
    global rcut, skin, fmax

    # update positions
    x += v * dt + 0.5 * f * dt * dt

    # compute maximal position update
    # vectorial
    dx = x - xup
    # square
    dx *= dx
    # sum up
    dx = dx.sum(axis=0)
    # test whether the neighbor list needs to be rebuilt
    if max(dx) > (0.5 * skin)**2:
        rebuild_neighbor_lists(x, rcut + skin)
        xup = x.copy()

    # half update of the velocity
    v += 0.5 * f * dt

    # compute new forces
    f = compute_forces(x, fmax)
    # we assume that m=1 for all particles

    # second half update of the velocity
    v += 0.5 * f * dt

    return x, v, f, xup
Пример #2
0
def step_vv(x, v, f, dt, xup):
    global rcut, skin, fmax

    # update positions
    x += v * dt + 0.5 * f * dt * dt

    # compute maximal position update
    # vectorial
    dx = x - xup
    # square
    dx *= dx
    # sum up
    dx = dx.sum(axis=0)
    # test whether the neighbor list needs to be rebuilt
    if max(dx) > (0.5 * skin) ** 2:
        rebuild_neighbor_lists(x, rcut + skin)
        xup = x.copy()

    # half update of the velocity
    v += 0.5 * f * dt

    # compute new forces
    f = compute_forces(x, fmax) + force_ld(v)
    # we assume that m=1 for all particles

    # second half update of the velocity
    v += 0.5 * f * dt

    return x, v, f, xup
Пример #3
0
# variables to cumulate data
traj = np.empty((steps, 3, N))
ts = np.empty(steps)
Es = np.empty(steps)
Epots = np.empty(steps)
Ekins = np.empty(steps)
Ts = np.empty(steps)
Ps = np.empty(steps)

# ==== CALCULATION ====
print "Simulating until tmax=%s..." % (t + tadd)

set_globals(L, N, rcut, shift)
rebuild_neighbor_lists(x, rcut + skin)
xup = x.copy()
f = compute_forces(x, fmax)

# calculate or load the data from the time before the current run will start
if os.path.exists(datafilename):
    ts_old, Es_old, Epots_old, Ekins_old, Ts_old, Ps_old, traj_old = np.load(
        datafilename)
else:
    a, b, c = compute_energy(x, v)
    d = compute_temperature(c)
    e = compute_pressure(x, v)
    ts_old = np.array([t])
    Es_old = np.array([a])
    Epots_old = np.array([b])
    Ekins_old = np.array([c])
    Ts_old = np.array([d])
    Ps_old = np.array([e])
Пример #4
0
# variables to cumulate data
traj = np.empty((steps, 3, N))
ts = np.empty(steps)
Es = np.empty(steps)
Epots = np.empty(steps)
Ekins = np.empty(steps)
Ts = np.empty(steps)
Ps = np.empty(steps)

# ==== CALCULATION ====
print "Simulating until tmax=%s..." % (t + tadd)

set_globals(L, N, rcut, shift)
rebuild_neighbor_lists(x, rcut + skin)
xup = x.copy()
f = compute_forces(x, fmax) + force_ld(v)

# calculate or load the data from the time before the current run will start
if os.path.exists(datafilename):
    ts_old, Es_old, Epots_old, Ekins_old, Ts_old, Ps_old, traj_old = np.load(datafilename)
else:
    a, b, c = compute_energy(x, v)
    d = compute_temperature(c)
    e = compute_pressure(x, v)
    ts_old = np.array([t])
    Es_old = np.array([a])
    Epots_old = np.array([b])
    Ekins_old = np.array([c])
    Ts_old = np.array([d])
    Ps_old = np.array([e])
    traj_old = np.array([x])
Пример #5
0
# variables to cumulate data
traj = np.empty((steps,3,N))
ts = np.empty(steps)
Es = np.empty(steps)
Epots = np.empty(steps)
Ekins = np.empty(steps)
Ts = np.empty(steps)
Ps = np.empty(steps)

# ==== CALCULATION ====
print "Simulating until tmax=%s..." % (t + tadd)

set_globals(L, N, rcut, shift)
rebuild_neighbor_lists(x, rcut+skin)
xup = x.copy()
f = compute_forces(x,fmax)

# calculate or load the data from the time before the current run will start
if os.path.exists(datafilename):
    ts_old, Es_old, Epots_old, Ekins_old, Ts_old, Ps_old, traj_old = np.load(datafilename)
else:
    a,b,c = compute_energy(x, v)
    d = compute_temperature(c)
    e = compute_pressure(x,v)
    ts_old = np.array([t])
    Es_old = np.array([a])
    Epots_old = np.array([b])
    Ekins_old = np.array([c])
    Ts_old = np.array([d])
    Ps_old = np.array([e])
    traj_old = np.array([x])
Пример #6
0
# variables to cumulate data
traj = np.empty((steps, 3, N))
ts = np.empty(steps)
Es = np.empty(steps)
Epots = np.empty(steps)
Ekins = np.empty(steps)
Ts = np.empty(steps)
Ps = np.empty(steps)

# ==== CALCULATION ====
print "Simulating until tmax=%s..." % (t + tadd)

set_globals(L, N, rcut, shift)
rebuild_neighbor_lists(x, rcut + skin)
xup = x.copy()
f = compute_forces(x, fmax) + force_ld(v)

# calculate or load the data from the time before the current run will start
if os.path.exists(datafilename):
    ts_old, Es_old, Epots_old, Ekins_old, Ts_old, Ps_old, traj_old = np.load(
        datafilename)
else:
    a, b, c = compute_energy(x, v)
    d = compute_temperature(c)
    e = compute_pressure(x, v)
    ts_old = np.array([t])
    Es_old = np.array([a])
    Epots_old = np.array([b])
    Ekins_old = np.array([c])
    Ts_old = np.array([d])
    Ps_old = np.array([e])