|
37 | 37 | ], |
38 | 38 | "source": [ |
39 | 39 | "%pip install pybamm -q # install PyBaMM if it is not installed\n", |
40 | | - "import pybamm" |
| 40 | + "import pybamm\n", |
| 41 | + "from datetime import datetime" |
41 | 42 | ] |
42 | 43 | }, |
43 | 44 | { |
|
77 | 78 | { |
78 | 79 | "data": { |
79 | 80 | "application/vnd.jupyter.widget-view+json": { |
80 | | - "model_id": "5516f708a0264190a51d1811064afd82", |
| 81 | + "model_id": "86a9137722254204893ad9cf3402c6df", |
81 | 82 | "version_major": 2, |
82 | 83 | "version_minor": 0 |
83 | 84 | }, |
|
91 | 92 | { |
92 | 93 | "data": { |
93 | 94 | "text/plain": [ |
94 | | - "<pybamm.plotting.quick_plot.QuickPlot at 0x7f3194e00eb0>" |
| 95 | + "<pybamm.plotting.quick_plot.QuickPlot at 0x7f8910adb4f0>" |
95 | 96 | ] |
96 | 97 | }, |
97 | 98 | "execution_count": 3, |
|
124 | 125 | { |
125 | 126 | "data": { |
126 | 127 | "application/vnd.jupyter.widget-view+json": { |
127 | | - "model_id": "4832134ba802437e957ccdd5072d6d93", |
| 128 | + "model_id": "a22e45e9e8ff46b194efe28b21f7a9a6", |
128 | 129 | "version_major": 2, |
129 | 130 | "version_minor": 0 |
130 | 131 | }, |
|
138 | 139 | { |
139 | 140 | "data": { |
140 | 141 | "text/plain": [ |
141 | | - "<pybamm.plotting.quick_plot.QuickPlot at 0x7f31943d3760>" |
| 142 | + "<pybamm.plotting.quick_plot.QuickPlot at 0x7f8910b8e250>" |
142 | 143 | ] |
143 | 144 | }, |
144 | 145 | "execution_count": 4, |
|
151 | 152 | "\n", |
152 | 153 | "experiment = pybamm.Experiment(\n", |
153 | 154 | " [\n", |
154 | | - " s(\"Discharge at 1C for 1 hour\", start_time=\"Day 1 08:00:00\"),\n", |
155 | | - " s(\"Charge at C/3 for 10 minutes\", start_time=\"Day 1 08:30:00\"),\n", |
156 | | - " s(\"Discharge at C/2 for 30 minutes\", start_time=\"Day 1 09:00:00\"),\n", |
| 155 | + " s(\"Discharge at 1C for 1 hour\", start_time=datetime(1, 1, 1, 8, 0, 0)),\n", |
| 156 | + " s(\"Charge at C/3 for 10 minutes\", start_time=datetime(1, 1, 1, 8, 30, 0)),\n", |
| 157 | + " s(\"Discharge at C/2 for 30 minutes\", start_time=datetime(1, 1, 1, 9, 0, 0)),\n", |
157 | 158 | " s(\"Rest for 1 hour\"),\n", |
158 | 159 | " ]\n", |
159 | 160 | ")\n", |
|
171 | 172 | "In the example above, we note that the first step (1C discharge) is cut short as the second step (C/3 charge) start time occurs before the end of the first step. On the other hand, an additional resting period is added after the second step as the third step (C/2 discharge) start time is 20 minutes later than the end of the second step. The final step does not have a start time so it is triggered immediately after the previous step. Note that if the argument `start_time` is used in an experiment, the first step should always have a `start_time`, otherwise the solver will throw an error." |
172 | 173 | ] |
173 | 174 | }, |
| 175 | + { |
| 176 | + "attachments": {}, |
| 177 | + "cell_type": "markdown", |
| 178 | + "id": "fff78a14", |
| 179 | + "metadata": {}, |
| 180 | + "source": [ |
| 181 | + "Note that you can use the `datetime.strptime` (see [the docs](https://docs.python.org/3/library/datetime.html#datetime.datetime.strptime) for more info) function to convert a string to a datetime object. For example, to start the experiment at 8:30 on the 2nd of January 2023, you can use" |
| 182 | + ] |
| 183 | + }, |
174 | 184 | { |
175 | 185 | "cell_type": "code", |
176 | 186 | "execution_count": 5, |
| 187 | + "id": "bb616043", |
| 188 | + "metadata": {}, |
| 189 | + "outputs": [ |
| 190 | + { |
| 191 | + "data": { |
| 192 | + "text/plain": [ |
| 193 | + "datetime.datetime(2023, 1, 2, 8, 30)" |
| 194 | + ] |
| 195 | + }, |
| 196 | + "execution_count": 5, |
| 197 | + "metadata": {}, |
| 198 | + "output_type": "execute_result" |
| 199 | + } |
| 200 | + ], |
| 201 | + "source": [ |
| 202 | + "datetime.strptime(\"2023-01-02 8:30:00\", \"%Y-%m-%d %H:%M:%S\")" |
| 203 | + ] |
| 204 | + }, |
| 205 | + { |
| 206 | + "cell_type": "code", |
| 207 | + "execution_count": 6, |
177 | 208 | "id": "driven-sensitivity", |
178 | 209 | "metadata": {}, |
179 | 210 | "outputs": [ |
|
0 commit comments