def plot_surf(u): from help_classes import make_periodic umat = make_periodic(u.ext_umat, 'umat', sym_op = u.sym_op) init_surf = make_periodic(u.ext_surf, 'surf', phi_period = u.phi_period) X_init, Y_init, Z_init = get_coord(init_surf) X, Y, Z = get_coord(init_surf + umat) xs, ys, zs = get_coord(u.phys_surf + u.phys_umat) xss, yss, zss = get_coord(u.calc_surf + u.calc_umat) limits = [np.amin([np.amin(X),np.amin(Y),np.amin(Z)]), np.amax([np.amax(X),np.amax(Y),np.amax(Z)])] fig = plt.figure(figsize=plt.figaspect(0.5)*1.5) vv = max(int(len(X)/30), 1) #1 ax = fig.add_subplot(131, projection='3d') ax.plot_surface(X_init, Y_init, Z_init, alpha = 0.2, rstride = vv, cstride = vv) ax.plot_surface(X, Y, Z, rstride = vv, cstride = vv, alpha = 1., shade=False) ax.auto_scale_xyz(limits, limits, limits) #2 ax1 = fig.add_subplot(132, projection='3d') ax1.plot_surface(xs, ys, zs, rstride = vv, cstride = vv, alpha = 1., shade=False) #, c='r', marker='o') ax1.auto_scale_xyz(limits, limits, limits) #3 ax2 = fig.add_subplot(133, projection='3d') ax2.plot_surface(xss, yss, zss, rstride = vv, cstride = vv, alpha = 1., shade=False) #, c='r', marker='o') ax2.auto_scale_xyz(limits, limits, limits) plt.show() plt.clf()
def plot_all(phys_surf, calc_surf, phys_umat, calc_umat, E_b, E_s, normals, path = '', show = False): phi_slice = 0 X_init, Y_init, Z_init = get_coord(phys_surf) #init_surf) X, Y, Z = get_coord(phys_surf + phys_umat) #deform(init_surf, ue)) X_ss, Y_ss, Z_ss = get_coord(calc_surf + calc_umat) #deform(e_surf, ue)) # PLOT BEGINS! if np.amax(E_s) != 0: N_s = E_s/np.amax(E_s) else: N_s = E_s if np.amax(E_b) != 0: N_b = E_b/np.amax(E_b) else: N_b = E_b x, y, nx, ny, nz, nr = [],[],[],[],[], [] r = np.zeros(len(calc_surf[:,phi_slice])) for ik, k in enumerate(np.array(calc_surf[:,phi_slice] + calc_umat[:,phi_slice])): r[ik] = k[0] z = Z_ss[:,phi_slice] for i in X_ss: for j in i: x.append(j) for i in Y_ss: for j in i: y.append(j) n = 0 for i in range(normals.shape[0]): for j in range(normals.shape[1]): normal = normals[i,j] if abs(normal[0]**2 + normal[1]**2 + normal[2]**2 - 1) > 0.00001 : print 'ALERT ALERT!1' nx.append(normal[0]) ny.append(normal[1]) nnr = x[n]/np.sqrt(x[n]**2 + y[n]**2)*normal[0] + y[n]/np.sqrt(x[n]**2 + y[n]**2)*normal[1] if j == phi_slice: nr.append(nnr) nz.append(normal[2]) n += 1 limits = [np.amin([np.amin(X),np.amin(Y),np.amin(Z)]), np.amax([np.amax(X),np.amax(Y),np.amax(Z)])] fig = plt.figure(figsize=plt.figaspect(0.5)*1.5) #1 ax = fig.add_subplot(121, projection='3d') vv = max(int(len(X)/30), 1) ax.plot_surface(X_init, Y_init, Z_init, alpha = 0.2, rstride = 4*vv, cstride = 4*vv) ax.plot_surface(X, Y, Z, rstride = vv, cstride = vv, \ alpha = 1., facecolors=cm.cool(N_b), shade=False) #OrRd ax.auto_scale_xyz(limits, limits, limits) #2 ax1 = fig.add_subplot(122, projection='3d') ax1.plot_surface(X_init, Y_init, Z_init, alpha = 0.2, rstride = 4*vv, cstride = 4*vv) ax1.plot_surface(X, Y, Z, rstride = vv, cstride = vv, \ alpha = 1., facecolors=cm.cool(N_s), shade=False) ax1.auto_scale_xyz(limits, limits, limits) if path != '': if not exists(path + 'pictures/'): makedirs(path + 'pictures/') plt.savefig(path + 'pictures/ener_surf.png') fig2 = plt.figure(figsize=plt.figaspect(0.5)*1.5) #3 ax2 = fig2.add_subplot(131) ax2.quiver(x, y, nx, ny, scale=3.2) #, units='width') ax2.axis('equal') ax3 = fig2.add_subplot(132) ax3.scatter(X, Y, marker = "+") #, units='width') ax3.axis('equal') #4 ax4 = fig2.add_subplot(133) ax4.plot(r,z) ax4.quiver(r, z, nr, nz, scale=2.8) #, units='width') ax4.axis('equal') if path != '': plt.savefig(path + 'pictures/normals.png') if show: plt.show()