@@ -1316,7 +1316,7 @@ def add_sectorcoupled_parameters(
13161316
13171317
13181318# Sempre nella classe Transformation
1319- def apply_expansion_overrides (IntermittentUnitBlock_parameters = None , BatteryUnitBlock_store_parameters = None , IntermittentUnitBlock_inverse = None , BatteryUnitBlock_inverse = None , InvestmentBlock = None ):
1319+ def apply_expansion_overrides (IntermittentUnitBlock_parameters = None , BatteryUnitBlock_parameters = None , BatteryUnitBlock_store_parameters = None , IntermittentUnitBlock_inverse = None , BatteryUnitBlock_inverse = None , InvestmentBlock = None ):
13201320 """
13211321 Inject missing keys for UC expansion to be solved inside UCBlock instead of a separate InvestmentBlock.
13221322 Keys are only added if missing, so it remains idempotent.
@@ -1348,6 +1348,57 @@ def _min_cap_design(p_nom, p_nom_extendable, p_nom_min):
13481348 if bool (first_scalar (p_nom_extendable ))
13491349 else first_scalar (p_nom ))
13501350 d ["MinCapacityDesign" ] = _min_cap_design
1351+
1352+ # --- BatteryUnitBlock ---
1353+ b = BatteryUnitBlock_parameters
1354+
1355+ # "BatteryInvestmentCost"
1356+ if "BatteryInvestmentCost" not in b :
1357+ b ["BatteryInvestmentCost" ] = lambda capital_cost , p_nom_extendable : capital_cost if bool (first_scalar (p_nom_extendable )) else 0.0
1358+
1359+ # "ConverterInvestmentCost"
1360+ if "ConverterInvestmentCost" not in b :
1361+ b ["ConverterInvestmentCost" ] = lambda p_nom_extendable : 1e-12 if bool (first_scalar (p_nom_extendable )) else 0.0
1362+
1363+ # "BatteryMaxCapacityDesign"
1364+ if "BatteryMaxCapacityDesign" not in b :
1365+ def _battery_max_cap_design (p_nom , p_nom_extendable , p_nom_max ):
1366+ p_nom_max_safe = p_nom_max .replace (np .inf , 1e9 )
1367+ return (first_scalar (p_nom_max_safe )
1368+ if bool (first_scalar (p_nom_extendable ))
1369+ else first_scalar (p_nom ))
1370+ b ["BatteryMaxCapacityDesign" ] = _battery_max_cap_design
1371+
1372+ # "BatteryMinCapacityDesign"
1373+ if "BatteryMinCapacityDesign" not in b :
1374+ def _battery_min_cap_design (p_nom , p_nom_extendable , p_nom_min ):
1375+ p_nom_min_safe = p_nom_min
1376+ return (first_scalar (p_nom_min_safe )
1377+ if bool (first_scalar (p_nom_extendable ))
1378+ else first_scalar (p_nom ))
1379+ b ["BatteryMinCapacityDesign" ] = _battery_min_cap_design
1380+
1381+ # "ConverterMaxCapacityDesign"
1382+ if "ConverterMaxCapacityDesign" not in b :
1383+ def _conv_max_cap_design (p_nom , p_nom_extendable , p_nom_max ):
1384+ p_nom_max_safe = p_nom_max .replace (np .inf , 1e9 )
1385+ # Your rule of thumb: 10x battery energy cap when extendable, else p_nom
1386+ return (10.0 * first_scalar (p_nom_max_safe )
1387+ if bool (first_scalar (p_nom_extendable ))
1388+ else first_scalar (p_nom ))
1389+ b ["ConverterMaxCapacityDesign" ] = _conv_max_cap_design
1390+
1391+
1392+ # "ConverterMinCapacityDesign"
1393+ if "ConverterMinCapacityDesign" not in b :
1394+ def _conv_min_cap_design (p_nom , p_nom_extendable , p_nom_min ):
1395+ p_nom_min_safe = p_nom_min .replace (np .inf , 1e9 )
1396+ # Your rule of thumb: 10x battery energy cap when extendable, else p_nom
1397+ return (10.0 * first_scalar (p_nom_min_safe )
1398+ if bool (first_scalar (p_nom_extendable ))
1399+ else first_scalar (p_nom ))
1400+ b ["ConverterMinCapacityDesign" ] = _conv_min_cap_design
1401+
13511402
13521403 # --- BatteryUnitBlock_store ---
13531404 b = BatteryUnitBlock_store_parameters
0 commit comments