name='rdf') n = 0 for medium, values in sorted(datadict['rdf'].iteritems()): i1 = signal.find_peaks_cwt(values[2], np.arange(1, 20), noise_perc=1)[0] i2 = signal.find_peaks_cwt(values[2], np.arange(20, 40), noise_perc=1)[1:3] peakindex = np.append(i1, i2) mx = values[1][peakindex] my = values[2][peakindex] print medium + ":" for i in range(0, 3): print "(%f | %f)" % (mx[i], my[i]) p.plot(mx, my, c[n] + '*', ms=11, mew=1) p.plot(values[1], values[2], c[n] + '-', label=medium) n += 1 p.make() '''f.loadFunction(lambda x, *p: p[1]*x**p[0], [1,1]) p.new(xlabel=r'time [ps]', ylabel=r'mean aquare displacement',name='regimes', xscale='log',yscale='log') for medium, values in sorted(datadict['msd'].iteritems()): i = values[1] < 600 j = values[1][i] < 0.3 f.loadData(values[1][i][j], values[2][i][j], scale='log') x = np.linspace(0.1, 10,2) p.plot(x, f(x), 'k-') j = values[1][i] > 0.5 f.loadData(values[1][i][j], values[2][i][j], scale='log') x = np.linspace(0.1, 1,2) p.plot(x, f(x), 'k-')
# --- Auslenkung --- p.new(title='Auslenkung',xlabel='t',ylabel='x') for v,w,name in x_s: p.plot(v,w,label=name) # --- Auslenkung --- p.new(title='Plots für ausgeschaltete Anregung',xlabel='t') v,w,name = x_s[0] p.plot(v,w,label='Auslenkung x') v,w,name = v_s[0] p.plot(v,w,label='Geschwindigkeit v') v,w,name = a_s[0] p.plot(v,w,label='Beschleunigung a') # --- Energie --- p.new(title='Gesamte Energie', yscale='log',xlabel='t',ylabel='E') for v,w,name in E_s: p.plot(v,w,label=name) # --- Amplitude --- p.new(title='Amplitude',xlabel=r'$\omega$',ylabel=r'$\hat{x}$') f_amp = lambda x, *p: p[0]/np.sqrt((p[1]*p[1]-x*x)**2+(2*p[2]*x)**2) alpha = Fmax/m omeganull = np.sqrt(D/m) gamma = b/m/2 f = Fitter(f_amp, [alpha, omeganull, gamma]) f.loadData(w_s, amp_s, scale='linear') p.plot(w_s,amp_s,'+',label=r'Simulation mit $\alpha = %.4f$, $\gamma = %.4f$, $\omega_0 = %.4f$'%(alpha, gamma, omeganull)) p.plot(f.x,f.y,'-',label=r'Fitt mit $\alpha = %.4f \pm %.4f$, $\gamma = %.4f \pm %.4f$, $\omega_0 = %.4f \pm %.4f$'%(f.params[0],f.std[0],f.params[2],f.std[2],f.params[1],f.std[1])) p.make(ncols = 2, savewindow = False)
datadict[type][0] = np.append(datadict[type][0], volume) datadict[type][1] = np.append(datadict[type][1], energy) datadict[type][2] = np.append(datadict[type][2], lattice) print "%s, run %2s) lattice constant = %f, cell volume = %f, total energy = %f \n" % ( type, runnumber, lattice, volume, energy) with open('data.pkl', 'wb') as f: pickle.dump(datadict, f) else: with open('data.pkl', 'rb') as f: datadict = pickle.load(f) # ==== PLOT ==== for type, [volume, energy, lattice] in datadict.items(): sort = np.argsort(volume) lattice = np.array(lattice)[sort] volume = np.array(volume)[sort] energy = np.array(energy)[sort] p.new(xlabel=r'cell volume [Ang$^3$]', ylabel=r'total energy [eV]', name=type + "_energy") p.plot(volume, energy, '-', label=type) p.new(xlabel=r'cell volume [Ang$^3$]', ylabel=r'lattice constant [Ang]', name=type + "_lattice") p.plot(volume, lattice, 'x', label=type) p.make(ncols=2)
lattice = float(l) except: continue datadict[type][0] = np.append(datadict[type][0], volume) datadict[type][1] = np.append(datadict[type][1], energy) datadict[type][2] = np.append(datadict[type][2], lattice) print "%s, run %2s) lattice constant = %f, cell volume = %f, total energy = %f \n"%(type, runnumber,lattice,volume,energy) with open('data.pkl', 'wb') as f: pickle.dump(datadict, f) else: with open('data.pkl', 'rb') as f: datadict = pickle.load(f) # ==== PLOT ==== for type, [volume,energy,lattice] in datadict.items(): sort = np.argsort(volume) lattice = np.array(lattice)[sort] volume = np.array(volume)[sort] energy = np.array(energy)[sort] p.new(xlabel=r'cell volume [Ang$^3$]', ylabel=r'total energy [eV]',name=type+"_energy") p.plot(volume, energy, '-', label=type) p.new(xlabel=r'cell volume [Ang$^3$]',ylabel=r'lattice constant [Ang]',name=type+"_lattice") p.plot(volume, lattice, 'x', label=type) p.make(ncols = 2)
# --- Energie --- p.new(title='Gesamte Energie', yscale='log', xlabel='t', ylabel='E') for v, w, name in E_s: p.plot(v, w, label=name) # --- Amplitude --- p.new(title='Amplitude', xlabel=r'$\omega$', ylabel=r'$\hat{x}$') f_amp = lambda x, *p: p[0] / np.sqrt((p[1] * p[1] - x * x)**2 + (2 * p[2] * x)**2) alpha = Fmax / m omeganull = np.sqrt(D / m) gamma = b / m / 2 f = Fitter(f_amp, [alpha, omeganull, gamma]) f.loadData(w_s, amp_s, scale='linear') p.plot( w_s, amp_s, '+', label=r'Simulation mit $\alpha = %.4f$, $\gamma = %.4f$, $\omega_0 = %.4f$' % (alpha, gamma, omeganull)) p.plot( f.x, f.y, '-', label= r'Fitt mit $\alpha = %.4f \pm %.4f$, $\gamma = %.4f \pm %.4f$, $\omega_0 = %.4f \pm %.4f$' % (f.params[0], f.std[0], f.params[2], f.std[2], f.params[1], f.std[1])) p.make(ncols=2, savewindow=False)
p.new(xlabel=r'distance [nm]', ylabel=r'radial distribution function',name='rdf') n = 0 for medium, values in sorted(datadict['rdf'].iteritems()): i1 = signal.find_peaks_cwt(values[2], np.arange(1,20),noise_perc=1)[0] i2 = signal.find_peaks_cwt(values[2], np.arange(20,40),noise_perc=1)[1:3] peakindex = np.append(i1,i2) mx = values[1][peakindex] my = values[2][peakindex] print medium+":" for i in range(0,3): print "(%f | %f)"%(mx[i],my[i]) p.plot(mx, my, c[n]+'*',ms=11, mew=1) p.plot(values[1], values[2], c[n]+'-', label=medium) n += 1 p.make() '''f.loadFunction(lambda x, *p: p[1]*x**p[0], [1,1]) p.new(xlabel=r'time [ps]', ylabel=r'mean aquare displacement',name='regimes', xscale='log',yscale='log') for medium, values in sorted(datadict['msd'].iteritems()): i = values[1] < 600 j = values[1][i] < 0.3 f.loadData(values[1][i][j], values[2][i][j], scale='log') x = np.linspace(0.1, 10,2) p.plot(x, f(x), 'k-') j = values[1][i] > 0.5