-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSA-June2024.Rmd
171 lines (152 loc) · 8.77 KB
/
SA-June2024.Rmd
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
---
title: "SA-June2024"
author: "GeoffRussell"
date: "2024-12-04"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
dopng<-function(name,p,w=2200,h=1300) {
png(name,width=w,height=h,units="px",res=300,type="cairo-png")
print(p)
dev.off()
}
comma<-function(x) prettyNum(signif(x,digits=3),big.mark=",")
scaleRight<-100/4000
dir<-"~/ARTICLES/STATS/MasteringShiny/SouthAustralianPower/SouthAustralianElectricity/"
```
## Data
```{r data}
df<-read_csv("dfsum-nobl-BATT11,400MW-FAC2-June2024.csv")
dfbl<-read_csv("dfsum-BL1200MW-BATT11,400MW-FAC2-June2024.csv")
dfbl600<-read_csv("dfsum-BL600MW-BATT11,400MW-FAC2-June2024.csv")
```
```{r}
p<-df |> filter(day(Time)<10) |> ggplot() +
geom_line(aes(x=Time,y=demand),color="black")+
geom_line(aes(x=Time,y=renew),color="green")+
annotate('text',x=ymd_hms("2024-06-04 00:00:00"),y=2500,label="Demand",hjust=0,color="black")+
annotate('text',x=ymd_hms("2024-06-06 00:00:00"),y=0,label="Wind+Solar",hjust=0,color="green",vjust=0)+
labs(x="",y="Demand (megawatts)",title="South Australia, beginning of June 2024")
p
dopng("June24-base.png",p)
p<-df |> filter(day(Time)<10) |> ggplot() +
geom_line(aes(x=Time,y=demand),color="black")+
geom_line(aes(x=Time,y=dblrenew),color="green")+
annotate('text',x=ymd_hms("2024-06-04 00:00:00"),y=2500,label="Demand",hjust=0,color="black")+
annotate('text',x=ymd_hms("2024-06-05 12:00:00"),y=0,label="Double the 2024 wind+solar",hjust=0,color="green",vjust=0)+
labs(x="",y="Demand (megawatts)",title="South Australia, beginning of June 2024,\nbut with double the wind and solar")
p
dopng("June24-doublebase.png",p)
```
```{r}
cumShort<-as.numeric(df |> filter(day(Time)<10) |> summarise(s=sum(shortFall)))
p<-df |> filter(day(Time)<10) |> ggplot() +
geom_col(aes(x=Time,y=shortFall*12),color="grey80")+
geom_line(aes(x=Time,y=demand),color="black")+
# geom_line(aes(x=Time,y=renew),color="green",linetype=3)+
geom_line(aes(x=Time,y=dblrenew),color="green")+
geom_line(aes(x=Time,y=batteryStatus/11380*4000),color="red",linetype=4)+
annotate('text',x=ymd_hms("2024-06-07 00:00:00"),y=2300,label="Demand",hjust=0,color="black")+
annotate('text',x=ymd_hms("2024-06-05 18:00:00"),y=3500,label="Double the 2024 wind+solar",hjust=0,color="green",vjust=0)+
annotate('text',x=ymd_hms("2024-06-07 12:00:00"),y=500,label="Blackouts (unmet demand)",hjust=0.5,color="grey40",vjust=0)+
scale_y_continuous(sec.axis=sec_axis(~.*scaleRight,breaks=seq(0,100,10),name="battery charge (%)"))+
labs(x="",y="Demand (megawatts)",title="South Australia, June 2024, with double the wind and solar\nAND 11.4 gigaWatt-hours of big batteries\n(over 20 times the current battery level) ")+
annotate('text',x=ymd_hms("2024-06-05 00:00:00"),y=4500,label=paste0("Cumulative shortfall: ",comma(cumShort/1000)," gigaWatt hours"),hjust=0)+
theme(axis.ticks.y.right = element_line(color = "red"),
axis.text.y.right = element_text(color = "red"),
axis.title.y.right = element_text(color = "red"))
p
dopng("June24-base-batteries.png",p)
```
```{r}
doplot<-function(file,bl,batt,ofac) {
df<-read_csv(paste0(dir,file))
cumShort<-as.numeric(df |> filter(day(Time)<10) |> summarise(s=sum(shortFall)))
gwb<-paste0(comma(batt/1000),"GW")
p<-df |> filter(day(Time)<10) |> ggplot() +
geom_col(aes(x=Time,y=shortFall*12),color="grey80")+
geom_line(aes(x=Time,y=demand),color="black")+
# geom_line(aes(x=Time,y=renew),color="green",linetype=3)+
geom_line(aes(x=Time,y=dblrenew),color="green")+
geom_line(aes(x=Time,y=batteryStatus/batt*4000),color="red",linetype=4)+
annotate('text',x=ymd_hms("2024-06-07 00:00:00"),y=2300,label="Demand",hjust=0,color="black")+
annotate('text',x=ymd_hms("2024-06-05 18:00:00"),y=3500,label="Double the 2024 wind+solar",hjust=0,color="green",vjust=0)+
annotate('text',x=ymd_hms("2024-06-05 12:00:00"),y=200,label=ifelse(cumShort>0,"Shortfalls (unmet demand)",""),hjust=0.5,color="grey40",vjust=0)+
{if (bl>0) {
geom_hline(aes(yintercept=bl),color="purple")
}}+
{if (bl>0) {
annotate('text',x=ymd_hms("2024-06-01 00:00:00"),y=bl-250,label=paste0("nuclear baseload ,",bl,"MW"),hjust=0,color="purple",vjust=0)
}}+
scale_y_continuous(sec.axis=sec_axis(~.*scaleRight,breaks=seq(0,100,10),name="battery charge (%)"))+
labs(x="",y="Demand (megawatts)",title=paste0("South Australia, June 2024, with ",ofac," times the 2024 wind and solar\nAND ",gwb," of big batteries\nWith ",bl,"MW of nuclear as baseload "))+
annotate('text',x=ymd_hms("2024-06-05 00:00:00"),y=4500,label=paste0("Cumulative shortfall: ",comma(cumShort/1000)," GW hours"),hjust=0) +
theme(axis.ticks.y.right = element_line(color = "red"),
axis.text.y.right = element_text(color = "red"),
axis.title.y.right = element_text(color = "red"))
p
}
p<-doplot("dfsum-BL1200MW-BATT5,500MW-FAC2-June2024.csv",1200,5500,2)
p
dopng("June24-batteries5500baseload1200FAC2.png",p)
p<-doplot("dfsum-BL1200MW-BATT11,500MW-FAC2-June2024.csv",1200,11500,2)
p
dopng("June24-batteries11500baseload1200FAC2.png",p)
p<-doplot("dfsum-BL600MW-BATT11,500MW-FAC2-June2024.csv",600,11500,2)
p
dopng("June24-batteries11500baseload600FAC2.png",p)
p<-doplot("dfsum-BL600MW-BATT5,500MW-FAC2-June2024.csv",600,5500,2)
p
dopng("June24-batteries5500baseload600FAC2.png",p)
p<-doplot("dfsum-nobl-BATT11,500MW-FAC2-June2024.csv",0,11500,2)
p
dopng("June24-batteries11500nobaseloadFAC2.png",p)
p<-doplot("dfsum-BL1200MW-BATT5,500MW-FAC1.4-June2024.csv",1200,5500,1.4)
p
dopng("June24-batteries5500baseload1200-FAC14.png",p)
```
## OBSOLETE CODE
```{r}
cumShortBl<-as.numeric(dfbl |> filter(day(Time)<10) |> summarise(s=sum(shortFall)))
p<-dfbl |> filter(day(Time)<10) |> ggplot() +
geom_col(aes(x=Time,y=shortFall*12),color="grey80")+
geom_line(aes(x=Time,y=demand),color="black")+
# geom_line(aes(x=Time,y=renew),color="green",linetype=3)+
geom_line(aes(x=Time,y=dblrenew),color="green")+
geom_line(aes(x=Time,y=batteryStatus/11380*4000),color="red",linetype=4)+
annotate('text',x=ymd_hms("2024-06-07 00:00:00"),y=2300,label="Demand",hjust=0,color="black")+
annotate('text',x=ymd_hms("2024-06-05 18:00:00"),y=3500,label="Double the 2024 wind+solar",hjust=0,color="green",vjust=0)+
annotate('text',x=ymd_hms("2024-06-05 12:00:00"),y=500,label="No Blackouts!",hjust=0.5,color="grey40",vjust=0)+
geom_hline(aes(yintercept=1200),color="purple")+
annotate('text',x=ymd_hms("2024-06-04 12:00:00"),y=1250,label="nuclear baseload 2x600MW CANDU",hjust=0,color="purple",vjust=0)+
scale_y_continuous(sec.axis=sec_axis(~.*scaleRight,breaks=seq(0,100,10),name="battery charge (%)"))+
labs(x="",y="Demand (megawatts)",title="South Australia, June 2024, with double the wind and solar\nAND 11.4 gigaWatt-hours of big batteries\n(over 20 times the current battery level)\nAND 1.2 GW of nuclear as baseload ")+
annotate('text',x=ymd_hms("2024-06-05 00:00:00"),y=4500,label=paste0("Cumulative shortfall: ",comma(cumShortBl/1000)," gigaWatt hours"),hjust=0) +
theme(axis.ticks.y.right = element_line(color = "red"),
axis.text.y.right = element_text(color = "red"),
axis.title.y.right = element_text(color = "red"))
p
dopng("June24-batteries1p2baseload.png",p)
cumShortBl600<-as.numeric(dfbl600 |> filter(day(Time)<10) |> summarise(s=sum(shortFall)))
p<-dfbl600 |> filter(day(Time)<10) |> ggplot() +
geom_col(aes(x=Time,y=shortFall*12),color="grey80")+
geom_line(aes(x=Time,y=demand),color="black")+
# geom_line(aes(x=Time,y=renew),color="green",linetype=3)+
geom_line(aes(x=Time,y=dblrenew),color="green")+
geom_line(aes(x=Time,y=batteryStatus/11380*4000),color="red",linetype=4)+
annotate('text',x=ymd_hms("2024-06-07 00:00:00"),y=2300,label="Demand",hjust=0,color="black")+
annotate('text',x=ymd_hms("2024-06-05 18:00:00"),y=3500,label="Double the 2024 wind+solar",hjust=0,color="green",vjust=0)+
annotate('text',x=ymd_hms("2024-06-05 12:00:00"),y=300,label="Blackouts (unmet demand)",hjust=0.5,color="grey40",vjust=0)+
geom_hline(aes(yintercept=600),color="purple")+
annotate('text',x=ymd_hms("2024-06-04 12:00:00"),y=750,label="nuclear baseload 600MW CANDU",hjust=0,color="purple",vjust=0)+
scale_y_continuous(sec.axis=sec_axis(~.*scaleRight,breaks=seq(0,100,10),name="battery charge (%)"))+
labs(x="",y="Demand (megawatts)",title="South Australia, June 2024, with double the wind and solar\nAND 11.4 gigaWatt-hours of big batteries\n(over 20 times the current battery level)\nAND 600 MW of nuclear as baseload ")+
annotate('text',x=ymd_hms("2024-06-05 00:00:00"),y=4500,label=paste0("Cumulative shortfall: ",comma(cumShortBl600/1000)," gigaWatt hours"),hjust=0) +
theme(axis.ticks.y.right = element_line(color = "red"),
axis.text.y.right = element_text(color = "red"),
axis.title.y.right = element_text(color = "red"))
p
dopng("June24-batteries1p2baseload600BL.png",p)
```