-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSA_Sweep_Example.py
More file actions
81 lines (67 loc) · 2.03 KB
/
Copy pathSA_Sweep_Example.py
File metadata and controls
81 lines (67 loc) · 2.03 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
#!/usr/bin/env python
from src.TireModel import SolverMode
from src.TireModel.PAC2002 import PAC2002
from src.Core import TireState
import numpy as np
import matplotlib.pyplot as plt
if __name__ == "__main__":
# Initialize the tire model
#myTireModel = ot.tire('PAC2002')
myTireModel = PAC2002()
# Initialize the tire state
state = TireState()
state.FZ = 4000
state.IA = 0.0
state.SR = 0.0
state.SA = 0.0
state.FY = 0.0
state.V = 10.0
state.P = 260000
# Define the slip angle range
slip_angles = np.linspace(-15, 15, 50) * 3.14 / 180
# Print out some pretty formatting
print('OpenTire Slip Angle Sweep Demo\n')
print('{0:>10} | {1:>10} | {2:>10} | {3:>10} | {4:>10}'
.format('SA [deg]',
'FZ [N]',
'FY [N]',
'MZ [Nm]',
'MX [Nm]'))
print('=' * 62)
# Pre-allocate an array for the result
FyArray = []
MzArray = []
MxArray = []
# Calculate and print out the tire model outputs
for sa in slip_angles:
state.SA = sa
myTireModel.solve(state, SolverMode.PureFy)
# Grab results for plotting
FyArray.append(state.FY)
#MzArray.append(state.MZ)
#MxArray.append(state.MX)
print('{0:>10.1f} \t {1:>10.0f} \t {2:>10.1f} \t {3:>10.1f} \t {4:>10.1f}'
.format(state.SA * 180 / 3.14,
state.FZ,
state.FY,
state.MZ,
state.MX))
# Plot results
fig = plt.figure()
ax1 = fig.add_subplot(211)
ax1.plot(slip_angles, FyArray)
ax1.set_xlabel("Slip Angle (rad)")
ax1.set_ylabel("FY (N)")
ax1.set_title("Lateral Force")
ax2 = fig.add_subplot(223)
ax2.plot(slip_angles, MzArray)
ax2.set_xlabel("Slip Angle (rad)")
ax2.set_ylabel("MZ (Nm)")
ax2.set_title("Self aligning moment")
ax3 = fig.add_subplot(224)
ax3.plot(slip_angles, MxArray)
ax3.set_xlabel("Slip Angle (rad)")
ax3.set_ylabel("MX (Nm)")
ax3.set_title("Overturning moment")
plt.tight_layout()
plt.show()