|
10 | 10 | import seaborn as sns
|
11 | 11 |
|
12 | 12 | import altrios as alt
|
13 |
| -sns.set() |
| 13 | +sns.set_theme() |
14 | 14 |
|
15 | 15 | SHOW_PLOTS = alt.utils.show_plots()
|
16 | 16 |
|
|
78 | 78 | # pull out solved locomotive for plotting convenience
|
79 | 79 | loco0:alt.Locomotive = train_sim.loco_con.loco_vec.tolist()[0]
|
80 | 80 |
|
| 81 | +fig, ax = plt.subplots(4, 1, sharex=True) |
| 82 | +ax[0].plot( |
| 83 | + np.array(train_sim.history.time_seconds) / 3_600, |
| 84 | + train_sim.history.pwr_whl_out_watts, |
| 85 | + label="tract pwr", |
| 86 | +) |
| 87 | +ax[0].set_ylabel('Power') |
| 88 | +ax[0].legend() |
| 89 | + |
| 90 | +ax[1].plot( |
| 91 | + np.array(train_sim.history.time_seconds) / 3_600, |
| 92 | + train_sim.history.res_aero_newtons, |
| 93 | + label='aero', |
| 94 | +) |
| 95 | +ax[1].plot( |
| 96 | + np.array(train_sim.history.time_seconds) / 3_600, |
| 97 | + train_sim.history.res_rolling_newtons, |
| 98 | + label='rolling', |
| 99 | +) |
| 100 | +ax[1].plot( |
| 101 | + np.array(train_sim.history.time_seconds) / 3_600, |
| 102 | + train_sim.history.res_curve_newtons, |
| 103 | + label='curve', |
| 104 | +) |
| 105 | +ax[1].plot( |
| 106 | + np.array(train_sim.history.time_seconds) / 3_600, |
| 107 | + train_sim.history.res_bearing_newtons, |
| 108 | + label='bearing', |
| 109 | +) |
| 110 | +ax[1].plot( |
| 111 | + np.array(train_sim.history.time_seconds) / 3_600, |
| 112 | + train_sim.history.res_grade_newtons, |
| 113 | + label='grade', |
| 114 | +) |
| 115 | +ax[1].set_ylabel('Force [N]') |
| 116 | +ax[1].legend() |
| 117 | + |
| 118 | +ax[-1].plot( |
| 119 | + np.array(train_sim.history.time_seconds) / 3_600, |
| 120 | + train_sim.speed_trace.speed_meters_per_second, |
| 121 | +) |
| 122 | +ax[-1].set_xlabel('Time [hr]') |
| 123 | +ax[-1].set_ylabel('Speed [m/s]') |
| 124 | + |
| 125 | +ax[2].plot( |
| 126 | + np.array(train_sim.history.time_seconds) / 3_600, |
| 127 | + np.array(loco0.res.history.soc) |
| 128 | +) |
| 129 | + |
| 130 | +ax[2].set_ylabel('SOC') |
| 131 | +ax[2].legend() |
| 132 | + |
| 133 | +plt.suptitle("Set Speed Train Sim Demo") |
| 134 | +plt.tight_layout() |
| 135 | + |
81 | 136 | if SHOW_PLOTS:
|
82 |
| - fig, ax = plt.subplots(4, 1, sharex=True) |
83 |
| - ax[0].plot( |
84 |
| - np.array(train_sim.history.time_seconds) / 3_600, |
85 |
| - train_sim.history.pwr_whl_out_watts, |
86 |
| - label="tract pwr", |
87 |
| - ) |
88 |
| - ax[0].set_ylabel('Power') |
89 |
| - ax[0].legend() |
90 |
| - |
91 |
| - ax[1].plot( |
92 |
| - np.array(train_sim.history.time_seconds) / 3_600, |
93 |
| - train_sim.history.res_aero_newtons, |
94 |
| - label='aero', |
95 |
| - ) |
96 |
| - ax[1].plot( |
97 |
| - np.array(train_sim.history.time_seconds) / 3_600, |
98 |
| - train_sim.history.res_rolling_newtons, |
99 |
| - label='rolling', |
100 |
| - ) |
101 |
| - ax[1].plot( |
102 |
| - np.array(train_sim.history.time_seconds) / 3_600, |
103 |
| - train_sim.history.res_curve_newtons, |
104 |
| - label='curve', |
105 |
| - ) |
106 |
| - ax[1].plot( |
107 |
| - np.array(train_sim.history.time_seconds) / 3_600, |
108 |
| - train_sim.history.res_bearing_newtons, |
109 |
| - label='bearing', |
110 |
| - ) |
111 |
| - ax[1].plot( |
112 |
| - np.array(train_sim.history.time_seconds) / 3_600, |
113 |
| - train_sim.history.res_grade_newtons, |
114 |
| - label='grade', |
115 |
| - ) |
116 |
| - ax[1].set_ylabel('Force [N]') |
117 |
| - ax[1].legend() |
118 |
| - |
119 |
| - ax[-1].plot( |
120 |
| - np.array(train_sim.history.time_seconds) / 3_600, |
121 |
| - train_sim.speed_trace.speed_meters_per_second, |
122 |
| - ) |
123 |
| - ax[-1].set_xlabel('Time [hr]') |
124 |
| - ax[-1].set_ylabel('Speed [m/s]') |
125 |
| - |
126 |
| - ax[2].plot( |
127 |
| - np.array(train_sim.history.time_seconds) / 3_600, |
128 |
| - np.array(loco0.res.history.soc) |
129 |
| - ) |
130 |
| - |
131 |
| - ax[2].set_ylabel('SOC') |
132 |
| - ax[2].legend() |
133 |
| - |
134 |
| - plt.suptitle("Set Speed Train Sim Demo") |
135 |
| - |
136 |
| - plt.tight_layout() |
137 |
| - plt.show() |
| 137 | + fig.show() |
138 | 138 |
|
139 | 139 | # %%
|
0 commit comments