Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PSY base methods #6

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
79d8928
bug fix in struct defination
sourabhdalvi Mar 25, 2024
a6c9880
adding some examples
sourabhdalvi Mar 26, 2024
b21e855
fixed UUID
Mar 26, 2024
2d553ed
Merge branch 'main' into sd/dev
sourabhdalvi Mar 27, 2024
fc74eb2
removing function redefination
sourabhdalvi Mar 27, 2024
825c74c
add setter methods
rodrigomha Apr 4, 2024
f6eb445
add more base.jl methods for portfolios
rodrigomha Apr 4, 2024
ba277d7
update removal of components
rodrigomha Apr 5, 2024
3c9283c
add script example to add technology
rodrigomha Apr 5, 2024
b03645b
remove technology script
rodrigomha Apr 5, 2024
2456312
Merge remote-tracking branch 'origin/rh/psy_methods' into sd/dev
sourabhdalvi Apr 9, 2024
ee45ef4
add pretty print
rodrigomha Apr 9, 2024
86458f8
add pretty tables
rodrigomha Apr 9, 2024
74d43f0
add portfolio constructors
rodrigomha Apr 9, 2024
7e64882
Merge remote-tracking branch 'origin/rh/psy_methods' into sd/dev
sourabhdalvi Apr 10, 2024
b7deead
adding auto generated structs
sourabhdalvi Apr 10, 2024
2582284
adding serialization
sourabhdalvi Apr 10, 2024
60193d2
updating test script
sourabhdalvi Apr 10, 2024
e43614e
adding to_json function
sourabhdalvi Apr 10, 2024
5e5efc7
removing old files
sourabhdalvi Apr 11, 2024
d22568c
remove subportfolios
rodrigomha Apr 11, 2024
d40072b
update printing
rodrigomha Apr 11, 2024
3ad9147
update tomls
rodrigomha Apr 12, 2024
afac1ab
update exports
rodrigomha Apr 12, 2024
e8cd006
update typo get techs
rodrigomha Apr 12, 2024
5aa51d2
update tests
rodrigomha Apr 12, 2024
eefce02
updating structs
sourabhdalvi Apr 12, 2024
7abe741
Merge remote-tracking branch 'origin/rh/psy_methods' into sd/dev
sourabhdalvi Apr 12, 2024
3bfde43
merging test script
sourabhdalvi Apr 12, 2024
ae2d652
adding formatter changes
sourabhdalvi Apr 12, 2024
525f4dd
Merge pull request #8 from NREL-Sienna/sd/dev
rodrigomha Apr 15, 2024
5d18b60
update structs
rodrigomha Apr 15, 2024
dbf8652
remove general accesors to avoid ambiguities
rodrigomha Apr 15, 2024
67d5acb
remove extra IS
rodrigomha Apr 15, 2024
af1c5d9
update compats
rodrigomha Apr 15, 2024
d056ef5
update test using structs
rodrigomha Apr 15, 2024
09e5b69
remove container stuff
rodrigomha May 29, 2024
f3c391e
add ext stuff
rodrigomha May 29, 2024
487c847
remove container in portfolio
rodrigomha May 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
name = "PowerSystemsInvestmentsPortfolios"
uuid = "bed98974-b02a-5e2f-9fe0-a103f8c450dd"
authors = ["Jose Daniel Lara"]
authors = ["Jose Daniel Lara", "Sourabh Dalvi", "Rodrigo Henriquez-Auba"]
version = "0.1.0"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
InfrastructureSystems = "2cd47ed4-ca9b-11e9-27f2-ab636a7671f1"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
PowerSystems = "bcd98974-b02a-5e2f-9ee0-a103f5c450dd"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"

[compat]
DocStringExtensions = "~0.9"
julia = "^1.6"
InfrastructureSystems = "1"
PowerSystems = "^3.3"
PrettyTables = "1, 2"
JSON3 = "1"
DataStructures = "~0.18"
91 changes: 91 additions & 0 deletions scripts/portfolio_test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using Pkg
Pkg.activate("")
Pkg.instantiate()
using Revise
using PowerSystems
import InfrastructureSystems
using PowerSystemsInvestmentsPortfolios
const IS = InfrastructureSystems
const PSY = PowerSystems
const PSIP = PowerSystemsInvestmentsPortfolios

data = PSY._create_system_data_from_kwargs()

#bus = ACBus(nothing)
#discount_rate = 0.07
#investment_schedule = Dict()
#port_metadata = PSIP.PortfolioMetadata("portfolio_test", nothing, nothing)

p = Portfolio(0.07)

t_th = SupplyTechnology{ThermalStandard}(
name="thermal_tech",
available=true,
fuel=PSY.ThermalFuels.COAL,
prime_mover=PSY.PrimeMovers.ST,
capacity_factor=0.98, # cap factor
capital_cost=nothing,
operational_cost=nothing,
)

t_th_ext = t_th.ext
t_th_ext["capital_cost"] = 50.0
t_th_ext["investment_periods"] = [2030, 2040]
# one option is to repeat these for each investment
t_th_ext["operational_periods"] = [1, 2, 3]
t_th_ext["operational_periods_2"] = [
1, 2, 3, # first investment period
4, 5, 6 # second investment period
Comment on lines +37 to +38

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
1, 2, 3, # first investment period
4, 5, 6 # second investment period
1,
2,
3, # first investment period
4,
5,
6, # second investment period

]
t_th_ext["investment_operational_periods_map"] = Dict(
2030 => [1, 2, 3],
2040 => [4, 5, 6],
)
Comment on lines +40 to +43

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
t_th_ext["investment_operational_periods_map"] = Dict(
2030 => [1, 2, 3],
2040 => [4, 5, 6],
)
t_th_ext["investment_operational_periods_map"] = Dict(2030 => [1, 2, 3], 2040 => [4, 5, 6])

