Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2703 remove warning if temperature not provided #2704

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions pybamm/experiments/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import numpy as np
import re
import pybamm


examples = """

Expand Down Expand Up @@ -417,30 +417,12 @@ def convert_electric(self, electric):
)
)

def _detect_mistyped_temperatures(self, cond):
if "oC" in cond:
raise ValueError(f"Temperature not written correctly on step: '{cond}'")

def _read_and_drop_temperature(self, cond):
matches = re.findall(r"at\s-*\d+\.*\d*\s*oC", cond)

if len(matches) == 0:
self._detect_mistyped_temperatures(cond)

if self.temperature is None:
pybamm.logger.warning(
"Temperature not found on step: "
f"'{cond}', using temperature "
"from parameter values."
)

else:
pybamm.logger.warning(
f"Temperature not found on step: '{cond}', "
f"using global temperature "
f"({self.temperature}oC) instead"
)

if "oC" in cond:
raise ValueError(f"Temperature not written correctly on step: '{cond}'")
temperature = self.temperature
reduced_cond = cond

Expand Down