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

Renames set_events to add_events_from #4421

Merged
merged 6 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
## Optimizations
- Removed the `start_step_offset` setting and disabled minimum `dt` warnings for drive cycles with the (`IDAKLUSolver`). ([#4416](https://github.com/pybamm-team/PyBaMM/pull/4416))

## Breaking changes
- Renamed `set_events` function to `add_events_from` to better reflect its purpose. ([#4421](https://github.com/pybamm-team/PyBaMM/pull/4421))

# [v24.9.0](https://github.com/pybamm-team/PyBaMM/tree/v24.9.0) - 2024-09-03

## Features
Expand Down
2 changes: 1 addition & 1 deletion src/pybamm/models/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ def build_model_equations(self):
f"Setting initial conditions for {submodel_name} submodel ({self.name})"
)
submodel.set_initial_conditions(self.variables)
submodel.set_events(self.variables)
submodel.add_events_from(self.variables)
pybamm.logger.verbose(f"Updating {submodel_name} submodel ({self.name})")
self.update(submodel)
self.check_no_repeated_keys()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ def build_model_equations(self):
f"Setting initial conditions for {submodel_name} submodel ({self.name})"
)
submodel.set_initial_conditions(self.variables)
submodel.set_events(self.variables)
submodel.add_events_from(self.variables)
pybamm.logger.verbose(f"Updating {submodel_name} submodel ({self.name})")
self.update(submodel)
self.check_no_repeated_keys()
Expand Down
2 changes: 1 addition & 1 deletion src/pybamm/models/submodels/base_submodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def set_initial_conditions(self, variables):
"""
pass

def set_events(self, variables):
def add_events_from(self, variables):
"""
A method to set events related to the state of submodel variable. Note: this
method modifies the state of self.events. Unless overwritten by a submodel, the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ def set_boundary_conditions(self, variables):
}
}

def set_events(self, variables):
def add_events_from(self, variables):
# No event since the concentration is constant
pass
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def set_initial_conditions(self, variables):
z = variables["Distributed SoC"]
self.initial_conditions = {z: self.param.initial_soc}

def set_events(self, variables):
def add_events_from(self, variables):
z_surf = variables["Surface SoC"]
self.events += [
pybamm.Event("Minimum surface SoC", z_surf),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def set_initial_conditions(self, variables):
soc = variables["SoC"]
self.initial_conditions = {soc: self.param.initial_soc}

def set_events(self, variables):
def add_events_from(self, variables):
soc = variables["SoC"]
self.events += [
pybamm.Event("Minimum SoC", soc),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def x_not_zero(x):

return variables

def set_events(self, variables):
def add_events_from(self, variables):
voltage = variables["Voltage [V]"]

# Add voltage events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def set_initial_conditions(self, variables):

self.initial_conditions = {u: u_init}

def set_events(self, variables):
def add_events_from(self, variables):
domain, Domain = self.domain_Domain

if self.reaction_loc == "full electrode":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def set_initial_conditions(self, variables):
l_cr_0 = pybamm.PrimaryBroadcast(l_cr_0, f"{domain} electrode")
self.initial_conditions = {l_cr: l_cr_0}

def set_events(self, variables):
def add_events_from(self, variables):
domain, Domain = self.domain_Domain

if self.x_average is True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ def get_fundamental_variables(self):

return variables

def set_events(self, variables):
def add_events_from(self, variables):
# No events since porosity is constant
pass
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get_coupled_variables(self, variables):

return variables

def set_events(self, variables):
def add_events_from(self, variables):
eps_p = variables["Positive electrode porosity"]
self.events.append(
pybamm.Event(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def set_initial_conditions(self, variables):
eps = variables["Porosity"]
self.initial_conditions = {eps: self.param.epsilon_init}

def set_events(self, variables):
def add_events_from(self, variables):
for domain in self.options.whole_cell_domains:
if domain == "separator":
continue
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_models/test_base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def set_initial_conditions(self, variables):
u = variables["u"]
self.initial_conditions = {u: c}

def set_events(self, variables):
def add_events_from(self, variables):
e = pybamm.InputParameter("e")
u = variables["u"]
self.events = [pybamm.Event("u=e", u - e)]
Expand Down Expand Up @@ -1178,7 +1178,7 @@ def set_initial_conditions(self, variables):
v = variables["v"]
self.initial_conditions = {u: 0, v: 0}

def set_events(self, variables):
def add_events_from(self, variables):
u = variables["u"]
self.events.append(
pybamm.Event(
Expand Down
Loading