Skip to content

Commit

Permalink
Renames set_events to add_events_from (#4421)
Browse files Browse the repository at this point in the history
* changed set_events to add_events_from

* all changes made

* changelog added

* changelog updated

* corrected changelog
  • Loading branch information
medha-14 authored Sep 6, 2024
1 parent b073fc7 commit 613230c
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 14 deletions.
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
2 changes: 1 addition & 1 deletion src/pybamm/models/submodels/porosity/constant_porosity.py
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

0 comments on commit 613230c

Please sign in to comment.