-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathdb_schema.sql
More file actions
8920 lines (8312 loc) · 395 KB
/
db_schema.sql
File metadata and controls
8920 lines (8312 loc) · 395 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- noinspection SqlNoDataSourceInspectionForFile
-- Copyright 2016-2024 Blue Marble Analytics LLC.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- A description of the database schema structure is in db.__init__
-----------------
-- -- MODEL -- --
-----------------
-- Implemented horizon boundary types
DROP TABLE IF EXISTS mod_horizon_boundary_types;
CREATE TABLE mod_horizon_boundary_types
(
horizon_boundary_type VARCHAR(16) PRIMARY KEY,
description VARCHAR(128)
);
-- Months
DROP TABLE IF EXISTS mod_months;
CREATE TABLE mod_months
(
month INTEGER PRIMARY KEY,
description VARCHAR(16)
);
-- Implemented capacity types
DROP TABLE IF EXISTS mod_capacity_types;
CREATE TABLE mod_capacity_types
(
capacity_type VARCHAR(32) PRIMARY KEY,
description VARCHAR(128)
);
-- Implemented availability types
DROP TABLE IF EXISTS mod_availability_types;
CREATE TABLE mod_availability_types
(
availability_type VARCHAR(32) PRIMARY KEY,
description VARCHAR(128)
);
-- Implemented operational types
DROP TABLE IF EXISTS mod_operational_types;
CREATE TABLE mod_operational_types
(
operational_type VARCHAR(32) PRIMARY KEY,
description VARCHAR(128)
);
-- Implemented reserve types
DROP TABLE IF EXISTS mod_reserve_types;
CREATE TABLE mod_reserve_types
(
reserve_type VARCHAR(32) PRIMARY KEY,
description VARCHAR(128)
);
-- Implemented transmission operational types
DROP TABLE IF EXISTS mod_tx_operational_types;
CREATE TABLE mod_tx_operational_types
(
operational_type VARCHAR(32) PRIMARY KEY,
description VARCHAR(128)
);
-- Implemented transmission capacity types
DROP TABLE IF EXISTS mod_tx_capacity_types;
CREATE TABLE mod_tx_capacity_types
(
capacity_type VARCHAR(32) PRIMARY KEY,
description VARCHAR(128)
);
-- Implemented transmission availability types
DROP TABLE IF EXISTS mod_tx_availability_types;
CREATE TABLE mod_tx_availability_types
(
availability_type VARCHAR(32) PRIMARY KEY,
description VARCHAR(128)
);
-- Implemented prm types
DROP TABLE IF EXISTS mod_prm_types;
CREATE TABLE mod_prm_types
(
prm_type VARCHAR(32) PRIMARY KEY,
description VARCHAR(128)
);
-- Invalid combinations of capacity type and operational type
DROP TABLE IF EXISTS mod_capacity_and_operational_type_invalid_combos;
CREATE TABLE mod_capacity_and_operational_type_invalid_combos
(
capacity_type VARCHAR(32),
operational_type VARCHAR(32),
PRIMARY KEY (capacity_type, operational_type),
FOREIGN KEY (capacity_type) REFERENCES mod_capacity_types (capacity_type),
FOREIGN KEY (operational_type) REFERENCES mod_operational_types
(operational_type)
);
-- Invalid combinations of tx capacity type and tx operational type
DROP TABLE IF EXISTS mod_tx_capacity_and_tx_operational_type_invalid_combos;
CREATE TABLE mod_tx_capacity_and_tx_operational_type_invalid_combos
(
capacity_type VARCHAR(32),
operational_type VARCHAR(32),
PRIMARY KEY (capacity_type, operational_type),
FOREIGN KEY (capacity_type) REFERENCES mod_tx_capacity_types (capacity_type),
FOREIGN KEY (operational_type) REFERENCES mod_tx_operational_types
(operational_type)
);
DROP TABLE IF EXISTS mod_feature_subscenarios;
CREATE TABLE mod_feature_subscenarios
(
feature VARCHAR(32),
subscenario_id VARCHAR(32),
PRIMARY KEY (feature, subscenario_id),
FOREIGN KEY (feature) REFERENCES mod_features (feature)
);
-- Features
DROP TABLE IF EXISTS mod_features;
CREATE TABLE mod_features
(
feature VARCHAR(32) PRIMARY KEY,
description VARCHAR(128)
);
-- Scenario validation status types
DROP TABLE IF EXISTS mod_validation_status_types;
CREATE TABLE mod_validation_status_types
(
validation_status_id INTEGER PRIMARY KEY,
validation_status_name VARCHAR(32) UNIQUE
);
-- Units of measurements and their abbreviations
-- Core units will be populated with defaults but can be changed by the user
-- Secondary units are derived from the core units
DROP TABLE IF EXISTS mod_units;
CREATE TABLE mod_units
(
metric VARCHAR(32) PRIMARY KEY,
type VARCHAR(32), -- 'core' or 'secondary'
numerator_core_units VARCHAR(32),
denominator_core_units VARCHAR(32),
unit VARCHAR(32), -- this will be derived for secondary units
description VARCHAR(128)
);
-- Run status types
DROP TABLE IF EXISTS mod_run_status_types;
CREATE TABLE mod_run_status_types
(
run_status_id INTEGER PRIMARY KEY,
run_status_name VARCHAR(32) UNIQUE
);
--------------------
-- -- STATUS -- --
--------------------
-- Validation Results
DROP TABLE IF EXISTS status_validation;
CREATE TABLE status_validation
(
scenario_id INTEGER,
subproblem_id INTEGER,
stage_id INTEGER,
gridpath_module VARCHAR(64),
db_table VARCHAR(64),
severity VARCHAR(32),
description VARCHAR(64),
time_stamp TEXT, -- ISO8601 String
FOREIGN KEY (scenario_id) REFERENCES scenarios (scenario_id)
);
-- Scenario results: objective function, solver status
DROP TABLE IF EXISTS results_scenario;
CREATE TABLE results_scenario
(
scenario_id INTEGER,
weather_iteration INTEGER,
hydro_iteration INTEGER,
availability_iteration INTEGER,
subproblem_id INTEGER,
stage_id INTEGER,
objective_function_value FLOAT,
solver_termination_condition VARCHAR(128),
PRIMARY KEY (scenario_id, weather_iteration, hydro_iteration,
availability_iteration, subproblem_id,
stage_id),
FOREIGN KEY (scenario_id) REFERENCES scenarios (scenario_id)
);
-------------------------------------------------------------------------------
---- SUBSCENARIOS AND INPUTS -----
-------------------------------------------------------------------------------
--------------------
-- -- TEMPORAL -- --
--------------------
-- Temporal Scenarios
DROP TABLE IF EXISTS subscenarios_temporal;
CREATE TABLE subscenarios_temporal
(
temporal_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
-- Weather, hydro, and availability iterations
DROP TABLE IF EXISTS inputs_temporal_iterations;
CREATE TABLE inputs_temporal_iterations
(
temporal_scenario_id INTEGER,
weather_iteration INTEGER NOT NULL,
hydro_iteration INTEGER NOT NULL,
availability_iteration INTEGER NOT NULL,
PRIMARY KEY (temporal_scenario_id, weather_iteration, hydro_iteration,
availability_iteration,
availability_iteration),
FOREIGN KEY (temporal_scenario_id) REFERENCES subscenarios_temporal
(temporal_scenario_id)
);
-- Subproblems
DROP TABLE IF EXISTS inputs_temporal_subproblems;
CREATE TABLE inputs_temporal_subproblems
(
temporal_scenario_id INTEGER,
subproblem_id INTEGER NOT NULL,
PRIMARY KEY (temporal_scenario_id, subproblem_id),
FOREIGN KEY (temporal_scenario_id) REFERENCES subscenarios_temporal
(temporal_scenario_id)
);
-- Stages (within subproblems)
DROP TABLE IF EXISTS inputs_temporal_subproblems_stages;
CREATE TABLE inputs_temporal_subproblems_stages
(
temporal_scenario_id INTEGER,
subproblem_id INTEGER NOT NULL,
stage_id INTEGER NOT NULL,
PRIMARY KEY (temporal_scenario_id, subproblem_id, stage_id),
FOREIGN KEY (temporal_scenario_id) REFERENCES subscenarios_temporal
(temporal_scenario_id),
-- Make sure subproblem exists in this temporal_scenario_id
FOREIGN KEY (temporal_scenario_id, subproblem_id) REFERENCES
inputs_temporal_subproblems (temporal_scenario_id, subproblem_id)
);
-- Periods
-- These have to be the same for each subproblem
DROP TABLE IF EXISTS inputs_temporal_periods;
CREATE TABLE inputs_temporal_periods
(
temporal_scenario_id INTEGER,
period INTEGER,
discount_factor FLOAT,
period_start_year FLOAT,
period_end_year FLOAT, -- exclusive, i.e. if 2030, last day is 2029-12-31
prev_period INTEGER,
PRIMARY KEY (temporal_scenario_id, period),
FOREIGN KEY (temporal_scenario_id) REFERENCES subscenarios_temporal
(temporal_scenario_id)
);
-- Superperiods (combinations of periods)
DROP TABLE IF EXISTS inputs_temporal_superperiods;
CREATE TABLE inputs_temporal_superperiods
(
temporal_scenario_id INTEGER,
superperiod INTEGER,
period INTEGER,
PRIMARY KEY (temporal_scenario_id, superperiod, period),
FOREIGN KEY (temporal_scenario_id) REFERENCES subscenarios_temporal
(temporal_scenario_id)
);
-- Timepoints
-- Note on linked timepoints: the user can designate timepoints from the last
-- horizon of the subproblem to be linked to the first horizon of the next
-- subproblem -- it is up to the user to ensure that only the last horizon
-- of a subproblem and the first horizon of the next subproblem are linked
-- like this
-- Linked timepoints should be non-positive integers, ordered, and the most
-- recent linked timepoint should be 0, i.e. the linked timepoint indexed 0
-- will be the previous timepoint for the first timepoint of the first
-- horizon of the next subproblem. The previous timepoint for linked
-- timepoint 0 will be -1, and so on.
-- If linked timepoints are specified for a subproblem, GP will use those as
-- the previous timepoints for the first horizon of the next subproblem
-- (subproblem_id + 1) BUT ONLY IF the first horizon of the next subproblem has
-- a 'linked' boundary
-- The spinup_or_lookahead is not NULL, as we rely on 0s downstream
-- There is a unique key on timepoint/spinup_or_lookahead, as some functionality
-- requires unique timepoint IDs, but we want to allow for the same
-- timepoint IDs to be duplicated if they are spinup/lookahead timepoints
DROP TABLE IF EXISTS inputs_temporal;
CREATE TABLE inputs_temporal
(
temporal_scenario_id INTEGER,
subproblem_id INTEGER NOT NULL,
stage_id INTEGER NOT NULL,
timepoint INTEGER NOT NULL,
period INTEGER NOT NULL,
number_of_hours_in_timepoint INTEGER NOT NULL,
timepoint_weight FLOAT NOT NULL,
previous_stage_timepoint_map INTEGER,
spinup_or_lookahead INTEGER NOT NULL,
linked_timepoint INTEGER, -- should be non-positive
year INTEGER,
month INTEGER,
day_of_month INTEGER,
hour_of_day FLOAT, -- FLOAT to accommodate subhourly timepoints
timestamp DATETIME,
PRIMARY KEY (temporal_scenario_id, subproblem_id, stage_id, timepoint),
UNIQUE (temporal_scenario_id, stage_id, timepoint, spinup_or_lookahead),
FOREIGN KEY (temporal_scenario_id) REFERENCES subscenarios_temporal
(temporal_scenario_id),
-- Make sure period exists in this temporal_scenario_id
FOREIGN KEY (temporal_scenario_id, period)
REFERENCES inputs_temporal_periods (temporal_scenario_id, period),
-- Month must be 1-12
FOREIGN KEY (month) REFERENCES mod_months (month)
);
-- Horizons (with balancing types)
-- How timepoints are organized for operational-decision purposes
-- Each timepoint can belong to more than one balancing_type-horizon (e.g.
-- it can be on day 1 of the year, in week 1 of the year, in month 1 of the
-- year, etc.)
-- The balancing_type-horizons can be different by subproblem (e.g. one
-- subproblem can be a week and have days as horizons and another one
-- can be a week and have the week as horizon), but will have to be same for
-- each stage of a subproblem
-- Balancing_type-horizons within
DROP TABLE IF EXISTS inputs_temporal_horizons;
CREATE TABLE inputs_temporal_horizons
(
temporal_scenario_id INTEGER NOT NULL,
balancing_type_horizon VARCHAR(32) NOT NULL,
horizon INTEGER NOT NULL,
boundary VARCHAR(16) NOT NULL,
PRIMARY KEY (temporal_scenario_id, balancing_type_horizon, horizon),
FOREIGN KEY (temporal_scenario_id) REFERENCES subscenarios_temporal
(temporal_scenario_id),
-- Make sure boundary type is correct
FOREIGN KEY (boundary) REFERENCES mod_horizon_boundary_types
(horizon_boundary_type)
);
-- This table is auxiliary for 1) readability and 2) populating the
-- inputs_temporal_horizon_timepoints table if we're using the CSV-to-DB
-- functionality
DROP TABLE IF EXISTS inputs_temporal_horizon_timepoints_start_end;
CREATE TABLE inputs_temporal_horizon_timepoints_start_end
(
temporal_scenario_id INTEGER NOT NULL,
stage_id INTEGER NOT NULL,
balancing_type_horizon VARCHAR(32) NOT NULL,
horizon INTEGER NOT NULL,
tmp_start INTEGER NOT NULL,
tmp_start_spinup_or_lookahead INTEGER NOT NULL DEFAULT 0,
tmp_end INTEGER NOT NULL,
tmp_end_spinup_or_lookahead INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (temporal_scenario_id, stage_id, balancing_type_horizon,
horizon, tmp_start, tmp_start_spinup_or_lookahead,
tmp_end, tmp_end_spinup_or_lookahead),
FOREIGN KEY (temporal_scenario_id) REFERENCES subscenarios_temporal
(temporal_scenario_id),
-- Make sure we have the right balancing_type-horizons
FOREIGN KEY (temporal_scenario_id, balancing_type_horizon, horizon)
REFERENCES inputs_temporal_horizons (temporal_scenario_id,
balancing_type_horizon, horizon),
-- Make sure the start and end timepoints exist in the main timepoints table
FOREIGN KEY (temporal_scenario_id, stage_id, tmp_start,
tmp_start_spinup_or_lookahead)
REFERENCES inputs_temporal (temporal_scenario_id, stage_id, timepoint,
spinup_or_lookahead),
FOREIGN KEY (temporal_scenario_id, stage_id, tmp_end,
tmp_end_spinup_or_lookahead)
REFERENCES inputs_temporal (temporal_scenario_id, stage_id, timepoint,
spinup_or_lookahead)
);
-- This table is what GridPath uses to get inputs
DROP TABLE IF EXISTS inputs_temporal_horizon_timepoints;
CREATE TABLE inputs_temporal_horizon_timepoints
(
temporal_scenario_id INTEGER NOT NULL,
subproblem_id INTEGER NOT NULL,
stage_id INTEGER NOT NULL,
timepoint INTEGER NOT NULL,
balancing_type_horizon VARCHAR(32) NOT NULL,
horizon INTEGER NOT NULL,
PRIMARY KEY (temporal_scenario_id, subproblem_id, stage_id, timepoint,
balancing_type_horizon, horizon),
FOREIGN KEY (temporal_scenario_id)
REFERENCES subscenarios_temporal (temporal_scenario_id),
-- Make sure these are the same timepoints as in the main timepoints table
FOREIGN KEY (temporal_scenario_id, subproblem_id, stage_id, timepoint)
REFERENCES inputs_temporal (temporal_scenario_id,
subproblem_id, stage_id, timepoint),
-- Make sure horizons exist in this temporal_scenario_id and subproblem_id
FOREIGN KEY (temporal_scenario_id, balancing_type_horizon, horizon)
REFERENCES inputs_temporal_horizons (temporal_scenario_id,
balancing_type_horizon, horizon)
);
---------------------
-- -- GEOGRAPHY -- --
---------------------
-- Load zones
-- This is the unit at which load is met in the model
-- This table defines the load zone "portfolio"
DROP TABLE IF EXISTS subscenarios_geography_load_zones;
CREATE TABLE subscenarios_geography_load_zones
(
load_zone_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_load_zones;
CREATE TABLE inputs_geography_load_zones
(
load_zone_scenario_id INTEGER,
load_zone VARCHAR(32),
PRIMARY KEY (load_zone_scenario_id, load_zone),
FOREIGN KEY (load_zone_scenario_id) REFERENCES
subscenarios_geography_load_zones (load_zone_scenario_id)
);
-- Load balance
-- This table defines various load balance parameters for each load zone (e.g.,
-- if unserved energy is allowed, at what cost, etc.)
DROP TABLE IF EXISTS subscenarios_geography_load_balance;
CREATE TABLE subscenarios_geography_load_balance
(
load_balance_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_load_balance;
CREATE TABLE inputs_geography_load_balance
(
load_balance_scenario_id INTEGER,
load_zone VARCHAR(32),
allow_overgeneration INTEGER,
overgeneration_penalty_per_mw FLOAT,
allow_unserved_energy INTEGER,
unserved_energy_penalty_per_mwh FLOAT,
unserved_energy_limit_mwh FLOAT, -- limit on the total USE
max_unserved_load_penalty_per_mw FLOAT,
max_unserved_load_limit_mw FLOAT, -- limit on the max unserved load
export_penalty_cost_per_mwh FLOAT,
unserved_energy_stats_threshold_mw FLOAT, -- defaults to 0
PRIMARY KEY (load_balance_scenario_id, load_zone),
FOREIGN KEY (load_balance_scenario_id) REFERENCES
subscenarios_geography_load_balance (load_balance_scenario_id)
);
-- Reserves
-- This is the unit at which reserves are met at the model; it can be
-- different from the load zones
DROP TABLE IF EXISTS subscenarios_geography_lf_reserves_up_bas;
CREATE TABLE subscenarios_geography_lf_reserves_up_bas
(
lf_reserves_up_ba_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_lf_reserves_up_bas;
CREATE TABLE inputs_geography_lf_reserves_up_bas
(
lf_reserves_up_ba_scenario_id INTEGER,
lf_reserves_up_ba VARCHAR(32),
allow_violation INTEGER,
violation_penalty_per_mw FLOAT,
reserve_to_energy_adjustment FLOAT,
PRIMARY KEY (lf_reserves_up_ba_scenario_id, lf_reserves_up_ba),
FOREIGN KEY (lf_reserves_up_ba_scenario_id) REFERENCES
subscenarios_geography_lf_reserves_up_bas (lf_reserves_up_ba_scenario_id)
);
DROP TABLE IF EXISTS subscenarios_geography_lf_reserves_down_bas;
CREATE TABLE subscenarios_geography_lf_reserves_down_bas
(
lf_reserves_down_ba_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_lf_reserves_down_bas;
CREATE TABLE inputs_geography_lf_reserves_down_bas
(
lf_reserves_down_ba_scenario_id INTEGER,
lf_reserves_down_ba VARCHAR(32),
allow_violation INTEGER,
violation_penalty_per_mw FLOAT,
reserve_to_energy_adjustment FLOAT,
PRIMARY KEY (lf_reserves_down_ba_scenario_id, lf_reserves_down_ba),
FOREIGN KEY (lf_reserves_down_ba_scenario_id) REFERENCES
subscenarios_geography_lf_reserves_down_bas (lf_reserves_down_ba_scenario_id)
);
DROP TABLE IF EXISTS subscenarios_geography_regulation_up_bas;
CREATE TABLE subscenarios_geography_regulation_up_bas
(
regulation_up_ba_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_regulation_up_bas;
CREATE TABLE inputs_geography_regulation_up_bas
(
regulation_up_ba_scenario_id INTEGER,
regulation_up_ba VARCHAR(32),
allow_violation INTEGER,
violation_penalty_per_mw FLOAT,
reserve_to_energy_adjustment FLOAT,
PRIMARY KEY (regulation_up_ba_scenario_id, regulation_up_ba),
FOREIGN KEY (regulation_up_ba_scenario_id) REFERENCES
subscenarios_geography_regulation_up_bas (regulation_up_ba_scenario_id)
);
DROP TABLE IF EXISTS subscenarios_geography_regulation_down_bas;
CREATE TABLE subscenarios_geography_regulation_down_bas
(
regulation_down_ba_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_regulation_down_bas;
CREATE TABLE inputs_geography_regulation_down_bas
(
regulation_down_ba_scenario_id INTEGER,
regulation_down_ba VARCHAR(32),
allow_violation INTEGER,
violation_penalty_per_mw FLOAT,
reserve_to_energy_adjustment FLOAT,
PRIMARY KEY (regulation_down_ba_scenario_id, regulation_down_ba),
FOREIGN KEY (regulation_down_ba_scenario_id) REFERENCES
subscenarios_geography_regulation_down_bas (regulation_down_ba_scenario_id)
);
DROP TABLE IF EXISTS subscenarios_geography_frequency_response_bas;
CREATE TABLE subscenarios_geography_frequency_response_bas
(
frequency_response_ba_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_frequency_response_bas;
CREATE TABLE inputs_geography_frequency_response_bas
(
frequency_response_ba_scenario_id INTEGER,
frequency_response_ba VARCHAR(32),
allow_violation INTEGER,
violation_penalty_per_mw FLOAT,
reserve_to_energy_adjustment FLOAT,
PRIMARY KEY (frequency_response_ba_scenario_id, frequency_response_ba),
FOREIGN KEY (frequency_response_ba_scenario_id) REFERENCES
subscenarios_geography_frequency_response_bas
(frequency_response_ba_scenario_id)
);
DROP TABLE IF EXISTS subscenarios_geography_spinning_reserves_bas;
CREATE TABLE subscenarios_geography_spinning_reserves_bas
(
spinning_reserves_ba_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_spinning_reserves_bas;
CREATE TABLE inputs_geography_spinning_reserves_bas
(
spinning_reserves_ba_scenario_id INTEGER,
spinning_reserves_ba VARCHAR(32),
allow_violation INTEGER,
violation_penalty_per_mw FLOAT,
reserve_to_energy_adjustment FLOAT,
PRIMARY KEY (spinning_reserves_ba_scenario_id, spinning_reserves_ba),
FOREIGN KEY (spinning_reserves_ba_scenario_id) REFERENCES
subscenarios_geography_spinning_reserves_bas (spinning_reserves_ba_scenario_id)
);
DROP TABLE IF EXISTS subscenarios_geography_inertia_reserves_bas;
CREATE TABLE subscenarios_geography_inertia_reserves_bas
(
inertia_reserves_ba_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_inertia_reserves_bas;
CREATE TABLE inputs_geography_inertia_reserves_bas
(
inertia_reserves_ba_scenario_id INTEGER,
inertia_reserves_ba VARCHAR(32),
allow_violation INTEGER,
violation_penalty_per_mws FLOAT,
PRIMARY KEY (inertia_reserves_ba_scenario_id, inertia_reserves_ba),
FOREIGN KEY (inertia_reserves_ba_scenario_id) REFERENCES
subscenarios_geography_inertia_reserves_bas (inertia_reserves_ba_scenario_id)
);
-- Energy target
-- This is the unit at which energy target requirements are met in the model; it can be
-- different from the load zones
DROP TABLE IF EXISTS subscenarios_geography_energy_target_zones;
CREATE TABLE subscenarios_geography_energy_target_zones
(
energy_target_zone_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_energy_target_zones;
CREATE TABLE inputs_geography_energy_target_zones
(
energy_target_zone_scenario_id INTEGER,
energy_target_zone VARCHAR(32),
allow_violation INTEGER DEFAULT 0, -- constraint is hard by default
violation_penalty_per_mwh FLOAT DEFAULT 0,
PRIMARY KEY (energy_target_zone_scenario_id, energy_target_zone),
FOREIGN KEY (energy_target_zone_scenario_id) REFERENCES
subscenarios_geography_energy_target_zones (energy_target_zone_scenario_id)
);
-- Instantaneous penetration
DROP TABLE IF EXISTS subscenarios_geography_instantaneous_penetration_zones;
CREATE TABLE subscenarios_geography_instantaneous_penetration_zones
(
instantaneous_penetration_zone_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_instantaneous_penetration_zones;
CREATE TABLE inputs_geography_instantaneous_penetration_zones
(
instantaneous_penetration_zone_scenario_id INTEGER,
instantaneous_penetration_zone VARCHAR(32),
allow_violation_min_penetration INTEGER DEFAULT 0, -- constraint is hard by default
violation_penalty_min_penetration_per_mwh FLOAT DEFAULT 0,
allow_violation_max_penetration INTEGER DEFAULT 0, -- constraint is hard by default
violation_penalty_max_penetration_per_mwh FLOAT DEFAULT 0,
PRIMARY KEY (instantaneous_penetration_zone_scenario_id,
instantaneous_penetration_zone),
FOREIGN KEY (instantaneous_penetration_zone_scenario_id) REFERENCES
subscenarios_geography_instantaneous_penetration_zones (instantaneous_penetration_zone_scenario_id)
);
-- Transmission target
-- This is the unit at which transmission target requirements are met in the model; it can be
-- different from the load zones
DROP TABLE IF EXISTS subscenarios_geography_transmission_target_zones;
CREATE TABLE subscenarios_geography_transmission_target_zones
(
transmission_target_zone_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_transmission_target_zones;
CREATE TABLE inputs_geography_transmission_target_zones
(
transmission_target_zone_scenario_id INTEGER,
transmission_target_zone VARCHAR(32),
allow_violation INTEGER DEFAULT 0, -- constraint is hard by default
violation_penalty_per_mwh FLOAT DEFAULT 0,
PRIMARY KEY (transmission_target_zone_scenario_id,
transmission_target_zone),
FOREIGN KEY (transmission_target_zone_scenario_id) REFERENCES
subscenarios_geography_transmission_target_zones (transmission_target_zone_scenario_id)
);
-- Carbon cap
-- This is the unit at which the carbon cap is applied in the model; it can be
-- different from the load zones
DROP TABLE IF EXISTS subscenarios_geography_carbon_cap_zones;
CREATE TABLE subscenarios_geography_carbon_cap_zones
(
carbon_cap_zone_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_carbon_cap_zones;
CREATE TABLE inputs_geography_carbon_cap_zones
(
carbon_cap_zone_scenario_id INTEGER,
carbon_cap_zone VARCHAR(32),
allow_violation INTEGER DEFAULT 0, -- constraint is hard by default
violation_penalty_per_emission FLOAT DEFAULT 0,
PRIMARY KEY (carbon_cap_zone_scenario_id, carbon_cap_zone),
FOREIGN KEY (carbon_cap_zone_scenario_id) REFERENCES
subscenarios_geography_carbon_cap_zones (carbon_cap_zone_scenario_id)
);
-- Carbon tax
-- This is the unit at which the carbon tax is applied in the model; it can be
-- different from the load zones
DROP TABLE IF EXISTS subscenarios_geography_carbon_tax_zones;
CREATE TABLE subscenarios_geography_carbon_tax_zones
(
carbon_tax_zone_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_carbon_tax_zones;
CREATE TABLE inputs_geography_carbon_tax_zones
(
carbon_tax_zone_scenario_id INTEGER,
carbon_tax_zone VARCHAR(32),
PRIMARY KEY (carbon_tax_zone_scenario_id, carbon_tax_zone),
FOREIGN KEY (carbon_tax_zone_scenario_id) REFERENCES
subscenarios_geography_carbon_tax_zones (carbon_tax_zone_scenario_id)
);
-- Performance standard
-- This is the unit at which the performance standard is applied in the model; it can be
-- different from the load zones
DROP TABLE IF EXISTS subscenarios_geography_performance_standard_zones;
CREATE TABLE subscenarios_geography_performance_standard_zones
(
performance_standard_zone_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_performance_standard_zones;
CREATE TABLE inputs_geography_performance_standard_zones
(
performance_standard_zone_scenario_id INTEGER,
performance_standard_zone VARCHAR(32),
energy_allow_violation INTEGER DEFAULT 0, -- constraint is hard by default
energy_violation_penalty_per_emission FLOAT DEFAULT 0,
power_allow_violation INTEGER DEFAULT 0, -- constraint is hard by default
power_violation_penalty_per_emission FLOAT DEFAULT 0,
PRIMARY KEY (performance_standard_zone_scenario_id,
performance_standard_zone),
FOREIGN KEY (performance_standard_zone_scenario_id) REFERENCES
subscenarios_geography_performance_standard_zones (performance_standard_zone_scenario_id)
);
-- Carbon credits
-- This is the unit at which the carbon credits are traded; it can be different
-- from the load zones
DROP TABLE IF EXISTS subscenarios_geography_carbon_credits_zones;
CREATE TABLE subscenarios_geography_carbon_credits_zones
(
carbon_credits_zone_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_carbon_credits_zones;
CREATE TABLE inputs_geography_carbon_credits_zones
(
carbon_credits_zone_scenario_id INTEGER,
carbon_credits_zone VARCHAR(32),
PRIMARY KEY (carbon_credits_zone_scenario_id, carbon_credits_zone),
FOREIGN KEY (carbon_credits_zone_scenario_id) REFERENCES
subscenarios_geography_carbon_credits_zones (carbon_credits_zone_scenario_id)
);
-- Carbon cap zone <--> carbon credit zone mapping
DROP TABLE IF EXISTS subscenarios_system_carbon_cap_zones_carbon_credits_zones;
CREATE TABLE subscenarios_system_carbon_cap_zones_carbon_credits_zones
(
carbon_cap_zones_carbon_credits_zones_scenario_id INTEGER PRIMARY KEY
AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_system_carbon_cap_zones_carbon_credits_zones;
CREATE TABLE inputs_system_carbon_cap_zones_carbon_credits_zones
(
carbon_cap_zones_carbon_credits_zones_scenario_id INTEGER,
carbon_cap_zone VARCHAR(32),
carbon_credits_zone VARCHAR(32),
PRIMARY KEY (carbon_cap_zones_carbon_credits_zones_scenario_id,
carbon_cap_zone, carbon_credits_zone),
FOREIGN KEY (carbon_cap_zones_carbon_credits_zones_scenario_id) REFERENCES
subscenarios_system_carbon_cap_zones_carbon_credits_zones
(carbon_cap_zones_carbon_credits_zones_scenario_id)
);
-- Performance standard zone <--> carbon credit zone mapping
DROP TABLE IF EXISTS subscenarios_system_performance_standard_zones_carbon_credits_zones;
CREATE TABLE subscenarios_system_performance_standard_zones_carbon_credits_zones
(
performance_standard_zones_carbon_credits_zones_scenario_id INTEGER PRIMARY KEY
AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_system_performance_standard_zones_carbon_credits_zones;
CREATE TABLE inputs_system_performance_standard_zones_carbon_credits_zones
(
performance_standard_zones_carbon_credits_zones_scenario_id INTEGER,
performance_standard_zone VARCHAR(32),
carbon_credits_zone VARCHAR(32),
PRIMARY KEY (performance_standard_zones_carbon_credits_zones_scenario_id,
performance_standard_zone, carbon_credits_zone),
FOREIGN KEY (performance_standard_zones_carbon_credits_zones_scenario_id) REFERENCES
subscenarios_system_performance_standard_zones_carbon_credits_zones
(performance_standard_zones_carbon_credits_zones_scenario_id)
);
-- Carbon tax zone <--> carbon credit zone mapping
DROP TABLE IF EXISTS subscenarios_system_carbon_tax_zones_carbon_credits_zones;
CREATE TABLE subscenarios_system_carbon_tax_zones_carbon_credits_zones
(
carbon_tax_zones_carbon_credits_zones_scenario_id INTEGER PRIMARY KEY
AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_system_carbon_tax_zones_carbon_credits_zones;
CREATE TABLE inputs_system_carbon_tax_zones_carbon_credits_zones
(
carbon_tax_zones_carbon_credits_zones_scenario_id INTEGER,
carbon_tax_zone VARCHAR(32),
carbon_credits_zone VARCHAR(32),
PRIMARY KEY (carbon_tax_zones_carbon_credits_zones_scenario_id,
carbon_tax_zone, carbon_credits_zone),
FOREIGN KEY (carbon_tax_zones_carbon_credits_zones_scenario_id) REFERENCES
subscenarios_system_carbon_tax_zones_carbon_credits_zones
(carbon_tax_zones_carbon_credits_zones_scenario_id)
);
-- Carbon credit prices (price at which can sell to other sectors)
DROP TABLE IF EXISTS subscenarios_system_carbon_credits_params;
CREATE TABLE subscenarios_system_carbon_credits_params
(
carbon_credits_params_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_system_carbon_credits_params;
CREATE TABLE inputs_system_carbon_credits_params
(
carbon_credits_params_scenario_id INTEGER,
carbon_credits_zone VARCHAR(32),
period INTEGER,
allow_carbon_credits_infinite_demand INTEGER DEFAULT 0, -- constraint is hard by default
carbon_credits_demand_tco2 FLOAT,
carbon_credits_demand_price FLOAT,
allow_carbon_credits_infinite_supply INTEGER DEFAULT 0, -- constraint is hard by default
carbon_credits_supply_tco2 FLOAT,
carbon_credits_supply_price FLOAT,
PRIMARY KEY (carbon_credits_params_scenario_id, carbon_credits_zone,
period),
FOREIGN KEY (carbon_credits_params_scenario_id) REFERENCES
subscenarios_system_carbon_credits_params (carbon_credits_params_scenario_id)
);
-- Generic policy
-- TODO: add a generic policy list subscenario
-- This is the unit at which the policy is applied in the model
DROP TABLE IF EXISTS subscenarios_geography_policy_zones;
CREATE TABLE subscenarios_geography_policy_zones
(
policy_zone_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_policy_zones;
CREATE TABLE inputs_geography_policy_zones
(
policy_zone_scenario_id INTEGER,
policy_name TEXT,
policy_zone TEXT,
allow_violation INTEGER DEFAULT 0, -- constraint is hard by default
violation_penalty_per_unit FLOAT DEFAULT 0,
PRIMARY KEY (policy_zone_scenario_id, policy_name, policy_zone),
FOREIGN KEY (policy_zone_scenario_id) REFERENCES
subscenarios_geography_policy_zones (policy_zone_scenario_id)
);
-- PRM
-- This is the unit at which PRM requirements are met in the model; it can be
-- different from the load zones
DROP TABLE IF EXISTS subscenarios_geography_prm_zones;
CREATE TABLE subscenarios_geography_prm_zones
(
prm_zone_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_prm_zones;
CREATE TABLE inputs_geography_prm_zones
(
prm_zone_scenario_id INTEGER,
prm_zone VARCHAR(32),
allow_violation INTEGER DEFAULT 0, -- constraint is hard by default
violation_penalty_per_mw FLOAT DEFAULT 0,
PRIMARY KEY (prm_zone_scenario_id, prm_zone),
FOREIGN KEY (prm_zone_scenario_id) REFERENCES
subscenarios_geography_prm_zones (prm_zone_scenario_id)
);
-- Local capacity
-- This is the unit at which local capacity requirements are met in the model;
-- it can be different from the load zones
DROP TABLE IF EXISTS subscenarios_geography_local_capacity_zones;
CREATE TABLE subscenarios_geography_local_capacity_zones
(
local_capacity_zone_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_local_capacity_zones;
CREATE TABLE inputs_geography_local_capacity_zones
(
local_capacity_zone_scenario_id INTEGER,
local_capacity_zone VARCHAR(32),
allow_violation INTEGER DEFAULT 0, -- constraint is hard by default
violation_penalty_per_mw FLOAT DEFAULT 0,
PRIMARY KEY (local_capacity_zone_scenario_id, local_capacity_zone),
FOREIGN KEY (local_capacity_zone_scenario_id) REFERENCES
subscenarios_geography_local_capacity_zones (local_capacity_zone_scenario_id)
);
-- Market hubs
-- This is the unit at which prices are specified in the model;
-- it can be different from the load zones
DROP TABLE IF EXISTS subscenarios_geography_markets;
CREATE TABLE subscenarios_geography_markets
(
market_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_geography_markets;
CREATE TABLE inputs_geography_markets
(
market_scenario_id INTEGER,
market VARCHAR(32),
PRIMARY KEY (market_scenario_id, market),
FOREIGN KEY (market_scenario_id) REFERENCES
subscenarios_geography_markets (market_scenario_id)
);
DROP TABLE IF EXISTS subscenarios_market_prices;
CREATE TABLE subscenarios_market_prices
(
market_price_scenario_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(32),
description VARCHAR(128)
);
DROP TABLE IF EXISTS inputs_market_prices;