def plot2d01(N=25): meshfile = gmsh.buildmesh2d('condenser11', N) Th = siMesh(meshfile) u = Th.feval( lambda x, y: 5 * np.exp(-3 * (x**2 + y**2)) * np.cos(x) * np.sin(y)) plt.rcParams['text.usetex'] = True plt.rcParams['text.latex.unicode'] = True plt.close('all') plt.ion() DisplayFigures(nfig=4) fig = plt.figure(1) siplt.plot(Th, u) plt.colorbar() set_axes_equal() plt.figure(2) siplt.plot(Th, u, labels=[20, 2, 4, 6, 8]) siplt.plotmesh(Th, labels=10, color='LightGray') set_axes_equal() plt.axis('off') plt.figure(3) #plt.set_cmap(plt.cm.get_cmap(name='jet')) h = siplt.plot(Th, u, plane=False, colormap='jet') siplt.plotmesh(Th, d=1, color='Black', z=u) plt.colorbar(h) set_axes_equal() plt.figure(4) h = siplt.plot(Th, u, d=1, plane=False, linewidth=3) plt.colorbar(h) siplt.plotmesh(Th, labels=10, color='LightGray', z=u) set_axes_equal() plt.axis('off') return Th
def plotmesh3ds01(): meshfile = gmsh.buildmesh3ds('demisphere5', 20) plt.close('all') plt.ion() DisplayFigures(nfig=4) Th = siMesh(meshfile) plt.figure(1) siplt.plotmesh(Th, legend=True) set_axes_equal() plt.figure(2) siplt.plotmesh(Th, color='LightGray', alpha=0.1) siplt.plotmesh(Th, d=1, legend=True, linewidth=2) plt.axis('off') set_axes_equal() plt.figure(3) siplt.plotmesh(Th, labels=[1, 10, 13, 12], facecolor=None) siplt.plotmesh(Th, labels=[11], edgecolor='black') plt.axis('off') set_axes_equal() plt.figure(4) siplt.plotmesh(Th, legend=True, labels=[10, 13, 12], edgecolor='black') siplt.plotmesh(Th, labels=[1, 11], color='LightGray', alpha=0.1) plt.axis('off') set_axes_equal() return Th
def plotmesh3d02(): meshfile = gmsh.buildmesh3d('cylinderkey', 5) Th = siMesh(meshfile) plt.close('all') plt.ion() DisplayFigures(nfig=4) plt.figure(1) siplt.plotmesh(Th, legend=True) #siplt.plotmesh(Th,d=1,color='black',linewidth=3) set_axes_equal() plt.figure(2) siplt.plotmesh(Th, d=2, legend=True) plt.axis('off') set_axes_equal() plt.figure(3) siplt.plotmesh(Th, d=2, labels=[1, 1000, 1020, 1021], color='LightGray', alpha=0.05) siplt.plotmesh(Th, d=2, labels=[10, 11, 31, 2000, 2020, 2021], legend=True, alpha=1) plt.axis('off') set_axes_equal() plt.figure(4) siplt.plotmesh(Th, d=2, color='LightGray', alpha=0.05) siplt.plotmesh(Th, d=1, legend=True, linewidth=3) plt.axis('off') set_axes_equal() return Th
def plotmesh3Ds(): q2,me2=getMesh3Ds(2) q1,me1=getMesh3Ds(1) plt.ion() plt.close('all') plt.figure(1) plt4sim.plotmesh(q2,me2,edgecolor='Red',facecolor=None) plt4sim.plotmesh(q1,me1,color='Black',linewidths=2) set_axes_equal() plt.figure(2) plt4sim.plotmesh(q2,me2,color='LightGray',alpha=0.1) plt4sim.plotmesh(q1,me1,color='Magenta',linewidths=2) plt.axis('off') set_axes_equal()
def plotmesh3D(): q3,me3=getMesh3D(3) q2,me2=getMesh3D(2) q1,me1=getMesh3D(1) plt.ion() plt.close('all') plt.figure(1) plt4sim.plotmesh(q3,me3) set_axes_equal() plt.figure(2) plt4sim.plotmesh(q2,me2,color='Red') set_axes_equal() plt.axis('off') plt.figure(3) plt4sim.plotmesh(q3,me3,color='LightGray',alpha=0.02) plt4sim.plotmesh(q1,me1,color='Magenta',linewidths=2) from fc_tools.graphics import Plane P=[Plane(origin=[0,0,1],normal=[0,0,-1]), Plane(origin=[0,0,1],normal=[0,-1,-1])] set_axes_equal() plt.axis('off') plt.figure(4) plt4sim.plotmesh(q3,me3,cut_planes=P,color='DarkGrey') plt4sim.plotmesh(q2,me2,cut_planes=P) plt4sim.plotmesh(q1,me1,color='Black',linewidths=2) set_axes_equal() plt.axis('off')
def plotmesh3d01(): meshfile = gmsh.buildmesh3d('cylinder3holes', 10, force=True, verbose=1) Th = siMesh(meshfile, dim=3) plt.close('all') plt.ion() DisplayFigures(nfig=2) plt.figure(1) siplt.plotmesh(Th, legend=True) siplt.plotmesh(Th, d=1, color='black') set_axes_equal() plt.figure(2) siplt.plotmesh(Th, d=2, labels=[10, 20, 21, 100, 101], legend=True) set_axes_equal() plt.axis('off') return Th
def plotmesh2d01(): meshfile = gmsh.buildmesh2d('disk5holes.geo', 20, force=True, verbose=1) Th = siMesh(meshfile, dim=2) plt.close('all') plt.ion() DisplayFigures(nfig=2) plt.figure(1) siplt.plotmesh(Th, legend=True) set_axes_equal() plt.figure(2) siplt.plotmesh(Th, color='LightGray') siplt.plotmesh(Th, d=1, linewidth=2, legend=True) plt.axis('off') set_axes_equal() return Th
def plot3ds01(N=30): meshfile = gmsh.buildmesh3ds('demisphere5', N) Th = siMesh(meshfile) u = Th.feval(lambda x, y, z: 3 * x**2 - y**3 + z**2 + x * y) plt.close('all') plt.ion() DisplayFigures(nfig=2) plt.figure(1) h = siplt.plot(Th, u) set_axes_equal() plt.colorbar(h) plt.figure(2) h2 = siplt.plot(Th, u, labels=[10, 12]) siplt.plotmesh(Th, labels=[1, 11], color='LightGray', linewidth=0.5) plt.colorbar(h2) return Th
def plotiso2D01(): q2,me2=getMesh2D(2) q1,me1=getMesh2D(1) f=lambda x,y: 5*np.exp(-3*(x**2+y**2))*np.cos(x)*np.sin(y) u2=f(q2[:,0],q2[:,1]) plt.close('all') plt.ion() cmap=plt.cm.get_cmap(name='viridis') plt4sim.plotiso(q2,me2,u2,niso=25,cmap=cmap) plt.colorbar() plt4sim.plotmesh(q1,me1,color='black') plt4sim.plotmesh(q2,me2,color='LightGray',alpha=0.04) set_axes_equal() plt.figure(2) plt4sim.plot(q2,me2,u2,cmap=cmap) plt.colorbar() set_axes_equal() plt4sim.plotiso(q2,me2,u2,isorange=np.arange(-1,1,0.2),color='White')
def plot3Ds(): q2,me2=getMesh3Ds(2) q1,me1=getMesh3Ds(1) f=lambda x,y,z: np.cos(3*x-1)*np.sin(2*y-2)*np.sin(3*z) u2=f(q2[:,0],q2[:,1],q2[:,2]) u1=f(q1[:,0],q1[:,1],q1[:,2]) plt.close('all') plt.ion() plt.figure(1) pp=plt4sim.plot(q2,me2,u2) plt4sim.plotmesh(q1,me1,color='Black',linewidths=2) plt.colorbar(pp) plt.axis('off') set_axes_equal() plt.figure(2) pp=plt4sim.plot(q1,me1,u1,linewidths=2,vmin=min(u2),vmax=max(u2)) plt4sim.plotmesh(q2,me2,color='LightGray',alpha=0.1) plt.colorbar(pp) plt.axis('off') set_axes_equal()
def quiver3D01(): (q3,me3)=getMesh3D(3) (q2,me2)=getMesh3D(2) (q1,me1)=getMesh3D(1) f=lambda x,y,z: 3*x**2-y**3+z**2+x*y w=[lambda x,y,z: y*np.cos(-(x**2+y**2)/10), lambda x,y,z: -x*np.cos(-(x**2+y**2)/10), lambda x,y,z: z] q=q3 u3=f(q[:,0],q[:,1],q[:,2]) W3=np.array([w[0](q[:,0],q[:,1],q[:,2]),w[1](q[:,0],q[:,1],q[:,2]),w[2](q[:,0],q[:,1],q[:,2])]) q=q2 u2=f(q[:,0],q[:,1],q[:,2]) W2=np.array([w[0](q[:,0],q[:,1],q[:,2]),w[1](q[:,0],q[:,1],q[:,2]),w[2](q[:,0],q[:,1],q[:,2])]) q=q1 u1=f(q[:,0],q[:,1],q[:,2]) W1=np.array([w[0](q[:,0],q[:,1],q[:,2]),w[1](q[:,0],q[:,1],q[:,2]),w[2](q[:,0],q[:,1],q[:,2])]) cmap=plt.cm.get_cmap(name='jet') plt.ion() plt.close('all') plt.figure(1) pq=plt4sim.quiver(q3,W3,scale=20,nvec=3000) plt.colorbar(pq) plt4sim.plotmesh(q1,me1,color='Black') set_axes_equal() plt.figure(2) pq=plt4sim.quiver(q3,W3,scalars=u3,scale=20,nvec=3000,cmap=cmap) plt4sim.plotmesh(q1,me1,color='Black') plt.colorbar(pq) set_axes_equal() plt.axis('off') plt.figure(3) plt4sim.quiver(q3,W3,scale=20,nvec=3000,color='Blue') plt4sim.plotmesh(q1,me1,color='Black') set_axes_equal() plt.axis('off')
def quiver2D01(): (q,me)=getMesh2D(2) (q1,me1)=getMesh2D(1) f=lambda x,y:5*np.exp(-3*(x**2+y**2))*np.cos(x)*np.sin(y) u=f(q[:,0],q[:,1]) w=[lambda x,y: y*np.cos(-(x**2+y**2)/10), lambda x,y: -x*np.cos(-(x**2+y**2)/10)] W=np.array([w[0](q[:,0],q[:,1]),w[1](q[:,0],q[:,1])]) cmap=plt.cm.get_cmap(name='viridis') plt.ion() plt.close('all') plt.figure(1) plt4sim.quiver(q,W,scale=50,nvec=3000) plt4sim.plotmesh(q1,me1,color='Black') plt.colorbar() set_axes_equal() plt.figure(2) plt4sim.quiver(q,W,scalars=u,scale=50,nvec=3000) plt4sim.plotmesh(q1,me1,color='Black') #plt4sim.plotiso(q,me,u) plt.colorbar() set_axes_equal() plt.figure(3) plt4sim.quiver(q,W,scale=50,nvec=3000,color='Blue') plt4sim.plotmesh(q1,me1,color='Black') set_axes_equal()
def plotiso2d01(N=15): meshfile = gmsh.buildmesh2d('condenser11', N) Th = siMesh(meshfile) u = Th.feval( lambda x, y: 5 * np.exp(-3 * (x**2 + y**2)) * np.cos(x) * np.sin(y)) plt.close('all') plt.ion() DisplayFigures(nfig=4) fig = plt.figure(1) siplt.plotiso(Th, u, niso=15) siplt.plotmesh(Th, d=1, color='Black') set_axes_equal() plt.colorbar() fig = plt.figure(2) isos = np.linspace(-1, 1, 21) siplt.plotiso(Th, u, niso=15, color='LightGray', isorange=isos, linestyles=':') siplt.plotmesh(Th, d=1, color='Black') plt.axis('off') set_axes_equal() fig = plt.figure(3) siplt.plotiso(Th, u, labels=10, niso=15, linewidths=1) plt.colorbar() siplt.plotmesh(Th, labels=10, color='LightGray', linewidth=1, alpha=0.05) siplt.plotiso(Th, u, labels=[2, 4, 6, 8, 20], niso=15, color='Gray', linewidths=1) siplt.plot(Th, u, labels=[2, 4, 6, 8, 20]) siplt.plotiso(Th, u, isorange=0, color='Black', linewidths=2) plt.axis('off') set_axes_equal() fig = plt.figure(4) siplt.plotiso(Th, u, labels=10, niso=15, linewidths=1, color='White') siplt.plot(Th, u, labels=10) siplt.plotiso(Th, u, labels=[2, 4, 6, 8, 20], niso=15, linewidths=1) cb = plt.colorbar() cb.lines[0].set_linewidth(4) plt.axis('off') set_axes_equal() return Th
def quiver3d01(N=10): meshfile = gmsh.buildmesh3d('cylinder3dom', N, force=True) plt.close('all') Th = siMesh(meshfile) u = Th.feval(lambda x, y, z: 3 * x**2 - y**3 + z**2 + x * y) w = [ lambda x, y, z: y * np.cos(-(x**2 + y**2) / 10), lambda x, y, z: -x * np.cos(-(x**2 + y**2) / 10), lambda x, y, z: z / 5 ] W = np.array([Th.feval(w[0]), Th.feval(w[1]), Th.feval(w[2])]) scale = 20 plt.ion() DisplayFigures(nfig=4) plt.figure(1) sq = siplt.quiver(Th, W, nvec=3000, scale=scale) siplt.plotmesh(Th, d=2, color='LightGray', alpha=0.05) plt.colorbar(sq) set_axes_equal() plt.figure(2) sq = siplt.quiver(Th, W, scalars=u, nvec=3000, scale=scale) siplt.plotmesh(Th, d=2, color='LightGray', alpha=0.05) plt.colorbar(sq) plt.axis('off') set_axes_equal() plt.figure(3) sq = siplt.quiver(Th, W, labels=[10, 11], nvec=3000, scale=scale) siplt.plotmesh(Th, d=2, color='LightGray', alpha=0.05) plt.axis('off') set_axes_equal() plt.colorbar(sq) plt.figure(4) sq = siplt.quiver(Th, W, scalars=u, labels=[10, 11], nvec=3000, scale=scale) siplt.plotmesh(Th, d=2, color='LightGray', alpha=0.05) plt.axis('off') set_axes_equal() plt.colorbar(sq) plt.show() return Th
def quiver2d01(N=15): meshfile = gmsh.buildmesh2d('condenser11', N) plt.close('all') DisplayFigures(nfig=4) Th = siMesh(meshfile) u = Th.feval( lambda x, y: 5 * np.exp(-3 * (x**2 + y**2)) * np.cos(x) * np.sin(y)) w = [ lambda x, y: y * np.cos(-(x**2 + y**2) / 10), lambda x, y: -x * np.cos(-(x**2 + y**2) / 10) ] W = np.array([Th.feval(w[0]), Th.feval(w[1])]) plt.ion() plt.figure(1) siplt.quiver(Th, W, scale=50, nvec=3000) siplt.plotmesh(Th, d=1, color='black') set_axes_equal() plt.colorbar() plt.figure(2) siplt.quiver(Th, W, scalars=u, scale=50, nvec=3000) siplt.plotmesh(Th, d=1, color='black') plt.axis('off') set_axes_equal() plt.colorbar() plt.figure(3) siplt.quiver(Th, W, labels=[2, 4, 6, 8, 20], nvec=1000, scale=50) siplt.plotmesh(Th, d=1, color='black') plt.axis('off') set_axes_equal() plt.colorbar() plt.figure(4) siplt.quiver(Th, W, labels=[2, 4, 6, 8, 20], scalars=u, scale=50, nvec=1000) siplt.plotmesh(Th, d=1, color='black') plt.axis('off') set_axes_equal() plt.colorbar() plt.show() return Th
def plot3d01(N=15): meshfile = gmsh.buildmesh3d('cylinderkey', N) Th = siMesh(meshfile) plt.close('all') plt.ion() DisplayFigures(nfig=4) u = Th.feval(lambda x, y, z: 3 * x**2 - y**3 + z**2 + x * y) plt.figure(1) h = siplt.plot(Th, u, s=2) plt.colorbar(h) plt.axis('off') set_axes_equal() plt.figure(2) h2 = siplt.plot(Th, u, d=2, labels=[1000, 1020, 1021, 2000, 2020, 2021]) siplt.plot(Th, u, d=2, labels=[10, 11, 31], edgecolor='black', linewidth=0.5) plt.colorbar(h2) plt.axis('off') set_axes_equal() plt.figure(3) h2 = siplt.plot(Th, u, d=2, labels=[2000, 2020, 2021]) h1 = siplt.plot(Th, u, d=1, labels=[1075, 1077, 1078, 1081], linewidth=3) siplt.plotmesh(Th, d=2, labels=[10, 11, 31], color='LightGray', alpha=0.2) plt.colorbar(h1) plt.axis('off') set_axes_equal() plt.figure(4) siplt.plot(Th, u, d=2, labels=[1], alpha=0.1) siplt.plot(Th, u, d=2, labels=[2000, 2020, 2021]) siplt.plot(Th, u, d=1, labels=[1075, 1077, 1078, 1081], linewidth=3) siplt.plotmesh(Th, d=2, labels=[10, 11, 31], color='LightGray', alpha=0.2) siplt.plotmesh(Th, d=1, labels=[1080, 1079], color='black', linewidth=2) plt.axis('off') set_axes_equal() return Th
def quiver3Ds01(): (q2,me2)=getMesh3Ds(2) (q1,me1)=getMesh3Ds(1) f=lambda x,y,z: 3*x**2-y**3+z**2+x*y w=[lambda x,y,z: y*np.cos(-(x**2+y**2)/10), lambda x,y,z: -x*np.cos(-(x**2+y**2)/10), lambda x,y,z: z] q=q2 u2=f(q[:,0],q[:,1],q[:,2]) W2=np.array([w[0](q[:,0],q[:,1],q[:,2]),w[1](q[:,0],q[:,1],q[:,2]),w[2](q[:,0],q[:,1],q[:,2])]) q=q1 u1=f(q[:,0],q[:,1],q[:,2]) W1=np.array([w[0](q[:,0],q[:,1],q[:,2]),w[1](q[:,0],q[:,1],q[:,2]),w[2](q[:,0],q[:,1],q[:,2])]) cmap=plt.cm.get_cmap(name='jet') plt.close('all') plt.ion() plt.figure(1) pq=plt4sim.quiver(q2,W2,scale=20,nvec=3000) plt.colorbar(pq) plt4sim.plotmesh(q1,me1,color='Black') set_axes_equal() plt.figure(2) pq=plt4sim.quiver(q2,W2,scalars=u2,scale=20,nvec=3000,cmap=cmap) plt4sim.plotmesh(q1,me1,color='Black') plt.colorbar(pq) set_axes_equal() plt.axis('off') plt.figure(3) plt4sim.quiver(q2,W2,scale=20,nvec=3000,color='Blue') plt4sim.plotmesh(q1,me1,color='Black') set_axes_equal() plt.axis('off') #def iso_surface3D01(): #q3,me3=getMesh3D(3) #q2,me2=getMesh3D(2) #q1,me1=getMesh3D(1) #f=lambda x,y,z: np.cos(3*x)*np.sin(2*y)*np.sin(3*z) #u=f(q3[:,0],q3[:,1],q3[:,2]) #plt.close('all') #plt.figure(1) #plt4sim.iso_surface(q3,me3,u,contours=5) #plt4sim.plotmesh(q2,me2,color='LightGray',alpha=0.05) #plt.colorbar() #plt.figure(2) #plt4sim.iso_surface(q3,me3,u,contours=np.linspace(-0.8,0.8,10)) #plt4sim.plotmesh(q2,me2,color='LightGray',alpha=0.05) #plt.colorbar() #def streamline3D01(N=15): #q3,me3=getMesh3D(3) #q2,me2=getMesh3D(2) #q1,me1=getMesh3D(1) #f=lambda x,y,z: 3*x**2-y**3+z**2+x*y #u=f(q3[:,0],q3[:,1],q3[:,2]) #w=[lambda x,y,z: y*np.cos(-(x**2+y**2)/10), lambda x,y,z: -x*np.cos(-(x**2+y**2)/10), lambda x,y,z: z/5] #W=np.array([w[0](q3[:,0],q3[:,1],q3[:,2]), #w[1](q3[:,0],q3[:,1],q3[:,2]), #w[2](q3[:,0],q3[:,1],q3[:,2])]) #plt.close('all') #plt.figure(1) #plt4sim.streamline(q3,me3,u,W) #plt4sim.plotmesh(q2,me2,color='LightGray',alpha=0.05) #plt.colorbar() #plt.figure(2) #s_options={'visible':True} #sw_options={'normal':(0,0,1),'resolution':6} #st_options={'integration_direction':'both'} #plt4sim.streamline(q3,me3,u,W,seedtype='plane',linetype='tube', #seed_options=s_options, #seed_widget_options=sw_options, #streamtracer_options=st_options) #plt4sim.plotmesh(q2,me2,color='LightGray',alpha=0.05) #plt.colorbar() #plt.figure(3) #sw_options={'center':(0.9,0,1), 'radius':0.1,'phi_resolution':8, #'theta_resolution':12,'enabled':False} #st_options={'integration_direction':'both'} #plt4sim.streamline(q3,me3,u,W,seed_widget_options=sw_options, #streamtracer_options=st_options,colormap='jet') #sw_options['center']=(0,0,1) #sw_options['radius']=0.3 #plt4sim.streamline(q3,me3,u,W,seed_widget_options=sw_options, #streamtracer_options=st_options,colormap='jet') #plt.scalarbar() #plt.view(46.6,58,6.7) #plt4sim.plotmesh(q2,me2,color='LightGray',alpha=0.05) #plt.figure(4) #sw_options={'origin':(0,-1,0),'point1':(0,-1,2),'point2':(0,1,0), #'enabled':True,'resolution':6} #st_options={'integration_direction':'both'} #plt4sim.streamline(q3,me3,u,W,seedtype='plane', #seed_widget_options=sw_options, #streamtracer_options=st_options,colormap='jet') #plt.scalarbar() #plt.view(46.6,58,6.7) #plt4sim.plotmesh(q2,me2,color='LightGray',alpha=0.05)