diff --git a/docs/src/manual/dcOptimalPowerFlow.md b/docs/src/manual/dcOptimalPowerFlow.md index 777aabb89..13adb511f 100644 --- a/docs/src/manual/dcOptimalPowerFlow.md +++ b/docs/src/manual/dcOptimalPowerFlow.md @@ -340,17 +340,17 @@ model.power.from.active ##### Powers Related to Bus Instead of calculating powers for all components, users have the option to compute specific quantities for particular components. In this regard, the following function can be utilized to calculate active powers associated with a specific bus: -```@example DCOptimalPowerFlowPower -injection = powerInjection(system, model; label = 1) -supply = powerSupply(system, model; label = 1) +```@repl DCOptimalPowerFlowPower +powerInjection(system, model; label = 1) +powerSupply(system, model; label = 1) ``` --- ##### Powers Related to Branch Similarly, we can compute the active powers related to a particular branch using the following function: -```@example DCOptimalPowerFlowPower -from = powerFrom(system, model; label = 2) -to = powerTo(system, model; label = 2) +```@repl DCOptimalPowerFlowPower +powerFrom(system, model; label = 2) +powerTo(system, model; label = 2) ``` diff --git a/docs/src/manual/dcPowerFlow.md b/docs/src/manual/dcPowerFlow.md index ade15b79d..58ad3e3c5 100644 --- a/docs/src/manual/dcPowerFlow.md +++ b/docs/src/manual/dcPowerFlow.md @@ -175,31 +175,32 @@ system.base.power.value * model.power.from.active ``` !!! note "Info" - To better understand the powers associated with buses, branches and generators that are calculated by the [`power`](@ref power(::PowerSystem, ::DCPowerFlow)) function, we suggest referring to the tutorials on [DC power flow analysis](@ref DCPowerAnalysisTutorials). + To better understand the powers associated with buses, branches and generators that are calculated by the [`power!`](@ref power!(::PowerSystem, ::DCPowerFlow)) function, we suggest referring to the tutorials on [DC power flow analysis](@ref DCPowerAnalysisTutorials). --- ##### Powers Related to Bus Instead of calculating powers for all components, users have the option to compute specific quantities for particular components. In this regard, the following function can be utilized to calculate active powers associated with a specific bus: -```@example ComputationPowersCurrentsLosses -injection = powerInjection(system, model; label = 1) -supply = powerSupply(system, model; label = 1) +```@repl ComputationPowersCurrentsLosses +powerInjection(system, model; label = 1) + +powerSupply(system, model; label = 1) ``` --- ##### Powers Related to Branch Similarly, we can compute the active powers related to a particular branch using the following function: -```@example ComputationPowersCurrentsLosses -from = powerFrom(system, model; label = 2) -to = powerTo(system, model; label = 2) +```@repl ComputationPowersCurrentsLosses +powerFrom(system, model; label = 2) +powerTo(system, model; label = 2) ``` --- ##### Power Related to Generator Finally, we can compute the active output power of a particular generator using the function: -```@example ComputationPowersCurrentsLosses -generator = powerGenerator(system, model; label = 1) +```@repl ComputationPowersCurrentsLosses +powerGenerator(system, model; label = 1) ``` diff --git a/docs/src/tutorials/acOptimalPowerFlow.md b/docs/src/tutorials/acOptimalPowerFlow.md index 6a416631f..b67f3950e 100644 --- a/docs/src/tutorials/acOptimalPowerFlow.md +++ b/docs/src/tutorials/acOptimalPowerFlow.md @@ -161,7 +161,7 @@ V_i - V_{\text{slack}} = 0,\;\;\; i \in \mathcal{N_{\text{sb}}} \\ \theta_i - \theta_{\text{slack}} = 0,\;\;\; i \in \mathcal{N_{\text{sb}}}. \\ \end{aligned} ``` -Here, the set ``\mathcal{N}_{\text{sb}}`` contains the index of the slack bus. These constraints are implemented using the `magnitude` and `angle` keywords within the [addBus!](@ref addBus!) function, where the bus is defined as a slack bus (`type = 3`). +Here, the set ``\mathcal{N}_{\text{sb}}`` contains the index of the slack bus. These constraints are implemented using the `magnitude` and `angle` keywords within the [`addBus!`](@ref addBus!) function, where the bus is defined as a slack bus (`type = 3`). To retrieve the equality constraints from the model, you can access the corresponding variables using the following code: ```@repl ACOptimalPowerFlow @@ -179,7 +179,7 @@ h_{P_i}(\mathbf {P}_{\text{g}}, \mathbf {V}, \boldsymbol{\theta}) = 0,\;\;\; \f \end{aligned} ``` -The active power balance equation is derived using the [unified branch model](@ref ACUnifiedBranchModelTutorials) and can be represented as: +The active power balance equation is derived using the [unified branch model](@ref UnifiedBranchModelTutorials) and can be represented as: ```math h_{P_i}(\mathbf {P}_{\text{g}}, \mathbf {V}, \boldsymbol{\theta}) = {V}_{i}\sum\limits_{j=1}^n {V}_{j} (G_{ij}\cos\theta_{ij}+B_{ij}\sin\theta_{ij}) - \sum_{k=1}^{n_{\text{g}i}} P_{\text{g}k} + P_{\text{d}i} ``` @@ -196,7 +196,7 @@ Similarly, the next constraint in the optimization problem is associated with th h_{Q_i}(\mathbf {Q}_{\text{g}}, \mathbf {V}, \boldsymbol{\theta}) = 0,\;\;\; \forall i \in \mathcal{N} \\ \end{aligned} ``` -The reactive power balance equation is derived using the [unified branch model](@ref ACUnifiedBranchModelTutorials) and can be represented as: +The reactive power balance equation is derived using the [unified branch model](@ref UnifiedBranchModelTutorials) and can be represented as: ```math h_{Q_i}(\mathbf {Q}_{\text{g}}, \mathbf {V}, \boldsymbol{\theta}) = {V}_{i}\sum\limits_{j=1}^n {V}_{j} (G_{ij}\sin\theta_{ij}-B_{ij}\cos\theta_{ij}) - \sum_{k=1}^{n_{\text{g}i}} Q_{\text{g}k} + Q_{\text{d}i} ``` diff --git a/src/postprocessing/dcAnalysis.jl b/src/postprocessing/dcAnalysis.jl index 905daefc8..564fd434a 100644 --- a/src/postprocessing/dcAnalysis.jl +++ b/src/postprocessing/dcAnalysis.jl @@ -174,7 +174,7 @@ function powerInjection(system::PowerSystem, model::DCOptimalPowerFlow; label) injectionActive = copy(-system.bus.demand.active[index]) @inbounds for i in system.bus.supply.generator[index] - injectionActive += model.power.active[i] + injectionActive += model.power.generator.active[i] end return injectionActive @@ -237,6 +237,8 @@ function powerSupply(system::PowerSystem, model::DCPowerFlow; label) else supplyActive = bus.supply.active[index] end + + return supplyActive end function powerSupply(system::PowerSystem, model::DCOptimalPowerFlow; label) @@ -248,7 +250,7 @@ function powerSupply(system::PowerSystem, model::DCOptimalPowerFlow; label) supplyActive = 0.0 @inbounds for i in system.bus.supply.generator[index] - supplyActive += model.power.active[i] + supplyActive += model.power.generator.active[i] end return supplyActive