-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_hysteresis.py
53 lines (18 loc) · 5.03 KB
/
plot_hysteresis.py
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
import numpy as np
import matplotlib.pyplot as plt
torques = [-2.0, -1.8974358974358974, -1.794871794871795, -1.6923076923076923, -1.5897435897435899, -1.4871794871794872, -1.3846153846153846, -1.282051282051282, -1.1794871794871795, -1.076923076923077, -0.9743589743589745, -0.8717948717948718, -0.7692307692307692, -0.6666666666666667, -0.5641025641025641, -0.4615384615384617, -0.35897435897435903, -0.2564102564102564, -0.15384615384615397, -0.05128205128205132, 0.0512820512820511, 0.15384615384615374, 0.2564102564102564, 0.35897435897435903, 0.4615384615384617, 0.5641025641025639, 0.6666666666666665, 0.7692307692307692, 0.8717948717948718, 0.9743589743589745, 1.0769230769230766, 1.1794871794871793, 1.282051282051282, 1.3846153846153846, 1.4871794871794872, 1.5897435897435894, 1.692307692307692, 1.7948717948717947, 1.8974358974358974, 2.0, 2.0, 1.8974358974358974, 1.794871794871795, 1.6923076923076923, 1.5897435897435899, 1.4871794871794872, 1.3846153846153846, 1.282051282051282, 1.1794871794871795, 1.076923076923077, 0.9743589743589745, 0.8717948717948718, 0.7692307692307692, 0.6666666666666667, 0.5641025641025641, 0.4615384615384617, 0.35897435897435903, 0.2564102564102564, 0.15384615384615397, 0.05128205128205132, -0.0512820512820511, -0.15384615384615374, -0.2564102564102564, -0.35897435897435903, -0.4615384615384617, -0.5641025641025639, -0.6666666666666665, -0.7692307692307692, -0.8717948717948718, -0.9743589743589745, -1.0769230769230766, -1.1794871794871793, -1.282051282051282, -1.3846153846153846, -1.4871794871794872, -1.5897435897435894, -1.692307692307692, -1.7948717948717947, -1.8974358974358974, -2.0]
xs = [0.9335804264972017, 0.9335804264972017, 0.9335804264972017, 0.9335804264972017, 0.9335804264972017, 0.9335804264972017, 0.9335804264972017, 0.9335804264972017, 0.9335804264972017, 0.9335804264972017, 0.9335804264972017, 0.9335804264972017, 0.9978589232386035, 0.9978589232386035, 1.0, 0.9996573249755573, 0.9996573249755573, 0.9996573249755573, 0.9996573249755573, 0.9996573249755573, 0.9996573249755573, 0.9996573249755573, 0.9992290362407229, 0.9992290362407229, 0.9992290362407229, 0.9896513868196702, 0.9876883405951378, 0.9876883405951378, 0.9807852804032304, 0.9659258262890683, 0.9659258262890683, 0.9659258262890683, 0.9187912101488983, 0.9187912101488983, 0.9187912101488983, 0.9187912101488983, 0.9187912101488983, 0.9187912101488983, 0.9187912101488983, 0.8012538126910607, 0.8012538126910607, 0.8012538126910607, 0.8012538126910607, 0.8012538126910607, 0.8012538126910607, 0.8012538126910607, 0.8012538126910607, 0.8012538126910607, 0.8012538126910607, 0.8849876374630419, 0.8849876374630419, 0.8849876374630419, 0.9659258262890683, 0.9659258262890683, 0.9781476007338057, 0.9781476007338057, 0.9781476007338057, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.9914448613738104, 0.9914448613738104, 0.9914448613738104, 0.9855560590580777, 0.9855560590580777, 0.9807852804032304, 0.9781476007338057, 0.9781476007338057, 0.9288095528719242, 0.9288095528719242, 0.9288095528719242, 0.9081431738250813, 0.9081431738250813, 0.9081431738250813, 0.9081431738250813, 0.9081431738250813, 0.8457278217039733]
ys = [-0.35836794954530027, -0.35836794954530027, -0.35836794954530027, -0.35836794954530027, -0.35836794954530027, -0.35836794954530027, -0.35836794954530027, -0.35836794954530027, -0.35836794954530027, -0.35836794954530027, -0.35836794954530027, -0.35836794954530027, -0.06540312923014306, -0.06540312923014306, 0.0, 0.02617694830787315, 0.02617694830787315, 0.02617694830787315, 0.02617694830787315, 0.02617694830787315, 0.02617694830787315, 0.02617694830787315, 0.03925981575906861, 0.03925981575906861, 0.03925981575906861, 0.1434926219911793, 0.15643446504023087, 0.15643446504023087, 0.19509032201612825, 0.25881904510252074, 0.25881904510252074, 0.25881904510252074, 0.39474385638426723, 0.39474385638426723, 0.39474385638426723, 0.39474385638426723, 0.39474385638426723, 0.39474385638426723, 0.39474385638426723, 0.598324600570659, 0.598324600570659, 0.598324600570659, 0.598324600570659, 0.598324600570659, 0.598324600570659, 0.598324600570659, 0.598324600570659, 0.598324600570659, 0.598324600570659, 0.4656145203251114, 0.4656145203251114, 0.4656145203251114, 0.25881904510252074, 0.25881904510252074, 0.20791169081775931, 0.20791169081775931, 0.20791169081775931, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.13052619222005157, -0.13052619222005157, -0.13052619222005157, -0.1693495038490246, -0.1693495038490246, -0.19509032201612825, -0.20791169081775931, -0.20791169081775931, -0.3705574375098362, -0.3705574375098362, -0.3705574375098362, -0.41865973753742813, -0.41865973753742813, -0.41865973753742813, -0.41865973753742813, -0.41865973753742813, -0.5336145159156115]
xs = np.array(xs)
ys = np.array(ys)
torques = np.array(torques)
angs = np.arctan2(ys, xs)
N = len(torques) // 2
plt.plot(torques[:N], angs[:N], 'o-', color='dodgerblue', label='neg to pos torque')
plt.plot(torques[N:], angs[N:], 'o-', color='tomato', label='pos to neg torque')
plt.xlabel('Applied torque')
plt.ylabel('Angle')
plt.legend()
plt.savefig('torque_ang_hysteresis.png')
plt.show()
#