def radialDistribution(this, bins, simulation = -1, states = "all", label = ''): print "Calculating radial distribution"; simPath = this.simulations[simulation]; length = this.stateNumbers[simulation]; mdf.combine(simPath, length, ); r, g = mda.calculateRadialDistribution(simPath, bins, length, states); mdplot.plotRadialDistribution(this.path, g, r, label = label); return r, g;
def forceDistribution(this, z0, z1, bins, simulation = -1, states = "all", label = ''): length = this.stateNumbers[simulation]; runName = this.simulations[simulation]; f, r = mda.forceDistribution(z0, z1, bins, runName, length, states, label); plt.figure(10); plt.plot(r, f); plt.savefig("/home/andre/Dropbox/plot/radialForceDistribution_%s.pdf"%label, bbox_inches = 'tight'); plt.close();
def angularDistribution(this, bins, states = "all", simulation = -1, label = ''): print "Calculating angular distribution"; length = this.stateNumbers[simulation]; runName = this.simulations[simulation]; mdf.combine(runName, length); angle, angleDistribution = mda.angularDistribution(bins, runName, length, states); mdplot.plotAngularDistribution(this.path, angleDistribution, angle*180/np.pi, label = label); return angle, angleDistribution;
def numberOfSilanol(this, A, t, simulation = -1, states = "all", label = ''): length = this.stateNumbers[simulation]; runName = this.simulations[simulation]; N = mda.silanolGroups(runName, length, states); if(states == "all"): states = np.arange(0, last + 1); #end print np.shape(N), np.shape(t); mdplot.plotSilanol(this.path, N, t, A, label = label); return t, N;
def forceDistribution(this, bins, senderMark, direction, simulation = -1, states = "all", label = ''): length = this.stateNumbers[simulation]; runName = this.simulations[simulation]; r, data = mda.forceDistribution(runName, bins, senderMark, states, direction, length); fz = data[0, :]; fr = data[1, :]; ft = data[2, :]; plt.figure(10); plt.plot(r, fz, '-b'); plt.figure(11); plt.plot(r, fr, '-g'); plt.figure(12); plt.plot(r, ft, '-r'); plt.show();
def angularDistribution(this, bins, states = "all", simulation = -1, label = ''): print "Calculating angular distribution"; length = this.stateNumbers[simulation]; runName = this.simulations[simulation]; mdf.combine(runName, length); angle, angleDistribution = mda.angularDistribution(bins, runName, length, states); datadirname = this.path + "/data/"; if(not os.path.exists(datadirname)): os.makedirs(datadirname); #end np.save(datadirname + "/angle" + label + ".npy", angle); np.save(datadirname + "/angleData" + label + ".npy", angleDistribution); # mdplot.plotAngularDistribution(this.path, angleDistribution, angle*180/np.pi, label = label); return angle, angleDistribution;
def radialDistribution(this, bins, simulation = -1, states = "all", label = ''): print "Calculating radial distribution"; simPath = this.simulations[simulation]; length = this.stateNumbers[simulation]; mdf.combine(simPath, length, ); r, g = mda.calculateRadialDistribution(simPath, bins, length, states); datadirname = this.path + "/data/"; if(not os.path.exists(datadirname)): os.makedirs(datadirname); #end np.save(datadirname + "/radial" + label + ".npy", r); np.save(datadirname + "/radialData" + label + ".npy", g); # mdplot.plotRadialDistribution(this.path, g, r, label = label); return r, g;
def analyze(this, simulation = -1, label = ''): simPath = this.simulations[simulation]; length = this.stateNumbers[simulation]; #Read dt and step from file datafile = open(simPath + "/init/data.dat"); datafile.readline(); datafile.readline(); dt = float(datafile.readline()); step = int(datafile.readline()); datafile.close(); t = step*dt*np.arange(0, length + 1); K, V, T, r2 = mda.getAnalysis(simPath, length); mdplot.plotEnergy(this.path, V, K, t, label = label); mdplot.plotTemperature(this.path, T, t, label = label); mdplot.plotDisplacement(this.path, r2, t, label = label); D = np.zeros(np.shape(r2)); for i in range(0, 3): D[1:, i] = r2[1:, i]/(6*t[1:]); #end return K, V, T, r2, D, t;
def forceDistribution(this, bins, senderMark, direction, simulation = -1, states = "all", label = ''): length = this.stateNumbers[simulation]; runName = this.simulations[simulation]; x, y, data = mda.forceDistribution(runName, bins, senderMark, states, direction, length); save = this.path + "/data"; if(not os.path.exists(save)): os.makedirs(save) #end saveZ = save + "/z" + label; saveX = save + "/x" + label; saveY = save + "/y" + label; np.save(saveZ, data); np.save(saveX, x); np.save(saveY, y); X, Y = np.meshgrid(x, y) Z = data[0, :, :]; if(not noplt): from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm from matplotlib.ticker import LinearLocator, FormatStrFormatter # import matplotlib.pyplot as plt # import numpy as np print np.shape(data), np.shape(x), np.shape(y); # print data[0, :, :]; fig = plt.figure() ax = fig.gca(projection = '3d') surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0, antialiased=False) # ax.set_zlim(-1.01, 1.01) ax.zaxis.set_major_locator(LinearLocator(10)) ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f')) fig.colorbar(surf, shrink=0.5, aspect=5) plt.axis('off'); plt.show();
def numberOfSilanol(this, simulation = -1, states = "all"): length = this.stateNumbers[simulation]; runName = this.simulations[simulation]; return mda.silanolGroups(runName, length, states);
def visualize(this): #Visualize using vmd mda.vmdVisualize();
def calculateDisplacement(this, simulation = -1): path = this.simulations[simulation]; length = this.stateNumbers[simulation]; return mda.calculateDisplacement(path, length);
def visualize(this): #Visualize using vmd this.makeVmdData(); mda.vmdVisualize();