Skip to content

Commit

Permalink
Add heat pump awareness intervention input arg
Browse files Browse the repository at this point in the history
Set rate of increase of heat pump awareness as input argument to the model: `heat-pump-awareness-intervention-factor`, for heat pump awareness intervention scenarios.
  • Loading branch information
charlotte-avery committed Oct 24, 2024
1 parent 2460108 commit 225c619
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 9 deletions.
4 changes: 4 additions & 0 deletions k8s/job.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ local job(name, args_excl_output) = {
'0.0682',
'--price-gbp-per-kwh-electricity',
'0.182',
'--heat-pump-awareness-intervention-factor',
'0.05',
]),
job('04a-%s-max-policy' % std.extVar('SHORT_SHA'), [
'--intervention',
Expand Down Expand Up @@ -187,6 +189,8 @@ local job(name, args_excl_output) = {
'0.0682',
'--price-gbp-per-kwh-electricity',
'0.182',
'--heat-pump-awareness-intervention-factor',
'0.05',
'--include-new-builds',
]),
job('05-%s-max-industry' % std.extVar('SHORT_SHA'), [
Expand Down
8 changes: 8 additions & 0 deletions simulation/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ def format_uuid(str):
help="Include new build projections (from constants.py). Installers will also build heat pumps in new builds from 2025.",
)

parser.add_argument(
"--heat-pump-awareness-intervention-factor",
type=float_between_0_and_1,
default=0,
help="A value between 0 and 1 which determines how quickly heat pump awareness increases over time with the heat pump awareness intervention. A value of 0 indicates no increase in heat pump awareness.",
)

def check_string_is_isoformat_datetime(string) -> str:
datetime.datetime.fromisoformat(string)
return string
Expand Down Expand Up @@ -225,6 +232,7 @@ def validate_args(args):
args.air_source_heat_pump_price_discount_date,
args.heat_pump_installer_count,
args.heat_pump_installer_annual_growth_rate,
args.heat_pump_awareness_intervention_factor,
ENGLAND_WALES_ANNUAL_NEW_BUILDS if args.include_new_builds else None,
)

Expand Down
15 changes: 10 additions & 5 deletions simulation/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
RETROFIT_COSTS_SMALL_PROPERTY_SQM_LIMIT,
SIGMOID_K,
SIGMOID_OFFSET,
HEAT_PUMP_AWARENESS_GDT,
BuiltForm,
ConstructionYearBand,
Element,
Expand Down Expand Up @@ -102,7 +101,7 @@ def reverse_sigmoid(x: float, k: float = SIGMOID_K, offset: float = SIGMOID_OFFS
return 1 / (1 + math.exp(k * (x + offset)))


def heat_pump_awareness_intervention(x: float, m: float = HEAT_PUMP_AWARENESS_GDT):
def heat_pump_awareness_intervention(x: float, m: float):

return min(m * x, 1)

Expand Down Expand Up @@ -422,11 +421,15 @@ def get_proba_rule_out_banned_heating_systems(self, model):

return reverse_sigmoid(years_to_ban)

def get_proba_becomes_heat_pump_aware(self, model):
def get_proba_becomes_heat_pump_aware(
self, model, heat_pump_awareness_intervention_factor
):

years_since_start = (model.current_datetime - model.start_datetime).days / 365

return heat_pump_awareness_intervention(years_since_start)
return heat_pump_awareness_intervention(
years_since_start, heat_pump_awareness_intervention_factor
)

def get_heating_system_options(
self, model: "DomesticHeatingABM", event_trigger: EventTrigger
Expand Down Expand Up @@ -456,7 +459,9 @@ def get_heating_system_options(
# if awareness intervention used, allow for more agents to become aware of heat pumps
if not self.is_heat_pump_aware:
self.is_heat_pump_aware = true_with_probability(
self.get_proba_becomes_heat_pump_aware(model)
self.get_proba_becomes_heat_pump_aware(
model, model.heat_pump_awareness_intervention_factor
)
)

if not is_gas_oil_boiler_ban_announced:
Expand Down
1 change: 0 additions & 1 deletion simulation/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class HeatingFuel(enum.Enum):
MAX_BAN_LEAD_TIME_YEARS = 10
SIGMOID_K = 2
SIGMOID_OFFSET = 0
HEAT_PUMP_AWARENESS_GDT = 0.1


class ConstructionYearBand(enum.Enum):
Expand Down
6 changes: 6 additions & 0 deletions simulation/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(
heat_pump_installer_count: int,
heat_pump_installer_annual_growth_rate: float,
annual_new_builds: Optional[Dict[int, int]],
heat_pump_intervention_awareness_factor: float,
):
self.start_datetime = start_datetime
self.step_interval = step_interval
Expand Down Expand Up @@ -74,6 +75,9 @@ def __init__(
)
self.heat_pump_installations_at_current_step = 0
self.annual_new_builds = annual_new_builds
self.heat_pump_intervention_awareness_factor = (
heat_pump_intervention_awareness_factor
)

super().__init__(UnorderedSpace())

Expand Down Expand Up @@ -263,6 +267,7 @@ def create_and_run_simulation(
heat_pump_installer_count: int,
heat_pump_installer_annual_growth_rate: float,
annual_new_builds: Dict[int, int],
heat_pump_awareness_intervention_factor: float,
):

model = DomesticHeatingABM(
Expand All @@ -282,6 +287,7 @@ 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_intervention_factor=heat_pump_awareness_intervention_factor,
)

households = create_household_agents(
Expand Down
1 change: 1 addition & 0 deletions simulation/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def model_factory(**model_attributes):
"heat_pump_installer_count": 2_800,
"heat_pump_installer_annual_growth_rate": 0,
"annual_new_builds": None,
"heat_pump_intervention_awareness_factor": 0,
}

return DomesticHeatingABM(**{**default_values, **model_attributes})
8 changes: 5 additions & 3 deletions simulation/tests/test_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,12 +707,14 @@ def test_households_increasingly_likely_to_become_heat_pump_aware(
)

proba_becomes_heat_pump_aware = household.get_proba_becomes_heat_pump_aware(
model
model, heat_pump_awareness_intervention_factor=0.1
)

model.increment_timestep()
proba_becomes_heat_pump_aware_updated = (
household.get_proba_becomes_heat_pump_aware(model)
household.get_proba_becomes_heat_pump_aware(
model, heat_pump_awareness_intervention_factor=0.1
)
)

assert proba_becomes_heat_pump_aware < proba_becomes_heat_pump_aware_updated
Expand All @@ -727,7 +729,7 @@ def test_heat_pump_awareness_increase_is_zero_in_first_year(
)

proba_becomes_heat_pump_aware = household.get_proba_becomes_heat_pump_aware(
model
model, heat_pump_awareness_intervention_factor=0.1
)

assert proba_becomes_heat_pump_aware == 0
Expand Down
18 changes: 18 additions & 0 deletions simulation/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ def test_rented_heating_system_hassle_factor_must_be_between_0_and_1(
[*mandatory_local_args, "--rented-heating-system-hassle-factor", "10"]
)

def test_heat_pump_awareness_intervention_factor(self, mandatory_local_args):
args = parse_args(
[*mandatory_local_args, "--rented-heating-system-hassle-factor", "0.05"]
)
assert args.rented_heating_system_hassle_factor == 0.05

def test_heat_pump_awareness_intervention_factor_must_be_between_0_and_1(
self, mandatory_local_args
):
with pytest.raises(SystemExit):
parse_args(
[
*mandatory_local_args,
"--heat-pump-awareness-intervention-factor",
"10",
]
)

def test_help_flag(self):
with pytest.raises(SystemExit):
parse_args(["-h"])
Expand Down

0 comments on commit 225c619

Please sign in to comment.