コード例 #1
0
ファイル: ljsim.py プロジェクト: simphys/exercises
tadd = min(tges - t, tadd)
steps = int(tadd // (dt * measurement_stride))

# 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])
コード例 #2
0
ファイル: ljanalyze.py プロジェクト: simphys/exercises
    print "Usage: python %s FILE" % sys.argv[0]
    datafilename = sys.argv[1]
else:
    datafilename = "data/ljsim.dat"

# check whether data file exists
if not os.path.exists(datafilename):
    print "ERROR: %s doesn't exist."
    sys.exit(1)

print "Reading data from %s." % datafilename
datafile = open(datafilename, 'r')
ts, Es, Epots, Ekins, Ts, Ps, traj = pickle.load(datafile)
datafile.close()

set_globals(L, N, 42, 42)

"""==== Functions==== """
def compute_running_average(O,M):
    length=np.shape(O)[0]
    av=[]
    for t in range(M-1,length):
        summe = 0.0
        for i in range(1,M+1):
            summe+=O[t-M+i]
        av.append(summe/M)
    return np.array(av)

"""==== PLOTTING ===="""
# mean values
meanEs=np.mean(Es[:10])
コード例 #3
0
ファイル: ljanalyze.py プロジェクト: simphys/exercises
    print "Usage: python %s FILE" % sys.argv[0]
    datafilename = sys.argv[1]
else:
    datafilename = "data/ljsim.dat"

# check whether data file exists
if not os.path.exists(datafilename):
    print "ERROR: %s doesn't exist."
    sys.exit(1)

print "Reading data from %s." % datafilename
datafile = open(datafilename, 'r')
ts, Es, Epots, Ekins, Ts, Ps, traj = pickle.load(datafile)
datafile.close()

set_globals(L, N, 42, 42)
"""==== Functions==== """


def compute_running_average(O, M):
    length = np.shape(O)[0]
    av = []
    for t in range(M - 1, length):
        summe = 0.0
        for i in range(1, M + 1):
            summe += O[t - M + i]
        av.append(summe / M)
    return np.array(av)


"""==== PLOTTING ===="""
コード例 #4
0
ファイル: ljsim.py プロジェクト: simphys/exercises
tadd = min(tges - t, tadd)
steps = int(tadd // (dt * measurement_stride))

# 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])