-
Notifications
You must be signed in to change notification settings - Fork 3
/
runner.py
95 lines (75 loc) · 2.9 KB
/
runner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
"""
A gathering of functions for running models solo
"""
from logging import getLogger
from pathlib import Path
from pyomo.environ import value
from src.integrator.config_setup import Config_settings
from src.integrator import utilities
from src.models.electricity.scripts.runner import run_elec_model
from src.models.hydrogen.model.actions import run_hydrogen_model
from src.models.residential.scripts.residential import run_residential
from src.integrator.progress_plot import plot_price_distro
logger = getLogger(__name__)
def run_elec_solo(settings: Config_settings | None = None):
"""
Runs electricity model by itself as defined in settings
Parameters
----------
settings: Config_settings
Contains configuration settings for which regions, years, and switches to run
"""
# engage the Electricity Model...
logger.info('Running Electricity Module')
instance = run_elec_model(settings)
print(f'Objective value: {value(instance.totalCost)}')
# write out prices and plot them
elec_price = utilities.get_elec_price(instance)
price_records = utilities.get_annual_wt_avg(elec_price)
elec_price.to_csv(Path(settings.OUTPUT_ROOT / 'electricity' / 'prices' / 'elec_price.csv'))
# plot_price_distro(list(elec_price.price_wt))
def run_h2_solo(settings: Config_settings | None = None):
"""
Runs hydrogen model by itself as defined in settings
Parameters
----------
settings: Config_settings
Contains configuration settings for which regions and years to run
"""
logger.info('Running Hydrogen Module')
if settings:
run_hydrogen_model(settings)
else:
logger.info('No settings passed to Hydrogen Module')
empty_settings = object()
empty_settings.years = None
empty_settings.regions = None
empty_settings.h2_data_folder = 'src/models/hydrogen/inputs/single_region'
run_hydrogen_model(empty_settings)
def run_residential_solo(settings: Config_settings | None = None):
"""
Runs residential model by itself as defined in settings
Parameters
----------
settings: Config_settings
Contains configuration settings for which regions and years to run
"""
logger.info('Running Residential Module')
run_residential(settings)
def run_standalone(settings: Config_settings):
"""Runs standalone methods based on settings selections; running 1 or more modules
Parameters
----------
settings : Config_settings
Instance of config_settings containing run options, mode and settings
"""
print('running standalone mode')
if settings.electricity:
print('running electricity module')
run_elec_solo(settings)
if settings.hydrogen:
print('running hydrogen module')
run_h2_solo(settings=settings)
if settings.residential:
print('running residential module')
run_residential_solo(settings)