@@ -69,9 +69,10 @@ def write_csv(data: Iterable[List], fname, headers: List[str], log=True):
6969 "switch_model.transmission.transport.build" ,
7070 "switch_model.transmission.transport.dispatch" ,
7171 "switch_model.policies.carbon_policies" ,
72- "switch_model.policies.rps_unbundled" ,
7372 "switch_model.policies.min_per_tech" , # Always include since it provides useful outputs even when unused
7473 # "switch_model.reporting.basic_exports_wecc",
74+ # Always include since by default it does nothing except output useful data
75+ "switch_model.policies.wind_to_solar_ratio" ,
7576]
7677
7778
@@ -107,6 +108,7 @@ def query_db(full_config, skip_cf):
107108 "enable_planning_reserves" ,
108109 "generation_plant_technologies_scenario_id" ,
109110 "variable_o_m_cost_scenario_id" ,
111+ "wind_to_solar_ratio" ,
110112 ]
111113
112114 db_cursor .execute (
@@ -143,6 +145,7 @@ def query_db(full_config, skip_cf):
143145 enable_planning_reserves = s_details [18 ]
144146 generation_plant_technologies_scenario_id = s_details [19 ]
145147 variable_o_m_cost_scenario_id = s_details [20 ]
148+ wind_to_solar_ratio = s_details [21 ]
146149
147150 print (f"Scenario: { scenario_id } : { name } ." )
148151
@@ -724,6 +727,7 @@ def query_db(full_config, skip_cf):
724727 order by 1, 2;
725728 """ ,
726729 )
730+ modules .append ("switch_model.policies.rps_unbundled" )
727731
728732 ########################################################
729733 # BIO_SOLID SUPPLY CURVE
@@ -864,20 +868,45 @@ def query_db(full_config, skip_cf):
864868 )
865869
866870 ca_policies (db_cursor , ca_policies_scenario_id , study_timeframe_id )
871+ write_wind_to_solar_ratio (wind_to_solar_ratio )
867872 if enable_planning_reserves :
868873 planning_reserves (db_cursor , time_sample_id , hydro_simple_scenario_id )
869874 create_modules_txt ()
870875
871876 # Make graphing files
872877 graph_config = os .path .join (os .path .dirname (__file__ ), "graph_config" )
873- print ("\t graph_tech_colors.csv..." )
874- shutil .copy (
875- os .path .join (graph_config , "graph_tech_colors.csv" ), "graph_tech_colors.csv"
876- )
877- print ("\t graph_tech_types.csv..." )
878- shutil .copy (
879- os .path .join (graph_config , "graph_tech_types.csv" ), "graph_tech_types.csv"
878+ print ("\t graph_config files..." )
879+ for root , dirs , files in os .walk (graph_config ):
880+ for name in files :
881+ shutil .copy (os .path .join (root , name ), "." )
882+
883+
884+ def write_wind_to_solar_ratio (wind_to_solar_ratio ):
885+ # TODO ideally we'd have a table where we can specify the wind_to_solar_ratios per period.
886+ # At the moment only the wind_to_solar_ratio is specified and which doesn't allow different values per period
887+ if wind_to_solar_ratio is None :
888+ return
889+
890+ print ("wind_to_solar_ratio.csv..." )
891+ df = pd .read_csv ("periods.csv" )[["INVESTMENT_PERIOD" ]]
892+ df ["wind_to_solar_ratio" ] = wind_to_solar_ratio
893+
894+ # wind_to_solar_ratio.csv requires a column called wind_to_solar_ratio_const_gt that is True (1) or False (0)
895+ # This column specifies whether the constraint is a greater than constraint or a less than constraint.
896+ # 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
897+ # and we want it to be a less than constraint if we're trying to force the ratio below its default.
898+ # Here the default is the ratio if we didn't have the constraint.
899+ cutoff_ratio = 0.28
900+ warnings .warn (
901+ "To determine the sign of the wind-to-solar ratio constraint we have "
902+ f"assumed that without the constraint, the wind-to-solar ratio is { cutoff_ratio } . "
903+ f"This value was accurate for Martin's LDES runs however it may not be accurate for you. "
904+ f"You should update this value in get_inputs or manually specify whether you want a greater than "
905+ f"or a less than constraint."
880906 )
907+ df ["wind_to_solar_ratio_const_gt" ] = 1 if wind_to_solar_ratio > cutoff_ratio else 0
908+
909+ df .to_csv ("wind_to_solar_ratio.csv" , index = False )
881910
882911
883912def ca_policies (db_cursor , ca_policies_scenario_id , study_timeframe_id ):
0 commit comments