Skip to content

Instantly share code, notes, and snippets.

@Rokt33r
Created July 9, 2014 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rokt33r/1d6da85986ac942d6048 to your computer and use it in GitHub Desktop.
Save Rokt33r/1d6da85986ac942d6048 to your computer and use it in GitHub Desktop.
上場率の計算
import sys
from tkinter import *
from math import *
R = 287.05
p = 101300
T = 15+273.15
rho = p/R/T
cLmax = 2.0
g = 9.81
weight = 29300
wingSpan = 13.56
wingArea = 78.04
aspectRatio = wingSpan**2/wingArea
# stallSpeed = (weight*g*2/rho/wingArea/cLmax)**0.5
stallSpeed = 0
cruiseSpeed = 1963 *1000/3600
cD0 = 0.02
e = 0.8
print("rho",rho)
print("stall",stallSpeed)
speeds = []
# for i in range(0, 101) :
# speeds.append(stallSpeed + (cruiseSpeed - stallSpeed)/100*i)
master = Tk()
w = Canvas(master, width=800, height=600)
w.pack()
xScale = 1
yScale = 1/300000
def convertPoint(point) :
(x, y) = point
cX = floor(x*xScale+50)
cY = floor(600-50-y*yScale)
return (cX, cY)
def drawAxis() :
w.create_line(50,50,50,550)
w.create_line(50,550,750,550)
def drawLine(p1, p2, color="black") :
cp1 = convertPoint(p1)
cp2 = convertPoint(p2)
w.create_line(cp1[0],cp1[1],cp2[0],cp2[1],fill=color)
def drawPoint(p1, color="black") :
cp = convertPoint(p1)
(x, y) = cp
w.create_oval(x,y,x+0.5,y+0.5, fill=color, outline="")
drawAxis()
i =0
maxSpeed = 0
maxIncSpeed = 0
maxInc = 0
while i < cruiseSpeed-stallSpeed :
i = i+0.1
speed = stallSpeed+i
cL = 2*g*weight/speed**2/rho/wingArea
pR = (cD0+cL**2/pi/aspectRatio/e)*rho*wingArea*speed**3/2
pA = 2*104*1000*speed
# print((speed,pA,pR))
inc = (pA-pR)/weight/g
if(inc > maxInc) :
maxIncSpeed = speed
maxInc = inc
if(abs(inc)<0.1) :
maxSpeed = speed
# drawLine((speed,0),(speed,300000*10000),color="blue")
drawPoint((speed,pA))
drawPoint((speed,pR))
drawLine((maxIncSpeed,0),(maxIncSpeed,300000*500),color="red")
drawLine((maxSpeed,0),(maxSpeed,300000*500),color="blue")
print("maxIncSpeed =",maxIncSpeed)
print("maxInc =",maxInc)
print("maxSpeed =",maxSpeed)
mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment