Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
47c3762
CompatHelper: add new compat entry for PowerModels at version 0.21, (…
Feb 17, 2025
c059961
CompatHelper: add new compat entry for Statistics at version 1, (keep…
Feb 17, 2025
69a372b
CompatHelper: add new compat entry for BenchmarkTools at version 1, (…
Feb 17, 2025
3466d75
CompatHelper: add new compat entry for StorageSystemsSimulations at v…
Feb 17, 2025
ff9e9bc
CompatHelper: add new compat entry for PowerAnalytics at version 1, (…
Feb 17, 2025
560e187
CompatHelper: add new compat entry for CSV at version 0.10, (keep exi…
Feb 17, 2025
0c4b523
CompatHelper: add new compat entry for StatsBase at version 0.34, (ke…
Feb 17, 2025
f486350
CompatHelper: add new compat entry for PowerSystemCaseBuilder at vers…
Feb 17, 2025
dec6fd8
CompatHelper: add new compat entry for IJulia at version 1, (keep exi…
Feb 17, 2025
3d02a4b
CompatHelper: add new compat entry for SCIP at version 0.12, (keep ex…
Feb 17, 2025
757ae02
CompatHelper: add new compat entry for MathProgBase at version 0.7, (…
Feb 17, 2025
7352fb7
CompatHelper: add new compat entry for MathOptInterface at version 1,…
Feb 17, 2025
828788b
CompatHelper: add new compat entry for Ipopt at version 1, (keep exis…
Feb 17, 2025
2b3410b
CompatHelper: add new compat entry for PowerGraphics at version 0.19,…
Feb 17, 2025
9a83e98
CompatHelper: add new compat entry for DataFrames at version 1, (keep…
Feb 17, 2025
d028f2d
CompatHelper: add new compat entry for HydroPowerSimulations at versi…
Feb 17, 2025
a4fd5e1
CompatHelper: add new compat entry for GLPK at version 1, (keep exist…
Feb 17, 2025
bec261d
CompatHelper: add new compat entry for DataStructures at version 0.18…
Feb 17, 2025
5c792d4
CompatHelper: add new compat entry for PowerSystems at version 4, (ke…
Feb 17, 2025
f38cbde
CompatHelper: add new compat entry for PowerSimulations at version 0.…
Feb 17, 2025
3355ab0
CompatHelper: add new compat entry for JuMP at version 1, (keep exist…
Feb 17, 2025
d210152
CompatHelper: add new compat entry for PowerGraphics at version 0.20,…
Mar 27, 2025
c13ef40
Merge branch 'main' into compathelper/new_version/2025-02-17-00-08-49…
sambuddhac Jun 2, 2025
f891930
Merge pull request #9 from sambuddhac/compathelper/new_version/2025-0…
sambuddhac Jun 2, 2025
d4d7ddf
Merge branch 'main' into compathelper/new_version/2025-02-17-00-08-50…
sambuddhac Jun 2, 2025
25806de
Merge pull request #10 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
1029e85
Merge branch 'main' into compathelper/new_version/2025-02-17-00-08-52…
sambuddhac Jun 2, 2025
626856c
Merge pull request #11 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
6006d4e
Merge branch 'main' into compathelper/new_version/2025-02-17-00-08-53…
sambuddhac Jun 2, 2025
5aaf022
Merge pull request #12 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
73166fc
Merge branch 'main' into compathelper/new_version/2025-02-17-00-08-54…
sambuddhac Jun 2, 2025
43b4e90
Merge pull request #13 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
9f48895
Merge branch 'main' into compathelper/new_version/2025-02-17-00-08-56…
sambuddhac Jun 2, 2025
44eccf6
Merge pull request #14 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
4bb5f8a
Merge branch 'main' into compathelper/new_version/2025-02-17-00-08-58…
sambuddhac Jun 2, 2025
ad19f54
Merge pull request #15 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
112b97a
Merge branch 'main' into compathelper/new_version/2025-02-17-00-08-59…
sambuddhac Jun 2, 2025
e41e55f
Merge pull request #16 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
0ef724c
Merge branch 'main' into compathelper/new_version/2025-02-17-00-09-01…
sambuddhac Jun 2, 2025
5774468
Merge pull request #17 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
e932910
Merge branch 'main' into compathelper/new_version/2025-02-17-00-09-02…
sambuddhac Jun 2, 2025
9f3c317
Merge pull request #18 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
f3970e0
Merge branch 'main' into compathelper/new_version/2025-02-17-00-09-04…
sambuddhac Jun 2, 2025
cc477a3
Merge pull request #19 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
f1340f4
Merge branch 'main' into compathelper/new_version/2025-02-17-00-09-05…
sambuddhac Jun 2, 2025
009caac
Merge pull request #20 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
ba7f3aa
Merge branch 'main' into compathelper/new_version/2025-02-17-00-09-07…
sambuddhac Jun 2, 2025
50e0e75
Merge pull request #21 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
a1948df
Merge branch 'main' into compathelper/new_version/2025-02-17-00-09-09…
sambuddhac Jun 2, 2025
4aa8742
Merge pull request #22 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
63d9d0b
Merge branch 'main' into compathelper/new_version/2025-02-17-00-09-10…
sambuddhac Jun 2, 2025
b995bda
Merge pull request #23 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
9b77d1d
Merge branch 'main' into compathelper/new_version/2025-02-17-00-09-12…
sambuddhac Jun 2, 2025
5d4f61f
Merge pull request #24 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
b1de506
Merge branch 'main' into compathelper/new_version/2025-02-17-00-09-13…
sambuddhac Jun 2, 2025
18a4430
Merge pull request #25 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
e8eab43
Merge branch 'main' into compathelper/new_version/2025-02-17-00-09-15…
sambuddhac Jun 2, 2025
a822e77
Merge pull request #26 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
e311553
Merge branch 'main' into compathelper/new_version/2025-02-17-00-09-16…
sambuddhac Jun 2, 2025
a7812ba
Merge pull request #27 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
e1a981e
Merge branch 'main' into compathelper/new_version/2025-02-17-00-09-18…
sambuddhac Jun 2, 2025
d27f808
Merge pull request #28 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
124ca4d
Merge branch 'main' into compathelper/new_version/2025-02-17-00-09-20…
sambuddhac Jun 2, 2025
a5cc381
Merge pull request #29 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
c1ffcd2
Merge branch 'main' into compathelper/new_version/2025-03-27-00-08-37…
sambuddhac Jun 2, 2025
24af3c8
Merge pull request #31 from sambuddhac/compathelper/new_version/2025-…
sambuddhac Jun 2, 2025
17eccb0
Merge pull request #38 from sambuddhac/develop
mvghavidel Jun 22, 2025
1ec1e81
Add CSV readers for PowerLASCOPF system creation
claude Nov 4, 2025
c4ee367
Integrate CSV readers into main PowerLASCOPF module
claude Nov 4, 2025
ad3f612
Update src/io/readers/csv_reader.jl
sambuddhac Nov 4, 2025
309360a
Conflict resolved
sambuddhac Nov 5, 2025
b1b43d0
Updated Project
sambuddhac Nov 5, 2025
3fcd37a
Attempted fixing ThermalFuels
sambuddhac Nov 5, 2025
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
40 changes: 26 additions & 14 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,37 +50,49 @@ TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e"
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"

[compat]
BenchmarkTools = "1"
CSV = "0.10"
Colors = "0.12"
DataFrames = "1"
JuMP = "1"
PowerSimulations = "0.30"
DataStructures = "0.18"
Distributions = "0.25"
GLPK = "1"
GraphRecipes = "0.5"
Graphs = "1"
#HydroPowerSimulations = "0.11"
DataFrames = "1"
#PowerGraphics = "0.19"
Ipopt = "1"
MathOptInterface = "1"
#MathProgBase = "0.7"
#SCIP = "0.12"
#IJulia = "1"
PowerSystemCaseBuilder = "1"
CSV = "0.10"
PowerAnalytics = "1"
StorageSystemsSimulations = "0.12"
BenchmarkTools = "1"
Statistics = "1"
GenX = "0.4"
Plots = "1"
#GeometryBasics = "0.5"
HiGHS = "1"
InfrastructureSystems = "2, 3"
Ipopt = "1"
JSON = "0.21"
JSON3 = "1"
JuMP = "1"
MathOptInterface = "1"
NetworkLayout = "0.4"
POMDPTools = "0.1"
POMDPs = "0.9"
PlotlyJS = "0.18"
Plots = "1"
PowerModels = "0.20, 0.21"
PowerSimulations = "0.27, 0.28"
#PowerSimulations = "0.27, 0.28"
PowerSystems = "3, 4"
Printf = "1"
PyCall = "1"
Random = "1"
Revise = "3.11.0"
SparseArrays = "1"
Statistics = "1"
StatsBase = "0.33, 0.34"
TimeSeries = "0.23, 0.24"
YAML = "0.4"
julia = "1.9, 1.10"
#RecursiveArrayTools = "3"
Gurobi = "1"
#Cbc = "1"
PowerGraphics = "0.20"
#QUBO = "0.3"
#QuantumAnnealing = "0.2"
167 changes: 167 additions & 0 deletions examples/read_csv_example.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
"""
Example: Reading Power System Data from CSV Files

This example demonstrates how to use the PowerLASCOPF CSV readers to load
power system data from various CSV formats.

The readers support:
1. RTS-GMLC format (standard PowerSystems format)
2. csv_118 custom format
3. Other CSV formats with appropriate configuration
"""

using PowerLASCOPF
using PowerSystems
const PSY = PowerSystems

# Example 1: Reading RTS-GMLC format data
function example_rts_gmlc()
println("\n" * "="^80)
println("Example 1: Reading RTS-GMLC Format")
println("="^80)

data_dir = joinpath(@__DIR__, "..", "example_cases", "RTS_GMLC")

if !isdir(data_dir)
@warn "RTS_GMLC directory not found at $data_dir"
return nothing
end

# Create a custom configuration if needed
config = CSVReaderConfig(
base_power = 100.0,
default_voltage_limits = (0.95, 1.05),
default_ramp_rate = 0.02
)

# Read the system
println("\nReading system from: $data_dir")
system = read_csv_system(data_dir, config=config)

# Display system information
println("\nSystem Information:")
println(" Name: $(system.name)")
println(" Base Power: $(system.base_power) MVA")
println(" Number of Buses: $(length(PSY.get_components(PSY.Bus, system)))")
println(" Number of Branches: $(length(PSY.get_components(PSY.Branch, system)))")
println(" Number of Generators: $(length(PSY.get_components(PSY.ThermalStandard, system)))")
println(" Number of Loads: $(length(PSY.get_components(PSY.PowerLoad, system)))")

# Show some sample buses
println("\nSample Buses:")
for (i, bus) in enumerate(PSY.get_components(PSY.Bus, system))
if i > 5
break
end
println(" $(bus.name): $(bus.bustype), $(bus.base_voltage) kV")
end

# Show some sample generators
println("\nSample Generators:")
for (i, gen) in enumerate(PSY.get_components(PSY.ThermalStandard, system))
if i > 5
break
end
pmax = gen.active_power_limits.max * system.base_power
println(" $(gen.name): $(gen.fuel), Pmax = $(round(pmax, digits=2)) MW")
end

return system
end

# Example 2: Reading csv_118 format data
function example_csv118()
println("\n" * "="^80)
println("Example 2: Reading csv_118 Format")
println("="^80)

data_dir = joinpath(@__DIR__, "..", "example_cases", "csv_118")

if !isdir(data_dir)
@warn "csv_118 directory not found at $data_dir"
return nothing
end

# Read the system with default configuration
println("\nReading system from: $data_dir")
system = read_csv_system(data_dir)

# Display system information
println("\nSystem Information:")
println(" Name: $(system.name)")
println(" Base Power: $(system.base_power) MVA")
println(" Number of Buses: $(length(PSY.get_components(PSY.Bus, system)))")
println(" Number of Branches: $(length(PSY.get_components(PSY.Branch, system)))")
println(" Number of Generators: $(length(PSY.get_components(PSY.ThermalStandard, system)))")
println(" Number of Loads: $(length(PSY.get_components(PSY.PowerLoad, system)))")

# Calculate total generation capacity
total_capacity = sum(
gen.active_power_limits.max * system.base_power
for gen in PSY.get_components(PSY.ThermalStandard, system)
)
println(" Total Generation Capacity: $(round(total_capacity, digits=2)) MW")

# Calculate total load
total_load = sum(
load.active_power * system.base_power
for load in PSY.get_components(PSY.PowerLoad, system)
)
println(" Total Load: $(round(total_load, digits=2)) MW")

return system
end

# Example 3: Automatic format detection
function example_auto_detect()
println("\n" * "="^80)
println("Example 3: Automatic Format Detection")
println("="^80)

# Try different directories
test_dirs = [
joinpath(@__DIR__, "..", "example_cases", "RTS_GMLC"),
joinpath(@__DIR__, "..", "example_cases", "csv_118")
]

for data_dir in test_dirs
if !isdir(data_dir)
continue
end

format = detect_csv_format(data_dir)
println("\nDirectory: $(basename(data_dir))")
println(" Detected format: $format")

if format != :unknown
try
system = read_csv_system(data_dir)
println(" Successfully loaded system with $(length(PSY.get_components(PSY.Bus, system))) buses")
catch e
println(" Error loading system: $e")
end
end
end
end

# Main execution
function main()
println("\n")
println("╔" * "="^78 * "╗")
println("║" * " "^20 * "PowerLASCOPF CSV Reader Examples" * " "^25 * "║")
println("╚" * "="^78 * "╝")

# Run examples
example_rts_gmlc()
example_csv118()
example_auto_detect()

println("\n" * "="^80)
println("Examples completed!")
println("="^80 * "\n")
end

# Run if executed directly
if abspath(PROGRAM_FILE) == @__FILE__
main()
end
28 changes: 28 additions & 0 deletions src/PowerLASCOPF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ include("io/readers/make_nrel_sienna_compatible.jl")
# ===== INCLUDE EXTENSION MODULES =====
include("extensions/powersystems_integration.jl")
include("extensions/extended_system.jl")
# Include CSV readers for loading power system data
include("io/readers/csv_reader.jl")

# Export CSV reader functions
export CSVReaderConfig, read_csv_system, detect_csv_format
export read_buses_rts_gmlc, read_buses_csv118
export read_branches_rts_gmlc, read_branches_csv118
export read_generators_rts_gmlc, read_generators_csv118
export read_loads_rts_gmlc, read_loads_csv118

# ===== POWERLAS COPF PSY.SYSTEM EXTENSION =====
# Export PSY functions for convenience
Expand Down Expand Up @@ -199,6 +208,25 @@ function convert_psy_system_to_power_lascopf!(psy_system::PSY.System,
println("✅ Conversion framework ready - connect with specific PowerLASCOPF component types")

return true

#=
include("models/solver_models/gensolver_cont.jl")
include("models/solver_models/gensolver_first_base.jl")
include("models/solver_models/gensolver_first_cont.jl")
include("models/solver_models/gensolver_first_dz_cont.jl")
include("models/solver_models/gensolver_first_dz.jl")
include("models/solver_models/gensolver_first.jl")
include("models/solver_models/gensolver_second_base.jl")
include("models/solver_models/gensolver_second_cont.jl")
include("models/solver_models/linesolver_base.jl")
include("models/solver_models/sdp_opf_centralized.jl")
include("models/subsystems/generator.jl")
include("models/subsystems/load.jl")
include("models/subsystems/transmission_line.jl")
include("models/subsystems/node.jl")
include("models/subsystems/network.jl")
include("models/subsystems/supernetwork.jl")
include("models/run_sim_lascopf_temp_app.jl")=#
end

"""
Expand Down
Loading