Ejemplo n.º 1
0
def run_snap(dirf, s):
    datfile = dirf + f'/correlation_grid{grid}/{s}.dat'
    data = read_dat(datfile)
    data = dict_to_np(data)
    avg = np.copy(data)
    n = 2
    dirf = '-'.join([dirf.split('-')[0], str(n)])
    datfile = dirf + f'/correlation_grid{grid}/{s}.dat'
    # print(datfile)
    while os.path.isfile(datfile):
        # print(datfile)
        data = read_dat(datfile)
        avg += dict_to_np(data)
        n += 1
        dirf = '-'.join([dirf.split('-')[0], str(n)])
        datfile = dirf + f'/correlation_grid{grid}/{s}.dat'
    return avg / (n - 1)
Ejemplo n.º 2
0
def color(r, l):
    cmap = matplotlib.cm.get_cmap('Spectral')
    # return cmap(r/l)
    return 'black'


from_freq = 5
r = 5
snap = 0
file = dir + f'/{snap}.dat'

plt.figure(1)
while os.path.isfile(file) and snap < 350:

    print(file)
    data = read_dat(file)
    col = len(data)

    max_freq = get_max(data['freq'][from_freq:], data[str(r)][from_freq:])
    print(max_freq)
    i = 1
    plt.scatter(snap,
                2 * np.pi / max_freq,
                edgecolors=color(i, col),
                facecolors=color(i, col))

    snap += 1
    file = dir + f'/{snap}.dat'

plt.xlabel(r'Time')
plt.ylabel(r'reduced wavenumber')
Ejemplo n.º 3
0
snaps = {50: [170], 60: [180], 70: [185, 200], 80: [200], 85: [215], 90: [240]}

plt.figure(1)


def func(x, a, b, c, d):
    return a + b * x + c * x * 2 + d * x**3


def gaus(x, a, x0, sigma):
    return a * exp(-(x - x0)**2 / (2 * sigma**2))


for snap in snaps[A]:
    print(snap)
    data = read_dat('/'.join([path_to_data, f'{snap}.dat']))
    l = len(data['freq'][7:]) // 6
    x = data['freq'][6:18]
    y = data[str(6)][6:18]
    n = len(x)
    plt.plot(x, y, label=f'time={snap}', marker='.')

    xx = np.linspace(x[0], x[-1], 1000)

    # f = interp1d(x,y, kind='quadratic')
    # # plt.plot(xx, f(xx), 'k--')
    # tck = splrep(x, y, s=None, k=4)
    # plt.plot(xx, splev(xx, tck), 'k--')
    # ste = np.sqrt( sum((splev(x, tck) - ar(y))**2)/(n-2))
    # chi = sum((splev(x, tck) - ar(y))**2/ar(y))
    # chi2 = sum((splev(x, tck) - ar(y))**2/splev(x, tck))