Difference between revisions of "Kelompok 16"
Eric Delbert (talk | contribs) (→Optimasi drag force dan lift force pada airfoil type NACA 2415) |
Eric Delbert (talk | contribs) (→Optimasi drag force dan lift force pada airfoil type NACA 2415) |
||
Line 198: | Line 198: | ||
#!/usr/bin/env python | #!/usr/bin/env python | ||
# coding: utf-8 | # coding: utf-8 | ||
− | |||
# In[11]: | # In[11]: | ||
− | |||
− | |||
import numpy as np | import numpy as np | ||
from scipy.optimize import minimize | from scipy.optimize import minimize | ||
− | |||
− | |||
− | |||
− | |||
def calc_drag(x):#drag | def calc_drag(x):#drag | ||
x1 = x[0] | x1 = x[0] | ||
drag = 0.0047*x1**6-0.1804*x1**5+2.5411*x1**4-17.088*x1**3+66.126*x1**2-91.635*x1+29.369 | drag = 0.0047*x1**6-0.1804*x1**5+2.5411*x1**4-17.088*x1**3+66.126*x1**2-91.635*x1+29.369 | ||
return drag | return drag | ||
− | |||
def calc_lift(x): #lift | def calc_lift(x): #lift | ||
x1 = x[0] | x1 = x[0] | ||
lift = -0.0016*x1**6+0.0597*x1**5-0.8644*x1**4+5.1299*x1**3-15.87*x1**2+78.924*x1+61.376 | lift = -0.0016*x1**6+0.0597*x1**5-0.8644*x1**4+5.1299*x1**3-15.87*x1**2+78.924*x1+61.376 | ||
return lift | return lift | ||
− | |||
def objective(x): #volume yang diminimalkan | def objective(x): #volume yang diminimalkan | ||
return calc_drag(x) | return calc_drag(x) | ||
− | |||
def constraint1(x): #variable SUDUT yang meminimalkan persamaan garis drag | def constraint1(x): #variable SUDUT yang meminimalkan persamaan garis drag | ||
return 90 - calc_drag(x) | return 90 - calc_drag(x) | ||
def constraint2(x): #variable SUDUT yang meminimalkan persamaan garis lift | def constraint2(x): #variable SUDUT yang meminimalkan persamaan garis lift | ||
return 90 - calc_lift(x) | return 90 - calc_lift(x) | ||
− | |||
con1=({'type':'ineq','fun':constraint1}) | con1=({'type':'ineq','fun':constraint1}) | ||
con2=({'type':'ineq','fun':constraint2}) | con2=({'type':'ineq','fun':constraint2}) | ||
cons = (con1,con2) | cons = (con1,con2) | ||
− | |||
x1_guess = 40 | x1_guess = 40 | ||
− | |||
x0 = np.array([x1_guess]) | x0 = np.array([x1_guess]) | ||
− | |||
sol = minimize(objective,x0, method='SLSQP',constraints=cons, options={'disp':True}) | sol = minimize(objective,x0, method='SLSQP',constraints=cons, options={'disp':True}) | ||
− | |||
xopt = sol.x | xopt = sol.x | ||
forceopt = -sol.fun | forceopt = -sol.fun | ||
− | |||
dragopt = calc_drag(xopt) # drag optimal | dragopt = calc_drag(xopt) # drag optimal | ||
liftopt = calc_lift(xopt) # lift optimal | liftopt = calc_lift(xopt) # lift optimal | ||
− | |||
print ('sudut optimal = '+str(-xopt[0])) | print ('sudut optimal = '+str(-xopt[0])) | ||
print ('total force optimal = '+str(forceopt)) | print ('total force optimal = '+str(forceopt)) | ||
print ('drag force optimal = '+str(-dragopt)) | print ('drag force optimal = '+str(-dragopt)) | ||
print ('lift force optimal = '+str(liftopt)) | print ('lift force optimal = '+str(liftopt)) | ||
− | |||
# In[10]: | # In[10]: | ||
− | |||
− | |||
import numpy as np | import numpy as np | ||
from scipy.optimize import minimize | from scipy.optimize import minimize | ||
− | |||
− | |||
def calc_drag(x):#drag | def calc_drag(x):#drag | ||
x1 = x[0] | x1 = x[0] | ||
drag = 0.0047*x1**6-0.1804*x1**5+2.5411*x1**4-17.088*x1**3+66.126*x1**2-91.635*x1+29.369 | drag = 0.0047*x1**6-0.1804*x1**5+2.5411*x1**4-17.088*x1**3+66.126*x1**2-91.635*x1+29.369 | ||
return drag | return drag | ||
− | |||
def calc_lift(x): #lift | def calc_lift(x): #lift | ||
x1 = x[0] | x1 = x[0] | ||
lift = -0.0016*x1**6+0.0597*x1**5-0.8644*x1**4+5.1299*x1**3-15.87*x1**2+78.924*x1+61.376 | lift = -0.0016*x1**6+0.0597*x1**5-0.8644*x1**4+5.1299*x1**3-15.87*x1**2+78.924*x1+61.376 | ||
return lift | return lift | ||
− | |||
def objective(x): #volume yang diminimalkan | def objective(x): #volume yang diminimalkan | ||
return calc_lift(x) | return calc_lift(x) | ||
− | |||
def constraint1(x): #variable SUDUT yang meminimalkan persamaan garis drag | def constraint1(x): #variable SUDUT yang meminimalkan persamaan garis drag | ||
return 90 - calc_drag(x) | return 90 - calc_drag(x) | ||
def constraint2(x): #variable SUDUT yang meminimalkan persamaan garis lift | def constraint2(x): #variable SUDUT yang meminimalkan persamaan garis lift | ||
return 90 - calc_lift(x) | return 90 - calc_lift(x) | ||
− | |||
con1=({'type':'ineq','fun':constraint1}) | con1=({'type':'ineq','fun':constraint1}) | ||
con2=({'type':'ineq','fun':constraint2}) | con2=({'type':'ineq','fun':constraint2}) | ||
cons = (con1,con2) | cons = (con1,con2) | ||
− | |||
x1_guess = 40 | x1_guess = 40 | ||
− | |||
x0 = np.array([x1_guess]) | x0 = np.array([x1_guess]) | ||
− | |||
sol = minimize(objective,x0, method='SLSQP',constraints=cons, options={'disp':True}) | sol = minimize(objective,x0, method='SLSQP',constraints=cons, options={'disp':True}) | ||
− | |||
xopt = sol.x | xopt = sol.x | ||
forceopt = -sol.fun | forceopt = -sol.fun | ||
− | |||
dragopt = calc_drag(xopt) # drag optimal | dragopt = calc_drag(xopt) # drag optimal | ||
liftopt = calc_lift(xopt) # lift optimal | liftopt = calc_lift(xopt) # lift optimal | ||
− | |||
print ('sudut optimal = '+str(xopt[0])) | print ('sudut optimal = '+str(xopt[0])) | ||
print ('total force optimal = '+str(-forceopt)) | print ('total force optimal = '+str(-forceopt)) | ||
print ('drag force optimal = '+str(dragopt)) | print ('drag force optimal = '+str(dragopt)) | ||
print ('lift force optimal = '+str(liftopt)) | print ('lift force optimal = '+str(liftopt)) | ||
− | |||
# In[ ]: | # In[ ]: |
Revision as of 13:01, 4 December 2019
Anggota Kelompok 16 :
- Eric Delbert
- Gabriella E.
- Gidion M. H.
- Sumardi
Contents
Eliminasi Gauss
Eliminasi gauss merupakan sebuah metode penyelesaian aljabar dengan memanfaatkan mmatriks sebagai variabel dalam operasi.
Contoh matriks
Matriks diatas dapat kita selesaikan dengan menggunakan python dengan algoritma dibawah ini
Hasil dari run file seperti ini
Untuk rincian cara muncul algoritma seperti diatas, Anda dapat lihat pada file PDF yang telah kami buat [1]
Untuk lebih lengkap inilah video tutorialnya.
Sistem Pegas
Video Teori
Video Programming
import numpy as np from numpy import array, zeros
#tentukan jumlah k N=eval(input('jumlah k pada sistem?'))
node = N + 1
k = np.zeros((node,node), float)
# define array berisi konstanta pegas
m_k = np.zeros(N)
for i in range(0,N): print('K',i+1,'?') m_k[i]=eval(input())
# membangun matriks global stiffness k[0,0] = m_k[0] k[N,N]= m_k[N-1]
#pola 1 a = 0 for b in range (0,N): a += 1 k[b,a]= -(m_k[b])
#pola 2 c = 0 for d in range (0,N): c += 1 k[c,d]=-(m_k[d])
#pola 3 e = 0 for f in range (1,N): e +=1 k[f,e]=m_k[f]+m_k[f-1]
print (k)
#gaya yang bekerja Fn = eval(input('jumlah force?'))
#===============================================
J = k[1:node,1:node]
n=len(J) B=np.zeros(n,float) B[n-1]=Fn
# eliminasi gauss
for k in range (0,n-1): for i in range (k+1, n): if J[i,k]!=0 : z= J[i,k]/J[k,k] J[i,k:n]=J[i,k:n]-(J[k,k:n]*z) B[i]=B[i]-(B[k]*z)
print(J)
u=np.zeros(n,float) for m in range (n-1 , -1, -1): u[m]=(B[m]-np.dot(J[m,m+1:n], u[m+1:n]))/J[m,m] print('nilai U',m+2,u[m])
F1=-m_k[0]*u[0]
print(F1)
Persamaan diferensial dengan Runge Kutta Method
x = float(input("Masukkan nilai t untuk displacement of mass yang ingin dicari: ")) x0 = 0 y = 0 h = 0.01 if 0 <= x < 2: def jarak(x, y): return (2 * x**2 - 30 * y * x)
def runge_kutta(x0, y0, x, h): n = (int)((x - x0) / h) y = y0 for i in range(1, n + 1): k1 = h * jarak(x0, y) k2 = h * jarak(x0 + 0.5 * h, y + 0.5 * k1) k3 = h * jarak(x0 + 0.5 * h, y + 0.5 * k2) k4 = h * jarak(x0 + h, y + k3)
y = y + (1.0 / 6.0) * (k1 + 2 * k2 + 2 * k3 + k4)
x0 = x0 + h return y print("Displacement of mass pada t = ", x, "s adalah", runge_kutta(x0, y, x, h), "meter"), elif x >= 2: def jarak(x, y): return (8 - 30 * y * x)
def runge_kutta(x0, y0, x, h): n = (int)((x - x0) / h) y = y0 for i in range(1, n + 1): k1 = h * jarak(x0, y) k2 = h * jarak(x0 + 0.5 * h, y + 0.5 * k1) k3 = h * jarak(x0 + 0.5 * h, y + 0.5 * k2) k4 = h * jarak(x0 + h, y + k3) y = y + (1.0 / 6.0) * (k1 + 2 * k2 + 2 * k3 + k4) x0 = x0 + h return y print("Displacement of mass pada t = ", x, "s adalah", runge_kutta(x0, y, x, h), "meter"),
else: print("t yang dimasukan negatif. Silakan masukkan t secara positif.")
Algoritma diatas merupakan algoritma untuk displacement mass spring system Untuk file pptnya dapat diakses dari link ini [2]
Optimasi drag force dan lift force pada airfoil type NACA 2415
Langkah - langkah dalam pengerjaan :
1. Melakukan 3d modelling pada software Inventor.
2. Melakukan simulasi pada software CFDSOF-NG dan mendapatkan nilai drag force dan lift force di Paraview.
3.Mendapatkan nilai drag force dan lift force yang kemudian diolah excel dan mendapatkan grafik.
4. Melakukan optimasi dengan bantuan python
Untuk algoritmanya sebagai berikut :
#!/usr/bin/env python # coding: utf-8 # In[11]: import numpy as np from scipy.optimize import minimize def calc_drag(x):#drag x1 = x[0] drag = 0.0047*x1**6-0.1804*x1**5+2.5411*x1**4-17.088*x1**3+66.126*x1**2-91.635*x1+29.369 return drag def calc_lift(x): #lift x1 = x[0] lift = -0.0016*x1**6+0.0597*x1**5-0.8644*x1**4+5.1299*x1**3-15.87*x1**2+78.924*x1+61.376 return lift def objective(x): #volume yang diminimalkan return calc_drag(x) def constraint1(x): #variable SUDUT yang meminimalkan persamaan garis drag return 90 - calc_drag(x) def constraint2(x): #variable SUDUT yang meminimalkan persamaan garis lift return 90 - calc_lift(x) con1=({'type':'ineq','fun':constraint1}) con2=({'type':'ineq','fun':constraint2}) cons = (con1,con2) x1_guess = 40 x0 = np.array([x1_guess]) sol = minimize(objective,x0, method='SLSQP',constraints=cons, options={'disp':True}) xopt = sol.x forceopt = -sol.fun dragopt = calc_drag(xopt) # drag optimal liftopt = calc_lift(xopt) # lift optimal print ('sudut optimal = '+str(-xopt[0])) print ('total force optimal = '+str(forceopt)) print ('drag force optimal = '+str(-dragopt)) print ('lift force optimal = '+str(liftopt))
# In[10]: import numpy as np from scipy.optimize import minimize def calc_drag(x):#drag x1 = x[0] drag = 0.0047*x1**6-0.1804*x1**5+2.5411*x1**4-17.088*x1**3+66.126*x1**2-91.635*x1+29.369 return drag def calc_lift(x): #lift x1 = x[0] lift = -0.0016*x1**6+0.0597*x1**5-0.8644*x1**4+5.1299*x1**3-15.87*x1**2+78.924*x1+61.376 return lift def objective(x): #volume yang diminimalkan return calc_lift(x) def constraint1(x): #variable SUDUT yang meminimalkan persamaan garis drag return 90 - calc_drag(x) def constraint2(x): #variable SUDUT yang meminimalkan persamaan garis lift return 90 - calc_lift(x) con1=({'type':'ineq','fun':constraint1}) con2=({'type':'ineq','fun':constraint2}) cons = (con1,con2) x1_guess = 40 x0 = np.array([x1_guess]) sol = minimize(objective,x0, method='SLSQP',constraints=cons, options={'disp':True}) xopt = sol.x forceopt = -sol.fun dragopt = calc_drag(xopt) # drag optimal liftopt = calc_lift(xopt) # lift optimal print ('sudut optimal = '+str(xopt[0])) print ('total force optimal = '+str(-forceopt)) print ('drag force optimal = '+str(dragopt)) print ('lift force optimal = '+str(liftopt))
# In[ ]: