Working on more result options to pick from

This commit is contained in:
Alex Gebben Work 2026-02-02 17:41:09 -07:00
parent d55898ce51
commit a58e82a8e1
4 changed files with 136 additions and 62 deletions

View File

@ -5,9 +5,12 @@ read_csv("./Data/Raw_Data/Cost_Tables/Texas/Table_C-3_Undiscounted_Cost_Estimate
CIFS_TEXAS <- rbind( read_csv("./Data/Raw_Data/Cost_Tables/Texas/Table_C-3_Undiscounted_Cost_Estimates_Phase_1_Low.csv") %>% mutate(Phase='Partial',Cost_Assumption="Low"),read_csv("./Data/Raw_Data/Cost_Tables/Texas/Table_C-4_Undiscounted_Cost_Estimates_Phase_1_High.csv") %>% mutate(Phase='Partial',Cost_Assumption="High"), read_csv("./Data/Raw_Data/Cost_Tables/Texas/Table_C-5_Undiscounted_Cost_Estimates_Full_Low.csv") %>% mutate(Phase='Full',Cost_Assumption="Low"), read_csv("./Data/Raw_Data/Cost_Tables/Texas/Table_C-6_Undiscounted_Cost_Estimates_Full_High.csv") %>% mutate(Phase='Full',Cost_Assumption="High")) %>% mutate(Location="Texas",Capacity=ifelse(Phase=='Partial',5000,8*5000)) %>% select(Year,Location,Phase,Capacity,Cost_Assumption,Total,everything()) CIFS_TEXAS <- rbind( read_csv("./Data/Raw_Data/Cost_Tables/Texas/Table_C-3_Undiscounted_Cost_Estimates_Phase_1_Low.csv") %>% mutate(Phase='Partial',Cost_Assumption="Low"),read_csv("./Data/Raw_Data/Cost_Tables/Texas/Table_C-4_Undiscounted_Cost_Estimates_Phase_1_High.csv") %>% mutate(Phase='Partial',Cost_Assumption="High"), read_csv("./Data/Raw_Data/Cost_Tables/Texas/Table_C-5_Undiscounted_Cost_Estimates_Full_Low.csv") %>% mutate(Phase='Full',Cost_Assumption="Low"), read_csv("./Data/Raw_Data/Cost_Tables/Texas/Table_C-6_Undiscounted_Cost_Estimates_Full_High.csv") %>% mutate(Phase='Full',Cost_Assumption="High")) %>% mutate(Location="Texas",Capacity=ifelse(Phase=='Partial',5000,8*5000)) %>% select(Year,Location,Phase,Capacity,Cost_Assumption,Total,everything())
CIFS_TEXAS <- rbind(CIFS_TEXAS,CIFS_TEXAS %>% group_by(Year,Location,Phase,Capacity) %>% summarize(Cost_Assumption="Average",Total=mean(Total),Construction=mean(Construction),Transportation_to_CISF=mean(Transportation_to_CISF),Operations=mean(Operations),Transportation_to_Repository=mean(Transportation_to_Repository),Decommissioning=mean(Decommissioning)) %>% ungroup) CIFS_TEXAS <- rbind(CIFS_TEXAS,CIFS_TEXAS %>% group_by(Year,Location,Phase,Capacity) %>% summarize(Cost_Assumption="Average",Total=mean(Total),Construction=mean(Construction),Transportation_to_CISF=mean(Transportation_to_CISF),Operations=mean(Operations),Transportation_to_Repository=mean(Transportation_to_Repository),Decommissioning=mean(Decommissioning)) %>% ungroup)
#CIFS_TEXAS %>% group_by(Year,Phase,
saveRDS(CIFS_TEXAS,"Data/Cleaned_Data/Texas_CIFS_Costs.Rds") saveRDS(CIFS_TEXAS,"Data/Cleaned_Data/Texas_CIFS_Costs.Rds")
CIFS_NEW_MEXICO <- rbind( read_csv("./Data/Raw_Data/Cost_Tables/New_Mexico/Table_C-3_Undiscounted_Cost_Estimates_Phase_1_Low.csv") %>% mutate(Phase='Partial',Cost_Assumption="Low"),read_csv("./Data/Raw_Data/Cost_Tables/New_Mexico/Table_C-4_Undiscounted_Cost_Estimates_Phase_1_High.csv") %>% mutate(Phase='Partial',Cost_Assumption="High"), read_csv("./Data/Raw_Data/Cost_Tables/New_Mexico/Table_C-5_Undiscounted_Cost_Estimates_Full_Low.csv") %>% mutate(Phase='Full',Cost_Assumption="Low"), read_csv("./Data/Raw_Data/Cost_Tables/New_Mexico/Table_C-6_Undiscounted_Cost_Estimates_Full_High.csv") %>% mutate(Phase='Full',Cost_Assumption="High"))%>% mutate(Location="New Mexico",Capacity=ifelse(Phase=='Partial',8680,8680+5000*19))%>% select(Year,Location,Phase,Capacity,Cost_Assumption,Total,everything()) CIFS_NEW_MEXICO <- rbind( read_csv("./Data/Raw_Data/Cost_Tables/New_Mexico/Table_C-3_Undiscounted_Cost_Estimates_Phase_1_Low.csv") %>% mutate(Phase='Partial',Cost_Assumption="Low"),read_csv("./Data/Raw_Data/Cost_Tables/New_Mexico/Table_C-4_Undiscounted_Cost_Estimates_Phase_1_High.csv") %>% mutate(Phase='Partial',Cost_Assumption="High"), read_csv("./Data/Raw_Data/Cost_Tables/New_Mexico/Table_C-5_Undiscounted_Cost_Estimates_Full_Low.csv") %>% mutate(Phase='Full',Cost_Assumption="Low"), read_csv("./Data/Raw_Data/Cost_Tables/New_Mexico/Table_C-6_Undiscounted_Cost_Estimates_Full_High.csv") %>% mutate(Phase='Full',Cost_Assumption="High"))%>% mutate(Location="New Mexico",Capacity=ifelse(Phase=='Partial',8680,8680+5000*19))%>% select(Year,Location,Phase,Capacity,Cost_Assumption,Total,everything())
CIFS_NEW_MEXICO <- rbind(CIFS_NEW_MEXICO,CIFS_NEW_MEXICO %>% group_by(Year,Location,Phase,Capacity) %>% summarize(Cost_Assumption="Average",Total=mean(Total),Construction=mean(Construction),Transportation_to_CISF=mean(Transportation_to_CISF),Operations=mean(Operations),Transportation_to_Repository=mean(Transportation_to_Repository),Decommissioning=mean(Decommissioning)) %>% ungroup) CIFS_NEW_MEXICO <- rbind(CIFS_NEW_MEXICO,CIFS_NEW_MEXICO %>% group_by(Year,Location,Phase,Capacity) %>% summarize(Cost_Assumption="Average",Total=mean(Total),Construction=mean(Construction),Transportation_to_CISF=mean(Transportation_to_CISF),Operations=mean(Operations),Transportation_to_Repository=mean(Transportation_to_Repository),Decommissioning=mean(Decommissioning)) %>% ungroup)
saveRDS(CIFS_NEW_MEXICO,"Data/Cleaned_Data/New_Mexico_CIFS_Costs.Rds") saveRDS(CIFS_NEW_MEXICO,"Data/Cleaned_Data/New_Mexico_CIFS_Costs.Rds")

View File

@ -1,42 +1,42 @@
Year,Construction,Transportation_to_CISF,Operations,Transportation_to_Repository,Decommissioning,Total Year,Construction,Transportation_to_CISF,Operations,Transportation_to_Repository,Decommissioning,Total
5041229,0,0,155305226 1,76552618,73711378,5041229,0,0,155305226
5041229,0,0,213789386 2,65910317,142837839,5041229,0,0,213789386
5041229,0,0,19326086 3,11737391,2547465,5041229,0,0,19326086
5041229,0,0,53313056 4,40629430,7642396,5041229,0,0,53313056
5041229,0,0,53313056 5,40629430,7642396,5041229,0,0,53313056
5041229,0,0,53313056 6,40629430,7642396,5041229,0,0,53313056
5041229,0,0,5041229 7,0,0,5041229,0,0,5041229
5041229,0,0,53313056 8,40629430,7642396,5041229,0,0,53313056
5041229,0,0,15768302 9,9028762,1698310,5041229,0,0,15768302
5041229,0,0,5041229 10,0,0,5041229,0,0,5041229
5041229,0,0,8647444 11,3606215,0,5041229,0,0,8647444
5041229,0,0,5041229 12,0,0,5041229,0,0,5041229
5041229,0,0,5041229 13,0,0,5041229,0,0,5041229
5041229,0,0,5041229 14,0,0,5041229,0,0,5041229
5041229,0,0,5041229 15,0,0,5041229,0,0,5041229
5041229,0,0,5041229 16,0,0,5041229,0,0,5041229
5041229,0,0,5041229 17,0,0,5041229,0,0,5041229
5041229,0,0,5041229 18,0,0,5041229,0,0,5041229
5041229,0,0,5041229 19,0,0,5041229,0,0,5041229
5041229,0,0,5041229 20,0,0,5041229,0,0,5041229
5041229,0,0,22895959 21,17854730,0,5041229,0,0,22895959
5041229,0,0,5041229 22,0,0,5041229,0,0,5041229
5041229,0,0,5041229 23,0,0,5041229,0,0,5041229
5041229,0,0,5041229 24,0,0,5041229,0,0,5041229
5041229,0,0,5041229 25,0,0,5041229,0,0,5041229
5041229,0,0,5041229 26,0,0,5041229,0,0,5041229
5041229,0,0,5041229 27,0,0,5041229,0,0,5041229
5041229,0,0,5041229 28,0,0,5041229,0,0,5041229
5041229,0,0,5041229 29,0,0,5041229,0,0,5041229
5041229,0,0,5041229 30,0,0,5041229,0,0,5041229
5041229,0,0,8647444 31,3606215,0,5041229,0,0,8647444
5041229,0,0,5041229 32,0,0,5041229,0,0,5041229
5041229,0,0,5041229 33,0,0,5041229,0,0,5041229
5041229,0,0,5041229 34,0,0,5041229,0,0,5041229
5041229,0,0,5041229 35,0,0,5041229,0,0,5041229
5041229,0,0,5041229 36,0,0,5041229,0,0,5041229
5041229,0,0,5041229 37,0,0,5041229,0,0,5041229
5041229,0,0,5041229 38,0,0,5041229,0,0,5041229
5041229,125682289,0,130723519 39,0,0,5041229,125682289,0,130723519
5041229,125682289,0,130723519 40,0,0,5041229,125682289,0,130723519
0,0,56740382,56740382 41,0,0,0,0,56740382,56740382

1 Year,Construction,Transportation_to_CISF,Operations,Transportation_to_Repository,Decommissioning,Total Year Construction Transportation_to_CISF Operations Transportation_to_Repository Decommissioning Total
2 5041229,0,0,155305226 1 76552618 73711378 5041229 0 0 155305226
3 5041229,0,0,213789386 2 65910317 142837839 5041229 0 0 213789386
4 5041229,0,0,19326086 3 11737391 2547465 5041229 0 0 19326086
5 5041229,0,0,53313056 4 40629430 7642396 5041229 0 0 53313056
6 5041229,0,0,53313056 5 40629430 7642396 5041229 0 0 53313056
7 5041229,0,0,53313056 6 40629430 7642396 5041229 0 0 53313056
8 5041229,0,0,5041229 7 0 0 5041229 0 0 5041229
9 5041229,0,0,53313056 8 40629430 7642396 5041229 0 0 53313056
10 5041229,0,0,15768302 9 9028762 1698310 5041229 0 0 15768302
11 5041229,0,0,5041229 10 0 0 5041229 0 0 5041229
12 5041229,0,0,8647444 11 3606215 0 5041229 0 0 8647444
13 5041229,0,0,5041229 12 0 0 5041229 0 0 5041229
14 5041229,0,0,5041229 13 0 0 5041229 0 0 5041229
15 5041229,0,0,5041229 14 0 0 5041229 0 0 5041229
16 5041229,0,0,5041229 15 0 0 5041229 0 0 5041229
17 5041229,0,0,5041229 16 0 0 5041229 0 0 5041229
18 5041229,0,0,5041229 17 0 0 5041229 0 0 5041229
19 5041229,0,0,5041229 18 0 0 5041229 0 0 5041229
20 5041229,0,0,5041229 19 0 0 5041229 0 0 5041229
21 5041229,0,0,5041229 20 0 0 5041229 0 0 5041229
22 5041229,0,0,22895959 21 17854730 0 5041229 0 0 22895959
23 5041229,0,0,5041229 22 0 0 5041229 0 0 5041229
24 5041229,0,0,5041229 23 0 0 5041229 0 0 5041229
25 5041229,0,0,5041229 24 0 0 5041229 0 0 5041229
26 5041229,0,0,5041229 25 0 0 5041229 0 0 5041229
27 5041229,0,0,5041229 26 0 0 5041229 0 0 5041229
28 5041229,0,0,5041229 27 0 0 5041229 0 0 5041229
29 5041229,0,0,5041229 28 0 0 5041229 0 0 5041229
30 5041229,0,0,5041229 29 0 0 5041229 0 0 5041229
31 5041229,0,0,5041229 30 0 0 5041229 0 0 5041229
32 5041229,0,0,8647444 31 3606215 0 5041229 0 0 8647444
33 5041229,0,0,5041229 32 0 0 5041229 0 0 5041229
34 5041229,0,0,5041229 33 0 0 5041229 0 0 5041229
35 5041229,0,0,5041229 34 0 0 5041229 0 0 5041229
36 5041229,0,0,5041229 35 0 0 5041229 0 0 5041229
37 5041229,0,0,5041229 36 0 0 5041229 0 0 5041229
38 5041229,0,0,5041229 37 0 0 5041229 0 0 5041229
39 5041229,0,0,5041229 38 0 0 5041229 0 0 5041229
40 5041229,125682289,0,130723519 39 0 0 5041229 125682289 0 130723519
41 5041229,125682289,0,130723519 40 0 0 5041229 125682289 0 130723519
42 0,0,56740382,56740382 41 0 0 0 0 56740382 56740382

View File

@ -1,7 +1,8 @@
library(tidyverse) library(tidyverse)
#########CIFS Costs #########CIFS Costs
DAT <- read_csv("Table_C-3_Undiscounted_Cost_Estimates_Phase_1.csv") DAT <- read_csv("Table_C-3_Undiscounted_Cost_Estimates_Phase_1_Low.csv")
rowSums(DAT[,2:6])-DAT$Total rowSums(DAT[,2:6])-DAT$Total
sum(DAT[,2:6])
DAT <- read_csv("Table_C-4_Undiscounted_Cost_Estimates_Phase_1_High.csv") DAT <- read_csv("Table_C-4_Undiscounted_Cost_Estimates_Phase_1_High.csv")
rowSums(DAT[,2:6])-DAT$Total rowSums(DAT[,2:6])-DAT$Total

View File

@ -1,12 +1,49 @@
#A script which attempts to pull in all data, and create a data frame with the maximum revenue values for each facility, year and discount rate. The output can then be used to make figures and graphs #A script which attempts to pull in all data, and create a data frame with the maximum revenue values for each facility, year and discount rate. The output can then be used to make figures and graphs
library(tidyverse) library(tidyverse)
library(parallel) library(parallel)
NCORES <- detectCores()-1
library(lpSolve) #For solving discrete value maximization for the power plants library(lpSolve) #For solving discrete value maximization for the power plants
####Manual inputs
TOTAL <- read_csv("Data/Raw_Data/Curie_Spent_Fuel_Site_Totals.csv") %>% mutate(OP_YEAR=year(Op_Date_Min),CLOSE_YEAR=year(Close_Date_Max))%>% select(Facility,Total_Assemblies,Total_Tons,OP_YEAR,CLOSE_YEAR) #DISCOUNT_RATE_LIST <- seq(0,1,by=0.0025)
DISCOUNT_RATE_LIST <- c(0.03,0.04,0.045,0.05,0.07,0.1)
SHIPPING_COST_PER_TON <- 1.2874*26000 #Inflation adjusted from New Mexico Report
CV1 <- 1.3074*(10607030-1060703) #Data from Texas Report, converted from 2018 to Dec 2025 dollars CV1 <- 1.3074*(10607030-1060703) #Data from Texas Report, converted from 2018 to Dec 2025 dollars
CV2 <- 1.2874*(6984013-1117442) #Data from New Mexico Report, Converted from 2019 to Dec 2025 CV2 <- 1.2874*(6984013-1117442) #Data from New Mexico Report, Converted from 2019 to Dec 2025
CV3 <- mean(CV1,CV2) #Average of the two
###################################Cost results
#source("Cost_Data_Proc.r")
CIFS <- rbind(readRDS("Data/Cleaned_Data/Texas_CIFS_Costs.Rds"),readRDS("Data/Cleaned_Data/New_Mexico_CIFS_Costs.Rds"))
COSTS <- do.call(rbind,lapply(DISCOUNT_RATE_LIST ,function(DISCOUNT){CIFS %>% group_by(Location,Capacity,Cost_Assumption) %>% mutate(NPC=Total/(1+DISCOUNT)^Year) %>% summarize(Discount=DISCOUNT,Costs=sum(NPC))})) %>% ungroup
TEMP <- COSTS%>% group_by(Location,Cost_Assumption,Discount) %>% summarize(ST_COST=min(Costs),ST_CAPACITY=min(Capacity),M_COST=(max(Costs)-min(Costs))/(max(Capacity)-min(Capacity))) %>% ungroup
CAPACITY_INCREMENT <- 5000
#rm(COST_DATA)
for(i in 1:nrow(TEMP)){
LOC <- as.character(TEMP[i,"Location"])
COST_LEVEL <- as.character(TEMP[i,"Cost_Assumption"])
DISCOUNT <- as.numeric(TEMP[i,"Discount"])
ST_CAP <- as.numeric(TEMP[i,"ST_CAPACITY"])
ST_COST <- as.numeric(TEMP[i,"ST_COST"])
COST_SLOPE <- as.numeric(TEMP[i,]$M_COST)
CAPACITY <- seq(ST_CAP,160000,by=5000)
COST <- ST_COST+COST_SLOPE*CAPACITY_INCREMENT*(0:(length(CAPACITY)-1))
C_RES <- cbind(CAPACITY,COST) %>% as_tibble %>% mutate(Location=LOC,Cost_Assumption=COST_LEVEL,Discount=DISCOUNT) %>% select(Location,Cost_Assumption,Discount,Capacity=CAPACITY,Cost=COST)
if(!exists("COST_DATA")){COST_DATA <- C_RES}else{COST_DATA<- rbind(COST_DATA,C_RES)}
}
saveRDS(COST_DATA ,"Data/Cleaned_Data/All_CIFS_Discounted_Costs.Rds")
COST_DATA <- COST_DATA %>% filter(Cost_Assumption=='Average') %>% select(-Cost_Assumption) %>% unique
##All unique capacity levels that the revenues need to be calculated for
CAPACITY_LIST <- COST_DATA %>% pull(Capacity) %>% unique
###
TOTAL <- read_csv("Data/Raw_Data/Curie_Spent_Fuel_Site_Totals.csv") %>% mutate(OP_YEAR=year(Op_Date_Min),CLOSE_YEAR=year(Close_Date_Max))%>% select(Facility,Total_Assemblies,Total_Tons,OP_YEAR,CLOSE_YEAR
TOTAL
###########Series of functions to calculate the gross consumer surplus from a CIFS for each facility, in each year from 1960 to 2082. ###########Series of functions to calculate the gross consumer surplus from a CIFS for each facility, in each year from 1960 to 2082.
#Function to find the net present revenue of a facility,given a discount rate, and the current year, and year the facility will close. This is the sum of discounted costs that WOULD have taken place if the facility was not built #Function to find the net present revenue of a facility,given a discount rate, and the current year, and year the facility will close. This is the sum of discounted costs that WOULD have taken place if the facility was not built
@ -26,48 +63,81 @@ colnames(RES) <- c("Facility",YEARS)
return(RES) return(RES)
} }
#A function which returns a list, of net present revenue calculation tables (facility by year) for a range of possible discount rates. This allows for the results to be quickly looked up, when we want to adjust the time value of money. These results combine costs savings to calculate NPV #A function which returns a list, of net present revenue calculation tables (facility by year) for a range of possible discount rates. This allows for the results to be quickly looked up, when we want to adjust the time value of money. These results combine costs savings to calculate NPV
MULTI_DISCOUNT_RATE_NPV <- function(INCREMENT=0.005,DATA=TOTAL,YEARS=1960:2083,DOLLARS_SAVED_PER_YEAR){ MULTI_DISCOUNT_RATE_NPV <- function(DISCOUNT_INCREMENT,DATA=TOTAL,YEARS=1960:2083,DOLLARS_SAVED_PER_YEAR){
NCORES <- detectCores()-1 NCORES <- detectCores()-1
RES <- mclapply(seq(0,1,by=INCREMENT),NPV_CALC,mc.cores = NCORES) RES <- mclapply(DISCOUNT_INCREMENT,NPV_CALC,mc.cores = NCORES)
RES <- do.call(rbind,RES) %>% mutate(Revenue=Revenue*DOLLARS_SAVED_PER_YEAR) RES <- do.call(rbind,RES) %>% mutate(Revenue=Revenue*DOLLARS_SAVED_PER_YEAR)
return(RES) return(RES)
} }
TOTAL_VALUE_METRICS <- MULTI_DISCOUNT_RATE_NPV(INCREMENT=0.1,DOLLARS_SAVED_PER_YEAR=CV2) TOTAL_VALUE_METRICS <- MULTI_DISCOUNT_RATE_NPV(DISCOUNT_RATE_LIST ,DOLLARS_SAVED_PER_YEAR=CV2)
TOTAL_VALUE_METRICS <- TOTAL_VALUE_METRICS %>% filter(!(Facility %in% c("Palo Verde","Vogtle")))#These facilities always have a negative NPV by the end date 2083 TOTAL_VALUE_METRICS <- TOTAL_VALUE_METRICS %>% filter(!(Facility %in% c("Palo Verde","Vogtle")))#These facilities always have a negative NPV by the end date 2083
TOTAL_VALUE_METRICS <- TOTAL_VALUE_METRICS %>% left_join(read_csv("Data/Raw_Data/Curie_Spent_Fuel_Site_Totals.csv")) %>% select(Year,Facility,Discount,Total_Tons,Revenue) TOTAL_VALUE_METRICS <- TOTAL_VALUE_METRICS %>% left_join(read_csv("Data/Raw_Data/Curie_Spent_Fuel_Site_Totals.csv")) %>% select(Year,Facility,Discount,Total_Tons,Revenue)
#TBL <- TOTAL_VALUE_METRICS
#DICOUNT=0.1
#CIFS_SIZE=1
#SHIPPING_COST <- 0
#YEAR=2026
#Function to find the maximum Revenue BUT it does not take dollars just relative savings #Function to find the maximum Revenue BUT it does not take dollars just relative savings
MAX_REV <- function(YEAR,TBL,DISCOUNT,CIFS_SIZE,SHIPPING_COST=0){ MAX_REV <- function(YEAR,TBL,DISCOUNT,CIFS_SIZE,SHIPPING_COST=0){
TBL <- TBL %>% filter(Year==YEAR,Discount==DISCOUNT,Revenue/Total_Tons>SHIPPING_COST) TBL <- TBL %>% filter(Year==YEAR,Discount==DISCOUNT,Revenue/Total_Tons>SHIPPING_COST)
REV <- TBL %>% pull(Revenue) REV <- TBL %>% pull(Revenue)
VOL <- TBL %>% pull(Total_Tons) VOL <- TBL %>% pull(Total_Tons)
VOL
RES <- lp(direction = "max", objective.in = REV, const.mat = matrix(VOL, nrow = 1),const.dir = "<=", const.rhs = CIFS_SIZE, all.bin = TRUE) RES <- lp(direction = "max", objective.in = REV, const.mat = matrix(VOL, nrow = 1),const.dir = "<=", const.rhs = CIFS_SIZE, all.bin = TRUE)
return(RES[[11]]) return(RES[[11]])
} }
SHIPPING_COST_PER_TON <- 1.2874*26000 #Inflation adjusted from New Mexico Report
#Unique values of discount rates used
DISCOUNTS <- TOTAL_VALUE_METRICS$Discount %>% unique
#Calculate all results for the start year to the end year. Discount rate, and capacities are fixed. #Calculate all results for the start year to the end year. Discount rate, and capacities are fixed.
YEARLY_RESULTS <- function(DATA,DISCOUNT,CAPACITY,SHIPPING_COSTS=0){ YEARLY_RESULTS <- function(DATA,DISCOUNT,CAPACITY,SHIPPING_COSTS=0){
RES <- cbind(1960:2083,sapply(1960:2083, function(x){MAX_REV(YEAR=x,TBL=DATA,DISCOUNT,CAPACITY,SHIPPING_COSTS)})) %>% as_tibble RES <- cbind(1960:2083,sapply(1960:2083, function(x){MAX_REV(YEAR=x,TBL=DATA,DISCOUNT,CAPACITY,SHIPPING_COSTS)})) %>% as_tibble
colnames(RES) <- c("Year","Revenue") colnames(RES) <- c("Year","Revenue")
RES <- RES %>% mutate(Discount=DISCOUNT,Capacity=CAPACITY) RES <- RES %>% mutate(Discount=DISCOUNT,Capacity=CAPACITY) %>% select(Year,Discount,Capacity,Revenue) %>% mutate(Shipping_Cost_Cuttoff=SHIPPING_COSTS)
return(RES) return(RES)
} }
#Calculate and individual facilities rate, for all discount rates, and all years #Calculate and individual facilities rate, for all discount rates, and all years
FACILITY_RESULTS <- function(CAPACITY){do.call(rbind,lapply(DISCOUNTS,function(x){YEARLY_RESULTS(TOTAL_VALUE_METRICS,x,CAPACITY)}))}
lapply(FACILITY_RESULTS()
FACILITY_RESULTS(10^5)
MAX_REV(YEAR=2020,TBL=TOTAL_VALUE_METRICS,DISCOUNT=0.1,CIFS_SIZE=100000,SHIPPING_COST_PER_TON ) Rev_No_Shipping <- do.call(rbind,mclapply(CAPACITY_LIST,function(CAPACITY){do.call(rbind,lapply(DISCOUNT_RATE_LIST,function(x){YEARLY_RESULTS(TOTAL_VALUE_METRICS,x,CAPACITY,0)}))},mc.cores=min(length(CAPACITY_LIST),NCORES)))
Rev_No_Shipping
TEST <- Rev_No_Shipping %>% left_join(COST_DATA) %>% mutate(Profit=Revenue-Cost) %>% group_by(Discount,Capacity,Location) %>% mutate(Time_Benefit=(1-Discount)*(lead(Profit)-Profit),Op_Cost=Discount*Profit,Marginal=Time_Benefit-Op_Cost) %>% unique
TEST <- TEST %>% mutate(Current_Profit=Profit/((1+Discount)^(Year-2026))) %>% ungroup
TEST <- TEST %>% group_by(Year,Location,Discount) %>% filter(Current_Profit==max(Current_Profit)) %>% ungroup
TEST %>% select(Profit,Current_Profit,Year,Discount) %>% tail
TEST %>% group_by(Location,Discount) %>% filter(Current_Profit==max(Current_Profit))
TEST %>% group_by(Location,Discount) %>% filter(Discount==0.04) %>% select(Year,Capacity,Profit,Current_Profit) %>% mutate(Delay_Profit=(lead(Current_Profit)-Current_Profit)/10^6) %>% print(n=70)
ggplot(TEST ,aes(x=Year,y=Current_Profit/10^9,color=Capacity))+geom_line()+facet_wrap(Discount~Location)
ggplot(TEST ,aes(x=Year,y=Current_Profit/10^9,color=Capacity))+geom_line()+facet_wrap(Discount~Location)
TEST2 <- TEST %>% filter(Discount==0.05,Location=='Texas')
ggplot(TEST2,aes(x=Year,y=Marginal,group=as.factor(Capacity),color=as.factor(Capacity)))+geom_line()
#Calculate the net present revenue of all facilities that can CURRENTLY be shipped to the site with a profit. Note that the total Revenue is more important because most of the sites will be willing to pay for the right to CIFS storage in the future even if the shipping costs are too high presently. This result is used to show what might be the current ideal facility size, even if future expansion is expected to maximize profit.
Rev_Shipping <- do.call(rbind,mclapply(CAPACITY_LIST,function(CAPACITY){do.call(rbind,lapply(DISCOUNT_RATE_LIST,function(x){YEARLY_RESULTS(TOTAL_VALUE_METRICS,x,CAPACITY,SHIPPING_COST_PER_TON )}))},mc.cores=min(length(CAPACITY_LIST),NCORES)))
Revenue_Results <- rbind(Rev_No_Shipping,Rev_Shipping) %>% mutate(Type=ifelse(Shipping_Cost_Cuttoff==0,"Revenue","Revenue_Shipping")) %>% pivot_wider(values_from=Revenue,names_from=Type) %>% select(-Shipping_Cost_Cuttoff) %>% group_by(Year,Discount,Capacity) %>% summarize(Revenue=mean(Revenue,na.rm=TRUE),Revenue_Shipping=mean(Revenue_Shipping,na.rm=TRUE)) %>% ungroup
Revenue_Results
####################################################
COSTS <- rbind(COSTS,EXTENDED_CAPACITY_NEW_MEXICO)
COST_DATA %>% pull(Cost_Assumption) %>% unique
saveRDS(COSTS,"Data/Cleaned_Data/All_CIFS_Discounted_Costs.Rds")
COSTS %>% group_by(Location,Capac
CIFS_Data <- Revenue_Results %>% left_join(COSTS) %>% mutate(Profit=Revenue-Costs,Profit_Shipping=Revenue_Shipping-Costs) %>% select(Year,Location,Capacity,Discount,Revenue,Costs,Profit,Revenue_Shipping,Profit_Shipping,everything())
#CIFS_Data <-
CIFS_Data <- CIFS_Data %>% group_by(Location,Capacity,Discount) %>% arrange(Location,Capacity,Discount,Year) %>% mutate(Time_Benefit=lead(Profit)-Profit,Op_Cost=Profit*Discount,Marginal=Time_Benefit-Op_Cost) %>% ungroup
TEMP <- CIFS_Data %>% filter(Discount==0.05) %>% mutate(Time_Benefit=lead(Profit)-Profit,Op_Cost=Profit*Discount,Marginal=Time_Benefit-Op_Cost)
CIFS_Data <- CIFS_Data %>% group_by(Location,Phase,Capacity,Discount) %>% mutate(Time_Benefit=(1-Discount)*(lead(Profit)-Profit),Op_Cost=Profit*Discount,Marginal=Time_Benefit-Op_Cost)
((-3504542954)-(-3530861857))-0.05*(-3530861857 )
STARTING_YEARS <- CIFS_Data %>% group_by(Location,Phase,Capacity,Discount) %>% mutate(PROFITABLE=Profit>0 & Marginal<=0) %>% filter(PROFITABLE) %>% filter(Year==min(Year)) %>% select(Location,Phase,Capacity,Discount,Start_Year=Year,Profit) %>% ungroup
CIFS_Data %>% mutate(Current_Profit=Profit/((1+Discount)^(Year-2026))) %>% group_by(Location,Discount,Capacity) %>% filter(Current_Profit==max(Current_Profit)) %>% select(Start_Year=Year,Location,Phase,Capacity,Current_Profit) %>% ungroup %>% arrange(Discount,Location,desc(Current_Profit)) %>% select(Discount,Location,Phase,Start_Year,Current_Profit)
#############
ggplot(CIFS_Data ,aes(x=Year,y=Marginal/10^6,group=Capacity,color=as.factor(Capacity)))+geom_line()+facet_wrap(~Discount,ncol=1)+scale_x_continuous(breaks=seq(1960,2083,by=5))
ggplot(CIFS_Data ,aes(x=Year,y=Marginal,group=Capacity,color=as.factor(Capacity)))+geom_line()+facet_grid(~Discount)