Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mcosovic committed Aug 17, 2024
1 parent 05a0214 commit 11223d7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/src/api/setupPrint.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ printPmuData

---

## Print Constraint Data
## [Print Constraint Data](@id PrintConstraintDataAPI)
```@docs
printBusConstraint
printBranchConstraint
Expand Down
40 changes: 39 additions & 1 deletion docs/src/manual/acOptimalPowerFlow.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ We also obtained all dual values. Here, we list only the dual variables for one
```@repl ACOptimalPowerFlow
print(system.generator.label, analysis.method.dual.capability.active)
```

---

##### Modify Optimal Power Flow
Expand All @@ -496,6 +495,45 @@ print(system.bus.label, analysis.voltage.magnitude, analysis.voltage.angle)

---

##### Print Results in the REPL
Users can utilize the functions [`printBusData`](@ref printBusData) and [`printGeneratorData`](@ref printGeneratorData) to display results. Additionally, to print bus, branch, or generator-related constraint data with the desired units, users can utilize any of the functions provided in the [Print Constraint Data](@ref PrintConstraintDataAPI) section. For example:
```@example ACOptimalPowerFlow
@power(MW, MVAr, pu)
show = Dict("Active Power Balance Solution" => false, "Active Power Balance Dual" => false)
printBusConstraint(system, analysis; show)
nothing # hide
```

Next, users can easily customize the print results for specific constraint, for example:
```julia
printBusConstraint(system, analysis; label = "Bus 1", header = true)
printBusConstraint(system, analysis; label = "Bus 2", footer = true)
```

---

##### Save Results to a File
Users can also redirect print output to a file. For example, data can be saved in a text file as follows:
```julia
open("bus.txt", "w") do file
printBusConstraint(system, analysis, file)
end
```

---

##### Save Results to a CSV File
For CSV output, users should first generate a simple table with `style = false`, and then save it to a CSV file:
```julia
using CSV

io = IOBuffer()
printBusConstraint(system, analysis, io; style = false)
CSV.write("constraint.csv", CSV.File(take!(io); delim = "|"))
```

---

##### Reset Primal and Dual Values
Users retain the flexibility to reset initial primal values to their default configurations at any juncture. This can be accomplished by utilizing the active and reactive power outputs of the generators and the initial bus voltage magnitudes and angles extracted from the `PowerSystem` type, employing the [`startingPrimal!`](@ref startingPrimal!) function:
```@example ACOptimalPowerFlow
Expand Down
2 changes: 1 addition & 1 deletion src/print/constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ function formatGeneratorConstraint(system::PowerSystem, analysis::ACOptimalPower
minmaxQprimal = [-Inf; Inf]
minmaxQdual = [-Inf; Inf]

@inbounds for (label, i) in system.bus.label
@inbounds for (label, i) in system.generator.label
width["Label"] = max(textwidth(label), width["Label"])

if haskey(constraint.capability.active, i) && is_valid(analysis.method.jump, constraint.capability.active[i])
Expand Down

0 comments on commit 11223d7

Please sign in to comment.