-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathCase7.py
More file actions
113 lines (109 loc) · 3.86 KB
/
Case7.py
File metadata and controls
113 lines (109 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env python
from tkinter import *
import numpy as np
from math import *
import matplotlib.pyplot as plt
import AppFunc2 as func
import BasicFunc as base
from matplotlib import cm
#
# Set initial values
#
ball_mass = 0.0458
ball_diameter= 0.0428
#COR = 0.775
C_D = 0.3
C_L = 0.0
rho_air = 1.2
v_wind = 0.0
wind_theta = 0.0
wind_phi = 0.0
ball_v = 45.0
ball_theta = 15.0
ball_phi = 0.0
ball_w_theta = 0.0
ball_w_phi = -90.0
Altitude = 0.0
#
# plot
#
#----------------------------------------------------------------------------------------
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.set_xlim(0, 100)
ax.set_ylim(0, 7)
ax.set_xlabel('x (m)', fontweight='bold', fontsize=25, linespacing=1.0)
ax.set_ylabel('z (m)', fontweight='bold', fontsize=25, linespacing=1.0)
ax.tick_params(labelsize=15)
for i in range(1, 7, 1):
set_C_D = i*0.1
print(set_C_D)
show_x, show_y, show_z = \
func.TRACK(ball_mass, ball_diameter, rho_air, set_C_D, C_L, \
ball_v, ball_theta, ball_phi, \
ball_w_theta, ball_w_phi, \
v_wind, wind_theta, wind_phi, \
Altitude)
step = len(show_x)-1
index=np.argmax(show_z)
ax.text(show_x[index], max(show_z)+0.05, \
r'$C_D = %s$'%(set_C_D), fontweight='bold', fontsize=15)
ax.plot(show_x, show_z, 'r-', markeredgecolor = 'none', linewidth=2)
plt.savefig('Case7-Fig1.eps', format='eps', dpi=1000, bbox_inches='tight')
#----------------------------------------------------------------------------------------
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.set_xlim(0, 140)
ax.set_ylim(0, 18)
ax.set_xlabel('x (m)', fontweight='bold', fontsize=25, linespacing=1.0)
ax.set_ylabel('z (m)', fontweight='bold', fontsize=25, linespacing=1.0)
ax.tick_params(labelsize=15)
for i in range(0, 4, 1):
set_C_L = i*0.1
print(set_C_L)
show_x, show_y, show_z = \
func.TRACK(ball_mass, ball_diameter, rho_air, C_D, set_C_L, \
ball_v, ball_theta, ball_phi, \
ball_w_theta, ball_w_phi, \
v_wind, wind_theta, wind_phi, \
Altitude)
step = len(show_x)-1
index=np.argmax(show_z)
ax.text(show_x[index], max(show_z)+0.3, \
r'$C_L = %s$'%(set_C_L), fontweight='bold', fontsize=15)
ax.plot(show_x, show_z, 'r-', markeredgecolor = 'none', linewidth=2)
plt.savefig('Case7-Fig2.eps', format='eps', dpi=1000, bbox_inches='tight')
#----------------------------------------------------------------------------------------
array_set_C_D = []
array_set_C_L = []
array_distance = []
set_grid_sections = 50
for i in range(0, set_grid_sections*2+1, 1):
for j in range(0, set_grid_sections*2+1, 1):
set_C_D = 0.1 + i*0.5/(set_grid_sections*2)
set_C_L = 0.0 + j*0.3/(set_grid_sections*2)
print(set_C_D, set_C_L)
show_x, show_y, show_z = \
func.TRACK(ball_mass, ball_diameter, rho_air, set_C_D, set_C_L, \
ball_v, ball_theta, ball_phi, \
ball_w_theta, ball_w_phi, \
v_wind, wind_theta, wind_phi, \
Altitude)
step = len(show_x)-1
distance = show_x[step]
array_set_C_D.append(set_C_D)
array_set_C_L.append(set_C_L)
array_distance.append(distance)
plt.figure(3)
ax = fig.add_subplot(111)
plt.xlabel(r'$C_D$', fontweight='bold', fontsize=25)
plt.ylabel(r'$C_L$', fontweight='bold', fontsize=25)
plt.xticks(fontsize=20)
plt.yticks(fontsize=20)
plt.hexbin(array_set_C_D, array_set_C_L, C=array_distance, gridsize=set_grid_sections, cmap=cm.jet, bins=None)
plt.axis([min(array_set_C_D), max(array_set_C_D), min(array_set_C_L), max(array_set_C_L)])
#cb = plt.colorbar(image,spacing='uniform',extend='max')
cb = plt.colorbar()
cb.set_label('Flight distance (m)', fontsize=25)
cb.ax.tick_params(labelsize=15)
plt.savefig('Case7-Fig3.eps', format='eps', dpi=1000, bbox_inches='tight')