2026-01-27 17:05:20 -07:00

66 lines
5.1 KiB
R

library(tidyverse)
library(scales)
library(RcppRoll)
RES <- readRDS("Results/Storage_Values_by_Facility_and_Variable_Discounts.Rds")
RES
RES_REDUCED_FEE <- RES
RES_INCREASED_FEE <- RES
CV <- 1.3074*(10607030-1060703)
LENGTH <- length(RES)
SUPPLY_RESULTS <- list()
for(i in 1:LENGTH){
RES[[i]]$Revenue <-CV*as.numeric(RES[[i]]$Revenue)
RES[[i]]$Year<-as.numeric(RES[[i]]$Year)
DISCOUNT <- as.numeric(gsub("Per_","",names(RES)[i]))/100
SUPPLY_RESULTS[[i]] <- RES[[i]] %>% left_join(read_csv("Data/Raw_Data/Curie_Spent_Fuel_Site_Totals.csv")) %>% mutate(Marginal_Value=Revenue/Total_Tons) %>% select(Year,Marginal_Value,Total_Tons) %>% group_by(Year) %>% arrange(Year,desc(Marginal_Value)) %>% mutate(Q=cumsum(Total_Tons),Discount=factor(percent(DISCOUNT,1),levels=c("3%","5%","7%","10%")))
}
names(SUPPLY_RESULTS) <- names(RES)
KEY_DATA <- do.call(rbind,SUPPLY_RESULTS[c("Per_3","Per_5","Per_7","Per_10")])
KEY_YEARS <- c(1986,2026,2066)
#Data for reduced and increased fee at 5% and 2026
FEE_DATA <- rbind(KEY_DATA %>% filter(Year %in% 2026 ,Q>=500,Discount=="5%") %>% mutate(Fee="Current Fee"),KEY_DATA %>% filter(Year %in% 2026 ,Q>=500,Discount=="5%") %>% mutate(Marginal_Value=Marginal_Value/2,Fee="Reduced Fee"),KEY_DATA %>% filter(Year %in% 2026 ,Q>=500,Discount=="5%") %>% mutate(Marginal_Value=2*Marginal_Value,Fee="Increased Fee"))
FEE_DATA$Fee <- factor(FEE_DATA$Fee,levels=c("Reduced Fee","Current Fee","Increased Fee"))
DEMAND_CURVE_YEARS <- ggplot(KEY_DATA %>% filter(Year %in% KEY_YEARS ,Q>=500,Discount=="5%") ,aes(x=Q/1000,y=Marginal_Value/1000,group=Year,color=Year))+geom_step(linewidth=1,arrow = arrow(length = unit(0.25, "cm")))+theme_bw()+scale_color_binned(high= "#132B43", low= "#56B1F7",breaks = KEY_YEARS)+scale_y_continuous(breaks=seq(0,2000,by=50))+scale_x_continuous(breaks=seq(0,150,by=5))+ylab("Price ($1000 per ton)")+xlab("Quantity (Thousand Tons)")+theme(text = element_text(size = 16),legend.position = "top")+ guides(color = guide_legend(reverse = FALSE))
DEMAND_CURVE_YEARS
DEMAND_CURVE_YEARS_PLOT_FULL <-ggplot(KEY_DATA %>% filter(Year %in% KEY_YEARS,Discount=="5%" ) ,aes(x=Q/1000,y=log(Marginal_Value),group=Year,color=Year))+geom_step(linewidth=2,arrow = arrow(length = unit(0.3, "cm")))+theme_bw()+scale_color_binned(high= "#132B43", low= "#56B1F7",breaks = KEY_YEARS)+ guides(color = guide_legend(reverse = TRUE))+scale_y_continuous(breaks=c(seq(4,20,by=0.5)))+scale_x_continuous(breaks=seq(0,150,by=5))+ylab("Price (Log dollar per Ton)")+xlab("Quantity (Thousand Tons)")+theme(text = element_text(size = 16),legend.position = "top")+ guides(color = guide_legend(reverse = FALSE))
DEMAND_CURVE_YEARS_PLOT_FULL
DEMAND_CURVE_DISCOUNT <- ggplot(KEY_DATA %>% filter(Year %in% KEY_YEARS ,Q>=500,Year==2026) ,aes(x=Q/1000,y=Marginal_Value/1000,group=Discount,color=Discount))+geom_step(linewidth=1,arrow = arrow(length = unit(0.1, "cm")))+theme_bw()+scale_y_continuous(breaks=seq(0,2000,by=50))+scale_x_continuous(breaks=seq(0,150,by=5))+ylab("Price ($1000 per ton)")+xlab("Quantity (Thousand Tons)")+theme(text = element_text(size = 16),legend.position = "top")+ guides(color = guide_legend(reverse = FALSE))+scale_color_manual(values = c("tomato1", "tomato2", "tomato3","tomato4"))
DEMAND_CURVE_DISCOUNT
DEMAND_CURVE_FEE <- ggplot(FEE_DATA ,aes(x=Q/1000,y=Marginal_Value/1000,group=Fee,color=Fee))+geom_step(linewidth=1,arrow = arrow(length = unit(0.25, "cm")))+theme_bw()+scale_y_continuous(breaks=seq(0,2000,by=50))+scale_x_continuous(breaks=seq(0,150,by=5))+ylab("Price ($1000 per ton)")+xlab("Quantity (Thousand Tons)")+theme(text = element_text(size = 16),legend.position = "top")+ guides(color = guide_legend(reverse = FALSE))+scale_color_manual(values = c("forestgreen", "darkblue", "red3"))
DEMAND_CURVE_FEE
DEMAND_CURVE_FACET <- ggplot(KEY_DATA %>% filter(Year %in% KEY_YEARS ,Q>=500) ,aes(x=Q/1000,y=Marginal_Value/1000,group=Year,color=Year))+geom_step(linewidth=1,arrow = arrow(length = unit(0.08, "cm")))+theme_bw()+scale_color_binned(high= "#132B43", low= "#56B1F7",breaks = KEY_YEARS)+scale_y_continuous(breaks=seq(0,2000,by=200))+scale_x_continuous(breaks=seq(0,150,by=10))+ylab("Price ($1000 per ton)")+xlab("Quantity (Thousand Tons)")+theme(text = element_text(size = 16),legend.position = "top")+ guides(color = guide_legend(reverse = FALSE))+facet_grid(Discount~Year)
DEMAND_CURVE_FACET
DEMAND_CURVE_YEARS_PLOT_FULL
DEMAND_CURVE_YEARS
DEMAND_CURVE_DISCOUNT
DEMAND_CURVE_FEE
DEMAND_CURVE_FACET
###
CIFS <- readRDS("Data/Cleaned_Data/Texas_CIFS_Costs.Rds")
CIFS %>% mutate(NPC=Total/(1+0.05)^Year) %>% group_by(Phase) %>% summarize(Cost=sum(NPC)) %>% mutate(Marginal=Cost/ifelse(Phase=="Partial",5000,40000)/1000)
#Added cost per unit
M <- (3373397183-1401068722)/(40000-5000)/1000
#Added cost for intial project
C <- 1401068722/5000/1000
####This is a plot of the supply curve in orange UNDER A COMPETITVE MARKET. Add in the monoplosty wating function next (value is gained by waiting another year.
DEMAND_CURVE_YEARS+geom_segment(aes(x = 0, y = C, xend = 5, yend = C),color="orange")+geom_segment(aes(x = 5, y = C, xend = 5, yend = M),color="orange")+geom_segment(aes(x = 5, y = M, xend = 140, yend = M),color="orange",arrow = arrow(length = unit(0.4, "cm")))