예제 #1
0
파일: ljsim.py 프로젝트: simphys/exercises
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
파일: ljsim.py 프로젝트: simphys/exercises
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
파일: ljsim.py 프로젝트: simphys/exercises
# 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
파일: ljsim.py 프로젝트: simphys/exercises
# 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
파일: ljsim.py 프로젝트: simphys/exercises
# 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
파일: ljsim.py 프로젝트: simphys/exercises
# 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])