Functions for Writing the Different Results/Outputs to Separate Files
GenX.write_annual
— Methodwrite_annual(fullpath::AbstractString, dfOut::DataFrame)
Internal function for writing annual outputs.
GenX.write_full_time_series_reconstruction
— Methodwritefulltimeseriesreconstruction(path::AbstractString, setup::Dict, DF::DataFrame, name::String) Create a DataFrame with all 8,760 hours of the year from the reduced output.
This function calls full_time_series_reconstruction()
`, which uses Period_map.csv to create a new DataFrame with 8,760 time steps, as well as other pre-existing rows such as "Zone". For each 52 weeks of the year, the corresponding representative week is taken from the input DataFrame and copied into the new DataFrame. Representative periods that represent more than one week will appear multiple times in the output.
Note: Currently, TDR only gives the representative periods in Period_map for 52 weeks, when a (non-leap) year is 52 weeks + 24 hours. This function takes the last 24 hours of the time series and copies them to get up to all 8,760 hours in a year.
This function is called when output files with time series data (e.g. power.csv, emissions.csv) are created, if the setup key "OutputFullTimeSeries" is set to "1".
Arguments
path
(AbstractString): Path input to the results foldersetup
(Dict): Case setupDF
(DataFrame): DataFrame to be reconstructedname
(String): Name desired for the .csv file
GenX.write_fulltimeseries
— Methodwrite_fulltimeseries(fullpath::AbstractString, dataOut::Matrix{Float64}, dfOut::DataFrame)
Internal function for writing full time series outputs. This function wraps the instructions for creating the full time series output files.
GenX.write_outputs
— Methodwrite_outputs(EP::Model, path::AbstractString, setup::Dict, inputs::Dict)
Function for the entry-point for writing the different output files. From here, onward several other functions are called, each for writing specific output files, like costs, capacities, etc.
GenX.write_settings_file
— Methodwrite_settings_file(path, setup)
Internal function for writing settings files
GenX.write_system_env_summary
— Methodwrite_system_env_summary(path::AbstractString)
Write a summary of the current testing environment to a YAML file. The summary includes information like the CPU name and architecture, number of CPU threads, JIT status, operating system kernel, machine name, Julia standard library path, Julia version and GenX version.
Arguments
path::AbstractString
: The directory path where the YAML file will be written.
Output
Writes a file named env_summary.yml
in the specified directory.
GenX.choose_output_dir
— Methodchoose_output_dir(pathinit)
Avoid overwriting (potentially important) existing results by appending to the directory name\n Checks if the suggested output directory already exists. While yes, it appends _1, _2, etc till an unused name is found
GenX.dftranspose
— Methoddf = dftranspose(df::DataFrame, withhead::Bool)
Returns a transpose of a Dataframe.
Write Status
GenX.write_status
— Methodwrite_status(path::AbstractString, inputs::Dict, EP::Model)
Function for writing the final solve status of the optimization problem solved.
Write CO_2 Cap
GenX.write_co2_cap
— Functionwrite_co2_cap(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for reporting carbon price associated with carbon cap constraints.
Write Costs
GenX.write_costs
— Methodwrite_costs(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for writing the costs pertaining to the objective function (fixed, variable O&M etc.).
Write Fuel Consumption
GenX.write_fuel_consumption
— Functionwrite_fuel_consumption(path::AbstractString, inputs::Dict, setup::Dict, EP::Model).
Write fuel consumption of each power plant.
Write Emissions
GenX.write_emissions
— Methodwrite_emissions(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for reporting time-dependent CO$_2$ emissions by zone.
Write Capacities
GenX.write_capacity
— Methodwrite_capacity(path::AbstractString, inputs::Dict, setup::Dict, EP::Model))
Function for writing the diferent capacities for the different generation technologies (starting capacities or, existing capacities, retired capacities, and new-built capacities).
Write Capacity Value
GenX.capacity_reserve_margin_price
— Methodcapacity_reserve_margin_price(EP::Model,
inputs::Dict,
setup::Dict,
capres_zone::Int)::Vector{Float64}
Marginal price for capacity constraint. This is equal to the dual variable of the capacity constraint. Returns a vector, with units of /MW
GenX.write_capacity_value
— Methodwrite_capacity_value(path::AbstractString,
inputs::Dict,
setup::Dict,
EP::Model)
This is the value of the derated capacities of different types of resources multiplied by the power generated by each of them
Arguments
- path::AbstractString: Path to the directory where the file will be written.
- inputs::Dict: Dictionary of input data.
- setup::Dict: Dictionary of setup data.
- EP::Model: EnergyModel object.
Results
- A CSV file named "CapacityValue.csv" is written to the directory specified by
path
.
Write Capacity Factors
GenX.write_capacityfactor
— Methodwrite_capacityfactor(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for writing the capacity factor of different resources. For co-located VRE-storage resources, this value is calculated if the site has either or both a solar PV or wind resource.
Write Charge Values
GenX.write_charge
— Methodwrite_charge(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for writing the charging energy values of the different storage technologies.
Write Non-served-energy
GenX.write_nse
— Methodwrite_nse(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for reporting non-served energy for every model zone, time step and cost-segment.
Write Storage State of Charge
GenX.write_storage
— Methodwrite_storage(path::AbstractString, inputs::Dict,setup::Dict, EP::Model)
Function for writing the capacities of different storage technologies, including hydro reservoir, flexible storage tech etc.
Write Storage Dual
GenX.write_storagedual
— Methodwrite_storagedual(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for reporting dual of storage level (state of charge) balance of each resource in each time step.
Write Power
GenX.write_power
— Methodwrite_power(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for writing the different values of power generated by the different technologies in operation.
Write Curtailment
GenX.write_curtailment
— Methodwrite_curtailment(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for writing the curtailment values of the different variable renewable resources (both standalone and co-located).
Write Prices
GenX.locational_marginal_price
— Methodlocational_marginal_price(EP::Model, inputs::Dict, setup::Dict)
Marginal electricity price for each model zone and time step. This is equal to the dual variable of the power balance constraint. When solving a linear program (i.e. linearized unit commitment or economic dispatch) this output is always available; when solving a mixed integer linear program, this can be calculated only if WriteShadowPrices
is activated.
Returns a matrix of size (T, Z).
Values have units of $/MWh
GenX.write_price
— Methodwrite_price(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for reporting marginal electricity price for each model zone and time step. Marginal electricity price is equal to the dual variable of the power balance constraint. If GenX is configured as a mixed integer linear program, then this output is only generated if WriteShadowPrices
flag is activated. If configured as a linear program (i.e. linearized unit commitment or economic dispatch) then output automatically available.
Write Reliability
GenX.write_reliability
— Methodwrite_reliability(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for reporting dual variable of maximum non-served energy constraint (shadow price of reliability constraint) for each model zone and time step.
Write Energy Revenue
GenX.write_energy_revenue
— Methodwrite_energy_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for writing energy revenue from the different generation technologies.
Write Subsidy Revenue
GenX.write_subsidy_revenue
— Methodwrite_subsidy_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for reporting subsidy revenue earned if a generator specified Min_Cap
is provided in the input file, or if a generator is subject to a Minimum Capacity Requirement constraint. The unit is $.
Write Operating Reserve and Regulation Revenue
GenX.write_operating_reserve_regulation_revenue
— Methodwrite_operating_reserve_regulation_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for reporting the operating reserve and regulation revenue earned by generators listed in the input file. GenX will print this file only when operating reserve and regulation are modeled and the shadow price can be obtained from the solver. The revenues are calculated as the operating reserve and regulation contributions in each time step multiplied by the corresponding shadow price, and then the sum is taken over all modeled time steps. The last column is the total revenue received from all operating reserve and regulation constraints. As a reminder, GenX models the operating reserve and regulation at the time-dependent level, and each constraint either stands for an overall market or a locality constraint.
Write Capacity Revenue
GenX.write_reserve_margin_revenue
— Methodwrite_reserve_margin_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for reporting the capacity revenue earned by each generator listed in the input file. GenX will print this file only when capacity reserve margin is modeled and the shadow price can be obtained form the solver. Each row corresponds to a generator, and each column starting from the 6th to the second last is the total revenue from each capacity reserve margin constraint. The revenue is calculated as the capacity contribution of each time steps multiplied by the shadow price, and then the sum is taken over all modeled time steps. The last column is the total revenue received from all capacity reserve margin constraints. As a reminder, GenX models the capacity reserve margin (aka capacity market) at the time-dependent level, and each constraint either stands for an overall market or a locality constraint.
Write Energy Share Requirement Revenue
GenX.write_esr_revenue
— Methodwrite_esr_revenue(path::AbstractString, inputs::Dict, setup::Dict, dfPower::DataFrame, dfESR::DataFrame, EP::Model)
Function for reporting the renewable/clean credit revenue earned by each generator listed in the input file. GenX will print this file only when RPS/CES is modeled and the shadow price can be obtained form the solver. Each row corresponds to a generator, and each column starting from the 6th to the second last is the total revenue earned from each RPS constraint. The revenue is calculated as the total annual generation (if elgible for the corresponding constraint) multiplied by the RPS/CES price. The last column is the total revenue received from all constraint. The unit is $.
Write Net Revenue
GenX.write_net_revenue
— Methodwrite_net_revenue(path::AbstractString, inputs::Dict, setup::Dict, EP::Model, dfCap::DataFrame, dfESRRev::DataFrame, dfResRevenue::DataFrame, dfChargingcost::DataFrame, dfPower::DataFrame, dfEnergyRevenue::DataFrame, dfSubRevenue::DataFrame, dfRegSubRevenue::DataFrame, dfVreStor::DataFrame, dfOpRegRevenue::DataFrame, dfOpRsvRevenue::DataFrame)
Function for writing net revenue of different generation technologies.
Write Co-Located VRE and Storage files
GenX.write_vre_stor
— Functionwrite_vre_stor(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for writing the vre-storage specific files.
GenX.write_vre_stor_capacity
— Functionwrite_vre_stor_capacity(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for writing the vre-storage capacities.
GenX.write_vre_stor_charge
— Functionwrite_vre_stor_charge(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for writing the vre-storage charging decision variables/expressions.
GenX.write_vre_stor_discharge
— Functionwrite_vre_stor_discharge(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for writing the vre-storage discharging decision variables/expressions.
Write Multi-stage files
GenX.write_multi_stage_outputs
— Methodwrite_multi_stage_outputs(stats_d::Dict,
outpath::String,
settings_d::Dict,
inputs_dict::Dict)
This function calls various methods which write multi-stage modeling outputs as .csv files.
Arguments:
- stats_d: Dictionary which contains the run time, upper bound, and lower bound of each DDP iteration.
- outpath: String which represents the path to the Results directory.
- settings_d: Dictionary containing settings configured in the GenX settings
genx_settings.yml
file as well as the multi-stage settings filemulti_stage_settings.yml
. - inputs_dict: Dictionary containing the input data for the multi-stage model.
GenX.write_multi_stage_costs
— Functionwrite_multi_stage_costs(outpath::String, settings_d::Dict)
This function writes the file costs_multi_stage.csv to the Results directory. This file contains variable, fixed, startup, network expansion, unmet reserve, and non-served energy costs discounted to year zero.
inputs:
- outpath – String which represents the path to the Results directory.
- settings_d - Dictionary containing settings dictionary configured in the multi-stage settings file multi_stage_settings.yml.
GenX.write_multi_stage_stats
— Functionwritemultistagestats(outpath::String, statsd::Dict)
This function writes the file stats_multi_stage.csv. to the Results directory. This file contains the runtime, upper bound, lower bound, and relative optimality gap for each iteration of the DDP algorithm.
inputs:
- outpath – String which represents the path to the Results directory.
- stats_d – Dictionary which contains the run time, upper bound, and lower bound of each DDP iteration.
GenX.write_multi_stage_settings
— Functionwrite_multi_stage_settings(outpath::AbstractString, settings_d::Dict)
Function for writing the multi-stage settings file to the output path for future reference.
GenX.write_multi_stage_network_expansion
— Functionwrite_multi_stage_network_expansion(outpath::String, settings_d::Dict)
This function writes the file network_expansion_multi_stage.csv to the Results directory. This file contains new transmission capacities for each modeled transmission line for the first and all subsequent model stages.
inputs:
- outpath – String which represents the path to the Results directory.
- settings_d - Dictionary containing settings dictionary configured in the multi-stage settings file multi_stage_settings.yml.
GenX.write_multi_stage_capacities_discharge
— Functionwrite_multi_stage_capacities_discharge(outpath::String, settings_d::Dict)
This function writes the file capacities_multi_stage.csv to the Results directory. This file contains starting resource capacities from the first model stage and end resource capacities for the first and all subsequent model stages.
inputs:
- outpath – String which represents the path to the Results directory.
- settings_d - Dictionary containing settings dictionary configured in the multi-stage settings file multi_stage_settings.yml.
GenX.write_multi_stage_capacities_charge
— Functionwrite_multi_stage_capacities_charge(outpath::String, settings_d::Dict)
This function writes the file capacities_charge_multi_stage.csv to the Results directory. This file contains starting resource charge capacities from the first model stage and end resource charge capacities for the first and all subsequent model stages.
inputs:
- outpath – String which represents the path to the Results directory.
- settings_d - Dictionary containing settings dictionary configured in the multi-stage settings file multi_stage_settings.yml.
GenX.write_multi_stage_capacities_energy
— Functionwrite_multi_stage_capacities_energy(outpath::String, settings_d::Dict)
This function writes the file capacities_energy_multi_stage.csv to the Results directory. This file contains starting resource energy capacities from the first model stage and end resource energy capacities for the first and all subsequent model stages.
inputs:
- outpath – String which represents the path to the Results directory.
- settings_d - Dictionary containing settings dictionary configured in the multi-stage settings file multi_stage_settings.yml.
GenX.create_multi_stage_stats_file
— Functioncreate_multi_stage_stats_file(outpath::String)
Create an empty CSV file in the specified output directory with the filename stats_multi_stage.csv
. The file contains the columns defined in _get_multi_stage_stats_header()
. The function first generates the filename and header using _get_multi_stage_stats_filename()
and _get_multi_stage_stats_header()
respectively. It then creates a DataFrame with column names as headers and writes it into a CSV file in the specified output directory.
Arguments
outpath::String
: The output directory where the statistics file will be written.
Returns
- Nothing. A CSV file is written to the
outpath
.
GenX.update_multi_stage_stats_file
— Functionupdate_multi_stage_stats_file(outpath::String, ic::Int64, upper_bound::Float64, lower_bound::Float64, iteration_time::Float64; new_row::Bool=false)
Update a multi-stage statistics file.
Arguments
outpath::String
: The output directory where the statistics file will be written.ic::Int64
: The iteration count.upper_bound::Float64
: The upper bound value.lower_bound::Float64
: The lower bound value.iteration_time::Float64
: The iteration time value.new_row::Bool=false
: Optional argument to determine whether to append a new row (if true) or update the current row (if false).
The function first checks if the file exists. If it does not, it creates a new one. Then, it reads the statistics from the existing file into a DataFrame. It calculates the relative gap based on the upper and lower bounds, and either appends a new row or updates the current row based on the new_row
argument. Finally, it writes the updated DataFrame back to the file.
Returns
- Nothing. A CSV file is updated or created at the
outpath
.
Write maintenance files
GenX.write_maintenance
— Methodwrite_maintenance(path::AbstractString, inputs::Dict, EP::Model)
Write DCOPF files
GenX.write_angles
— Functionwrite_angles(path::AbstractString, inputs::Dict, setup::Dict, EP::Model)
Function for reporting the bus angles for each model zone and time step if the DC_OPF flag is activated
Write Settings Files
GenX.write_settings_file
— Functionwrite_settings_file(path, setup)
Internal function for writing settings files