@@ -20,6 +20,7 @@ def __init__(
2020 model_name : str ,
2121 year : int ,
2222 sim_horizon : int ,
23+ num_sim_days : int = 365 ,
2324 use_spin_var : bool = True ,
2425 dc_opf : str = "kirchhoff" ,
2526 spin_reserve_factor : float = 0.15 ,
@@ -36,6 +37,10 @@ def __init__(
3637 self .model_dir : str = os .path .join (input_folder , model_name )
3738 self .year : int = year
3839 self .sim_horizon : int = sim_horizon
40+
41+ self .num_sim_days : int = num_sim_days
42+ self .num_sim_hours : int = num_sim_days * 24
43+
3944 self .use_spin_var : bool = use_spin_var
4045
4146 # The timestamp is used to create a unique folder for the model
@@ -433,9 +438,11 @@ def _load_contract_costs(self):
433438 "contract_cost.csv" , header_levels = 0
434439 )
435440
436- # Check that the contract costs timeseries is of length 8760
437- if len (contract_costs_df ) not in [0 , 8760 ]:
438- raise ValueError ("PowNet: Marginal cost timeseries must be of length 8760." )
441+ # Check that the contract costs timeseries is of length num_sim_hours
442+ if len (contract_costs_df ) not in [0 , self .num_sim_hours ]:
443+ raise ValueError (
444+ f"PowNet: Marginal cost timeseries must be of length { self .num_sim_hours } ."
445+ )
439446
440447 self .contract_costs = {
441448 (col , idx ): value
@@ -517,7 +524,7 @@ def _create_timeseries_of_edges(self, data: list, column_name: str) -> pd.DataFr
517524 columns = [column_name ],
518525 ).T
519526 # Repeat values for every hour of the year
520- df = df .loc [df .index .repeat (365 * 24 )].reset_index (drop = True )
527+ df = df .loc [df .index .repeat (self . num_sim_hours )].reset_index (drop = True )
521528 df .index += 1
522529 return df
523530
@@ -699,7 +706,7 @@ def load_data(self):
699706 #################
700707 if self .spin_reserve_mw is not None :
701708 self .spin_requirement = pd .Series (
702- self .spin_reserve_mw , index = range (1 , 8761 )
709+ self .spin_reserve_mw , index = range (1 , self . num_sim_hours + 1 )
703710 )
704711 else :
705712 self .spin_requirement = self .demand .sum (axis = 1 ) * self .spin_reserve_factor
@@ -782,8 +789,10 @@ def check_data(self):
782789 # Timeseries have the correct length
783790 ##################################
784791
785- if len (self .demand ) != 8760 :
786- raise ValueError ("PowNet: Demand timeseries must be of length 8760." )
792+ if len (self .demand ) != self .num_sim_hours :
793+ raise ValueError (
794+ f"PowNet: Demand timeseries must be of length { self .num_sim_hours } but got { len (self .demand )} ."
795+ )
787796
788797 attrs_to_check = [
789798 "solar_capacity" ,
@@ -795,12 +804,14 @@ def check_data(self):
795804 ]
796805 for attr in attrs_to_check :
797806 temp_df = getattr (self , attr )
798- if (not temp_df .empty ) and (len (temp_df ) != 8760 ):
799- raise ValueError (f"PowNet: { attr } must be of length 8760." )
807+ if (not temp_df .empty ) and (len (temp_df ) != self .num_sim_hours ):
808+ raise ValueError (
809+ f"PowNet: { attr } must be of length { self .num_sim_hours } but got { len (temp_df )} ."
810+ )
800811
801- if len (self .daily_hydro_capacity ) not in [0 , 365 ]:
812+ if len (self .daily_hydro_capacity ) not in [0 , self . num_sim_days ]:
802813 raise ValueError (
803- "PowNet: Daily hydropower timeseries must be of length 365 ."
814+ f "PowNet: Daily hydropower timeseries must be of length { self . num_sim_days } ."
804815 )
805816
806817 ##################################
@@ -941,6 +952,7 @@ def print_summary(self):
941952
942953 ---- Modeling parameters ----
943954 { 'Simulation horizon' :<25} = { self .sim_horizon } hours
955+ { 'Number of simulation days' :<25} = { self .num_sim_days }
944956 { 'Use spin variable' :<25} = { self .use_spin_var }
945957 { 'Power flow' :<25} = { self .dc_opf }
946958 { 'Spin reserve factor:' :<25} = { self .spin_reserve_factor if self .spin_reserve_mw is None else 'Use an absolute value in MW.' }
0 commit comments