Module for generating DER deployment scenarios.
A distributed energy resource (DER) deployment scenario is a hypothetical scenario defined on top
of base distribution system model that uses some rules/forecast/expertise
to come up with number, size and location of der units to be installed.
create_der_scenarios(list_of_customers, scenario_config, der_config)
Function for creating distributed DER scenarios
for distribution system.
Parameters:
Returns:
Source code in emerge\scenarios\scenario.py
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187 | def create_der_scenarios(
list_of_customers: List[data_model.CustomerModel],
scenario_config: data_model.ScenarioBaseConfig,
der_config: data_model.DERScenarioInputModel
) -> List[data_model.DistDERScenarioModel]:
"""Function for creating distributed DER scenarios
for distribution system.
Args:
list_of_loads (List[data_model.CustomerModel]): List of customer for
scenario generation.
scenario_config (data_model.ScenarioBaseConfig): Basic configuration data for
generating scenarios
der_config List[data_model.DERScenarioInputModel]: DER config.
Returns:
List[data_model.DistDERScenarioModel]: List of `DistDERScenarioModel`
models.
"""
select_strategy = selection_strategy.SELECTION_STRATEGY_MAPPER[
der_config.selection_strategy]()
scenarios: List[data_model.DistDERScenarioModel] = []
# Get total load
total_load_kw = sum(load.kw for load in list_of_customers)
# loop over all the samples and pv penetrations
for sample_id in range(scenario_config.max_num_of_samples):
# Idea is to keep pv systems installed in previous penetrations
past_ders: List[data_model.BasicDERModel] = []
past_capacity = 0
for der_penetration_id in range(1, scenario_config.num_of_penetration + 1):
der_capacity = (
der_penetration_id * scenario_config.pct_resolution / 100
) * total_load_kw
previous_loads = list(set([der.customer.name for der in past_ders]))
loads_without_der = [
load for load in list_of_customers if load.name not in previous_loads
]
# Returns order in which load is to be selected to add pv
loads = select_strategy.return_selection_order(
list_of_customers=loads_without_der
)
sizing_strategy_object = sizing_strategy.SIZING_STRATEGY_MAPPER.get(
der_config.sizing_strategy
)(_get_sizing_func_input(der_config))
main_der_models = _get_ders(loads, der_capacity - past_capacity,
sizing_strategy_object, der_config.der_type, der_config.der_tag)
other_der_models = []
for other_der in der_config.other_ders:
sizing_strategy_object = sizing_strategy.SIZING_STRATEGY_MAPPER.get(
other_der.sizing_strategy
)(_get_sizing_func_input(other_der))
other_der_models += _add_other_ders(main_der_models,
sizing_strategy_object, other_der.der_type, other_der.der_tag)
scenario = data_model.DistDERScenarioModel(
name=f"scenario_{sample_id}_"
f"{int(der_penetration_id*scenario_config.pct_resolution)}",
sample_id=sample_id,
penetration=round(der_capacity, 3),
ders=past_ders + main_der_models + other_der_models,
)
past_capacity = der_capacity
past_ders = past_ders + main_der_models + other_der_models
scenarios.append(scenario)
return scenarios
|
generate_scenarios(config_data)
Generate scenarios by taking high level configuration and writes opendss files.
Parameters:
Source code in emerge\scenarios\scenario.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216 | def generate_scenarios(config_data: data_model.DERScenarioConfigModel )-> None:
""" Generate scenarios by taking high level configuration and writes opendss files.
Args:
list_of_loads (data_model.DERScenarioConfigModel): Configuration model for defining
how to generate DER scenarios.
"""
for der_scen in config_data.der_scenario:
simulator = opendss.OpenDSSSimulator(config_data.master_file)
list_of_customers = dss_util.get_list_of_customer_models(simulator.dss_instance, 1,
cust_type=config_data.opendss_attr)
mapper_object = dss_util.get_load_mapper_objects(simulator.dss_instance)
derscenarios = create_der_scenarios(
list_of_customers, data_model.ScenarioBaseConfig(
**config_data.model_dump(include=['pct_resolution',
'num_of_penetration', 'max_num_of_samples'])
),
der_config=der_scen
)
writer_object = opendss_writer.OpenDSSPVScenarioWriter(
derscenarios, config_data.output_folder
)
writer_object.write(mapper_object,
file_name=der_scen.file_name
)
|