t_th_ext["initial_capacity"] = 200.0 # Data in MW
t_th_ext["maximum_capacity"] = 10000.0
t_th_ext["minimum_required_capacity"] = [0.0, 0.0]

t_th_exp = SupplyTechnology{ThermalStandard}(
name="thermal_tech_expensive",
available=true,
fuel=PSY.ThermalFuels.WASTE_OIL,
prime_mover=PSY.PrimeMovers.ST,
capacity_factor=0.92, # cap factor
capital_cost=nothing,
operational_cost=nothing,
)

t_th_exp_ext = t_th_exp.ext
t_th_exp_ext["capital_cost"] = 150.0

# Initial Capacity

t_re = SupplyTechnology{RenewableDispatch}(
name="renewable_tech",
available=true,
fuel=PSY.ThermalFuels.OTHER,
prime_mover=PSY.PrimeMovers.WT,
capacity_factor=0.98, # cap factor
capital_cost=nothing,
operational_cost=nothing,
)

t_re_ext = t_re.ext
t_re_ext["capital_cost"] = 100.0
t_re_ext["variable_capacity_factor"] = [0.8, 0.6, 0.3]


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

PSIP.add_technology!(p, t_th)
PSIP.add_technology!(p, t_re)


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

IS.serialize(t)
IS.serialize(p)

get_technologies(x -> (!get_available(x)), SupplyTechnology{ThermalStandard}, p)

get_technologies(SupplyTechnology{ThermalStandard}, p)
PSIP.remove_technology!(SupplyTechnology{ThermalStandard}, p, "thermal_tech")

get_available(t)
IS.deserialize(p)
127 changes: 112 additions & 15 deletions src/PowerSystemsInvestmentsPortfolios.jl
Original file line number Diff line number Diff line change
@@ -1,50 +1,147 @@
module PowerSystemsInvestmentsPortfolios

import InfrastructureSystems
import PowerSystems
# TODO: Some of these re-exports may cause name collisions with PowerSystems
import InfrastructureSystems:
add_time_series,
to_json,
from_json,
serialize,
deserialize,
import PowerSystems:
add_time_series!,
get_time_series,
has_time_series,
get_time_series_array,
get_time_series_timestamps,
get_time_series_values,
get_time_series_names,
ThermalGen,
HydroGen,
RenewableGen,
Storage,
ThermalStandard,
ThermalMultiStart,
ThermalFuels,
PrimeMovers,
RenewableFix,
RenewableDispatch,
GenericBattery,
BatteryEMS,
HydroEnergyReservoir,
HydroDispatch

import InfrastructureSystems
import InfrastructureSystems:
Components,
TimeSeriesData,
StaticTimeSeries,
Forecast,
AbstractDeterministic,
Deterministic,
Probabilistic,
SingleTimeSeries,
DeterministicSingleTimeSeries,
Scenarios,
ForecastCache,
StaticTimeSeriesCache,
InfrastructureSystemsComponent,
InfrastructureSystemsType,
InfrastructureSystemsInternal,
DeviceParameter,
FlattenIteratorWrapper,
LazyDictFromIterator,
DataFormatError,
InvalidRange,
InvalidValue,
copy_time_series!,
clear_ext!,
get_type_from_serialization_data,
get_count,
get_data,
get_horizon,
get_resolution,
get_window,
get_name,
set_name!,
get_internal,
set_internal!,
get_time_series_container,
iterate_windows,
get_time_series,
has_time_series,
get_time_series_array,
get_time_series_timestamps,
get_time_series_values,
get_time_series_names,
get_scenario_count, # Scenario Forecast Exports
get_percentiles, # Probabilistic Forecast Exports
get_next_time_series_array!,
get_next_time,
get_units_info,
set_units_info!,
to_json,
from_json,
serialize,
deserialize,
get_time_series_multiple,
compare_values,
CompressionSettings,
CompressionTypes,
NormalizationFactor,
NormalizationTypes,
UnitSystem,
SystemUnitsSettings,
open_file_logger,
make_logging_config_file,
validate_struct,
MultiLogger,
LogEventTracker,
StructField
StructField,
StructDefinition

const IS = InfrastructureSystems

import PowerSystems
import PrettyTables
import JSON3
import DataStructures: OrderedDict

export Portfolio
export Technology
export SupplyTechnology
export TransportTechnology
export DemandTechnology
export DemandSideTechnology
export StorageTechnology

export add_technology!
export add_technologies!
export remove_technology!
export remove_technologies!
export get_technology
export get_technologies
export get_technologies_by_name
export get_available_technologies
export iterate_technologies
export clear_technologies!

export get_name
export set_name!
export get_description
export set_description!
export get_available
export set_available!

const PSY = PowerSystems
const IS = InfrastructureSystems

include("technologies.jl")
include("demand_requirement.jl")
include("supply.jl")
include("demand_side.jl")
include("transport.jl")
include("storage.jl")
include("models/includes.jl")
include("models/serialization.jl")
# include("demand_requirement.jl")
# include("supply.jl")
# include("demand_side.jl")
# include("transport.jl")
# include("storage.jl")
include("portfolio.jl")
include("utils/print.jl")

using DocStringExtensions

const DATA_FORMAT_VERSION = "0.1.0"
@template (FUNCTIONS, METHODS) = """
$(TYPEDSIGNATURES)
$(DOCSTRING)
Expand Down
9 changes: 0 additions & 9 deletions src/demand_requirement.jl

This file was deleted.

9 changes: 0 additions & 9 deletions src/demand_side.jl

This file was deleted.

Loading
Loading