diff --git a/.gitignore b/.gitignore
index a67ec77ea..5355e24e1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,6 +15,7 @@ time_domain_reduction/PreCluster_Plots.jl
time_domain_reduction/TSC_Plots.jl
time_domain_reduction/TSC.jl
gurobi.log
+**/output.log
Example_Systems/SmallNewEngland/ThreeZones/TDR_*
Example_Systems/RealSystemExample/ISONE_Singlezone/Manifest.toml
Example_Systems/RealSystemExample/ISONE_Singlezone/Results*
diff --git a/Example_Systems/2020_NoEC/Run.jl b/Example_Systems/2020_NoEC/Run.jl
index ea95a1c9a..0ed8b67fc 100644
--- a/Example_Systems/2020_NoEC/Run.jl
+++ b/Example_Systems/2020_NoEC/Run.jl
@@ -27,7 +27,7 @@ src_path = "../../src/"
inpath = pwd()
### Load GenX
-println("Loading packages")
+print_and_log("Loading packages")
push!(LOAD_PATH, src_path)
using DOLPHYN
@@ -47,30 +47,30 @@ if mysetup["TimeDomainReduction"] == 1
if mysetup["ModelH2"] == 1
if (!isfile(TDRpath*"/Load_data.csv")) || (!isfile(TDRpath*"/Generators_variability.csv")) || (!isfile(TDRpath*"/Fuels_data.csv")) || (!isfile(TDRpath*"/HSC_generators_variability.csv")) || (!isfile(TDRpath*"/HSC_load_data.csv"))
- println("Clustering Time Series Data...")
+ print_and_log("Clustering Time Series Data...")
cluster_inputs(inpath, settings_path, mysetup)
else
- println("Time Series Data Already Clustered.")
+ print_and_log("Time Series Data Already Clustered.")
end
else
if (!isfile(TDRpath*"/Load_data.csv")) || (!isfile(TDRpath*"/Generators_variability.csv")) || (!isfile(TDRpath*"/Fuels_data.csv"))
- println("Clustering Time Series Data...")
+ print_and_log("Clustering Time Series Data...")
cluster_inputs(inpath, settings_path, mysetup)
else
- println("Time Series Data Already Clustered.")
+ print_and_log("Time Series Data Already Clustered.")
end
end
end
# ### Configure solver
-println("Configuring Solver")
+print_and_log("Configuring Solver")
OPTIMIZER = configure_solver(mysetup["Solver"], settings_path)
# #### Running a case
# ### Load inputs
-# println("Loading Inputs")
+# print_and_log("Loading Inputs")
myinputs = Dict() # myinputs dictionary will store read-in data and computed parameters
myinputs = load_inputs(mysetup, inpath)
@@ -80,17 +80,17 @@ if mysetup["ModelH2"] == 1
end
# ### Generate model
-# println("Generating the Optimization Model")
+# print_and_log("Generating the Optimization Model")
EP = generate_model(mysetup, myinputs, OPTIMIZER)
### Solve model
-println("Solving Model")
+print_and_log("Solving Model")
EP, solve_time = solve_model(EP, mysetup)
myinputs["solve_time"] = solve_time # Store the model solve time in myinputs
### Write power system output
-println("Writing Output")
+print_and_log("Writing Output")
outpath = "$inpath/Results"
outpath=write_outputs(EP, outpath, mysetup, myinputs)
diff --git a/Example_Systems/2030_CombEC_DETrans/Run.jl b/Example_Systems/2030_CombEC_DETrans/Run.jl
index 85eca8b64..afd29a532 100644
--- a/Example_Systems/2030_CombEC_DETrans/Run.jl
+++ b/Example_Systems/2030_CombEC_DETrans/Run.jl
@@ -27,7 +27,7 @@ src_path = "../../src/"
inpath = pwd()
### Load GenX
-println("Loading packages")
+print_and_log("Loading packages")
push!(LOAD_PATH, src_path)
using DOLPHYN
@@ -47,30 +47,30 @@ if mysetup["TimeDomainReduction"] == 1
if mysetup["ModelH2"] == 1
if (!isfile(TDRpath*"/Load_data.csv")) || (!isfile(TDRpath*"/Generators_variability.csv")) || (!isfile(TDRpath*"/Fuels_data.csv")) || (!isfile(TDRpath*"/HSC_generators_variability.csv")) || (!isfile(TDRpath*"/HSC_load_data.csv"))
- println("Clustering Time Series Data...")
+ print_and_log("Clustering Time Series Data...")
cluster_inputs(inpath, settings_path, mysetup)
else
- println("Time Series Data Already Clustered.")
+ print_and_log("Time Series Data Already Clustered.")
end
else
if (!isfile(TDRpath*"/Load_data.csv")) || (!isfile(TDRpath*"/Generators_variability.csv")) || (!isfile(TDRpath*"/Fuels_data.csv"))
- println("Clustering Time Series Data...")
+ print_and_log("Clustering Time Series Data...")
cluster_inputs(inpath, settings_path, mysetup)
else
- println("Time Series Data Already Clustered.")
+ print_and_log("Time Series Data Already Clustered.")
end
end
end
# ### Configure solver
-println("Configuring Solver")
+print_and_log("Configuring Solver")
OPTIMIZER = configure_solver(mysetup["Solver"], settings_path)
# #### Running a case
# ### Load inputs
-# println("Loading Inputs")
+# print_and_log("Loading Inputs")
myinputs = Dict() # myinputs dictionary will store read-in data and computed parameters
myinputs = load_inputs(mysetup, inpath)
@@ -80,17 +80,17 @@ if mysetup["ModelH2"] == 1
end
# ### Generate model
-# println("Generating the Optimization Model")
+# print_and_log("Generating the Optimization Model")
EP = generate_model(mysetup, myinputs, OPTIMIZER)
### Solve model
-println("Solving Model")
+print_and_log("Solving Model")
EP, solve_time = solve_model(EP, mysetup)
myinputs["solve_time"] = solve_time # Store the model solve time in myinputs
### Write power system output
-println("Writing Output")
+print_and_log("Writing Output")
outpath = "$inpath/Results"
outpath=write_outputs(EP, outpath, mysetup, myinputs)
diff --git a/Example_Systems/SmallNewEngland/ThreeZones/DOLPHYNJulEnv/Manifest.toml b/Example_Systems/SmallNewEngland/ThreeZones/DOLPHYNJulEnv/Manifest.toml
index 53c86a15f..4edf31c81 100644
--- a/Example_Systems/SmallNewEngland/ThreeZones/DOLPHYNJulEnv/Manifest.toml
+++ b/Example_Systems/SmallNewEngland/ThreeZones/DOLPHYNJulEnv/Manifest.toml
@@ -641,7 +641,7 @@ uuid = "d3d80556-e9d4-5f37-9878-2ab0fcc64255"
version = "7.1.1"
[[LinearAlgebra]]
-deps = ["Libdl"]
+deps = ["Libdl", "libblastrampoline_jll"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
[[LogExpFunctions]]
@@ -653,6 +653,12 @@ version = "0.3.0"
[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
+[[LoggingExtras]]
+deps = ["Dates", "Logging"]
+git-tree-sha1 = "5d4d2d9904227b8bd66386c1138cf4d5ffa826bf"
+uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36"
+version = "0.4.9"
+
[[LoopVectorization]]
deps = ["ArrayInterface", "DocStringExtensions", "IfElse", "LinearAlgebra", "OffsetArrays", "Polyester", "Requires", "SLEEFPirates", "Static", "StrideArraysCore", "ThreadingUtilities", "UnPack", "VectorizationBase"]
git-tree-sha1 = "9f23789217866ad9ecd053857ef202de5edcac4b"
@@ -793,6 +799,10 @@ git-tree-sha1 = "ba4a8f683303c9082e84afba96f25af3c7fb2436"
uuid = "656ef2d0-ae68-5445-9ca0-591084a874a2"
version = "0.3.12+1"
+[[OpenBLAS_jll]]
+deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
+uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
+
[[OpenLibm_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
@@ -911,7 +921,7 @@ deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
[[Random]]
-deps = ["Serialization"]
+deps = ["SHA", "Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
[[Random123]]
@@ -1262,6 +1272,10 @@ git-tree-sha1 = "f8b75e896a326a162a4f6e998990521d8302c810"
uuid = "508c9074-7a14-5c94-9582-3d4bc1871065"
version = "0.77.0+1"
+[[libblastrampoline_jll]]
+deps = ["Artifacts", "Libdl", "OpenBLAS_jll"]
+uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
+
[[libsass_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "663428b7ebaf60c60ee147f0f9466430e9959ad6"
diff --git a/Example_Systems/SmallNewEngland/ThreeZones/DOLPHYNJulEnv/Project.toml b/Example_Systems/SmallNewEngland/ThreeZones/DOLPHYNJulEnv/Project.toml
index f7b96d0fe..71596149f 100644
--- a/Example_Systems/SmallNewEngland/ThreeZones/DOLPHYNJulEnv/Project.toml
+++ b/Example_Systems/SmallNewEngland/ThreeZones/DOLPHYNJulEnv/Project.toml
@@ -17,6 +17,8 @@ Gurobi = "2e9cd046-0924-5485-92f1-d5272153d98b"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
+Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
+LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
MathProgBase = "fdba3010-5040-5b88-9595-932c9decdf73"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
diff --git a/Example_Systems/SmallNewEngland/ThreeZones/Run.jl b/Example_Systems/SmallNewEngland/ThreeZones/Run.jl
index 29e04ef5e..02388cd5e 100644
--- a/Example_Systems/SmallNewEngland/ThreeZones/Run.jl
+++ b/Example_Systems/SmallNewEngland/ThreeZones/Run.jl
@@ -14,12 +14,34 @@ in LICENSE.txt. Users uncompressing this from an archive may not have
received this license file. If not, see .
"""
+# Walk into current directory
cd(dirname(@__FILE__))
-
+# Loading settings
+using YAML
settings_path = joinpath(pwd(), "Settings")
+genx_settings = joinpath(settings_path, "genx_settings.yml") #Settings YAML file path for GenX
+hsc_settings = joinpath(settings_path, "hsc_settings.yml") #Settings YAML file path for HSC modelgrated model
+mysetup_genx = YAML.load(open(genx_settings)) # mysetup dictionary stores GenX-specific parameters
+mysetup_hsc = YAML.load(open(hsc_settings)) # mysetup dictionary stores H2 supply chain-specific parameters
+global_settings = joinpath(settings_path, "global_model_settings.yml") # Global settings for inte
+mysetup_global = YAML.load(open(global_settings)) # mysetup dictionary stores global settings
+mysetup = Dict()
+mysetup = merge(mysetup_hsc, mysetup_genx, mysetup_global) #Merge dictionary - value of common keys will be overwritten by value in global_model_settings
+
+# Start logging
+using LoggingExtras
+
+global Log = mysetup["Log"]
+
+if Log
+ logger = FileLogger(mysetup["LogFile"])
+ global_logger(logger)
+end
+
+# Activate environment
environment_path = "../../../package_activate.jl"
include(environment_path) #Run this line to activate the Julia virtual environment for GenX; skip it, if the appropriate package versions are installed
@@ -28,52 +50,41 @@ src_path = "../../../src/"
inpath = pwd()
-### Load GenX
+### Load DOLPHYN
println("Loading packages")
push!(LOAD_PATH, src_path)
using DOLPHYN
-using YAML
-
-genx_settings = joinpath(settings_path, "genx_settings.yml") #Settings YAML file path for GenX
-hsc_settings = joinpath(settings_path, "hsc_settings.yml") #Settings YAML file path for HSC modelgrated model
-mysetup_genx = YAML.load(open(genx_settings)) # mysetup dictionary stores GenX-specific parameters
-mysetup_hsc = YAML.load(open(hsc_settings)) # mysetup dictionary stores H2 supply chain-specific parameters
-global_settings = joinpath(settings_path, "global_model_settings.yml") # Global settings for inte
-mysetup_global = YAML.load(open(global_settings)) # mysetup dictionary stores global settings
-mysetup = Dict()
-mysetup = merge( mysetup_hsc, mysetup_genx, mysetup_global) #Merge dictionary - value of common keys will be overwritten by value in global_model_settings
## Cluster time series inputs if necessary and if specified by the user
TDRpath = joinpath(inpath, mysetup["TimeDomainReductionFolder"])
if mysetup["TimeDomainReduction"] == 1
-
if mysetup["ModelH2"] == 1
if (!isfile(TDRpath*"/Load_data.csv")) || (!isfile(TDRpath*"/Generators_variability.csv")) || (!isfile(TDRpath*"/Fuels_data.csv")) || (!isfile(TDRpath*"/HSC_generators_variability.csv")) || (!isfile(TDRpath*"/HSC_load_data.csv"))
- println("Clustering Time Series Data...")
+ print_and_log("Clustering Time Series Data...")
cluster_inputs(inpath, settings_path, mysetup)
else
- println("Time Series Data Already Clustered.")
+ print_and_log("Time Series Data Already Clustered.")
end
else
if (!isfile(TDRpath*"/Load_data.csv")) || (!isfile(TDRpath*"/Generators_variability.csv")) || (!isfile(TDRpath*"/Fuels_data.csv"))
- println("Clustering Time Series Data...")
+ print_and_log("Clustering Time Series Data...")
cluster_inputs(inpath, settings_path, mysetup)
else
- println("Time Series Data Already Clustered.")
+ print_and_log("Time Series Data Already Clustered.")
end
end
end
# ### Configure solver
-println("Configuring Solver")
+print_and_log("Configuring Solver")
OPTIMIZER = configure_solver(mysetup["Solver"], settings_path)
# #### Running a case
# ### Load power system inputs
-# println("Loading Inputs")
+# print_and_log("Loading Inputs")
myinputs = Dict() # myinputs dictionary will store read-in data and computed parameters
myinputs = load_inputs(mysetup, inpath)
@@ -83,17 +94,17 @@ if mysetup["ModelH2"] == 1
end
# ### Generate model
-# println("Generating the Optimization Model")
+# print_and_log("Generating the Optimization Model")
EP = generate_model(mysetup, myinputs, OPTIMIZER)
### Solve model
-println("Solving Model")
+print_and_log("Solving Model")
EP, solve_time = solve_model(EP, mysetup)
myinputs["solve_time"] = solve_time # Store the model solve time in myinputs
### Write power system output
-println("Writing Output")
+print_and_log("Writing Output")
outpath = "$inpath/Results"
outpath=write_outputs(EP, outpath, mysetup, myinputs)
diff --git a/Example_Systems/SmallNewEngland/ThreeZones/Settings/global_model_settings.yml b/Example_Systems/SmallNewEngland/ThreeZones/Settings/global_model_settings.yml
index 47b125c50..2a2aa8b00 100644
--- a/Example_Systems/SmallNewEngland/ThreeZones/Settings/global_model_settings.yml
+++ b/Example_Systems/SmallNewEngland/ThreeZones/Settings/global_model_settings.yml
@@ -7,3 +7,8 @@ WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active
OperationWrapping: 1 # Sets temporal resolution of the model; 0 = single period to represent the full year, with first-last time step linked; 1 = multiple representative periods
TimeDomainReductionFolder: "TDR_Results" # Directory name where results from time domain reduction will be saved. If results already exist here, these will be used without running time domain reduction script again.
TimeDomainReduction: 1 # Time domain reduce (i.e. cluster) inputs based on Load_data.csv, Generators_variability.csv, and Fuels_data.csv; 0 = not active (use input data as provided); 1 = active (cluster input data, or use data that has already been clustered)
+
+
+# Log file
+Log: true # Flag whether log directed to file, turing this on will record basic output into log file and keep console io stream
+LogFile: output.log # Filename for log file
\ No newline at end of file
diff --git a/Example_Systems/SmallNewEngland/ThreeZones/Settings/gurobi_settings.yml b/Example_Systems/SmallNewEngland/ThreeZones/Settings/gurobi_settings.yml
index def620fb4..96737258d 100644
--- a/Example_Systems/SmallNewEngland/ThreeZones/Settings/gurobi_settings.yml
+++ b/Example_Systems/SmallNewEngland/ThreeZones/Settings/gurobi_settings.yml
@@ -14,3 +14,7 @@ Crossover: -1 # Barrier crossver strategy.
BarObjRng: 1e+75 # Sets the maximum absolute value of the objective function
PreDual: 0 # Decides whether presolve should pass the primal or dual linear programming problem to the LP optimization algorithm.
AggFill: 10 # Allowed fill during presolve aggregation.
+
+# Gurobi log file
+GurobiLog: true # Flag whether record gurobi log into file
+GurobiLogFile: "gurobi.log" # Fulename for gurobi log
\ No newline at end of file
diff --git a/Project.toml b/Project.toml
index 12bf20be8..992f7188e 100644
--- a/Project.toml
+++ b/Project.toml
@@ -22,6 +22,8 @@ Gurobi = "2e9cd046-0924-5485-92f1-d5272153d98b"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
+Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
+LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
MathProgBase = "fdba3010-5040-5b88-9595-932c9decdf73"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
diff --git a/julenv.jl b/julenv.jl
index ac75c50ba..09fa6d200 100644
--- a/julenv.jl
+++ b/julenv.jl
@@ -52,3 +52,7 @@ Pkg.add(Pkg.PackageSpec(name="StatsBase", version="0.33.8"))
Pkg.add(Pkg.PackageSpec(name="YAML", version="0.4.7"))
Pkg.add(Pkg.PackageSpec(name="LinearAlgebra"))
Pkg.add(Pkg.PackageSpec(name="Revise"))
+
+# Logging
+Pkg.add(Pkg.PackageSpec(name="Logging"))
+Pkg.add(Pkg.PackageSpec(name="LoggingExtras"))
\ No newline at end of file
diff --git a/src/DOLPHYN.jl b/src/DOLPHYN.jl
index 8c4503dbc..638509ac3 100644
--- a/src/DOLPHYN.jl
+++ b/src/DOLPHYN.jl
@@ -17,6 +17,7 @@ received this license file. If not, see .
module DOLPHYN
#export package_activate
+export print_and_log
export configure_settings
export configure_solver
export load_inputs
@@ -60,6 +61,12 @@ ModelScalingFactor = 1e+3
# LHV is used when defining a system-wide CO2 constraint for the joint hydrogen and electricity infrastructures (SystemCO2Constraint =2)
H2_LHV = 33.33 # MWh per tonne
+# Logging flag
+Log = true
+
+# Auxiliary logging function
+include("print_and_log.jl")
+
# Configure settings
include("configure_settings/configure_settings.jl")
diff --git a/src/GenX/load_inputs/load_cap_reserve_margin.jl b/src/GenX/load_inputs/load_cap_reserve_margin.jl
index 62e0b842a..3c3e6c912 100644
--- a/src/GenX/load_inputs/load_cap_reserve_margin.jl
+++ b/src/GenX/load_inputs/load_cap_reserve_margin.jl
@@ -22,7 +22,7 @@ Function for reading input parameters related to planning reserve margin constra
function load_cap_reserve_margin(setup::Dict, path::AbstractString, sep::AbstractString, inputs_crm::Dict)
# Definition of capacity reserve margin (crm) by locational deliverability area (LDA)
- println("About to read Capacity_reserve_margin.csv")
+ print_and_log("About to read Capacity_reserve_margin.csv")
#inputs_crm["dfCapRes"] = CSV.read(string(path,sep,"Capacity_reserve_margin.csv"), header=true)
inputs_crm["dfCapRes"] = DataFrame(CSV.File(string(path, sep,"Capacity_reserve_margin.csv"), header=true), copycols=true)
@@ -36,14 +36,14 @@ function load_cap_reserve_margin(setup::Dict, path::AbstractString, sep::Abstrac
inputs_crm["dfCapRes"] = Matrix{Float64}(inputs_crm["dfCapRes"][:,first_col:last_col])
inputs_crm["NCapacityReserveMargin"] = res
- println("Capacity_reserve_margin.csv Successfully Read!")
+ print_and_log("Capacity_reserve_margin.csv Successfully Read!")
return inputs_crm
end
function load_cap_reserve_margin_trans(setup::Dict, path::AbstractString, sep::AbstractString, inputs_crm::Dict, network_var::DataFrame)
- println("About to Read Transmission's Participation in Capacity Reserve Margin")
+ print_and_log("About to Read Transmission's Participation in Capacity Reserve Margin")
res = inputs_crm["NCapacityReserveMargin"]
@@ -61,7 +61,7 @@ function load_cap_reserve_margin_trans(setup::Dict, path::AbstractString, sep::A
last_col_trans_excl = findall(s -> s == "CapRes_Excl_$res", names(network_var))[1]
dfTransCapRes_excl = network_var[:,first_col_trans_excl:last_col_trans_excl]
inputs_crm["dfTransCapRes_excl"] = Matrix{Float64}(dfTransCapRes_excl[completecases(dfTransCapRes_excl),:])
- println("Transmission's Participation in Capacity Reserve Margin is Successfully Read!")
+ print_and_log("Transmission's Participation in Capacity Reserve Margin is Successfully Read!")
return inputs_crm
end
diff --git a/src/GenX/load_inputs/load_co2_cap.jl b/src/GenX/load_inputs/load_co2_cap.jl
index ae7384d27..2a908c46b 100644
--- a/src/GenX/load_inputs/load_co2_cap.jl
+++ b/src/GenX/load_inputs/load_co2_cap.jl
@@ -71,6 +71,6 @@ function load_co2_cap(setup::Dict, path::AbstractString, sep::AbstractString, in
end
- println("CO2_cap.csv Successfully Read!")
+ print_and_log("CO2_cap.csv Successfully Read!")
return inputs_co2
end
diff --git a/src/GenX/load_inputs/load_energy_share_requirement.jl b/src/GenX/load_inputs/load_energy_share_requirement.jl
index f1304f77d..5a49a0dbd 100644
--- a/src/GenX/load_inputs/load_energy_share_requirement.jl
+++ b/src/GenX/load_inputs/load_energy_share_requirement.jl
@@ -32,6 +32,6 @@ function load_energy_share_requirement(setup::Dict, path::AbstractString, sep::A
inputs_ESR["dfESR"] = Matrix{Float64}(inputs_ESR["dfESR"][:,first_col:last_col])
inputs_ESR["nESR"] = ESR
- println("Energy_share_requirement.csv Successfully Read!")
+ print_and_log("Energy_share_requirement.csv Successfully Read!")
return inputs_ESR
end
diff --git a/src/GenX/load_inputs/load_fuels_data.jl b/src/GenX/load_inputs/load_fuels_data.jl
index 8551e0deb..378e131d4 100644
--- a/src/GenX/load_inputs/load_fuels_data.jl
+++ b/src/GenX/load_inputs/load_fuels_data.jl
@@ -50,7 +50,7 @@ function load_fuels_data(setup::Dict, path::AbstractString, sep::AbstractString,
inputs_fuel["fuel_costs"] = fuel_costs
inputs_fuel["fuel_CO2"] = fuel_CO2
- println("Fuels_data.csv Successfully Read!")
+ print_and_log("Fuels_data.csv Successfully Read!")
return inputs_fuel, fuel_costs, fuel_CO2
end
diff --git a/src/GenX/load_inputs/load_generators_data.jl b/src/GenX/load_inputs/load_generators_data.jl
index b41d52526..34d63933d 100644
--- a/src/GenX/load_inputs/load_generators_data.jl
+++ b/src/GenX/load_inputs/load_generators_data.jl
@@ -221,7 +221,7 @@ function load_generators_data(setup::Dict, path::AbstractString, sep::AbstractSt
end
end
- println("Generators_data.csv Successfully Read!")
+ print_and_log("Generators_data.csv Successfully Read!")
return inputs_gen
end
diff --git a/src/GenX/load_inputs/load_generators_variability.jl b/src/GenX/load_inputs/load_generators_variability.jl
index 29a8912d8..44a2ba6c6 100644
--- a/src/GenX/load_inputs/load_generators_variability.jl
+++ b/src/GenX/load_inputs/load_generators_variability.jl
@@ -35,7 +35,7 @@ function load_generators_variability(setup::Dict, path::AbstractString, sep::Abs
# Maximum power output and variability of each energy resource
inputs_genvar["pP_Max"] = transpose(Matrix{Float64}(gen_var[1:inputs_genvar["T"],2:(inputs_genvar["G"]+1)]))
- println("Generators_variability.csv Successfully Read!")
+ print_and_log("Generators_variability.csv Successfully Read!")
return inputs_genvar
end
diff --git a/src/GenX/load_inputs/load_inputs.jl b/src/GenX/load_inputs/load_inputs.jl
index 0335e4305..262b837f3 100644
--- a/src/GenX/load_inputs/load_inputs.jl
+++ b/src/GenX/load_inputs/load_inputs.jl
@@ -39,7 +39,7 @@ function load_inputs(setup::Dict,path::AbstractString)
data_directory = chop(replace(path, pwd() => ""), head = 1, tail = 0)
## Read input files
- println("Reading Input CSV Files")
+ print_and_log("Reading Input CSV Files")
## Declare Dict (dictionary) object used to store parameters
inputs = Dict()
# Read input data about power network topology, operating and expansion attributes
@@ -88,7 +88,7 @@ function load_inputs(setup::Dict,path::AbstractString)
inputs = load_period_map(setup, path, sep, inputs)
end
- println("CSV Files Successfully Read In From $path$sep")
+ print_and_log("CSV Files Successfully Read In From $path$sep")
return inputs
end
diff --git a/src/GenX/load_inputs/load_load_data.jl b/src/GenX/load_inputs/load_load_data.jl
index d0c1471fe..c3b66e0ec 100644
--- a/src/GenX/load_inputs/load_load_data.jl
+++ b/src/GenX/load_inputs/load_load_data.jl
@@ -75,7 +75,7 @@ function load_load_data(setup::Dict, path::AbstractString, sep::AbstractString,
inputs_load["INTERIOR_SUBPERIODS"] = setdiff(1:T,inputs_load["START_SUBPERIODS"]) # set of indexes for all time periods that do not start a subperiod
# Demand in MW for each zone
- #println(names(load_in))
+ #print_and_log(names(load_in))
start = findall(s -> s == "Load_MW_z1", names(load_in))[1] #gets the starting column number of all the columns, with header "Load_MW_z1"
if setup["ParameterScale"] ==1 # Parameter scaling turned on
# Max value of non-served energy
@@ -117,7 +117,7 @@ function load_load_data(setup::Dict, path::AbstractString, sep::AbstractString,
inputs_load["pMax_D_Curtail"][s] = collect(skipmissing(load_in[!,:Max_Demand_Curtailment]))[s]
end
- println("Load_data.csv Successfully Read!")
+ print_and_log("Load_data.csv Successfully Read!")
return inputs_load
end
diff --git a/src/GenX/load_inputs/load_minimum_capacity_requirement.jl b/src/GenX/load_inputs/load_minimum_capacity_requirement.jl
index 559006454..bc493f772 100644
--- a/src/GenX/load_inputs/load_minimum_capacity_requirement.jl
+++ b/src/GenX/load_inputs/load_minimum_capacity_requirement.jl
@@ -31,7 +31,7 @@ function load_minimum_capacity_requirement(path::AbstractString,sep::AbstractStr
inputs["MinCapReq"] = inputs["MinCapReq"]/ModelScalingFactor # Convert to GW
end
- println("Minimum_capacity_requirement.csv Successfully Read!")
+ print_and_log("Minimum_capacity_requirement.csv Successfully Read!")
return inputs
end
diff --git a/src/GenX/load_inputs/load_network_data.jl b/src/GenX/load_inputs/load_network_data.jl
index c256e7cab..d24cad383 100644
--- a/src/GenX/load_inputs/load_network_data.jl
+++ b/src/GenX/load_inputs/load_network_data.jl
@@ -106,7 +106,7 @@ function load_network_data(setup::Dict, path::AbstractString, sep::AbstractStrin
inputs_nw["NO_EXPANSION_LINES"] = findall(inputs_nw["pMax_Line_Reinforcement"].<0)
end
- println("Network.csv Successfully Read!")
+ print_and_log("Network.csv Successfully Read!")
return inputs_nw, network_var
end
diff --git a/src/GenX/load_inputs/load_period_map.jl b/src/GenX/load_inputs/load_period_map.jl
index 15a39932b..82dfd635c 100644
--- a/src/GenX/load_inputs/load_period_map.jl
+++ b/src/GenX/load_inputs/load_period_map.jl
@@ -27,7 +27,7 @@ function load_period_map(setup::Dict,path::AbstractString,sep::AbstractString, i
inputs["Period_Map"] = DataFrame(CSV.File(string(path,sep,"Period_map.csv"), header=true), copycols=true)
end
- println("Period_map.csv Successfully Read!")
+ print_and_log("Period_map.csv Successfully Read!")
return inputs
end
diff --git a/src/GenX/load_inputs/load_reserves.jl b/src/GenX/load_inputs/load_reserves.jl
index bc83fbc36..9754bfaa7 100644
--- a/src/GenX/load_inputs/load_reserves.jl
+++ b/src/GenX/load_inputs/load_reserves.jl
@@ -58,7 +58,7 @@ function load_reserves(setup::Dict,path::AbstractString,sep::AbstractString, inp
end
end
- println("Reserves.csv Successfully Read!")
+ print_and_log("Reserves.csv Successfully Read!")
return inputs_res
end
diff --git a/src/GenX/model/core/discharge/discharge.jl b/src/GenX/model/core/discharge/discharge.jl
index 710eea4e2..853f78f9d 100644
--- a/src/GenX/model/core/discharge/discharge.jl
+++ b/src/GenX/model/core/discharge/discharge.jl
@@ -31,7 +31,7 @@ This module additionally defines contributions to the objective function from va
"""
function discharge(EP::Model, inputs::Dict)
- println("Discharge Module")
+ print_and_log("Discharge Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/core/discharge/investment_discharge.jl b/src/GenX/model/core/discharge/investment_discharge.jl
index 2e472a178..abe6df1ce 100644
--- a/src/GenX/model/core/discharge/investment_discharge.jl
+++ b/src/GenX/model/core/discharge/investment_discharge.jl
@@ -56,7 +56,7 @@ In addition, this function adds investment and fixed O\&M related costs related
"""
function investment_discharge(EP::Model, inputs::Dict)
- println("Investment Discharge Module")
+ print_and_log("Investment Discharge Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/core/emissions_power.jl b/src/GenX/model/core/emissions_power.jl
index 804d6481c..6cd0ba0ef 100644
--- a/src/GenX/model/core/emissions_power.jl
+++ b/src/GenX/model/core/emissions_power.jl
@@ -21,7 +21,7 @@ This function creates expression to add the CO2 emissions by plants in each zone
"""
function emissions_power(EP::Model, inputs::Dict, setup::Dict)
- println("Emissions Module for CO2 Policy modularization")
+ print_and_log("Emissions Module for CO2 Policy modularization")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/core/non_served_energy.jl b/src/GenX/model/core/non_served_energy.jl
index 6705db581..b9789d7a8 100644
--- a/src/GenX/model/core/non_served_energy.jl
+++ b/src/GenX/model/core/non_served_energy.jl
@@ -61,7 +61,7 @@ Additionally, total demand curtailed in each time step cannot exceed total deman
"""
function non_served_energy(EP::Model, inputs::Dict)
- println("Non-served Energy Module")
+ print_and_log("Non-served Energy Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/core/reserves.jl b/src/GenX/model/core/reserves.jl
index fd665feb3..e39019e71 100644
--- a/src/GenX/model/core/reserves.jl
+++ b/src/GenX/model/core/reserves.jl
@@ -85,7 +85,7 @@ where $M_y$ is a `big M' constant equal to the largest possible capacity that ca
"""
function reserves_contingency(EP::Model, inputs::Dict, UCommit::Int)
- println("Reserves Contingency Module")
+ print_and_log("Reserves Contingency Module")
dfGen = inputs["dfGen"]
@@ -114,15 +114,15 @@ function reserves_contingency(EP::Model, inputs::Dict, UCommit::Int)
### Expressions ###
if UCommit == 1 && pDynamic_Contingency == 1
# Largest contingency defined as largest installed generator
- println("Dynamic Contingency Type 1: Modeling the largest contingency as the largest installed generator")
+ print_and_log("Dynamic Contingency Type 1: Modeling the largest contingency as the largest installed generator")
@expression(EP, eContingencyReq[t=1:T], vLARGEST_CONTINGENCY)
elseif UCommit == 1 && pDynamic_Contingency == 2
# Largest contingency defined for each hour as largest committed generator
- println("Dynamic Contingency Type 2: Modeling the largest contingency as the largest largest committed generator")
+ print_and_log("Dynamic Contingency Type 2: Modeling the largest contingency as the largest largest committed generator")
@expression(EP, eContingencyReq[t=1:T], vLARGEST_CONTINGENCY[t])
else
# Largest contingency defined fixed as user-specifed static contingency in MW
- println("Static Contingency: Modeling the largest contingency as user-specifed static contingency")
+ print_and_log("Static Contingency: Modeling the largest contingency as user-specifed static contingency")
@expression(EP, eContingencyReq[t=1:T], inputs["pStatic_Contingency"])
end
@@ -206,7 +206,7 @@ function reserves_core(EP::Model, inputs::Dict, UCommit::Int)
# DEV NOTE: After simplifying reserve changes are integrated/confirmed, should we revise such that reserves can be modeled without UC constraints on?
# Is there a use case for economic dispatch constraints with reserves?
- println("Reserves Core Module")
+ print_and_log("Reserves Core Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/core/transmission.jl b/src/GenX/model/core/transmission.jl
index a5a45aa04..2ab27b241 100644
--- a/src/GenX/model/core/transmission.jl
+++ b/src/GenX/model/core/transmission.jl
@@ -130,7 +130,7 @@ As with losses option 2, this segment-wise approximation of a quadratic loss fun
"""
function transmission(EP::Model, inputs::Dict, UCommit::Int, NetworkExpansion::Int)
- println("Transmission Module")
+ print_and_log("Transmission Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/core/ucommit.jl b/src/GenX/model/core/ucommit.jl
index 5bbc8210b..f60143843 100644
--- a/src/GenX/model/core/ucommit.jl
+++ b/src/GenX/model/core/ucommit.jl
@@ -40,7 +40,7 @@ The sum of start-up costs is added to the objective function.
"""
function ucommit(EP::Model, inputs::Dict, UCommit::Int)
- println("Unit Commitment Module")
+ print_and_log("Unit Commitment Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/policies/cap_reserve_margin.jl b/src/GenX/model/policies/cap_reserve_margin.jl
index c1e644564..b2ef857a2 100644
--- a/src/GenX/model/policies/cap_reserve_margin.jl
+++ b/src/GenX/model/policies/cap_reserve_margin.jl
@@ -33,7 +33,7 @@ Note that multiple capacity reserve margin requirements can be specified coverin
"""
function cap_reserve_margin(EP::Model, inputs::Dict, setup::Dict)
# capacity reserve margin constraint
- println("Capacity Reserve Margin Policies Module")
+ print_and_log("Capacity Reserve Margin Policies Module")
dfGen = inputs["dfGen"]
G = inputs["G"]
SEG = inputs["SEG"] # Number of lines
diff --git a/src/GenX/model/policies/co2_cap_power.jl b/src/GenX/model/policies/co2_cap_power.jl
index 18845e36a..5ae874746 100644
--- a/src/GenX/model/policies/co2_cap_power.jl
+++ b/src/GenX/model/policies/co2_cap_power.jl
@@ -60,7 +60,7 @@ Note that the generator-side rate-based constraint can be used to represent a fe
"""
function co2_cap_power(EP::Model, inputs::Dict, setup::Dict)
- println("C02 Policies Module")
+ print_and_log("C02 Policies Module")
dfGen = inputs["dfGen"]
SEG = inputs["SEG"] # Number of lines
diff --git a/src/GenX/model/policies/energy_share_requirement.jl b/src/GenX/model/policies/energy_share_requirement.jl
index d1dd5c2ed..381bd4bc3 100644
--- a/src/GenX/model/policies/energy_share_requirement.jl
+++ b/src/GenX/model/policies/energy_share_requirement.jl
@@ -34,7 +34,7 @@ The final term in the summation above adds roundtrip storage losses to the total
"""
function energy_share_requirement(EP::Model, inputs::Dict, setup::Dict)
- println("Energy Share Requirement Policies Module")
+ print_and_log("Energy Share Requirement Policies Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/policies/minimum_capacity_requirement.jl b/src/GenX/model/policies/minimum_capacity_requirement.jl
index 5ad46052d..73c82014f 100644
--- a/src/GenX/model/policies/minimum_capacity_requirement.jl
+++ b/src/GenX/model/policies/minimum_capacity_requirement.jl
@@ -29,7 +29,7 @@ Note that $\epsilon_{y,z,p}^{MinCapReq}$ is the eligiblity of a generator of tec
"""
function minimum_capacity_requirement(EP::Model, inputs::Dict)
- println("Minimum Capacity Requirement Module")
+ print_and_log("Minimum Capacity Requirement Module")
dfGen = inputs["dfGen"]
NumberOfMinCapReqs = inputs["NumberOfMinCapReqs"]
diff --git a/src/GenX/model/resources/curtailable_variable_renewable/curtailable_variable_renewable.jl b/src/GenX/model/resources/curtailable_variable_renewable/curtailable_variable_renewable.jl
index 855048ad8..edbff9f62 100644
--- a/src/GenX/model/resources/curtailable_variable_renewable/curtailable_variable_renewable.jl
+++ b/src/GenX/model/resources/curtailable_variable_renewable/curtailable_variable_renewable.jl
@@ -39,7 +39,7 @@ function curtailable_variable_renewable(EP::Model, inputs::Dict, Reserves::Int)
## Controllable variable renewable generators
### Option of modeling VRE generators with multiple availability profiles and capacity limits - Num_VRE_Bins in Generators_data.csv >1
## Default value of Num_VRE_Bins ==1
- println("Dispatchable Resources Module")
+ print_and_log("Dispatchable Resources Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/resources/flexible_demand/flexible_demand.jl b/src/GenX/model/resources/flexible_demand/flexible_demand.jl
index 838091e7c..dbd925f7c 100644
--- a/src/GenX/model/resources/flexible_demand/flexible_demand.jl
+++ b/src/GenX/model/resources/flexible_demand/flexible_demand.jl
@@ -68,7 +68,7 @@ If $t$ is first time step of the year (or the first time step of the representat
function flexible_demand(EP::Model, inputs::Dict)
## Flexible demand resources available during all hours and can be either delayed or advanced (virtual storage-shiftable demand) - DR ==1
- println("Flexible Demand Resources Module")
+ print_and_log("Flexible Demand Resources Module")
dfGen = inputs["dfGen"]
@@ -136,12 +136,12 @@ function flexible_demand(EP::Model, inputs::Dict)
FLEXIBLE_DEMAND_DELAY_HOURS = [] # Set of hours in the summation term of the maximum demand delay constraint for the first subperiod of each representative period
for s in START_SUBPERIODS
flexible_demand_delay_start = s+hours_per_subperiod-max_flexible_demand_delay
- println("Max flexible demand delay type")
- println(typeof(max_flexible_demand_delay))
- println("Hours per subperiod type")
- println(typeof(hours_per_subperiod))
- println("Type of s")
- println(typeof(s))
+ print_and_log("Max flexible demand delay type")
+ print_and_log(typeof(max_flexible_demand_delay))
+ print_and_log("Hours per subperiod type")
+ print_and_log(typeof(hours_per_subperiod))
+ print_and_log("Type of s")
+ print_and_log(typeof(s))
FLEXIBLE_DEMAND_DELAY_HOURS = union(FLEXIBLE_DEMAND_DELAY_HOURS, flexible_demand_delay_start:(s+hours_per_subperiod-2))
end
diff --git a/src/GenX/model/resources/hydro/hydro_inter_period_linkage.jl b/src/GenX/model/resources/hydro/hydro_inter_period_linkage.jl
index 649dde547..c9e2839f6 100644
--- a/src/GenX/model/resources/hydro/hydro_inter_period_linkage.jl
+++ b/src/GenX/model/resources/hydro/hydro_inter_period_linkage.jl
@@ -60,7 +60,7 @@ Finally, the next constraint enforces that the initial storage level for each in
"""
function hydro_inter_period_linkage(EP::Model, inputs::Dict)
- println("Long Duration Storage Module for Hydro Reservoir")
+ print_and_log("Long Duration Storage Module for Hydro Reservoir")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/resources/hydro/hydro_res.jl b/src/GenX/model/resources/hydro/hydro_res.jl
index 36ab80a5d..a1754a801 100644
--- a/src/GenX/model/resources/hydro/hydro_res.jl
+++ b/src/GenX/model/resources/hydro/hydro_res.jl
@@ -92,7 +92,7 @@ In case the reservoir capacity is known ($y \in W^{cap}$), then an additional co
"""
function hydro_res(EP::Model, inputs::Dict, Reserves::Int)
- println("Hydro Reservoir Core Resources Module")
+ print_and_log("Hydro Reservoir Core Resources Module")
dfGen = inputs["dfGen"]
@@ -213,7 +213,7 @@ r_{y,z, t} \leq \upsilon^{rsv}_{y,z}\times \Delta^{total}_{y,z}
"""
function hydro_res_reserves(EP::Model, inputs::Dict)
- println("Hydro Reservoir Reserves Module")
+ print_and_log("Hydro Reservoir Reserves Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/resources/must_run/must_run.jl b/src/GenX/model/resources/must_run/must_run.jl
index 6a95fab12..9385c95d9 100644
--- a/src/GenX/model/resources/must_run/must_run.jl
+++ b/src/GenX/model/resources/must_run/must_run.jl
@@ -30,7 +30,7 @@ For must-run resources ($y\in \mathcal{MR}$) output in each time period $t$ must
"""
function must_run(EP::Model, inputs::Dict)
- println("Must-Run Resources Module")
+ print_and_log("Must-Run Resources Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/resources/storage/investment_charge.jl b/src/GenX/model/resources/storage/investment_charge.jl
index dc8f0326b..86bfaacd3 100644
--- a/src/GenX/model/resources/storage/investment_charge.jl
+++ b/src/GenX/model/resources/storage/investment_charge.jl
@@ -56,7 +56,7 @@ In addition, this function adds investment and fixed O&M related costs related t
"""
function investment_charge(EP::Model, inputs::Dict)
- println("Charge Investment Module")
+ print_and_log("Charge Investment Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/resources/storage/investment_energy.jl b/src/GenX/model/resources/storage/investment_energy.jl
index 93e3743b7..ea1250800 100644
--- a/src/GenX/model/resources/storage/investment_energy.jl
+++ b/src/GenX/model/resources/storage/investment_energy.jl
@@ -59,7 +59,7 @@ In addition, this function adds investment and fixed O\&M related costs related
"""
function investment_energy(EP::Model, inputs::Dict)
- println("Storage Investment Module")
+ print_and_log("Storage Investment Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/resources/storage/long_duration_storage.jl b/src/GenX/model/resources/storage/long_duration_storage.jl
index f82dffd7e..f02673ca5 100644
--- a/src/GenX/model/resources/storage/long_duration_storage.jl
+++ b/src/GenX/model/resources/storage/long_duration_storage.jl
@@ -73,7 +73,7 @@ Finally, the next constraint enforces that the initial storage level for each in
"""
function long_duration_storage(EP::Model, inputs::Dict)
- println("Long Duration Storage Module")
+ print_and_log("Long Duration Storage Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/resources/storage/storage.jl b/src/GenX/model/resources/storage/storage.jl
index 7e3f285d5..6536e8e00 100644
--- a/src/GenX/model/resources/storage/storage.jl
+++ b/src/GenX/model/resources/storage/storage.jl
@@ -146,7 +146,7 @@ The above reserve related constraints are established by ```storage_all_reserves
"""
function storage(EP::Model, inputs::Dict, Reserves::Int, OperationWrapping::Int)
- println("Storage Resources Module")
+ print_and_log("Storage Resources Module")
if !isempty(inputs["STOR_ALL"]) #&& OperationWrapping == 1
EP = investment_energy(EP, inputs)
diff --git a/src/GenX/model/resources/storage/storage_all.jl b/src/GenX/model/resources/storage/storage_all.jl
index 42b9c8355..55a1884e2 100644
--- a/src/GenX/model/resources/storage/storage_all.jl
+++ b/src/GenX/model/resources/storage/storage_all.jl
@@ -21,7 +21,7 @@ Sets up variables and constraints common to all storage resources. See ```storag
"""
function storage_all(EP::Model, inputs::Dict, Reserves::Int, OperationWrapping::Int)
# Setup variables, constraints, and expressions common to all storage resources
- println("Storage Core Resources Module")
+ print_and_log("Storage Core Resources Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/resources/storage/storage_asymmetric.jl b/src/GenX/model/resources/storage/storage_asymmetric.jl
index eddac0eea..9c4a8efc8 100644
--- a/src/GenX/model/resources/storage/storage_asymmetric.jl
+++ b/src/GenX/model/resources/storage/storage_asymmetric.jl
@@ -24,7 +24,7 @@ function storage_asymmetric(EP::Model, inputs::Dict, Reserves::Int)
# (e.g. most chemical, thermal, and mechanical storage options with distinct charge & discharge components/processes)
# STOR = 2 corresponds to storage with distinct power and energy capacity decisions and distinct charge and discharge power capacity decisions/ratings
- println("Storage Resources with Asmymetric Charge/Discharge Capacity Module")
+ print_and_log("Storage Resources with Asmymetric Charge/Discharge Capacity Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/resources/storage/storage_symmetric.jl b/src/GenX/model/resources/storage/storage_symmetric.jl
index 88dff3b9a..2aab66564 100644
--- a/src/GenX/model/resources/storage/storage_symmetric.jl
+++ b/src/GenX/model/resources/storage/storage_symmetric.jl
@@ -24,7 +24,7 @@ function storage_symmetric(EP::Model, inputs::Dict, Reserves::Int)
# (e.g. most electrochemical batteries that use same components for charge & discharge)
# STOR = 1 corresponds to storage with distinct power and energy capacity decisions but symmetric charge/discharge power ratings
- println("Storage Resources with Symmetric Charge/Discharge Capacity Module")
+ print_and_log("Storage Resources with Symmetric Charge/Discharge Capacity Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/resources/thermal/thermal_commit.jl b/src/GenX/model/resources/thermal/thermal_commit.jl
index a268df1ea..50725abc6 100644
--- a/src/GenX/model/resources/thermal/thermal_commit.jl
+++ b/src/GenX/model/resources/thermal/thermal_commit.jl
@@ -142,7 +142,7 @@ It is recommended that users of GenX must use longer subperiods than the longest
"""
function thermal_commit(EP::Model, inputs::Dict, Reserves::Int)
- println("Thermal (Unit Commitment) Resources Module")
+ print_and_log("Thermal (Unit Commitment) Resources Module")
dfGen = inputs["dfGen"]
@@ -289,7 +289,7 @@ Note there are multiple versions of these constraints in the code in order to av
"""
function thermal_commit_reserves(EP::Model, inputs::Dict)
- println("Thermal Commit Reserves Module")
+ print_and_log("Thermal Commit Reserves Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/model/resources/thermal/thermal_no_commit.jl b/src/GenX/model/resources/thermal/thermal_no_commit.jl
index f2ad3b4cc..c847f09e5 100644
--- a/src/GenX/model/resources/thermal/thermal_no_commit.jl
+++ b/src/GenX/model/resources/thermal/thermal_no_commit.jl
@@ -59,7 +59,7 @@ When not modeling regulation and reserves, thermal units not subject to unit com
"""
function thermal_no_commit(EP::Model, inputs::Dict, Reserves::Int)
- println("Thermal (No Unit Commitment) Resources Module")
+ print_and_log("Thermal (No Unit Commitment) Resources Module")
dfGen = inputs["dfGen"]
@@ -166,7 +166,7 @@ Note there are multiple versions of these constraints in the code in order to av
"""
function thermal_no_commit_reserves(EP::Model, inputs::Dict)
- println("Thermal No Commit Reserves Module")
+ print_and_log("Thermal No Commit Reserves Module")
dfGen = inputs["dfGen"]
diff --git a/src/GenX/write_outputs/write_outputs.jl b/src/GenX/write_outputs/write_outputs.jl
index 6d2cf5296..33125dfee 100644
--- a/src/GenX/write_outputs/write_outputs.jl
+++ b/src/GenX/write_outputs/write_outputs.jl
@@ -61,63 +61,48 @@ function write_outputs(EP::Model, path::AbstractString, setup::Dict, inputs::Dic
write_status(path, sep, inputs, setup, EP)
elapsed_time_costs = @elapsed write_costs(path, sep, inputs, setup, EP)
- println("Time elapsed for writing costs is")
- println(elapsed_time_costs)
+ print_and_log("Time elapsed for writing costs is $elapsed_time_costs")
dfCap = write_capacity(path, sep, inputs, setup, EP)
dfPower = write_power(path, sep, inputs, setup, EP)
dfCharge = write_charge(path, sep, inputs, setup, EP)
elapsed_time_storage = @elapsed write_storage(path, sep, inputs, setup, EP)
- println("Time elapsed for writing storage is")
- println(elapsed_time_storage)
+ print_and_log("Time elapsed for writing storage is $elapsed_time_storage")
dfCurtailment = write_curtailment(path, sep, inputs, setup, EP)
elapsed_time_nse = @elapsed write_nse(path, sep, inputs, setup, EP)
- println("Time elapsed for writing nse is")
- println(elapsed_time_nse)
+ print_and_log("Time elapsed for writing nse is $elapsed_time_nse")
elapsed_time_power_balance = @elapsed write_power_balance(path, sep, inputs, setup, EP)
- println("Time elapsed for writing power balance is")
- println(elapsed_time_power_balance)
+ print_and_log("Time elapsed for writing power balance is $elapsed_time_power_balance")
if inputs["Z"] > 1
elapsed_time_flows = @elapsed write_transmission_flows(path, sep, setup, inputs, EP)
- println("Time elapsed for writing transmission flows is")
- println(elapsed_time_flows)
+ print_and_log("Time elapsed for writing transmission flows is $elapsed_time_flows")
elapsed_time_losses = @elapsed write_transmission_losses(path, sep, inputs, setup, EP)
- println("Time elapsed for writing transmission losses is")
- println(elapsed_time_losses)
+ print_and_log("Time elapsed for writing transmission losses is $elapsed_time_losses")
if setup["NetworkExpansion"] == 1
elapsed_time_expansion = @elapsed write_nw_expansion(path, sep, inputs, setup, EP)
- println("Time elapsed for writing network expansion is")
- println(elapsed_time_expansion)
+ print_and_log("Time elapsed for writing network expansion is $elapsed_time_expansion")
end
end
elapsed_time_emissions = @elapsed write_emissions(path, sep, inputs, setup, EP)
- println("Time elapsed for writing emissions is")
- println(elapsed_time_emissions)
+ print_and_log("Time elapsed for writing emissions is $elapsed_time_emissions")
if has_duals(EP) == 1
elapsed_time_reliability = @elapsed write_reliability(path, sep, inputs, setup, EP)
- println("Time elapsed for writing reliability is")
- println(elapsed_time_reliability)
+ print_and_log("Time elapsed for writing reliability is $elapsed_time_reliability")
elapsed_time_stordual = @elapsed write_storagedual(path, sep, inputs, setup, EP)
- println("Time elapsed for writing storage duals is")
- println(elapsed_time_stordual)
+ print_and_log("Time elapsed for writing storage duals is $elapsed_time_stordual")
end
if setup["UCommit"] >= 1
elapsed_time_commit = @elapsed write_commit(path, sep, inputs, setup, EP)
- println("Time elapsed for writing commitment is")
- println(elapsed_time_commit)
+ print_and_log("Time elapsed for writing commitment is $elapsed_time_commit")
elapsed_time_start = @elapsed write_start(path, sep, inputs, setup, EP)
- println("Time elapsed for writing startup is")
- println(elapsed_time_start)
+ print_and_log("Time elapsed for writing startup is $elapsed_time_start")
elapsed_time_shutdown = @elapsed write_shutdown(path, sep, inputs, setup, EP)
- println("Time elapsed for writing shutdown is")
- println(elapsed_time_shutdown)
+ print_and_log("Time elapsed for writing shutdown is $elapsed_time_shutdown")
if setup["Reserves"] == 1
elapsed_time_reg = @elapsed write_reg(path, sep, inputs, setup, EP)
- println("Time elapsed for writing regulation is")
- println(elapsed_time_reg)
+ print_and_log("Time elapsed for writing regulation is $elapsed_time_reg")
elapsed_time_rsv = @elapsed write_rsv(path, sep, inputs, setup, EP)
- println("Time elapsed for writing reserves is")
- println(elapsed_time_rsv)
+ print_and_log("Time elapsed for writing reserves is $elapsed_time_rsv")
end
end
@@ -125,11 +110,9 @@ function write_outputs(EP::Model, path::AbstractString, setup::Dict, inputs::Dic
# Output additional variables related inter-period energy transfer via storage
if setup["OperationWrapping"] == 1 && !isempty(inputs["STOR_LONG_DURATION"])
elapsed_time_lds_init = @elapsed write_opwrap_lds_stor_init(path, sep, inputs, setup, EP)
- println("Time elapsed for writing lds init is")
- println(elapsed_time_lds_init)
+ print_and_log("Time elapsed for writing lds init is $elapsed_time_lds_init")
elapsed_time_lds_dstor = @elapsed write_opwrap_lds_dstor(path, sep, inputs, setup, EP)
- println("Time elapsed for writing lds dstor is")
- println(elapsed_time_lds_dstor)
+ print_and_log("Time elapsed for writing lds dstor is $elapsed_time_lds_dstor")
end
dfPrice = DataFrame()
@@ -145,8 +128,7 @@ function write_outputs(EP::Model, path::AbstractString, setup::Dict, inputs::Dic
end
elapsed_time_time_weights = @elapsed write_time_weights(path, sep, inputs)
- println("Time elapsed for writing time weights is")
- println(elapsed_time_time_weights)
+ print_and_log("Time elapsed for writing time weights is $elapsed_time_time_weights")
dfESR = DataFrame()
dfESRRev = DataFrame()
if setup["EnergyShareRequirement"]==1 && has_duals(EP) == 1
@@ -158,19 +140,16 @@ function write_outputs(EP::Model, path::AbstractString, setup::Dict, inputs::Dic
if setup["CapacityReserveMargin"]==1 && has_duals(EP) == 1
dfResMar = write_reserve_margin(path, sep, setup, EP)
elapsed_time_rsv_margin = @elapsed write_reserve_margin_w(path, sep, inputs, setup, EP)
- println("Time elapsed for writing reserve margin is")
- println(elapsed_time_rsv_margin)
+ print_and_log("Time elapsed for writing reserve margin is $elapsed_time_rsv_margin")
dfResRevenue = write_reserve_margin_revenue(path, sep, inputs, setup, dfPower, dfCharge, dfResMar, dfCap)
elapsed_time_cap_value = @elapsed write_capacity_value(path, sep, inputs, setup, dfPower, dfCharge, dfResMar, dfCap)
- println("Time elapsed for writing capacity value is")
- println(elapsed_time_cap_value)
+ print_and_log("Time elapsed for writing capacity value is $elapsed_time_cap_value")
end
elapsed_time_net_rev = @elapsed write_net_revenue(path, sep, inputs, setup, EP, dfCap, dfESRRev, dfResRevenue, dfChargingcost, dfPower, dfEnergyRevenue, dfSubRevenue, dfRegSubRevenue)
- println("Time elapsed for writing net revenue is")
- println(elapsed_time_net_rev)
+ print_and_log("Time elapsed for writing net revenue is $elapsed_time_net_rev")
## Print confirmation
- println("Wrote outputs to $path$sep")
+ print_and_log("Wrote outputs to $path$sep")
return path
diff --git a/src/HSC/load_inputs/load_H2_inputs.jl b/src/HSC/load_inputs/load_H2_inputs.jl
index d60595a03..b57019c00 100644
--- a/src/HSC/load_inputs/load_H2_inputs.jl
+++ b/src/HSC/load_inputs/load_H2_inputs.jl
@@ -40,7 +40,7 @@ function load_h2_inputs(inputs::Dict,setup::Dict,path::AbstractString)
data_directory = chop(replace(path, pwd() => ""), head = 1, tail = 0)
## Read input files
- println("Reading H2 Input CSV Files")
+ print_and_log("Reading H2 Input CSV Files")
## Declare Dict (dictionary) object used to store parameters
inputs = load_h2_gen(setup, path, sep, inputs)
inputs = load_h2_demand(setup, path, sep, inputs)
@@ -84,7 +84,7 @@ function load_h2_inputs(inputs::Dict,setup::Dict,path::AbstractString)
(setup["OperationWrapping"]==1 && (setup["ModelH2Trucks"] == 1 || !isempty(inputs["H2_STOR_LONG_DURATION"])) && (isfile(data_directory*"/Period_map.csv") || isfile(joinpath(data_directory,string(joinpath(setup["TimeDomainReductionFolder"],"Period_map.csv")))))) # Use Time Domain Reduced data for GenX)
inputs = load_period_map(setup, path, sep, inputs)
end
- println("HSC Input CSV Files Successfully Read In From $path$sep")
+ print_and_log("HSC Input CSV Files Successfully Read In From $path$sep")
return inputs
end
diff --git a/src/HSC/load_inputs/load_co2_cap_hsc.jl b/src/HSC/load_inputs/load_co2_cap_hsc.jl
index 472cb337a..88603412e 100644
--- a/src/HSC/load_inputs/load_co2_cap_hsc.jl
+++ b/src/HSC/load_inputs/load_co2_cap_hsc.jl
@@ -79,6 +79,6 @@ function load_co2_cap_hsc(setup::Dict, path::AbstractString, sep::AbstractString
# when not scaled, the constraint unit is ton
end
end
- println("HSC_CO2_cap.csv Successfully Read!")
+ print_and_log("HSC_CO2_cap.csv Successfully Read!")
return inputs_co2_hsc
end
diff --git a/src/HSC/load_inputs/load_h2_demand.jl b/src/HSC/load_inputs/load_h2_demand.jl
index ad447053c..d0c5553ce 100644
--- a/src/HSC/load_inputs/load_h2_demand.jl
+++ b/src/HSC/load_inputs/load_h2_demand.jl
@@ -32,7 +32,7 @@ function load_h2_demand(setup::Dict, path::AbstractString, sep::AbstractString,
inputs_load["H2_SEG"]=size(collect(skipmissing(H2_load_in[!,:Demand_Segment])),1)
# Demand in tonnes per hour for each zone
- #println(names(load_in))
+ #print_and_log(names(load_in))
start = findall(s -> s == "Load_H2_tonne_per_hr_z1", names(H2_load_in))[1] #gets the starting column number of all the columns, with header "Load_H2_z1"
# Max value of non-served energy in $/(tonne)
@@ -52,7 +52,7 @@ function load_h2_demand(setup::Dict, path::AbstractString, sep::AbstractString,
inputs_load["pMax_H2_D_Curtail"][s] = collect(skipmissing(H2_load_in[!,:Max_Demand_Curtailment]))[s]
end
- println("HSC_load_data.csv Successfully Read!")
+ print_and_log("HSC_load_data.csv Successfully Read!")
return inputs_load
diff --git a/src/HSC/load_inputs/load_h2_g2p_variability.jl b/src/HSC/load_inputs/load_h2_g2p_variability.jl
index cea1cabf9..9546f29b4 100644
--- a/src/HSC/load_inputs/load_h2_g2p_variability.jl
+++ b/src/HSC/load_inputs/load_h2_g2p_variability.jl
@@ -36,7 +36,7 @@ function load_h2_g2p_variability(setup::Dict, path::AbstractString, sep::Abstrac
# Maximum power output and variability of each energy resource
inputs_genvar["pH2_g2p_Max"] = transpose(Matrix{Float64}(gen_var[1:inputs_genvar["T"],2:(inputs_genvar["H2_G2P_ALL"]+1)]))
- println("HSC_g2p_variability.csv Successfully Read!")
+ print_and_log("HSC_g2p_variability.csv Successfully Read!")
return inputs_genvar
end
diff --git a/src/HSC/load_inputs/load_h2_gen.jl b/src/HSC/load_inputs/load_h2_gen.jl
index 677fe608c..443768fe8 100644
--- a/src/HSC/load_inputs/load_h2_gen.jl
+++ b/src/HSC/load_inputs/load_h2_gen.jl
@@ -103,7 +103,7 @@ function load_h2_gen(setup::Dict, path::AbstractString, sep::AbstractString, inp
# end
- println("HSC_generation.csv Successfully Read!")
+ print_and_log("HSC_generation.csv Successfully Read!")
return inputs_gen
diff --git a/src/HSC/load_inputs/load_h2_generators_variability.jl b/src/HSC/load_inputs/load_h2_generators_variability.jl
index 8abc2e433..83beb4108 100644
--- a/src/HSC/load_inputs/load_h2_generators_variability.jl
+++ b/src/HSC/load_inputs/load_h2_generators_variability.jl
@@ -36,7 +36,7 @@ function load_h2_generators_variability(setup::Dict, path::AbstractString, sep::
# Maximum power output and variability of each energy resource
inputs_genvar["pH2_Max"] = transpose(Matrix{Float64}(gen_var[1:inputs_genvar["T"],2:(inputs_genvar["H2_RES_ALL"]+1)]))
- println("HSC_generators_variability.csv Successfully Read!")
+ print_and_log("HSC_generators_variability.csv Successfully Read!")
return inputs_genvar
end
diff --git a/src/HSC/load_inputs/load_h2_pipeline_data.jl b/src/HSC/load_inputs/load_h2_pipeline_data.jl
index 742b5e4a3..95b702675 100644
--- a/src/HSC/load_inputs/load_h2_pipeline_data.jl
+++ b/src/HSC/load_inputs/load_h2_pipeline_data.jl
@@ -132,7 +132,7 @@ function load_h2_pipeline_data(
collect(skipmissing(pipeline_var[!, :BoosterCompEnergy_MWh_per_tonne])),
)
- println("HSC_pipelines.csv Successfully Read!")
+ print_and_log("HSC_pipelines.csv Successfully Read!")
return inputs_nw
end
diff --git a/src/HSC/load_inputs/load_h2_truck.jl b/src/HSC/load_inputs/load_h2_truck.jl
index 24b95977a..dbc71008b 100644
--- a/src/HSC/load_inputs/load_h2_truck.jl
+++ b/src/HSC/load_inputs/load_h2_truck.jl
@@ -29,7 +29,7 @@ function load_h2_truck(path::AbstractString, sep::AbstractString, inputs_truck::
RouteLength = zone_distance[Z_set,Z_set.+1]
inputs_truck["RouteLength"] = RouteLength
- println("HSC_zone_truck_distances_miles.csv Successfully Read!")
+ print_and_log("HSC_zone_truck_distances_miles.csv Successfully Read!")
# H2 truck type inputs
h2_truck_in = DataFrame(CSV.File(string(path, sep, "HSC_trucks.csv"), header=true), copycols=true)
@@ -64,6 +64,6 @@ function load_h2_truck(path::AbstractString, sep::AbstractString, inputs_truck::
for j in inputs_truck["H2_TRUCK_TYPES"]
inputs_truck["TD"][j] = round.(Int, RouteLength ./ h2_truck_in[!, :AvgTruckSpeed_mile_per_hour][j])
end
- println("HSC_trucks.csv Successfully Read!")
+ print_and_log("HSC_trucks.csv Successfully Read!")
return inputs_truck
end
\ No newline at end of file
diff --git a/src/HSC/model/core/emissions_hsc.jl b/src/HSC/model/core/emissions_hsc.jl
index 309c131bc..4f0047b59 100644
--- a/src/HSC/model/core/emissions_hsc.jl
+++ b/src/HSC/model/core/emissions_hsc.jl
@@ -21,7 +21,7 @@ This function creates expression to add the CO2 emissions for hydrogen supply ch
"""
function emissions_hsc(EP::Model, inputs::Dict, setup::Dict)
- println("H2 Emissions Module for CO2 Policy modularization")
+ print_and_log("H2 Emissions Module for CO2 Policy modularization")
dfH2Gen = inputs["dfH2Gen"]
diff --git a/src/HSC/model/core/h2_investment.jl b/src/HSC/model/core/h2_investment.jl
index d933fdb78..da7e76581 100644
--- a/src/HSC/model/core/h2_investment.jl
+++ b/src/HSC/model/core/h2_investment.jl
@@ -60,7 +60,7 @@ In addition, this function adds investment and fixed O\&M related costs related
"""
function h2_investment(EP::Model, inputs::Dict, setup::Dict)
- println("Hydrogen Investment Discharge Module")
+ print_and_log("Hydrogen Investment Discharge Module")
dfH2Gen = inputs["dfH2Gen"]
diff --git a/src/HSC/model/core/h2_non_served.jl b/src/HSC/model/core/h2_non_served.jl
index 16579af36..b56f3d22b 100644
--- a/src/HSC/model/core/h2_non_served.jl
+++ b/src/HSC/model/core/h2_non_served.jl
@@ -61,7 +61,7 @@ Additionally, total demand curtailed in each time step cannot exceed total deman
"""
function h2_non_served_energy(EP::Model, inputs::Dict, setup::Dict)
- println("Hydrogen Non-served Energy Module")
+ print_and_log("Hydrogen Non-served Energy Module")
T = inputs["T"] # Number of time steps
Z = inputs["Z"] # Number of zones
diff --git a/src/HSC/model/core/h2_outputs.jl b/src/HSC/model/core/h2_outputs.jl
index 6432c05f1..4d3d29977 100644
--- a/src/HSC/model/core/h2_outputs.jl
+++ b/src/HSC/model/core/h2_outputs.jl
@@ -52,7 +52,7 @@ This module additionally defines contributions to the objective function from va
"""
function h2_outputs(EP::Model, inputs::Dict, setup::Dict)
- println("Hydrogen Generation and Storage Discharge Module")
+ print_and_log("Hydrogen Generation and Storage Discharge Module")
dfH2Gen = inputs["dfH2Gen"]
diff --git a/src/HSC/model/flexible_demand/h2_flexible_demand.jl b/src/HSC/model/flexible_demand/h2_flexible_demand.jl
index 0ad10c42c..88473ca39 100644
--- a/src/HSC/model/flexible_demand/h2_flexible_demand.jl
+++ b/src/HSC/model/flexible_demand/h2_flexible_demand.jl
@@ -68,7 +68,7 @@ If $t$ is first time step of the year (or the first time step of the representat
function h2_flexible_demand(EP::Model, inputs::Dict, setup::Dict)
## Flexible demand resources available during all hours and can be either delayed or advanced (virtual storage-shiftable demand) - DR ==1
-println("H2 Flexible Demand Resources Module")
+print_and_log("H2 Flexible Demand Resources Module")
dfH2Gen = inputs["dfH2Gen"]
diff --git a/src/HSC/model/g2p/h2_g2p_discharge.jl b/src/HSC/model/g2p/h2_g2p_discharge.jl
index b92a95e44..1a2fa299e 100644
--- a/src/HSC/model/g2p/h2_g2p_discharge.jl
+++ b/src/HSC/model/g2p/h2_g2p_discharge.jl
@@ -30,7 +30,7 @@ This module additionally defines contributions to the objective function from va
"""
function h2_g2p_discharge(EP::Model, inputs::Dict, setup::Dict)
- println("H2 g2p demand module")
+ print_and_log("H2 g2p demand module")
dfH2G2P = inputs["dfH2G2P"]
diff --git a/src/HSC/model/generation/h2_production.jl b/src/HSC/model/generation/h2_production.jl
index a57d58041..7a213ef57 100644
--- a/src/HSC/model/generation/h2_production.jl
+++ b/src/HSC/model/generation/h2_production.jl
@@ -22,7 +22,7 @@ This module creates decision variables, expressions, and constraints related to
"""
function h2_production(EP::Model, inputs::Dict, setup::Dict)
- println("Hydrogen Production Module")
+ print_and_log("Hydrogen Production Module")
if !isempty(inputs["H2_GEN"])
# expressions, variables and constraints common to all types of hydrogen generation technologies
diff --git a/src/HSC/model/generation/h2_production_all.jl b/src/HSC/model/generation/h2_production_all.jl
index d97852cba..42745c156 100644
--- a/src/HSC/model/generation/h2_production_all.jl
+++ b/src/HSC/model/generation/h2_production_all.jl
@@ -56,7 +56,7 @@ The numbers of units starting up and shutting down are modeled as:
"""
function h2_production_all(EP::Model, inputs::Dict, setup::Dict)
- println("H2 Production Core Module")
+ print_and_log("H2 Production Core Module")
dfH2Gen = inputs["dfH2Gen"]
diff --git a/src/HSC/model/generation/h2_production_commit.jl b/src/HSC/model/generation/h2_production_commit.jl
index 64e8af186..9c7ada673 100644
--- a/src/HSC/model/generation/h2_production_commit.jl
+++ b/src/HSC/model/generation/h2_production_commit.jl
@@ -142,7 +142,7 @@ It is recommended that users of GenX must use longer subperiods than the longest
"""
function h2_production_commit(EP::Model, inputs::Dict, setup::Dict)
- println("H2 Production (Unit Commitment) Module")
+ print_and_log("H2 Production (Unit Commitment) Module")
# Rename H2Gen dataframe
dfH2Gen = inputs["dfH2Gen"]
diff --git a/src/HSC/model/generation/h2_production_no_commit.jl b/src/HSC/model/generation/h2_production_no_commit.jl
index 695aa351c..b62ef94f1 100644
--- a/src/HSC/model/generation/h2_production_no_commit.jl
+++ b/src/HSC/model/generation/h2_production_no_commit.jl
@@ -58,7 +58,7 @@ When not modeling regulation and reserves, hydrogen units not subject to unit co
"""
function h2_production_no_commit(EP::Model, inputs::Dict,setup::Dict)
- println("H2 Production (No Unit Commitment) Module")
+ print_and_log("H2 Production (No Unit Commitment) Module")
#Rename H2Gen dataframe
dfH2Gen = inputs["dfH2Gen"]
diff --git a/src/HSC/model/storage/h2_long_duration_storage.jl b/src/HSC/model/storage/h2_long_duration_storage.jl
index c04803c13..5b98c49e2 100644
--- a/src/HSC/model/storage/h2_long_duration_storage.jl
+++ b/src/HSC/model/storage/h2_long_duration_storage.jl
@@ -73,7 +73,7 @@ Finally, the next constraint enforces that the initial storage level for each in
"""
function h2_long_duration_storage(EP::Model, inputs::Dict)
- println("Hydrogen Long Duration Storage Module")
+ print_and_log("Hydrogen Long Duration Storage Module")
dfH2Gen = inputs["dfH2Gen"]
diff --git a/src/HSC/model/storage/h2_storage.jl b/src/HSC/model/storage/h2_storage.jl
index 0f29b4334..7c1222d29 100644
--- a/src/HSC/model/storage/h2_storage.jl
+++ b/src/HSC/model/storage/h2_storage.jl
@@ -22,7 +22,7 @@ A wide range of energy storage devices (all $o \in \mathcal{O}$) can be modeled
"""
function h2_storage(EP::Model, inputs::Dict, setup::Dict)
- println("Hydrogen Storage Module")
+ print_and_log("Hydrogen Storage Module")
if !isempty(inputs["H2_STOR_ALL"])
# investment variables expressions and related constraints for H2 storage tehcnologies
diff --git a/src/HSC/model/storage/h2_storage_all.jl b/src/HSC/model/storage/h2_storage_all.jl
index 47c8ade75..1663aa422 100644
--- a/src/HSC/model/storage/h2_storage_all.jl
+++ b/src/HSC/model/storage/h2_storage_all.jl
@@ -66,7 +66,7 @@ The above constraints are established in ```h2_storage_all()``` in ```h2_storage
"""
function h2_storage_all(EP::Model, inputs::Dict, setup::Dict)
# Setup variables, constraints, and expressions common to all hydrogen storage resources
- println("H2 Storage Core Resources Module")
+ print_and_log("H2 Storage Core Resources Module")
dfH2Gen = inputs["dfH2Gen"]
H2_STOR_ALL = inputs["H2_STOR_ALL"] # Set of all h2 storage resources
diff --git a/src/HSC/model/storage/h2_storage_investment_charge.jl b/src/HSC/model/storage/h2_storage_investment_charge.jl
index 664cdd525..f41df8309 100644
--- a/src/HSC/model/storage/h2_storage_investment_charge.jl
+++ b/src/HSC/model/storage/h2_storage_investment_charge.jl
@@ -59,7 +59,7 @@ In addition, this function adds investment and fixed O\&M related costs related
"""
function h2_storage_investment_charge(EP::Model, inputs::Dict, setup::Dict)
- println("H2 Storage Charging Investment Module")
+ print_and_log("H2 Storage Charging Investment Module")
dfH2Gen = inputs["dfH2Gen"]
diff --git a/src/HSC/model/storage/h2_storage_investment_energy.jl b/src/HSC/model/storage/h2_storage_investment_energy.jl
index 179226717..a66172892 100644
--- a/src/HSC/model/storage/h2_storage_investment_energy.jl
+++ b/src/HSC/model/storage/h2_storage_investment_energy.jl
@@ -59,7 +59,7 @@ In addition, this function adds investment and fixed O\&M related costs related
"""
function h2_storage_investment_energy(EP::Model, inputs::Dict, setup::Dict)
- println("H2 Storage Energy Investment Module")
+ print_and_log("H2 Storage Energy Investment Module")
dfH2Gen = inputs["dfH2Gen"]
diff --git a/src/HSC/model/transmission/h2_pipeline.jl b/src/HSC/model/transmission/h2_pipeline.jl
index 0efc93f44..43de65e45 100644
--- a/src/HSC/model/transmission/h2_pipeline.jl
+++ b/src/HSC/model/transmission/h2_pipeline.jl
@@ -46,7 +46,7 @@ The pipeline has storage capacity via line packing:
"""
function h2_pipeline(EP::Model, inputs::Dict, setup::Dict)
- println("Hydrogen Pipeline Module")
+ print_and_log("Hydrogen Pipeline Module")
T = inputs["T"] # Model operating time steps
Z = inputs["Z"] # Model demand zones - assumed to be same for H2 and electricity
diff --git a/src/HSC/model/truck/h2_long_duration_truck.jl b/src/HSC/model/truck/h2_long_duration_truck.jl
index c480924b4..a0d694b5f 100644
--- a/src/HSC/model/truck/h2_long_duration_truck.jl
+++ b/src/HSC/model/truck/h2_long_duration_truck.jl
@@ -44,7 +44,7 @@ State of charge of truck at beginning of each modeled period cannot exceed insta
"""
function h2_long_duration_truck(EP::Model, inputs::Dict)
- println("H2 Long Duration Truck Module")
+ print_and_log("H2 Long Duration Truck Module")
Z = inputs["Z"] # Number of zone locations
H2_TRUCK_TYPES = inputs["H2_TRUCK_TYPES"]
diff --git a/src/HSC/model/truck/h2_truck.jl b/src/HSC/model/truck/h2_truck.jl
index 128c16fe6..3f5a0f96f 100644
--- a/src/HSC/model/truck/h2_truck.jl
+++ b/src/HSC/model/truck/h2_truck.jl
@@ -22,7 +22,7 @@ This function includes three parts of the Truck Model.The details can be found s
"""
function h2_truck(EP::Model, inputs::Dict, setup::Dict)
- println("Hydrogen Truck Module")
+ print_and_log("Hydrogen Truck Module")
# investment variables expressions and related constraints for H2 trucks
EP = h2_truck_investment(EP::Model, inputs::Dict, setup::Dict)
diff --git a/src/HSC/model/truck/h2_truck_all.jl b/src/HSC/model/truck/h2_truck_all.jl
index 12ccca239..6c06fe37e 100644
--- a/src/HSC/model/truck/h2_truck_all.jl
+++ b/src/HSC/model/truck/h2_truck_all.jl
@@ -94,7 +94,7 @@ The charging capability of truck stations is limited by their compression or liq
function h2_truck_all(EP::Model, inputs::Dict, setup::Dict)
# Setup variables, constraints, and expressions common to all hydrogen truck resources
- println("H2 Truck Core Resources Module")
+ print_and_log("H2 Truck Core Resources Module")
dfH2Truck = inputs["dfH2Truck"]
H2_TRUCK_TYPES = inputs["H2_TRUCK_TYPES"] # Set of h2 truck types
diff --git a/src/HSC/model/truck/h2_truck_investment.jl b/src/HSC/model/truck/h2_truck_investment.jl
index 24529b644..c8534d552 100644
--- a/src/HSC/model/truck/h2_truck_investment.jl
+++ b/src/HSC/model/truck/h2_truck_investment.jl
@@ -71,7 +71,7 @@ Truck compression energy: Cannot retire more energy capacity than existing energ
"""
function h2_truck_investment(EP::Model, inputs::Dict, setup::Dict)
- println("H2 Truck Investment Module")
+ print_and_log("H2 Truck Investment Module")
dfH2Truck = inputs["dfH2Truck"]
diff --git a/src/HSC/write_outputs/write_HSC_outputs.jl b/src/HSC/write_outputs/write_HSC_outputs.jl
index 59bfe2475..dfacd5e01 100644
--- a/src/HSC/write_outputs/write_HSC_outputs.jl
+++ b/src/HSC/write_outputs/write_HSC_outputs.jl
@@ -70,6 +70,6 @@ function write_HSC_outputs(EP::Model, path::AbstractString, setup::Dict, inputs:
end
## Print confirmation
- println("Wrote outputs HSC outputs to $path$sep")
+ print_and_log("Wrote outputs HSC outputs to $path$sep")
end # END output()
diff --git a/src/co2_cap_power_hsc.jl b/src/co2_cap_power_hsc.jl
index 395244a03..14e97de4d 100644
--- a/src/co2_cap_power_hsc.jl
+++ b/src/co2_cap_power_hsc.jl
@@ -24,7 +24,7 @@ The CO$_2$ emissions limit can be defined in one of the following ways: a) a mas
"""
function co2_cap_power_hsc(EP::Model, inputs::Dict, setup::Dict)
- println("C02 Policies Module for power and hydrogen system combined")
+ print_and_log("C02 Policies Module for power and hydrogen system combined")
SEG = inputs["SEG"] # Number of non-served energy segments for power demand
diff --git a/src/configure_solver/configure_gurobi.jl b/src/configure_solver/configure_gurobi.jl
index 02a763768..fe9177438 100644
--- a/src/configure_solver/configure_gurobi.jl
+++ b/src/configure_solver/configure_gurobi.jl
@@ -85,6 +85,14 @@ function configure_gurobi(solver_settings_path::String)
if (haskey(solver_settings, "NumericFocus"))
MyNumericFocus = solver_settings["NumericFocus"]
end
+
+ MyGurobiLogFile = "" # Gurobi log file. See https://www.gurobi.com/documentation/9.5/refman/logfile.html#parameter:LogFile
+ if (haskey(solver_settings, "GurobiLog"))
+ MyGurobiLog = solver_settings["GurobiLog"]
+ if MyGurobiLog
+ MyGurobiLogFile = solver_settings["GurobiLogFile"]
+ end
+ end
########################################################################
OPTIMIZER = optimizer_with_attributes(
@@ -100,6 +108,7 @@ function configure_gurobi(solver_settings_path::String)
"BarConvTol" => MyBarConvTol,
"NumericFocus" => MyNumericFocus,
"Crossover" => MyCrossover,
+ "LogFile" => MyGurobiLogFile
)
return OPTIMIZER
diff --git a/src/generate_model.jl b/src/generate_model.jl
index 136e2af07..e51b25061 100644
--- a/src/generate_model.jl
+++ b/src/generate_model.jl
@@ -274,7 +274,7 @@ function generate_model(setup::Dict,inputs::Dict,OPTIMIZER::MOI.OptimizerWithAtt
filepath = joinpath(modeloutput, "YourModel.lp")
JuMP.write_to_file(EP, filepath)
end
- println("Model Printed")
+ print_and_log("Model Printed")
end
return EP
diff --git a/src/print_and_log.jl b/src/print_and_log.jl
new file mode 100644
index 000000000..142b4eb23
--- /dev/null
+++ b/src/print_and_log.jl
@@ -0,0 +1,34 @@
+"""
+DOLPHYN: Decision Optimization for Low-carbon Power and Hydrogen Networks
+Copyright (C) 2022, Massachusetts Institute of Technology
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+A complete copy of the GNU General Public License v2 (GPLv2) is available
+in LICENSE.txt. Users uncompressing this from an archive may not have
+received this license file. If not, see .
+"""
+
+@doc raw"""
+ print_and_log(message::AbstractString)
+
+This function takes a message which is one-piece string in julia and print it in console or
+log file depending on global ```Log``` flag.
+"""
+function print_and_log(message::AbstractString)
+
+ # Log is set as global variable
+
+ if Log
+ println(message)
+ @info(message)
+ else
+ println(message)
+ end
+
+end
diff --git a/src/solve_model.jl b/src/solve_model.jl
index c1ed7e749..cb052b8cb 100644
--- a/src/solve_model.jl
+++ b/src/solve_model.jl
@@ -79,16 +79,16 @@ function solve_model(EP::Model, setup::Dict)
optimize!(EP)
if has_duals(EP) # fully linear model
- println("LP solved for primal")
+ print_and_log("LP solved for primal")
else
- println("MILP solved for primal")
+ print_and_log("MILP solved for primal")
end
if !has_duals(EP) && setup["WriteShadowPrices"] == 1
# function to fix integers and linearize problem
fix_integers(EP)
# re-solve statement for LP solution
- println("Solving LP solution for duals")
+ print_and_log("Solving LP solution for duals")
optimize!(EP)
end