Skip to content

Commit

Permalink
update ifelse case for other type of gens
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigomha committed Dec 9, 2024
1 parent 9dff0db commit 2d4b336
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions src/parsers/power_models_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,14 @@ function make_hydro_gen(
ramp_agc = get(d, "ramp_agc", get(d, "ramp_10", get(d, "ramp_30", abs(d["pmax"]))))
curtailcost = HydroGenerationCost(zero(CostCurve), 0.0)

base_conversion = sys_mbase / d["mbase"]
if d["mbase"] != 0.0
mbase = d["mbase"]
else
@warn "Generator $gen_name has base power equal to zero: $(d["mbase"]). Changing it to system base: $sys_mbase"
mbase = sys_mbase

Check warning on line 381 in src/parsers/power_models_data.jl

View check run for this annotation

Codecov / codecov/patch

src/parsers/power_models_data.jl#L380-L381

Added lines #L380 - L381 were not covered by tests
end

base_conversion = sys_mbase / mbase
return HydroDispatch(; # No way to define storage parameters for gens in PM so can only make HydroDispatch
name = gen_name,
available = Bool(d["gen_status"]),
Expand All @@ -394,7 +401,7 @@ function make_hydro_gen(
ramp_limits = (up = ramp_agc, down = ramp_agc),
time_limits = nothing,
operation_cost = curtailcost,
base_power = d["mbase"],
base_power = mbase,
)
end

Expand All @@ -405,12 +412,20 @@ function make_renewable_dispatch(
sys_mbase::Float64,
)
cost = RenewableGenerationCost(zero(CostCurve))
base_conversion = sys_mbase / d["mbase"]

if d["mbase"] != 0.0
mbase = d["mbase"]
else
@warn "Generator $gen_name has base power equal to zero: $(d["mbase"]). Changing it to system base: $sys_mbase"
mbase = sys_mbase

Check warning on line 420 in src/parsers/power_models_data.jl

View check run for this annotation

Codecov / codecov/patch

src/parsers/power_models_data.jl#L419-L420

Added lines #L419 - L420 were not covered by tests
end

base_conversion = sys_mbase / mbase

rating = calculate_rating(d["pmax"], d["qmax"])
if rating > d["mbase"]
@warn "rating is larger than base power for $gen_name, setting to $(d["mbase"])"
rating = d["mbase"]
if rating > mbase
@warn "rating is larger than base power for $gen_name, setting to $mbase"
rating = mbase

Check warning on line 428 in src/parsers/power_models_data.jl

View check run for this annotation

Codecov / codecov/patch

src/parsers/power_models_data.jl#L427-L428

Added lines #L427 - L428 were not covered by tests
end

generator = RenewableDispatch(;
Expand All @@ -427,7 +442,7 @@ function make_renewable_dispatch(
),
power_factor = 1.0,
operation_cost = cost,
base_power = d["mbase"],
base_power = mbase,
)

return generator
Expand All @@ -439,7 +454,14 @@ function make_renewable_fix(
bus::ACBus,
sys_mbase::Float64,
)
base_conversion = sys_mbase / d["mbase"]
if d["mbase"] != 0.0
mbase = d["mbase"]
else
@warn "Generator $gen_name has base power equal to zero: $(d["mbase"]). Changing it to system base: $sys_mbase"
mbase = sys_mbase

Check warning on line 461 in src/parsers/power_models_data.jl

View check run for this annotation

Codecov / codecov/patch

src/parsers/power_models_data.jl#L460-L461

Added lines #L460 - L461 were not covered by tests
end

base_conversion = sys_mbase / mbase
generator = RenewableNonDispatch(;
name = gen_name,
available = Bool(d["gen_status"]),
Expand All @@ -449,7 +471,7 @@ function make_renewable_fix(
rating = float(d["pmax"]) * base_conversion,
prime_mover_type = parse_enum_mapping(PrimeMovers, d["type"]),
power_factor = 1.0,
base_power = d["mbase"],
base_power = mbase,
)

return generator
Expand Down

0 comments on commit 2d4b336

Please sign in to comment.