コード例 #1
0
ファイル: run_asparagus.py プロジェクト: gallauneru/medea
# *** read in all sets over which adjusted parameters are defined ***
dict_r = {rec.keys[0] for rec in db_input['n']}

# *** read in all parameters to be adjusted ***
INITIAL_CAP_G = gdx2df(db_input, 'INITIAL_CAP_G', ['z', 'i'], [])
INITIAL_CAP_R = gdx2df(db_input, 'INITIAL_CAP_R', ['z', 'n'], [])
DEMAND = gdx2df(db_input, 'DEMAND', ['z', 't', 'm'], [])
GEN_PROFILE = gdx2df(db_input, 'GEN_PROFILE', ['z', 't', 'n'], [])

# %% generate 'dynamic' parameter variations (modifications that constitute the scenarios, i.e. that change across runs)
# -------------------------------------------------------------------------------------------------------------------- #
# ensure that we are in the correct model directory
os.chdir(os.path.join(cfg.MEDEA_ROOT_DIR, 'projects', PROJECT_NAME, 'opt'))

# create empty scenario parameter in GAMS database so that it can be modified subsequently
CO2_SCENARIO = df2gdx(db_input, pd.DataFrame(data=[0]), 'CO2_SCENARIO', 'par',
                      0, 'CO2 price scenario')
WIND_ON_LIMIT = df2gdx(db_input, pd.DataFrame(data=[0]), 'WIND_ON_LIMIT',
                       'par', 0, 'max wind_on capacity addition')
PV_CAPEX = df2gdx(db_input, pd.DataFrame(data=[0]), 'PV_CAPEX', 'par', 0,
                  'capex for solar PV at 5.5% interest')
SWITCH_ANCILLARY = df2gdx(db_input, pd.DataFrame(data=[0]), 'SWITCH_ANCILLARY',
                          'par', 0, 'CO2 price scenario')
SWITCH_POLICY = df2gdx(db_input, pd.DataFrame(data=[1]), 'SWITCH_POLICY',
                       'par', 0, 'switch for policy constraint')
INITIAL_CAP_X = pd.DataFrame(data=0,
                             columns=['Value'],
                             index=pd.MultiIndex.from_product(
                                 [cfg.zones, cfg.zones]))
FLOW_LIMIT = df2gdx(db_input, pd.DataFrame(data=[0]), 'FLOW_LIMIT', 'par', 0,
                    'max transmission expansion')
コード例 #2
0
# *** read in all parameters to be adjusted ***
# general example for reading parameter 'PARAMETER_NAME' defined over 'set_name' to pandas DataFrame df
# df = gdx2df(db_input, 'PARAMETER_NAME', ['set_name'], [])
# ---

# fuel_thermal = ['Biomass', 'Coal', 'Gas', 'Lignite', 'Nuclear', 'Oil']


# %% generate 'dynamic' parameter variations (modifications that constitute the scenarios, i.e. that change each run)
# -------------------------------------------------------------------------------------------------------------------- #
# ensure that we are in the correct model directory
os.chdir(medea_path('projects', PROJECT_NAME, 'opt'))

# create empty scenario parameter in GAMS database so that it can be modified subsequently
RE_SHARE = df2gdx(db_input, pd.DataFrame(data=[0]), 'RE_SHARE', 'par', 0, 'Minimum share of RE generation')
WIND_ON_LIMIT = df2gdx(db_input, pd.DataFrame(data=[0]), 'WIND_ON_LIMIT', 'par', 0, 'max wind_on capacity addition')
CO2_BUDGET = df2gdx(db_input, pd.DataFrame(data=[0]), 'CO2_BUDGET', 'par', 0, 'max amount of co2 emitted')
CO2_SCENARIO = df2gdx(db_input, pd.DataFrame(data=[0]), 'CO2_SCENARIO', 'par', 0, 'CO2 price scenario')
SWITCH_ANCILLARY = df2gdx(db_input, pd.DataFrame(data=[0]), 'SWITCH_ANCILLARY', 'par', 0,
                          'switch to activate ancillary service demand')

# modify scenario parameter and solve medea for each scenario (i.e. for each parameter modification)

for campaign in dict_campaigns.keys():
    # update campaign dictionary
    dict_camp = dict_base.copy()
    dict_camp.update(dict_campaigns[campaign])

    # (de)activate must-run
    reset_symbol(db_input, 'SWITCH_ANCILLARY', pd.DataFrame(data=dict_camp['must_run']))
コード例 #3
0
from src.utils.gams_io import df2gdx
from src.utils.prepare_data import dict_sets, dict_instantiate, static_data, plant_data, ts_data, invest_limits

# TODO: Add energy stored in hydro reservoirs - STORAGE_LEVEL

