Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
junzis
GitHub Repository: junzis/openap
Path: blob/master/test/test_emission.py
532 views
1
import numpy as np
2
import matplotlib.pyplot as plt
3
from openap import Emission, FuelFlow, prop
4
from mpl_toolkits.mplot3d import Axes3D
5
6
ac = "A320"
7
8
aircraft = prop.aircraft(ac)
9
fuelflow = FuelFlow(ac=ac)
10
emission = Emission(ac=ac)
11
12
13
tas = np.linspace(50, 500, 50)
14
alt = np.linspace(100, 35000, 50)
15
tas_, alt_ = np.meshgrid(tas, alt)
16
mass = aircraft["limits"]["MTOW"] * 0.85
17
18
19
ff = fuelflow.enroute(mass=mass, tas=tas_, alt=alt_, path_angle=0)
20
21
co2 = emission.co2(ff)
22
h2o = emission.h2o(ff)
23
sox = emission.sox(ff)
24
nox = emission.nox(ff, tas=tas_, alt=alt_)
25
co = emission.co(ff, tas=tas_, alt=alt_)
26
hc = emission.hc(ff, tas=tas_, alt=alt_)
27
28
fig = plt.figure()
29
ax = fig.gca(projection="3d")
30
surf = ax.plot_surface(tas_, alt_, ff)
31
plt.title("fuel flow (kg/s)")
32
plt.xlabel("TAS (kt)")
33
plt.ylabel("Altitude (ft)")
34
plt.show()
35
36
fig = plt.figure()
37
ax = fig.gca(projection="3d")
38
surf = ax.plot_surface(tas_, alt_, h2o)
39
plt.title("H2O (g/s)")
40
plt.xlabel("TAS (kt)")
41
plt.ylabel("Altitude (ft)")
42
plt.show()
43
44
fig = plt.figure()
45
ax = fig.gca(projection="3d")
46
surf = ax.plot_surface(tas_, alt_, co2)
47
plt.title("CO2 (kg/s)")
48
plt.xlabel("TAS (kt)")
49
plt.ylabel("Altitude (ft)")
50
plt.show()
51
52
fig = plt.figure()
53
ax = fig.gca(projection="3d")
54
surf = ax.plot_surface(tas_, alt_, sox)
55
plt.title("SOx (g/s)")
56
plt.xlabel("TAS (kt)")
57
plt.ylabel("Altitude (ft)")
58
plt.show()
59
60
fig = plt.figure()
61
ax = fig.gca(projection="3d")
62
surf = ax.plot_surface(tas_, alt_, nox)
63
plt.title("NOx (g/s)")
64
plt.xlabel("TAS (kt)")
65
plt.ylabel("Altitude (ft)")
66
plt.show()
67
68
fig = plt.figure()
69
ax = fig.gca(projection="3d")
70
surf = ax.plot_surface(tas_, alt_, co)
71
plt.title("CO (g/s)")
72
plt.xlabel("TAS (kt)")
73
plt.ylabel("Altitude (ft)")
74
plt.show()
75
76
fig = plt.figure()
77
ax = fig.gca(projection="3d")
78
surf = ax.plot_surface(tas_, alt_, hc)
79
plt.title("HC (g/s)")
80
plt.xlabel("TAS (kt)")
81
plt.ylabel("Altitude (ft)")
82
plt.show()
83
84