Nathan Collier avatar Nathan Collier committed c52113b

changed name of file

Comments (0)

Files changed (2)

demo/flapping_wing.py

+from pyfly.uvlm import base,influence
+from pyfly.grid import UVLMGrid
+import numpy as np
+import pylab as plt
+
+def flap(grid,t,t_period):
+    tmp = np.copy(grid)
+
+    # flap angle
+    a = np.sin(2.*np.pi*t/t_period)*np.pi*0.25
+    R = np.zeros((3,3))
+    R[0,0] = 1
+    R[1,[1,2]] = [ np.cos(a), np.sin(a)]
+    R[2,[1,2]] = [-np.sin(a), np.cos(a)]
+    tmp = np.dot(tmp,R)
+
+    # pitch
+    a = 0./180.*np.pi
+    R = np.zeros((3,3))
+    R[1,1] = 1
+    R[0,[0,2]] = [ np.cos(a), np.sin(a)]
+    R[2,[0,2]] = [-np.sin(a), np.cos(a)]
+    tmp = np.dot(tmp,R)
+
+    # forward flight @ 10 m/s
+    tmp[:,:,0] -= 10.0*t
+    return tmp
+
+# Compute the wing, regular wing in x-y directions
+Lr,Lc = 1.,3.
+nr,nc = 3,3
+rho   = 1.225
+wing = np.zeros((nr,nc,3))
+wing[:,:,0] = np.outer(np.linspace(0,Lr,nr),np.ones(nc))
+wing[:,:,1] = np.outer(np.ones(nr),np.linspace(0,Lc,nc))
+grid = UVLMGrid(wing,flap,rho,symaxis=-1,symcord=0.,maxwake=10)
+
+# Temporal stuffs
+N_period = 40
+Omega = 2.
+t_period = (2.*np.pi/Omega)
+dt = t_period/N_period
+N_steps = 50
+np.set_printoptions(precision=15)
+t = 0.
+for i in range(N_steps):
+    
+    print "Step %d:" % i
+    
+    # Setup/solve the linear system
+    A,b = grid.Influence(grid)
+
+    b += grid.RelativeMotion(dt)
+    c = np.linalg.solve(A,-b)
+    grid.circ = c.reshape(grid.circ.shape)
+
+    # Convect the wake
+    grid.ConvectWake([grid],t,t_period,dt)
+    t += dt
+
+    # Plot
+    #grid.Plot("simple",i)
+
+data = np.fromfile('./demo/data.dat',sep=' ').reshape((-1,4))
+
+ts = np.linspace(0,t,N_steps)
+
+CL =  np.trapz(grid.Clift[-N_period:],ts[-N_period:], dx=dt)/(t-ts[-N_period])
+CT = -np.trapz(grid.Cdrag[-N_period:],ts[-N_period:], dx=dt)/(t-ts[-N_period])
+PW =  np.trapz(grid.power[-N_period:],ts[-N_period:], dx=dt)/(t-ts[-N_period])/(rho*0.5*6.*10.0**3.)
+EFF = CT/PW
+print CL,CT,PW,EFF
+
+plt.subplot(311)
+plt.title('Cdrag')
+plt.plot(ts,grid.Cdrag,'r-')
+plt.plot((data[:,0]-1.)*dt,data[:,1],'k--')
+plt.subplot(312)
+plt.title('Clift')
+plt.plot(ts,grid.Clift,'b-')
+plt.plot((data[:,0]-1.)*dt,data[:,2],'k--')
+plt.subplot(313)
+plt.title('Power')
+plt.plot(ts,grid.power,'g-')
+plt.plot((data[:,0]-1.)*dt,data[:,3],'k--')
+plt.show()
+

demo/simple.py

-from pyfly.uvlm import base,influence
-from pyfly.grid import UVLMGrid
-import numpy as np
-import pylab as plt
-
-def flap(grid,t,t_period):
-    tmp = np.copy(grid)
-
-    # flap angle
-    a = np.sin(2.*np.pi*t/t_period)*np.pi*0.25
-    R = np.zeros((3,3))
-    R[0,0] = 1
-    R[1,[1,2]] = [ np.cos(a), np.sin(a)]
-    R[2,[1,2]] = [-np.sin(a), np.cos(a)]
-    tmp = np.dot(tmp,R)
-
-    # pitch
-    a = 0./180.*np.pi
-    R = np.zeros((3,3))
-    R[1,1] = 1
-    R[0,[0,2]] = [ np.cos(a), np.sin(a)]
-    R[2,[0,2]] = [-np.sin(a), np.cos(a)]
-    tmp = np.dot(tmp,R)
-
-    # forward flight @ 10 m/s
-    tmp[:,:,0] -= 10.0*t
-    return tmp
-
-# Compute the wing, regular wing in x-y directions
-Lr,Lc = 1.,3.
-nr,nc = 3,3
-rho   = 1.225
-wing = np.zeros((nr,nc,3))
-wing[:,:,0] = np.outer(np.linspace(0,Lr,nr),np.ones(nc))
-wing[:,:,1] = np.outer(np.ones(nr),np.linspace(0,Lc,nc))
-grid = UVLMGrid(wing,flap,rho,symaxis=-1,symcord=0.,maxwake=10)
-
-# Temporal stuffs
-N_period = 40
-Omega = 2.
-t_period = (2.*np.pi/Omega)
-dt = t_period/N_period
-N_steps = 50
-np.set_printoptions(precision=15)
-t = 0.
-for i in range(N_steps):
-    
-    print "Step %d:" % i
-    
-    # Setup/solve the linear system
-    A,b = grid.Influence(grid)
-
-    b += grid.RelativeMotion(dt)
-    c = np.linalg.solve(A,-b)
-    grid.circ = c.reshape(grid.circ.shape)
-
-    # Convect the wake
-    grid.ConvectWake([grid],t,t_period,dt)
-    t += dt
-
-    # Plot
-    #grid.Plot("simple",i)
-
-data = np.fromfile('./demo/data.dat',sep=' ').reshape((-1,4))
-
-ts = np.linspace(0,t,N_steps)
-
-CL =  np.trapz(grid.Clift[-N_period:],ts[-N_period:], dx=dt)/(t-ts[-N_period])
-CT = -np.trapz(grid.Cdrag[-N_period:],ts[-N_period:], dx=dt)/(t-ts[-N_period])
-PW =  np.trapz(grid.power[-N_period:],ts[-N_period:], dx=dt)/(t-ts[-N_period])/(rho*0.5*6.*10.0**3.)
-EFF = CT/PW
-print CL,CT,PW,EFF
-
-plt.subplot(311)
-plt.title('Cdrag')
-plt.plot(ts,grid.Cdrag,'r-')
-plt.plot((data[:,0]-1.)*dt,data[:,1],'k--')
-plt.subplot(312)
-plt.title('Clift')
-plt.plot(ts,grid.Clift,'b-')
-plt.plot((data[:,0]-1.)*dt,data[:,2],'k--')
-plt.subplot(313)
-plt.title('Power')
-plt.plot(ts,grid.power,'g-')
-plt.plot((data[:,0]-1.)*dt,data[:,3],'k--')
-plt.show()
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.