Skip to content

Commit

Permalink
Merge branch 'develop' into issue-1781-utilization
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Nov 24, 2021
2 parents 4d3087e + 88c778b commit 955bcbe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
17 changes: 17 additions & 0 deletions pybamm/experiments/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#

import numpy as np
import warnings

examples = """
Expand Down Expand Up @@ -75,6 +76,22 @@ def __init__(
if cccv_handling not in ["two-step", "ode"]:
raise ValueError("cccv_handling should be either 'two-step' or 'ode'")
self.cccv_handling = cccv_handling
# Deprecations
if parameters is None:
warnings.simplefilter("always", DeprecationWarning)
warnings.warn(
"'parameters' as an input to the Experiment class will soon be "
"deprecated. Please open an issue if you are using this feature.",
DeprecationWarning,
)
if use_simulation_setup_type == "old":
warnings.simplefilter("always", DeprecationWarning)
warnings.warn(
"'old' simulation setup type for the Experiment class will soon be "
"deprecated. Use 'new' instead. Please open an issue if this gives an "
"error or unexpected results.",
DeprecationWarning,
)

self.period = self.convert_time_to_seconds(period.split())
operating_conditions_cycles = []
Expand Down
27 changes: 14 additions & 13 deletions pybamm/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ def is_notebook():

def constant_current_constant_voltage_constant_power(variables):
I = variables["Current [A]"]
V = variables["Terminal voltage [V]"]
V = variables["Battery voltage [V]"]
s_I = pybamm.InputParameter("Current switch")
s_V = pybamm.InputParameter("Voltage switch")
s_P = pybamm.InputParameter("Power switch")
n_cells = pybamm.Parameter("Number of cells connected in series to make a battery")
return (
s_I * (I - pybamm.InputParameter("Current input [A]"))
+ s_V * (V - pybamm.InputParameter("Voltage input [V]") / n_cells)
+ s_P * (V * I - pybamm.InputParameter("Power input [W]") / n_cells)
+ s_V * (V - pybamm.InputParameter("Voltage input [V]"))
+ s_P * (V * I - pybamm.InputParameter("Power input [W]"))
)


Expand Down Expand Up @@ -346,9 +345,8 @@ def set_up_model_for_experiment_old(self, model):
),
pybamm.Event(
"Voltage cut-off [V] [experiment]",
new_model.variables["Terminal voltage [V]"]
- pybamm.InputParameter("Voltage cut-off [V]")
/ model.param.n_cells,
new_model.variables["Battery voltage [V]"]
- pybamm.InputParameter("Voltage cut-off [V]"),
),
]
)
Expand Down Expand Up @@ -443,7 +441,7 @@ def set_up_model_for_experiment_new(self, model):
+ abs(pybamm.InputParameter("Current cut-off [A]"))
- 1e4
* (
new_model.variables["Terminal voltage [V]"]
new_model.variables["Battery voltage [V]"]
< (
pybamm.InputParameter("Voltage input [V]")
- 1e-4
Expand Down Expand Up @@ -498,9 +496,8 @@ def set_up_model_for_experiment_new(self, model):
new_model.events.append(
pybamm.Event(
"Voltage cut-off [V] [experiment]",
new_model.variables["Terminal voltage [V]"]
- pybamm.InputParameter("Voltage cut-off [V]")
/ model.param.n_cells,
new_model.variables["Battery voltage [V]"]
- pybamm.InputParameter("Voltage cut-off [V]"),
)
)

Expand All @@ -521,7 +518,10 @@ def set_up_model_for_experiment_new(self, model):
)
elif op_inputs["Voltage switch"] == 1:
new_parameter_values.update(
{"Voltage function [V]": op_inputs["Voltage input [V]"]},
{
"Voltage function [V]": op_inputs["Voltage input [V]"]
/ model.param.n_cells
},
check_already_exists=False,
)
elif op_inputs["Power switch"] == 1:
Expand All @@ -533,7 +533,8 @@ def set_up_model_for_experiment_new(self, model):
new_parameter_values.update(
{
"Current function [A]": op_inputs["Current input [A]"],
"Voltage function [V]": op_inputs["Voltage input [V]"],
"Voltage function [V]": op_inputs["Voltage input [V]"]
/ model.param.n_cells,
},
check_already_exists=False,
)
Expand Down

0 comments on commit 955bcbe

Please sign in to comment.