• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

GenXProject / GenX / #380

09 Dec 2023 03:57AM UTC coverage: 0.102%. First build
#380

Pull #600

travis-ci

Pull Request #600: Gen x retrofit mit

0 of 793 new or added lines in 67 files covered. (0.0%)

4 of 3904 relevant lines covered (0.1%)

0.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/load_inputs/load_inputs.jl
1
@doc raw"""
2
        load_inputs(setup::Dict,path::AbstractString)
3

4
Loads various data inputs from multiple input .csv files in path directory and stores variables in a Dict (dictionary) object for use in model() function
5

6
inputs:
7
setup - dict object containing setup parameters
8
path - string path to working directory
9

10
returns: Dict (dictionary) object containing all data inputs
11
"""
12
function load_inputs(setup::Dict, path::AbstractString)
13

14
    ## Read input files
15
    println("Reading Input CSV Files")
16
    ## input paths
17
    system_path = joinpath(path, setup["SystemFolder"])
18
    resources_path = joinpath(path, setup["ResourcesFolder"])
19
    policies_path = joinpath(path, setup["PoliciesFolder"])
20
    ## Declare Dict (dictionary) object used to store parameters
21
    inputs = Dict()
22
    # Read input data about power network topology, operating and expansion attributes
23
    if isfile(joinpath(system_path, "Network.csv"))
24
        network_var = load_network_data!(setup, system_path, inputs)
25
    else
26
        inputs["Z"] = 1
27
        inputs["L"] = 0
28
    end
×
29

30
    # Read temporal-resolved load data, and clustering information if relevant
31
    load_demand_data!(setup, path, inputs)
×
32
    # Read fuel cost data, including time-varying fuel costs
33
    load_fuels_data!(setup, path, inputs)
×
34
    # Read in generator/resource related inputs
35
    load_resources_data!(inputs, setup, path, resources_path)
×
36
    # Read in generator/resource availability profiles
×
37
    load_generators_variability!(setup, path, inputs)
38

×
39
    validatetimebasis(inputs)
×
40

41
    if setup["CapacityReserveMargin"] == 1
42
        load_cap_reserve_margin!(setup, policies_path, inputs)
43
        if inputs["Z"] > 1
×
44
            load_cap_reserve_margin_trans!(setup, inputs, network_var)
NEW
45
        end
×
46
    end
47

×
48
    # Read in general configuration parameters for operational reserves (resource-specific reserve parameters are read in load_resources_data)
49
    if setup["OperationalReserves"] == 1
×
50
        load_operational_reserves!(setup, system_path, inputs)
51
    end
×
52

NEW
53
    if setup["MinCapReq"] == 1
×
54
        load_minimum_capacity_requirement!(policies_path, inputs, setup)
×
NEW
55
    end
×
56

×
57
    if setup["MaxCapReq"] == 1
58
        load_maximum_capacity_requirement!(policies_path, inputs, setup)
59
    end
60

NEW
61
    if setup["EnergyShareRequirement"] == 1
×
62
        load_energy_share_requirement!(setup, policies_path, inputs)
×
63
    end
64

65
    if setup["CO2Cap"] >= 1
×
66
        load_co2_cap!(setup, policies_path, inputs)
×
67
    end
68

69
    if !isempty(inputs["VRE_STOR"])
×
70
        load_vre_stor_variability!(setup, path, inputs)
×
71
    end
72

NEW
73
    # Read in hydrogen damand data
×
74
    if setup["HydrogenMinimumProduction"] == 1
×
75
        load_hydrogen_demand!(setup, policies_path, inputs)
76
    end
77

×
78
    # Read in mapping of modeled periods to representative periods
×
79
    if is_period_map_necessary(inputs) && is_period_map_exist(setup, path)
80
        load_period_map!(setup, path, inputs)
81
    end
NEW
82

×
83
    # Virtual charge discharge cost
×
84
    scale_factor = setup["ParameterScale"] == 1 ? ModelScalingFactor : 1
85
    inputs["VirtualChargeDischargeCost"] = setup["VirtualChargeDischargeCost"] /
86
                                           scale_factor
×
87

88
    println("CSV Files Successfully Read In From $path")
×
89

90
    return inputs
NEW
91
end
×
NEW
92

×
93
function is_period_map_necessary(inputs::Dict)
×
NEW
94
    multiple_rep_periods = inputs["REP_PERIOD"] > 1
×
95
    has_stor_lds = !isempty(inputs["STOR_LONG_DURATION"])
96
    has_hydro_lds = !isempty(inputs["STOR_HYDRO_LONG_DURATION"])
97
    has_vre_stor_lds = !isempty(inputs["VRE_STOR"]) && !isempty(inputs["VS_LDS"])
×
NEW
98
    multiple_rep_periods && (has_stor_lds || has_hydro_lds || has_vre_stor_lds)
×
NEW
99
end
×
NEW
100

×
101
function is_period_map_exist(setup::Dict, path::AbstractString)
×
102
    filename = "Period_map.csv"
103
    is_in_system_dir = isfile(joinpath(path, setup["SystemFolder"], filename))
104
    is_in_TDR_dir = isfile(joinpath(path, setup["TimeDomainReductionFolder"], filename))
105
    is_in_system_dir || is_in_TDR_dir
106
end
107

108
"""
109
        get_systemfiles_path(setup::Dict, TDR_directory::AbstractString, path::AbstractString)
110

111
Determine the directory based on the setup parameters.
112

113
This function checks if the TimeDomainReduction setup parameter is equal to 1 and if time domain reduced files exist in the data directory. 
114
If the condition is met, it returns the path to the TDR_results data directory. Otherwise, it returns the system directory specified in the setup.
115

116
Parameters:
117
- setup: Dict{String, Any} - The GenX settings parameters containing TimeDomainReduction and SystemFolder information.
118
- TDR_directory: String - The data directory where files are located.
119
- path: String - Path to the case folder.
120

121
Returns:
122
- String: The directory path based on the setup parameters.
123
"""
124
function get_systemfiles_path(setup::Dict,
125
        TDR_directory::AbstractString,
126
        path::AbstractString)
127
    if setup["TimeDomainReduction"] == 1 && time_domain_reduced_files_exist(TDR_directory)
128
        return TDR_directory
129
    else
130
        # If TDR is not used, then use the "system" directory specified in the setup
131
        return joinpath(path, setup["SystemFolder"])
132
    end
133
end
134

135
abstract type AbstractLogMsg end
136
struct ErrorMsg <: AbstractLogMsg
137
    msg::String
138
end
139
struct WarnMsg <: AbstractLogMsg
140
    msg::String
141
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc