Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
cfe316 committed Dec 13, 2023
1 parent 838c5c5 commit fe964d1
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions src/write_outputs/write_net_revenue.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,22 @@ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::
# Add investment cost to the dataframe
dfNetRevenue.Inv_cost_MW = dfGen[!,:Inv_Cost_per_MWyr] .* dfCap[1:G,:NewCap]
dfNetRevenue.Inv_cost_MWh = dfGen[!,:Inv_Cost_per_MWhyr] .* dfCap[1:G,:NewEnergyCap]

inv_cost_charge = :Inv_Cost_Charge_per_MWyr
inv_cost_charge_rev = :Inv_Cost_charge_MW
dfNetRevenue[!, inv_cost_charge_rev] = zeros(G)
if hasproperty(dfGen, inv_cost_charge)
dfNetRevenue[!, inv_cost_charge_rev] = dfGen[!, inv_cost_charge] .* dfCap[1:G,:NewChargeCap]
end

if !isempty(VRE_STOR)
# Doesn't include charge capacities
if !isempty(SOLAR)
dfNetRevenue.Inv_cost_MW[VRE_STOR] += dfVRE_STOR[!,:Inv_Cost_Solar_per_MWyr] .* dfVreStor[1:VRE_STOR_LENGTH,:NewCapSolar]
end
if !isempty(DC)
dfNetRevenue.Inv_cost_MW[VRE_STOR] += dfVRE_STOR[!,:Inv_Cost_Inverter_per_MWyr] .* dfVreStor[1:VRE_STOR_LENGTH,:NewCapDC]
end
end
if !isempty(WIND)
dfNetRevenue.Inv_cost_MW[VRE_STOR] += dfVRE_STOR[!,:Inv_Cost_Wind_per_MWyr] .* dfVreStor[1:VRE_STOR_LENGTH,:NewCapWind]
end
Expand All @@ -50,6 +58,14 @@ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::
# Add operations and maintenance cost to the dataframe
dfNetRevenue.Fixed_OM_cost_MW = dfGen[!,:Fixed_OM_Cost_per_MWyr] .* dfCap[1:G,:EndCap]
dfNetRevenue.Fixed_OM_cost_MWh = dfGen[!,:Fixed_OM_Cost_per_MWhyr] .* dfCap[1:G,:EndEnergyCap]

fixed_om_cost_charge = :Fixed_OM_Cost_Charge_per_MWyr
fixed_om_cost_charge_rev = :Fixed_OM_cost_charge_MW
dfNetRevenue[!, fixed_om_cost_charge_rev] = zeros(G)
if hasproperty(dfGen, fixed_om_cost_charge)
dfNetRevenue[!, fixed_om_cost_charge_rev] = dfGen[!, inv_cost_charge] .* dfCap[1:G,:EndChargeCap]
end

dfNetRevenue.Var_OM_cost_out = (dfGen[!,:Var_OM_Cost_per_MWh]) .* dfPower[1:G,:AnnualSum]
if !isempty(VRE_STOR)
if !isempty(SOLAR)
Expand All @@ -59,10 +75,10 @@ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::
if !isempty(WIND)
dfNetRevenue.Fixed_OM_cost_MW[VRE_STOR] += dfVRE_STOR[!,:Fixed_OM_Wind_Cost_per_MWyr] .* dfVreStor[1:VRE_STOR_LENGTH, :EndCapWind]
dfNetRevenue.Var_OM_cost_out[WIND] += dfVRE_STOR[(dfVRE_STOR.WIND.!=0),:Var_OM_Cost_per_MWh_Wind] .* (value.(EP[:vP_WIND][WIND, :]).data * inputs["omega"])
end
end
if !isempty(DC)
dfNetRevenue.Fixed_OM_cost_MW[VRE_STOR] += dfVRE_STOR[!,:Fixed_OM_Inverter_Cost_per_MWyr] .* dfVreStor[1:VRE_STOR_LENGTH, :EndCapDC]
end
end
if !isempty(DC_DISCHARGE)
dfNetRevenue.Var_OM_cost_out[DC_DISCHARGE] += dfVRE_STOR[(dfVRE_STOR.STOR_DC_DISCHARGE.!=0),:Var_OM_Cost_per_MWh_Discharge_DC] .* (value.(EP[:vP_DC_DISCHARGE][DC_DISCHARGE, :]).data .* dfVRE_STOR[(dfVRE_STOR.STOR_DC_DISCHARGE.!=0),:EtaInverter] * inputs["omega"])
end
Expand Down Expand Up @@ -169,7 +185,18 @@ function write_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::
end

dfNetRevenue.Revenue = dfNetRevenue.EnergyRevenue .+ dfNetRevenue.SubsidyRevenue .+ dfNetRevenue.ReserveMarginRevenue .+ dfNetRevenue.ESRRevenue .+ dfNetRevenue.RegSubsidyRevenue
dfNetRevenue.Cost = dfNetRevenue.Inv_cost_MW .+ dfNetRevenue.Inv_cost_MWh .+ dfNetRevenue.Fixed_OM_cost_MW .+ dfNetRevenue.Fixed_OM_cost_MWh .+ dfNetRevenue.Var_OM_cost_out .+ dfNetRevenue.Var_OM_cost_in .+ dfNetRevenue.Fuel_cost .+ dfNetRevenue.Charge_cost .+ dfNetRevenue.EmissionsCost .+ dfNetRevenue.StartCost
dfNetRevenue.Cost = dfNetRevenue.Inv_cost_MW .+
dfNetRevenue.Inv_cost_MWh .+
dfNetRevenue.Inv_cost_charge_MW .+
dfNetRevenue.Fixed_OM_cost_MW .+
dfNetRevenue.Fixed_OM_cost_MWh .+
dfNetRevenue.Fixed_OM_cost_charge_MW .+
dfNetRevenue.Var_OM_cost_out .+
dfNetRevenue.Var_OM_cost_in .+
dfNetRevenue.Fuel_cost .+
dfNetRevenue.Charge_cost .+
dfNetRevenue.EmissionsCost .+
dfNetRevenue.StartCost
dfNetRevenue.Profit = dfNetRevenue.Revenue .- dfNetRevenue.Cost

CSV.write(joinpath(path, "NetRevenue.csv"), dfNetRevenue)
Expand Down

0 comments on commit fe964d1

Please sign in to comment.