Skip to content

Commit 1996a11

Browse files
committed
#1839 update failing notebook
1 parent f641985 commit 1996a11

File tree

1 file changed

+39
-8
lines changed

1 file changed

+39
-8
lines changed

examples/notebooks/experiments-start-time.ipynb

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
],
3838
"source": [
3939
"%pip install pybamm -q # install PyBaMM if it is not installed\n",
40-
"import pybamm"
40+
"import pybamm\n",
41+
"from datetime import datetime"
4142
]
4243
},
4344
{
@@ -77,7 +78,7 @@
7778
{
7879
"data": {
7980
"application/vnd.jupyter.widget-view+json": {
80-
"model_id": "5516f708a0264190a51d1811064afd82",
81+
"model_id": "86a9137722254204893ad9cf3402c6df",
8182
"version_major": 2,
8283
"version_minor": 0
8384
},
@@ -91,7 +92,7 @@
9192
{
9293
"data": {
9394
"text/plain": [
94-
"<pybamm.plotting.quick_plot.QuickPlot at 0x7f3194e00eb0>"
95+
"<pybamm.plotting.quick_plot.QuickPlot at 0x7f8910adb4f0>"
9596
]
9697
},
9798
"execution_count": 3,
@@ -124,7 +125,7 @@
124125
{
125126
"data": {
126127
"application/vnd.jupyter.widget-view+json": {
127-
"model_id": "4832134ba802437e957ccdd5072d6d93",
128+
"model_id": "a22e45e9e8ff46b194efe28b21f7a9a6",
128129
"version_major": 2,
129130
"version_minor": 0
130131
},
@@ -138,7 +139,7 @@
138139
{
139140
"data": {
140141
"text/plain": [
141-
"<pybamm.plotting.quick_plot.QuickPlot at 0x7f31943d3760>"
142+
"<pybamm.plotting.quick_plot.QuickPlot at 0x7f8910b8e250>"
142143
]
143144
},
144145
"execution_count": 4,
@@ -151,9 +152,9 @@
151152
"\n",
152153
"experiment = pybamm.Experiment(\n",
153154
" [\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",
157158
" s(\"Rest for 1 hour\"),\n",
158159
" ]\n",
159160
")\n",
@@ -171,9 +172,39 @@
171172
"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."
172173
]
173174
},
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+
},
174184
{
175185
"cell_type": "code",
176186
"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,
177208
"id": "driven-sensitivity",
178209
"metadata": {},
179210
"outputs": [

0 commit comments

Comments
 (0)