Skip to content

Commit 5493cc5

Browse files
committed
#2358 removed degC (only use oC)
1 parent 5f8e52f commit 5493cc5

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

pybamm/experiments/experiment.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77

88
examples = """
99
10-
"Discharge at 1C for 0.5 hours at 27degC",
10+
"Discharge at 1C for 0.5 hours at 27oC",
1111
"Discharge at C/20 for 0.5 hours at 29oC",
1212
"Charge at 0.5 C for 45 minutes at -5oC",
1313
"Discharge at 1 A for 0.5 hours at -5.1oC",
14-
"Charge at 200 mA for 45 minutes at 10.2degC (1 minute period)",
14+
"Charge at 200 mA for 45 minutes at 10.2oC (1 minute period)",
1515
"Discharge at 1W for 0.5 hours at -10.4oC",
1616
"Charge at 200mW for 45 minutes",
1717
"Rest for 10 minutes (5 minute period)",
1818
"Hold at 1V for 20 seconds",
1919
"Charge at 1 C until 4.1V",
2020
"Hold at 4.1 V until 50mA",
2121
"Hold at 3V until C/50",
22-
"Discharge at C/3 for 2 hours or until 2.5 V at 26degC",
23-
"Run US06 (A) at -5degC",
22+
"Discharge at C/3 for 2 hours or until 2.5 V at 26oC",
23+
"Run US06 (A) at -5oC",
2424
"Run US06 (V) for 5 minutes",
2525
"Run US06 (W) for 0.5 hours",
2626
@@ -34,13 +34,13 @@ class Experiment:
3434
be of the form "Do this for this long" or "Do this until this happens". For example,
3535
"Charge at 1 C for 1 hour", or "Charge at 1 C until 4.2 V", or "Charge at 1 C for 1
3636
hour or until 4.2 V at 25oC". The instructions can be of the form
37-
"(Dis)charge at x A/C/W", "Rest", or "Hold at x V until y A at z degC". The running
37+
"(Dis)charge at x A/C/W", "Rest", or "Hold at x V until y A at z oC". The running
3838
time should be a time in seconds, minutes or
3939
hours, e.g. "10 seconds", "3 minutes" or "1 hour". The stopping conditions should be
4040
a circuit state, e.g. "1 A", "C/50" or "3 V". The parameter drive_cycles is
4141
mandatory to run drive cycle. For example, "Run x", then x must be the key
4242
of drive_cycles dictionary. The temperature should be provided after the stopping
43-
condition but before the period, e.g. "1 A at 25 degC (1 second period)". It is
43+
condition but before the period, e.g. "1 A at 25 oC (1 second period)". It is
4444
not essential to provide a temperature and a global temperature can be set either
4545
from within the paramter values of passing a temperature to this experiment class.
4646
If the temperature is not specified in a line, then the global temperature is used,
@@ -217,7 +217,7 @@ def read_string(self, cond, drive_cycles):
217217
# Read instructions
218218
if "Run" in cond:
219219
cond_list = cond.split()
220-
if "degC" not in cond and "oC" not in cond:
220+
if "oC" not in cond:
221221
if "at" in cond:
222222
raise ValueError(f"Instruction must be of the form: {examples}")
223223
dc_types = ["(A)", "(V)", "(W)"]
@@ -424,7 +424,7 @@ def convert_electric(self, electric):
424424
def read_temperature(self, cond):
425425

426426
if (len(re.findall("at", cond)) > 1 or ("Run" in cond and "at" in cond)) and (
427-
"degC" not in cond and "oC" not in cond
427+
"oC" not in cond
428428
):
429429
raise ValueError(
430430
"Instruction must be 'discharge', 'charge', 'rest', 'hold' or "
@@ -434,10 +434,8 @@ def read_temperature(self, cond):
434434
f"{cond}"
435435
)
436436

437-
if "degC" in cond or "oC" in cond:
438-
matches = re.findall(
439-
"(\-*[0-9]*\.*[0-9]*)(\s*degC)|(\-*[0-9]*\.*[0-9]*)(\s*oC)", cond
440-
)
437+
if "oC" in cond:
438+
matches = re.findall("(\-*[0-9]*\.*[0-9]*)(\s*oC)", cond)
441439

442440
non_empty_matches = [m for m in matches[0] if m]
443441

tests/unit/test_experiments/test_experiment.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ def test_read_strings(self):
2121

2222
experiment = pybamm.Experiment(
2323
[
24-
"Discharge at 1C for 0.5 hours at 27degC",
24+
"Discharge at 1C for 0.5 hours at 27oC",
2525
"Discharge at C/20 for 0.5 hours at 29oC",
2626
"Charge at 0.5 C for 45 minutes at -5oC",
2727
"Discharge at 1 A for 0.5 hours at -5.1oC",
28-
"Charge at 200 mA for 45 minutes at 10.2degC (1 minute period)",
28+
"Charge at 200 mA for 45 minutes at 10.2oC (1 minute period)",
2929
"Discharge at 1W for 0.5 hours at -10.4oC",
3030
"Charge at 200mW for 45 minutes",
3131
"Rest for 10 minutes (5 minute period)",
3232
"Hold at 1V for 20 seconds",
3333
"Charge at 1 C until 4.1V",
3434
"Hold at 4.1 V until 50mA",
3535
"Hold at 3V until C/50",
36-
"Discharge at C/3 for 2 hours or until 2.5 V at 26degC",
37-
"Run US06 (A) at -5degC",
36+
"Discharge at C/3 for 2 hours or until 2.5 V at 26oC",
37+
"Run US06 (A) at -5oC",
3838
"Run US06 (V) for 5 minutes",
3939
"Run US06 (W) for 0.5 hours",
4040
],
@@ -50,7 +50,7 @@ def test_read_strings(self):
5050
"period": 20.0,
5151
"temperature": 27.0,
5252
"dc_data": None,
53-
"string": "Discharge at 1C for 0.5 hours at 27degC",
53+
"string": "Discharge at 1C for 0.5 hours at 27oC",
5454
"events": None,
5555
},
5656
{
@@ -90,7 +90,7 @@ def test_read_strings(self):
9090
"period": 60.0,
9191
"temperature": 10.2,
9292
"dc_data": None,
93-
"string": "Charge at 200 mA for 45 minutes at 10.2degC",
93+
"string": "Charge at 200 mA for 45 minutes at 10.2oC",
9494
"events": None,
9595
},
9696
{
@@ -170,7 +170,7 @@ def test_read_strings(self):
170170
"period": 20.0,
171171
"temperature": 26,
172172
"dc_data": None,
173-
"string": "Discharge at C/3 for 2 hours or until 2.5 V at 26degC",
173+
"string": "Discharge at C/3 for 2 hours or until 2.5 V at 26oC",
174174
"events": {"Voltage input [V]": 2.5, "type": "voltage"},
175175
},
176176
]
@@ -215,9 +215,9 @@ def test_read_strings_cccv_combined(self):
215215
experiment = pybamm.Experiment(
216216
[
217217
(
218-
"Discharge at C/20 for 0.5 hours at 34 degC",
219-
"Charge at 0.5 C until 1V at 32 degC",
220-
"Hold at 1V until C/50 at 32 degC",
218+
"Discharge at C/20 for 0.5 hours at 34 oC",
219+
"Charge at 0.5 C until 1V at 32 oC",
220+
"Hold at 1V until C/50 at 32 oC",
221221
"Discharge at C/20 for 0.5 hours",
222222
),
223223
],
@@ -232,7 +232,7 @@ def test_read_strings_cccv_combined(self):
232232
"period": 60.0,
233233
"temperature": 34.0,
234234
"dc_data": None,
235-
"string": "Discharge at C/20 for 0.5 hours at 34 degC",
235+
"string": "Discharge at C/20 for 0.5 hours at 34 oC",
236236
"events": None,
237237
},
238238
{
@@ -243,8 +243,8 @@ def test_read_strings_cccv_combined(self):
243243
"period": 60.0,
244244
"temperature": 32.0,
245245
"dc_data": None,
246-
"string": "Charge at 0.5 C until 1V at 32 degC "
247-
"then hold at 1V until C/50 at 32 degC",
246+
"string": "Charge at 0.5 C until 1V at 32 oC "
247+
"then hold at 1V until C/50 at 32 oC",
248248
"events": {"C-rate input [-]": 0.02, "type": "C-rate"},
249249
},
250250
{
@@ -434,8 +434,8 @@ def test_bad_strings(self):
434434
pybamm.Experiment(
435435
[
436436
(
437-
"Discharge at 1A until 3.2V at 24degC",
438-
"Hold at 3.2V until C/50 at 27degC",
437+
"Discharge at 1A until 3.2V at 24oC",
438+
"Hold at 3.2V until C/50 at 27oC",
439439
)
440440
],
441441
cccv_handling="ode",

0 commit comments

Comments
 (0)