idx = pd.IndexSlice
# --------------------------------------------------------------------------- #
# %% create workspace and database
# --------------------------------------------------------------------------- #
ws = GamsWorkspace(system_directory=cfg.GMS_SYS_DIR)
db = ws.add_database()

# --------------------------------------------------------------------------- #
# %% instantiate SETS
# --------------------------------------------------------------------------- #
f_set = df2gdx(db, dict_sets['f'], 'f', 'set', [])
l_set = df2gdx(db, dict_sets['l'], 'l', 'set', [])
m_set = df2gdx(db, dict_sets['m'], 'm', 'set', [])
z_set = df2gdx(db, dict_sets['z'], 'z', 'set', [])
k_set = df2gdx(db, dict_sets['k'], 'k', 'set', [])
n_set = df2gdx(db, dict_sets['n'], 'n', 'set', [])
t_set = df2gdx(db, dict_sets['t'], 't', 'set', [])
i_set = df2gdx(db, dict_sets['i'], 'i', 'set', [])
j_set = df2gdx(db, pd.DataFrame.from_dict({x: True for x in [y for y in dict_sets['i'].index if 'chp' in y]},
                                          orient='index'), 'j', 'set', [])
h_set = df2gdx(db, pd.DataFrame.from_dict({x: True for x in [y for y in dict_sets['i'].index if 'pth' in y]},
                                          orient='index'), 'h', 'set', [])
logging.info('medea sets instantiated')

# --------------------------------------------------------------------------- #
# %% instantiate static PARAMETERS
コード例 #4
0
# modify fuel requirement of co-generation plants
df_fuelreq_mod = df_fuelreq.copy()
for fl in fuel_thermal:
    df_fuelreq_mod.loc[idx[:, :, fl], :] = \
        df_fuelreq.loc[idx[:, :, fl], :] / efficiency[f'e_{fl}'][0]
reset_symbol(db_input, 'FEASIBLE_INPUT', df_fuelreq_mod)

# %% generate 'dynamic' parameter variations (modifications that constitute the scenarios, i.e. that change each run)
# -------------------------------------------------------------------------------------------------------------------- #
# ensure that we are in the correct model directory
os.chdir(medea_path('projects', project_name, 'opt'))

# create empty scenario parameter in GAMS database so that it can be modified subsequently
# example: changing CO2 price
scenario_co2 = df2gdx(db_input, pd.DataFrame(data=[0]), 'CO2_SCENARIO', 'par', 0, 'CO2 price scenario')

# modify scenario parameter and solve medea for each scenario (i.e. for each parameter modification)
for price_co2 in range_co2price:
    # generate identifier / name of scenario
    identifier = output_naming.format(price_co2)

    # modify scenario parameter in GAMS database
    # example: change CO2 price
    reset_symbol(db_input, 'CO2_SCENARIO', pd.DataFrame(data=[price_co2]))

    # export modified GAMS database to a .gdx-file that is then being read by the GAMS model
    export_location = medea_path('projects', project_name, 'opt', f'medea_{identifier}_data.gdx')
    db_input.export(export_location)

    # generate path to medea model
コード例 #5
0
import config as cfg
from src.utils.gams_io import df2gdx
from src.utils.preprocess_data import dict_sets, plant_data, ts_data, estimates, invest_limits

idx = pd.IndexSlice
# --------------------------------------------------------------------------- #
# %% create workspace and database
# --------------------------------------------------------------------------- #
ws = GamsWorkspace(system_directory=cfg.GMS_SYS_DIR)
db = ws.add_database()

# --------------------------------------------------------------------------- #
# %% instantiate SETS
# --------------------------------------------------------------------------- #
all_set = df2gdx(db, dict_sets['all_tec'], 'all_tec', 'set', [])
f_set = df2gdx(db, dict_sets['f'], 'f', 'set', [])
l_set = df2gdx(db, dict_sets['l'], 'l', 'set', [])
m_set = df2gdx(db, dict_sets['m'], 'm', 'set', [])
z_set = df2gdx(db, dict_sets['z'], 'z', 'set', [])
k_set = df2gdx(db, dict_sets['k'], 'k', 'set', [])
n_set = df2gdx(db, dict_sets['n'], 'n', 'set', [])
t_set = df2gdx(db, dict_sets['t'], 't', 'set', [])
i_set = df2gdx(db, dict_sets['i'], 'i', 'set', [])
j_set = df2gdx(db, pd.DataFrame.from_dict({x: True for x in [y for y in dict_sets['i'].index if 'chp' in y]},
                                          orient='index'), 'j', 'set', [])
h_set = df2gdx(db, pd.DataFrame.from_dict({x: True for x in [y for y in dict_sets['i'].index if 'pth' in y]},
                                          orient='index'), 'h', 'set', [])
logging.info('medea sets instantiated')

# --------------------------------------------------------------------------- #