1+ -- Ran:
2+ insert into switch .generation_plant_cost_scenario
3+ values (28 ,' SWITCH 2020 Baseline costs from id 25. DOE_wave' ,
4+ ' same costs as id 25, and added costs for wave energy and offshore wind candidates from 2017 data (Deborah S., Brian, PHG), Natalia and Paul runs' );
5+
6+ -- Ran:
7+ create table public .generation_project_info_wave_offshore_wind_industry_sites(
8+ index bigint ,
9+ GENERATION_PROJECT double precision ,
10+ gen_capacity_limit_mw double precision ,
11+ gen_connect_cost_per_mw double precision ,
12+ gen_dbid double precision ,
13+ gen_energy_source text ,
14+ gen_forced_outage_rate double precision ,
15+ gen_full_load_heat_rate text ,
16+ gen_is_baseload boolean ,
17+ gen_is_cogen boolean ,
18+ gen_is_variable boolean ,
19+ gen_load_zone text ,
20+ gen_max_age double precision ,
21+ gen_min_build_capacity double precision ,
22+ gen_scheduled_outage_rate double precision ,
23+ gen_tech text ,
24+ gen_variable_om double precision ,
25+ lat double precision ,
26+ long double precision ,
27+ primary key (GENERATION_PROJECT, gen_tech)
28+ );
29+
30+
31+ select * from public .generation_project_info_wave_offshore_wind_industry_sites ;
32+
33+
34+ -- Ran:
35+ create table public .gen_build_cost_wave_offshore_wind_industry_sites(
36+ index bigint ,
37+ GENERATION_PROJECT double precision ,
38+ build_year double precision ,
39+ gen_fixed_om double precision ,
40+ gen_overnight_cost double precision ,
41+ primary key (GENERATION_PROJECT, build_year)
42+ );
43+
44+
45+
46+ COPY public .generation_project_info_wave_offshore_wind_industry_sites
47+ FROM ' /home/n7gonzalez/switch/wave_energy/generation_project_info.csv'
48+ DELIMITER ' ,' NULL AS ' NULL' CSV HEADER;
49+
50+
51+
52+ COPY public .gen_build_cost_wave_offshore_wind_industry_sites
53+ FROM ' /home/n7gonzalez/switch/wave_energy/nati_v1_gen_build_cost_wave_offshore_wind.csv'
54+ DELIMITER ' ,' NULL AS ' NULL' CSV HEADER;
55+
56+ -- QA/QC
57+
58+ select generation_project, count (* )
59+ from public .gen_build_cost_wave_offshore_wind_industry_sites
60+ group by generation_project
61+ order by generation_project;
62+
63+
64+
65+
66+ -- Wave energy sites (Ryan's sites of industry interest)
67+
68+
69+ -- version 3 and final:
70+ drop table public .wave_colocation_CF_v4 ;
71+
72+ create table public .wave_colocation_CF_v4(
73+ GENERATION_PROJECT double precision ,
74+ gen_max_capacity_factor double precision ,
75+ site int ,
76+ year text ,
77+ month text ,
78+ day text ,
79+ hour text ,
80+ primary key (GENERATION_PROJECT, year, month, day, hour)
81+ );
82+
83+ COPY public .wave_colocation_CF_v4
84+ FROM ' /home/n7gonzalez/switch/wave_energy/nati_wave_colocation_cf_v1.csv'
85+ DELIMITER ' ,' NULL AS ' NULL' CSV HEADER;
86+
87+
88+ -- QA/QC:
89+ select * from public .wave_colocation_CF_v4 ;
90+
91+ select generation_project, count (* )
92+ from wave_colocation_CF_v4
93+ group by 1
94+ order by 1 ;
95+
96+
97+
98+ -- Offshore wind
99+ drop table public .offshore_colocation_CF_v4 ;
100+
101+ create table public .offshore_colocation_CF_v4(
102+ GENERATION_PROJECT double precision ,
103+ gen_max_capacity_factor double precision ,
104+ site int ,
105+ year text ,
106+ month text ,
107+ day text ,
108+ hour text ,
109+ primary key (GENERATION_PROJECT, year, month, day, hour)
110+ );
111+
112+ COPY public .offshore_colocation_CF_v4
113+ FROM ' /home/n7gonzalez/switch/wave_energy/nati_offshore_wind_colocation_cf_v1.csv'
114+ DELIMITER ' ,' NULL AS ' NULL' CSV HEADER;
115+
116+
117+ -- QA/QC:
118+ select * from public .offshore_colocation_CF_v4 ;
119+
120+ select generation_project, count (* )
121+ from offshore_colocation_CF_v4
122+ group by 1
123+ order by 1 ;
124+
125+
126+ -- -----------------------------------------------------------------------
127+
128+ insert into switch .generation_plant_scenario
129+ values (26 ,
130+ ' EIA-WECC Existing and Proposed 2018 + colocated offshore wind and wave, AMPL Basecase for Canada and Mex, AMPL proposed non-wind plants (only best of solar), Env Screen Wind Cat 3, No CAES' ,
131+ ' same as id 22 adding (Calwave) Ryans industry sites for colocated wave and offshore wind (Natalia Paul Pedro PHG), but no Compressed Air Energy Storage gen_tech among candidate generators. No wave sites from Bryan and Deborah.'
132+ );
133+
134+
135+ insert into switch .generation_plant (generation_plant_id, name, gen_tech, load_zone_id, connect_cost_per_mw, variable_o_m,
136+ forced_outage_rate, scheduled_outage_rate, max_age, min_build_capacity, is_variable, is_baseload,
137+ is_cogen, energy_source, min_load_fraction, startup_fuel, startup_om)
138+ select
139+ t1 .generation_project as generation_plant_id, concat(t1 .generation_project , ' _Proposed_industry_site' ) as name,
140+ gen_tech, load_zone_id, gen_connect_cost_per_mw as connect_cost_per_mw,
141+ gen_variable_om as variable_o_m, gen_forced_outage_rate as forced_outage_rate, gen_scheduled_outage_rate as scheduled_outage_rate,
142+ gen_max_age as max_age, gen_min_build_capacity as min_build_capacity, gen_is_variable as is_variable, gen_is_baseload as is_baseload, gen_is_cogen as is_cogen,
143+ gen_energy_source as energy_source, 0 as min_load_fraction, 0 as startup_fuel, 0 as startup_om
144+ from public .generation_project_info_wave_offshore_wind_industry_sites as t1
145+ join switch .load_zone as t2 on (t2 .name = gen_load_zone);
146+
147+
148+ insert into switch .generation_plant_scenario_member
149+ select 26 as generation_plant_scenario_id, t1 .generation_project as generation_plant_id
150+ from public .generation_project_info_wave_offshore_wind_industry_sites as t1
151+ union
152+ select 26 as generation_plant_scenario_id, generation_plant_id
153+ from switch .generation_plant_scenario_member
154+ where generation_plant_scenario_id= 23 ;
155+
156+
157+
158+
159+ insert into switch .generation_plant_cost
160+ select 28 as generation_plant_cost_scenario_id, generation_plant_id, build_year, fixed_o_m, overnight_cost,
161+ storage_energy_capacity_cost_per_mwh
162+ from switch .generation_plant_cost
163+ where generation_plant_cost_scenario_id = 25 -- 25 is the previous baseline scenario used for CEC LDES 2020-2022
164+ union
165+ select 28 as generation_plant_cost_scenario_id, t .generation_project as generation_plant_id,
166+ build_year, gen_fixed_om as fixed_o_m, gen_overnight_cost as overnight_cost,
167+ NULL as storage_energy_capacity_cost_per_mwh
168+ from public .gen_build_cost_wave_offshore_wind_industry_sites as t;
169+
170+
171+ -- OLD code from April, 2022. Not updated to July 14, 2022:
172+ -- TO DO: QA/QC (as of april 25, 2022 it's still pending)
173+ -- -- reality check: --------------NOT UPDATED---------------------------------------------------------
174+ -- -----------------------------------------------------------------------------------------
175+ -- 238800 rows retrieved
176+ -- select * from switch.generation_plant_cost
177+ -- join switch.generation_plant using(generation_plant_id)
178+ -- where generation_plant_cost_scenario_id=25
179+ -- and energy_source not in ('Wave')
180+ -- and energy_source not in ('Wind');
181+
182+ -- -- select *
183+ -- -- from switch.generation_plant_cost
184+ -- -- where generation_plant_cost_scenario_id = 27;
185+
186+
187+ -- -- -- 303495 rows retrieved
188+ -- select 27 as generation_plant_cost_scenario_id, generation_plant_id, build_year, fixed_o_m, overnight_cost,
189+ -- storage_energy_capacity_cost_per_mwh
190+ -- from switch.generation_plant_cost
191+ -- where generation_plant_cost_scenario_id = 25;
192+
193+ -- 1078 rows retrieved = number of rows in Shiny's notebook (OK!)
194+ -- select 27 as generation_plant_cost_scenario_id, t.generation_project as generation_plant_id,
195+ -- build_year, gen_fixed_om as fixed_o_m, gen_overnight_cost as overnight_cost,
196+ -- NULL as storage_energy_capacity_cost_per_mwh
197+ -- from public.gen_build_cost_wave_offshore_wind_industry_sites as t;
198+
199+
200+ -- -- id 25: 303495 rows (2050-2010+1)
201+
202+
203+ -- -- end of reality check -----------------------------------------------------------------------------
204+ -- ---------------------------------------------------------------------------------------------------
205+
206+
207+
208+
209+ -- Summary: tables updated:
210+ -- generation_plant_cost_scenario,
211+ -- generation_plant_scenario,
212+ -- generation_plant,
213+ -- generation_plant_scenario_member,
214+ -- generation_plant_cost,
215+
216+
217+
218+
219+
220+ -- --------------------checked---------------------------------------------------------------
221+ -- -- 10354 (current scenario)
222+ -- select * from switch.generation_plant_scenario_member where generation_plant_scenario_id = 25;
223+
224+ -- 10354 + 23 - 28 = 10349 (previous scenario with 23 old wave sites,
225+ -- minus 28 new sites from generation_plant_scenario_id = 25)
226+ select * from switch .generation_plant_scenario_member
227+ where generation_plant_scenario_id = 24 ;
228+ -- ----------------------------------------------------------------------------------------
229+
230+
231+ -- __________________________________________________________________________________________________
232+ -- __________________________________________________________________________________________________
233+
234+ -- new table with WAVE capacity factors duplicated from 2010 for 2010-2060
235+
236+
237+ DROP TABLE public .test_variable_capacity_factors_wave_industry_sites ;
238+
239+ create table public .test_variable_capacity_factors_wave_industry_sites(
240+ generation_plant_id double precision ,
241+ capacity_factor double precision ,
242+ time_stamp_utc text );
243+
244+ do
245+ $$
246+ begin
247+ for year_index in 2010 ..2060 loop
248+ raise notice ' year: %' , year_index;
249+
250+ insert into public .test_variable_capacity_factors_wave_industry_sites
251+ select t .generation_project as generation_plant_id,
252+ gen_max_capacity_factor as capacity_factor,
253+ concat(year_index, ' -' , month, ' -' , day, ' ' , hour, ' :00:00' ) as new_stamp
254+ from public .wave_colocation_CF_v4 t;
255+ end loop;
256+ end;
257+ $$
258+
259+ -- QA/QC: 100 sites * 8760 hours * (2060 - 2010 + 1) = 44,676,000 rows retrieved. OK!
260+ select * from public .test_variable_capacity_factors_wave_industry_sites ;
261+
262+
263+
264+ select * from switch .variable_capacity_factors_exist_and_candidate_gen
265+ where generation_plant_id = 1191183122
266+ order by timestamp_utc asc ;
267+
268+ -- make sure the number of rows adds to the number you expect for wave energy and offshore wind sites
269+ -- The years with data should still be (2051-2011+1) because there is a join between the new tables you created and the SWITCH tables (which go from 2010 to 2051)
270+ -- PHG checked: 35,916,000 rows = (2051-2011+1) * 8760 * 100
271+ insert into switch .variable_capacity_factors_exist_and_candidate_gen
272+ select t .generation_plant_id as generation_plant_id, raw_timepoint_id, t2 .timestamp_utc ,
273+ t .capacity_factor as capacity_factor, 1 as is_new_cap_factor
274+ from public .test_variable_capacity_factors_wave_industry_sites as t
275+ join switch .variable_capacity_factors_exist_and_candidate_gen as t2 on (t .time_stamp_utc = to_char(t2 .timestamp_utc , ' YYYY-MM-DD HH24:MI:SS' ))
276+ where t2 .generation_plant_id = 1191183122 -- random plant_id chosen to match raw_timepoint_id
277+ order by 1 ,2 desc ;
278+
279+
280+
281+
282+ -- -- TODO: new table with OFFSHORE WIND capacity factors duplicated from 2010 for 2010-2060
283+ DROP TABLE public .test_variable_capacity_factors_wave_industry_sites ;
284+
285+ create table public .test_variable_capacity_factors_offshore_wind_industry_sites(
286+ generation_plant_id double precision ,
287+ capacity_factor double precision ,
288+ time_stamp_utc text );
289+
290+
291+ do
292+ $$
293+ begin
294+ for year_index in 2010 ..2060 loop
295+ raise notice ' year: %' , year_index;
296+
297+ insert into public .test_variable_capacity_factors_offshore_wind_industry_sites
298+ select t .generation_project as generation_plant_id,
299+ gen_max_capacity_factor as capacity_factor,
300+ concat(year_index, ' -' , month, ' -' , day, ' ' , hour, ' :00:00' ) as new_stamp
301+ from public .offshore_colocation_CF_v4 t;
302+ end loop;
303+ end;
304+ $$
305+
306+ -- QA/QC: 100 sites * 8760 hours * (2060 - 2010 + 1) = 44,676,000 rows retrieved. OK!
307+ select * from public .test_variable_capacity_factors_offshore_wind_industry_sites ;
308+
309+
310+ -- -- select * from switch.variable_capacity_factors_exist_and_candidate_gen
311+ -- -- where generation_plant_id = 1191183122
312+ -- -- order by timestamp_utc asc;
313+
314+ -- 35,916,000 rows retrieved = (2051 - 2011 + 1) * 100 * 8760. OK!
315+ insert into switch .variable_capacity_factors_exist_and_candidate_gen
316+ select t .generation_plant_id as generation_plant_id, raw_timepoint_id, t2 .timestamp_utc ,
317+ t .capacity_factor as capacity_factor, 1 as is_new_cap_factor
318+ from public .test_variable_capacity_factors_offshore_wind_industry_sites as t
319+ join switch .variable_capacity_factors_exist_and_candidate_gen as t2 on (t .time_stamp_utc = to_char(t2 .timestamp_utc , ' YYYY-MM-DD HH24:MI:SS' ))
320+ where t2 .generation_plant_id = 1191183122 -- random plant_id chosen to match raw_timepoint_id
321+ order by 1 ,2 desc ;
322+
323+ -- Not RAN, and won't:
324+ -- insert into switch.scenario
325+ -- values (179,
326+ -- '[DOE wave energy] same178+wave offshore wind Ryan',
327+ -- 'New: wave energy and offshore wind sites of industry Ryan. Same: WECC zero emissions, no RPS, NREL ATB 2020, updated gen listings (env cat 3), 2017 fuel costs from EIA, 2018 dollars, supply curve for Bio_Solid',
328+ -- 25, -- study_timeframe_id
329+ -- 25, -- time_sample_id
330+ -- 115, -- demand_scenario_id
331+ -- 4, -- fuel_simple_price_scenario, without Bio_Solid costs, because they are provided by supply curve
332+ -- 26, -- generation_plant_scenario_id
333+ -- 28, -- generation_plant_cost_scenario_id
334+ -- 21, -- generation_plant_existing_and_planned_scenario_id
335+ -- 23, -- hydro_simple_scenario_id
336+ -- 92, -- carbon_cap_scenario_id
337+ -- 2, -- supply_curve_scenario_id
338+ -- 1, -- regional_fuel_market_scenario_id
339+ -- NULL, -- rps_scenario_id
340+ -- NULL, --enable_dr
341+ -- NULL, --enable_ev
342+ -- 2, --transmission_base_capital_cost_scenario_id
343+ -- NULL, --ca_policies_scenario_id
344+ -- 0, --enable_planning_reserves
345+ -- 2, --generation_plant_technologies_scenario_id
346+ -- 3, --variable_o_m_cost_scenario_id
347+ -- NULL --wind_to_solar_ratio
348+ -- );
0 commit comments