# Economic impacts

## Question

How to assess typical economic impacts in an assessment?

## Rationale

### External and total costs

This code tells how to calculate prices of emissions, external costs of health and CO2 emissions, net costs of operating power plants (two different versions), and finally total cost.

 ```# This code is Op_en3283/totalCost [[Economic impacts]] library(OpasnetUtils) emissionprice <- Ovariable("emissionprice", dependencies = data.frame(Name = c("co2price")), formula = function(...) { temp <- c("CO2direct", "CO2eq", "CO2trade", "PM2.5") weight <- c(0.33, 0.34, 0.33, 0) if(openv\$N > 0) { temp <- sample(temp, size = max(1, openv\$N), replace = TRUE, prob = weight) weight <- 1 } out <- Ovariable( output = data.frame( Iter = 1:length(temp), Pollutant = temp, Result = weight ), marginal = c(TRUE, FALSE, FALSE) ) if(openv\$N == 0) { out <- unkeep(out, cols = "Iter") } out <- out * co2price return(out) } ) externalCost <- Ovariable("externalCost", dependencies = data.frame( Name = c( "emissions", "emissionprice", "DALYs", "DALYprice" ) ), formula = function(...) { health <- oapply( unkeep(DALYs, prevresults = TRUE, sources = TRUE), cols = c( "Fuel", "Pollutant", "Response", "Population", "Age", "Sex", "Exposure", "ER_function", "Exposure_unit" ), FUN = sum ) health <- health * DALYprice * 1E-6 * 10 # from € to M€ for 10 a climate <- oapply( unkeep(emissions, prevresults = TRUE, sources = TRUE), cols = c( "Fuel", "Emission_site", "Emission_height" ), FUN = sum ) climate <- climate * emissionprice * 1E-6 * 10 # from € to M€ for 10 a climate <- oapply(climate, cols = "Pollutant", FUN = sum) # Remove joint index Pollutant out <- combine(health, climate) # out\$Cost <- factor(out\$Cost, levels = c( # "Management cost", # "Operation cost", # "Fuel cost", # "Investment cost", # "Health", # "Climate", # "Profit" # )) out\$Time <- as.numeric(as.character(out\$Time)) out <- oapply(unkeep(out, sources = TRUE), cols = "", FUN = sum) return(out) } ) EnergyNetworkCost <- Ovariable("EnergyNetworkCost", # Energy network costs using profit (includes excesses and deficits but is not strictly plant or fuel-specific. dependencies = data.frame( Name = c( "plantParameters", "EnergyNetworkOptim", "fuelUse", "fuelPrice", "temperdays" ), Ident = c( NA, "Op_en5141/EnergyNetworkOptim", # [[Energy balance]] NA, "Op_en4151/fuelPrice", # [[Prices of fuels in heat production]] NA ) ), formula = function(...) { oper <- plantParameters[plantParameters\$Parameter == "Max" , colnames(plantParameters@output) != "Parameter"] result(oper)[result(oper) != 0] <- 1 oper <- plantParameters * oper # Take the first year when a plant is operated and put all investment cost there. investment <- oper[oper\$Parameter == "Investment cost" , ] investment <- investment[result(investment) > 0 , ] investment <- investment[order(investment@output\$Time) , ] investment <- investment[!duplicated(investment@output[investment@marginal & colnames(investment@output) != "Time"]) , ] investment <- unkeep(investment, sources = TRUE) proinve <- investment # Profit does not include investment, so must subtract. proinve\$Parameter <- "Profit" maintenance <- oper[oper\$Parameter == "Management cost" , ] maintenance <- unkeep(maintenance, sources = TRUE) promain <- maintenance # Profit does not include maintenance, so must subtract. promain\$Parameter <- "Profit" profit <- EnergyNetworkOptim[EnergyNetworkOptim\$Process_variable_name == "Profit" , ] colnames(profit@output)[colnames(profit@output) == "Process_variable_name"] <- "Parameter" profit <- profit * temperdays * 10 * 1E-6 # For 10-year periods, € -> M€ profit <- oapply(profit, cols = c("Temperature"), FUN = sum) profit <- unkeep(profit, cols = c("Process_variable_type"), sources = TRUE, prevresults = TRUE) profit <- profit * Ovariable(output = data.frame(Plant = "Profit", Result = -1), marginal = c(TRUE, FALSE)) EnergyFlow <- EnergyNetworkOptim[EnergyNetworkOptim\$Process_variable_type == "Activity" , colnames(EnergyNetworkOptim@output) != "Process_variable_type" ] colnames(EnergyFlow@output)[colnames(EnergyFlow@output) == "Process_variable_name"] <- "Plant" EnergyFlow <- unkeep(EnergyFlow, sources = TRUE, prevresults = TRUE) EnergyFlow <- EnergyFlow * temperdays * 24 * 10 # MW to MWh/10 a EnergyFlow <- oapply(EnergyFlow, cols = c("Temperature"), FUN = sum) opercost <- EnergyFlow * oper[oper\$Parameter == "Operation cost" , ] * 1E-6 # € to M€ fuelcost <- fuelPrice * fuelUse[!fuelUse\$Fuel %in% c("Heat", "Electricity") , ] / 3.6E+8 # From MJ to MWh, € to M€, and a to 10 a colnames(fuelcost@output)[colnames(fuelcost@output) == "Fuel"] <- "Parameter" fuelcost\$Parameter <- "Fuel cost" fuelcost <- oapply(unkeep(fuelcost, sources = TRUE), cols = c("Burner"), FUN = sum) cost <- combine( investment, # Investment cost maintenance, # Maintenance cost opercost, # Operation cost fuelcost, # Fuel cost profit, # Profit without maintenance and investment proinve, # Investment cost that reduces profit promain # Maintenance cost that reduces profit ) colnames(cost@output)[colnames(cost@output) == "Parameter"] <- "Cost" cost <- oapply(unkeep(cost, sources = TRUE), cols = "", FUN = sum) # aggregate rows cost\$Time <- as.numeric(as.character(cost\$Time)) marginals <- character() for(i in colnames(cost@output)[cost@marginal]) { if(any(is.na(cost@output[[i]]))) marginals <- c(marginals, i) } if(length(marginals) > 0) { cost@output <- fillna(cost@output, marginals) warning(paste("In combine had to fillna marginals", marginals, "\n")) } return(cost) } ) plantCost <- Ovariable("plantCost", # Energy network costs using income from heat and electricity as profit. # This is strictly plant and fuel-specific but does not account for excesses and deficits. dependencies = data.frame( Name = c( "plantParameters", "EnergyNetworkOptim", "fuelUse", "fuelPrice", "temperdays" ), Ident = c( NA, "Op_en5141/EnergyNetworkOptim", # [[Energy balance]] NA, "Op_en4151/fuelPrice", # [[Prices of fuels in heat production]] NA ) ), formula = function(...) { oper <- plantParameters[plantParameters\$Parameter == "Max" , colnames(plantParameters@output) != "Parameter"] result(oper)[result(oper) != 0] <- 1 oper <- plantParameters * oper # Take the first year when a plant is operated and put all investment cost there. investment <- oper[oper\$Parameter == "Investment cost" , ] investment <- investment[result(investment) > 0 , ] investment <- investment[order(investment@output\$Time) , ] investment <- investment[!duplicated(investment@output[investment@marginal & colnames(investment@output) != "Time"]) , ] investment <- unkeep(investment, sources = TRUE) maintenance <- oper[oper\$Parameter == "Management cost" , ] maintenance <- unkeep(maintenance, sources = TRUE) EnergyFlow <- EnergyNetworkOptim[EnergyNetworkOptim\$Process_variable_type == "Activity" , colnames(EnergyNetworkOptim@output) != "Process_variable_type" ] colnames(EnergyFlow@output)[colnames(EnergyFlow@output) == "Process_variable_name"] <- "Plant" EnergyFlow <- unkeep(EnergyFlow, sources = TRUE, prevresults = TRUE) EnergyFlow <- EnergyFlow * temperdays * 24 * 10 # MW to MWh/10 a EnergyFlow <- oapply(EnergyFlow, cols = c("Temperature"), FUN = sum) opercost <- EnergyFlow * oper[oper\$Parameter == "Operation cost" , ] * 1E-6 # € to M€ # Include all fuels in fuelcost, also Heat and electricity to get the profits. fuelcost <- fuelPrice * fuelUse[fuelUse\$Plant != "Domestic" , ] / 3.6E+8 # From MJ to MWh, € to M€, and a to 10 a fuelcost\$Fuel <- NULL fuelcost\$Parameter <- "Fuel cost" fuelcost\$Parameter[result(fuelcost) < 0] <- "Sales proceeds" fuelcost <- oapply(unkeep(fuelcost, sources = TRUE), cols = c("Burner"), FUN = sum) cost <- combine( investment, # Investment cost maintenance, # Maintenance cost opercost, # Operation cost fuelcost # Fuel cost and profit ) colnames(cost@output)[colnames(cost@output) == "Parameter"] <- "Cost" cost <- oapply(unkeep(cost, sources = TRUE), cols = "", FUN = sum) # aggregate rows cost\$Time <- as.numeric(as.character(cost\$Time)) return(cost) } ) totalCost <- Ovariable("totalCost", dependencies = data.frame( Name = c( "plantCost", "externalCost" ) ), formula = function(...) { out <- combine(plantCost, externalCost) # out\$Cost <- factor(out\$Cost, levels = c( # "Management cost", # "Operation cost", # "Fuel cost", # "Investment cost", # "Health", # "Climate", # "Sales proceeds", # "Profit" # )) out\$Time <- as.numeric(as.character(out\$Time)) out <- oapply(unkeep(out, sources = TRUE), cols = "", FUN = sum) return(out) } ) objects.store(emissionprice, externalCost, EnergyNetworkCost, plantCost, totalCost) cat("Ovariables emissionprice, externalCost, EnergyNetworkCost, plantCost, totalCost stored.\n") ```

