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

Update household heat pump awareness over time #149

Merged
merged 10 commits into from
Nov 21, 2024
24 changes: 24 additions & 0 deletions simulation/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,32 @@ def compute_heat_pump_capacity_kw(self, heat_pump_type: HeatingSystem) -> int:
)
)

def proba_of_becoming_heat_pump_aware_required_to_reach_campaign_target(
self, model
) -> float:
return (
model.campaign_target_heat_pump_awareness - model.heat_pump_awareness
) / (1 - model.heat_pump_awareness)

def update_heat_pump_awareness(self, model) -> None:

if InterventionType.HEAT_PUMP_CAMPAIGN in model.interventions:
if (
model.current_datetime == model.heat_pump_awareness_campaign_date
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this hard == safe? If user input is say '2028-01-31' will this work?

Maybe a safer one would be model.current_datetime >= model.heat_pump_awareness_campaign_date..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to change the logging to implement this. See latest commit.

In summary: we want to say "if the target HP awareness has not been met in the previous timestep (t-1), give a suitable probability of converting agents to becoming HP aware to meet the target at timestep t", however, before the HP awareness was recalculated every timestep (every timestep, HP awareness set to value of zero, then using the line of code in agents.py: model.households_heat_pump_aware_at_current_step += 1 we count the HP awareness in that timstep). Remember, the simulation loops over each agent every timestep. So if you are on agent num. 3 in the loop, the HP awareness is calculated by looking at how many of the 3 agents are heat pump aware so far, and on timestep 5, we see the HP awareness by looking at how many of the 5 agents are heat pump aware so far etc. So we need to store the HP awareness at t-1, to access it at t, so we can convert a suitable number of households to become HP aware to meet the target.

and model.heat_pump_awareness_at_timestep
< model.campaign_target_heat_pump_awareness
and not self.is_heat_pump_aware
):
proba_to_become_heat_pump_aware = self.proba_of_becoming_heat_pump_aware_required_to_reach_campaign_target(
model
)
self.is_heat_pump_aware = true_with_probability(
proba_to_become_heat_pump_aware
)

def make_decisions(self, model):

self.update_heat_pump_awareness(model)
self.update_heating_status(model)
self.evaluate_renovation(model)

Expand Down
11 changes: 11 additions & 0 deletions simulation/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def __init__(
heat_pump_installer_count: int,
heat_pump_installer_annual_growth_rate: float,
annual_new_builds: Optional[Dict[int, int]],
heat_pump_awareness: float,
campaign_target_heat_pump_awareness: float,
heat_pump_awareness_campaign_date: datetime.datetime,
):
self.start_datetime = start_datetime
self.step_interval = step_interval
Expand Down Expand Up @@ -74,6 +77,9 @@ def __init__(
)
self.heat_pump_installations_at_current_step = 0
self.annual_new_builds = annual_new_builds
self.heat_pump_awareness = heat_pump_awareness
self.campaign_target_heat_pump_awareness = campaign_target_heat_pump_awareness
self.heat_pump_awareness_campaign_date = heat_pump_awareness_campaign_date
self.households_heat_pump_aware_at_current_step = 0

super().__init__(UnorderedSpace())
Expand Down Expand Up @@ -269,6 +275,8 @@ def create_and_run_simulation(
heat_pump_installer_count: int,
heat_pump_installer_annual_growth_rate: float,
annual_new_builds: Dict[int, int],
campaign_target_heat_pump_awareness: float,
heat_pump_awareness_campaign_date: datetime.datetime,
):

model = DomesticHeatingABM(
Expand All @@ -288,6 +296,9 @@ def create_and_run_simulation(
heat_pump_installer_count=heat_pump_installer_count,
heat_pump_installer_annual_growth_rate=heat_pump_installer_annual_growth_rate,
annual_new_builds=annual_new_builds,
heat_pump_awareness=heat_pump_awareness,
campaign_target_heat_pump_awareness=campaign_target_heat_pump_awareness,
heat_pump_awareness_campaign_date=heat_pump_awareness_campaign_date,
)

households = create_household_agents(
Expand Down
3 changes: 3 additions & 0 deletions simulation/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def model_factory(**model_attributes):
"heat_pump_installer_count": 2_800,
"heat_pump_installer_annual_growth_rate": 0,
"annual_new_builds": None,
"heat_pump_awareness": 0.5,
"campaign_target_heat_pump_awareness": 0.8,
"heat_pump_awareness_campaign_date": datetime.datetime(2028, 1, 1),
}

return DomesticHeatingABM(**{**default_values, **model_attributes})
Loading