@@ -69,6 +69,8 @@ def write_csv(data: Iterable[List], fname, headers: List[str], log=True):
6969 "switch_model.policies.rps_unbundled" ,
7070 "switch_model.policies.min_per_tech" , # Always include since it provides useful outputs even when unused
7171 # "switch_model.reporting.basic_exports_wecc",
72+ # Always include since by default it does nothing except output useful data
73+ "switch_model.policies.wind_to_solar_ratio" ,
7274]
7375
7476
@@ -103,7 +105,8 @@ def query_db(full_config, skip_cf):
103105 "ca_policies_scenario_id" ,
104106 "enable_planning_reserves" ,
105107 "generation_plant_technologies_scenario_id" ,
106- "variable_o_m_cost_scenario_id"
108+ "variable_o_m_cost_scenario_id" ,
109+ "wind_to_solar_ratio"
107110 ]
108111
109112 db_cursor .execute (
@@ -140,6 +143,7 @@ def query_db(full_config, skip_cf):
140143 enable_planning_reserves = s_details [18 ]
141144 generation_plant_technologies_scenario_id = s_details [19 ]
142145 variable_o_m_cost_scenario_id = s_details [20 ]
146+ wind_to_solar_ratio = s_details [21 ]
143147
144148 print (f"Scenario: { scenario_id } : { name } ." )
145149
@@ -856,6 +860,7 @@ def query_db(full_config, skip_cf):
856860 )
857861
858862 ca_policies (db_cursor , ca_policies_scenario_id , study_timeframe_id )
863+ write_wind_to_solar_ratio (wind_to_solar_ratio )
859864 if enable_planning_reserves :
860865 planning_reserves (db_cursor , time_sample_id , hydro_simple_scenario_id )
861866 create_modules_txt ()
@@ -868,6 +873,32 @@ def query_db(full_config, skip_cf):
868873 shutil .copy (os .path .join (graph_config , "graph_tech_types.csv" ), "graph_tech_types.csv" )
869874
870875
876+ def write_wind_to_solar_ratio (wind_to_solar_ratio ):
877+ # TODO ideally we'd have a table where we can specify the wind_to_solar_ratios per period.
878+ # At the moment only the wind_to_solar_ratio is specified and which doesn't allow different values per period
879+ if wind_to_solar_ratio is None :
880+ return
881+
882+ print ("wind_to_solar_ratio.csv..." )
883+ df = pd .read_csv ("periods.csv" )[["INVESTMENT_PERIOD" ]]
884+ df ["wind_to_solar_ratio" ] = wind_to_solar_ratio
885+
886+ # wind_to_solar_ratio.csv requires a column called wind_to_solar_ratio_const_gt that is True (1) or False (0)
887+ # This column specifies whether the constraint is a greater than constraint or a less than constraint.
888+ # In our case we want it to be a greater than constraint if we're trying to force wind-to-solar ratio above its default
889+ # and we want it to be a less than constraint if we're trying to force the ratio below its default.
890+ # Here the default is the ratio if we didn't have the constraint.
891+ cutoff_ratio = 0.28
892+ warnings .warn (
893+ "To determine the sign of the wind-to-solar ratio constraint we have "
894+ f"assumed that without the constraint, the wind-to-solar ratio is { cutoff_ratio } . "
895+ f"This value was accurate for Martin's LDES runs however it may not be accurate for you. "
896+ f"You should update this value in get_inputs or manually specify whether you want a greater than "
897+ f"or a less than constraint."
898+ )
899+ df ["wind_to_solar_ratio_const_gt" ] = 1 if wind_to_solar_ratio > cutoff_ratio else 0
900+
901+ df .to_csv ("wind_to_solar_ratio.csv" , index = False )
871902
872903def ca_policies (db_cursor , ca_policies_scenario_id , study_timeframe_id ):
873904 if ca_policies_scenario_id is None :
0 commit comments