diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 43ba9e6..4c16c70 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -169,7 +169,7 @@ jobs: - name: Clone SMSpp run: | - git clone -b develop --recurse-submodules https://gitlab.com/smspp/smspp-project.git + git clone -b test_win --recurse-submodules https://gitlab.com/davide-f/smspp-project.git - name: Compile SMSpp run: | diff --git a/configs/S_2N.yaml b/configs/S_2N.yaml index 0c0f904..efe079e 100644 --- a/configs/S_2N.yaml +++ b/configs/S_2N.yaml @@ -12,11 +12,11 @@ apply_weighting_patch: true # Whether to apply the weighting path to the model: model_parameters: # Parameters for the model (example for microgrid) buses_demand: [0, 1] # (mandatory) List of nodes where demand is installed; the same profile applies to each - bus_PV: null # Node where PV is installed; when null or missing, no PV is installed + bus_PV: 0 # Node where PV is installed; when null or missing, no PV is installed bus_wind: null # Node where wind is installed; when null or missing, no wind is installed bus_storage: null # Node where battery storage is installed; when null or missing, no battery storage is installed bus_store: 2 # Node where the store is installed - bus_diesel: 0 # Node where diesel is installed; when null or missing, no diesel is installed + bus_diesel: 1 # Node where diesel is installed; when null or missing, no diesel is installed buses_transformer: null # Nodes connected by a transformer; the trasformer is connected to each node and its following bus_hydro: null # Node where hydro power plant is installed; when null or missing, no hydro is installed # the available inflow is calculated proportionally to match a fraction (hydro_factor) of the total demand diff --git a/scripts/microgrid_builder.py b/scripts/microgrid_builder.py index cfcfc6e..a07c1f2 100644 --- a/scripts/microgrid_builder.py +++ b/scripts/microgrid_builder.py @@ -209,8 +209,8 @@ def build_microgrid_model( "battery", bus=f"Bus {bus_store}", carrier="battery", - p_nom_extendable=True, - capital_cost=assumptions.at["battery", "capital_cost"], + e_nom_extendable=True, + capital_cost=assumptions.at["battery", "capital_cost"]*4/5, # assumption: 80% cost of cell, 20% cost of converter e_initial=0., e_cyclic=e_cycling, ) @@ -218,14 +218,27 @@ def build_microgrid_model( n.add( "Link", "battery link", - carrier = "battery link", + carrier = "battery discharger", bus0 = f"Bus {bus_store}", bus1 = f"Bus {bus_store-1}", - p_min_pu = -1, + p_min_pu = 0, p_max_pu = 1, - capital_cost=assumptions.at["battery", "capital_cost"], + capital_cost=assumptions.at["battery", "capital_cost"]/10, marginal_cost=assumptions.at["battery", "OPEX_marginal"], - efficiency = 1, + efficiency = 0.9, + p_nom_extendable = True + ) + + n.add( + "Link", + "battery charger", + carrier = "battery link", + bus0 = f"Bus {bus_store-1}", + bus1 = f"Bus {bus_store}", + p_min_pu = 0, + p_max_pu = 1, + capital_cost=assumptions.at["battery", "capital_cost"]/10, + efficiency = 1., p_nom_extendable = True ) diff --git a/scripts/smspp_dispatch_builder.py b/scripts/smspp_dispatch_builder.py index 1b964b7..abd864a 100644 --- a/scripts/smspp_dispatch_builder.py +++ b/scripts/smspp_dispatch_builder.py @@ -184,7 +184,7 @@ def add_network( n.links.p_nom_opt.values * n.links.p_min_pu.values, - n.transformers.s_nom_opt, ]) - + # Max power flow max_power_flow = mb.createVariable("MaxPowerFlow", NC_DOUBLE, ("NumberLines",)) max_power_flow[:] = np.concatenate([ @@ -192,6 +192,14 @@ def add_network( n.links.p_nom_opt.values * n.links.p_max_pu.values, n.transformers.s_nom_opt.values, ]) + + # Efficiency + efficiency = mb.createVariable("Efficiency", NC_DOUBLE, ("NumberLines",)) + efficiency[:] = np.concatenate([ + np.full(len(get_bus_idx(n, n.lines.bus1).values), 1.0), + n.links.efficiency.values, + np.full(len(get_bus_idx(n, n.transformers.bus1).values), 1.0), + ]) # Susceptance susceptance = mb.createVariable("LineSusceptance", NC_DOUBLE, ("NumberLines",)) @@ -372,8 +380,8 @@ def get_battery_blocks(n, id_initial, bub_carriers): "MinStorage": 0.0, "MaxStorage": row.p_nom_opt * row.max_hours, "InitialStorage": init_store, - "StoringBatteryRho": row.efficiency_store, - "ExtractingBatteryRho": row.efficiency_dispatch, + "StoringBatteryRho": 1/row.efficiency_store, + "ExtractingBatteryRho": 1/row.efficiency_dispatch, } ) id_battery += 1 @@ -389,7 +397,7 @@ def get_battery_blocks(n, id_initial, bub_carriers): { "id": id_battery, "block_type": "BatteryUnitBlock", - "MinPower": (row.e_nom_opt * e_min_pu.loc[:, idx_name]).values * 10, + "MinPower": - (row.e_nom_opt * e_max_pu.loc[:, idx_name]).values * 10, "MaxPower": (row.e_nom_opt * e_max_pu.loc[:, idx_name]).values * 10, "MinStorage": 0.0, "MaxStorage": row.e_nom_opt, @@ -600,7 +608,7 @@ def add_hydro_unit_blocks(mb, n, unit_count, hub_carriers): from helpers import mock_snakemake os.chdir(os.path.dirname(os.path.abspath(__file__))) - snakemake = mock_snakemake("smspp_dispatch_builder", configfiles=["configs/ALLbuthydro_5N.yaml"]) + snakemake = mock_snakemake("smspp_dispatch_builder", configfiles=["configs/S_2N.yaml"]) logger = create_logger("smspp_dispatch_builder", logfile=snakemake.log[0])