### Net present value

Net present value is the total value of a product, when all its costs and benefits are discounted and then summed to the present time (as if all costs and benefits would occur today). The effective annual cost is similar, but it is scaled differently: it is as if all costs and benefits would occur every year at constant rate.

### Effective annual cost

 ```# This code is Op_en3283/EAC [[Economic impacts]] library(OpasnetUtils) EAC <- Ovariable("EAC", dependencies = data.frame(Name = c( "totalCost", # costs and revenues for each year in time "discount", # discount rate (atomic number) "time" # vector of years considered )), formula = function(...) { times <- min(times):max(times) out <- 1 / (1 + discount)^(times - min(times)) out <- Ovariable( output = data.frame(Time = times, Result = out), marginal = c(TRUE, FALSE) ) out <- oapply(totalCost * out, cols = "Time", FUN = sum) # Change NPV to EAC out <- out / ((1 - 1/(1+discount)^(max(times) - min(times)))/discount) return(out) } ) # An extremely slow attempt to use different time intervals for different unique index combinations. # This code is NOT used. EACC <- function( ..., # different cost items discount = 0.03, # discount rate (atomic number) time = "Time" # column name for time index ) { allcost <- combine(...) temp <- unique(allcost[ , allcost@marginal & colnames(allcost@output) != time]@output) out <- data.frame() for(i in 1:nrow(temp)) { temp2 <- allcost temp2@output <- merge(temp2@output, temp[i , ]) times <- as.numeric(as.character(temp2@output[[time]])) times <- min(times):max(times) NPV <- 1 / (1 + discount)^(times - min(times)) NPV <- Ovariable( output = data.frame(Time = times, Result = NPV), marginal = c(TRUE, FALSE) ) NPV <- oapply(temp2 * NPV, cols = "Time", FUN = sum) # Change NPV to EAC EAC <- NPV / ((1 - 1/(1+discount)^(max(times) - min(times)))/discount) out <- rbind(out, EAC@output) } return(out) } objects.store(EAC) cat("Ovariable EAC stored.\n") ```