-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Boundary classes formulas as util (#364)
Signed-off-by: Sébastien LAIGRE <[email protected]>
- Loading branch information
Showing
8 changed files
with
193 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* Copyright (c) 2022, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#ifndef POWSYBL_IIDM_UTIL_ABSTRACTHALFLINEBOUNDARY_HPP | ||
#define POWSYBL_IIDM_UTIL_ABSTRACTHALFLINEBOUNDARY_HPP | ||
|
||
#include <powsybl/iidm/Boundary.hpp> | ||
|
||
namespace powsybl { | ||
|
||
namespace iidm { | ||
|
||
class Bus; | ||
class Terminal; | ||
class TieLine; | ||
|
||
namespace tie_line { | ||
|
||
class HalfLine; | ||
|
||
} // namespace tie_line | ||
|
||
namespace util { | ||
|
||
namespace half_line { | ||
|
||
class AbstractHalfLineBoundary : public Boundary { | ||
// side represents the network side. | ||
// side here is Side.ONE for the half line 1 of a tie line. | ||
// side is Side.TWO for the half line 2 of a tie line. | ||
|
||
public: // iidm::Boundary | ||
double getAngle() const override; | ||
|
||
double getP() const override; | ||
|
||
double getQ() const override; | ||
|
||
stdcxx::optional<Branch::Side> getSide() const override; | ||
|
||
double getV() const override; | ||
|
||
const VoltageLevel& getVoltageLevel() const override; | ||
|
||
VoltageLevel& getVoltageLevel() override; | ||
|
||
public: | ||
AbstractHalfLineBoundary(tie_line::HalfLine& halfLine, const Branch::Side& side); | ||
|
||
AbstractHalfLineBoundary(const Boundary&) = delete; | ||
|
||
AbstractHalfLineBoundary(Boundary&&) = delete; | ||
|
||
~AbstractHalfLineBoundary() noexcept override = default; | ||
|
||
AbstractHalfLineBoundary& operator=(const AbstractHalfLineBoundary&) = delete; | ||
|
||
AbstractHalfLineBoundary& operator=(AbstractHalfLineBoundary&&) noexcept = delete; | ||
|
||
protected: | ||
const tie_line::HalfLine& getParent() const; | ||
|
||
tie_line::HalfLine& getParent(); | ||
|
||
private: | ||
const TieLine& getTieLine() const; | ||
|
||
TieLine& getTieLine(); | ||
|
||
private: | ||
tie_line::HalfLine& m_parent; | ||
|
||
Branch::Side m_side; | ||
}; | ||
|
||
} // namespace half_line | ||
|
||
} // namespace util | ||
|
||
} // namespace iidm | ||
|
||
} // namespace powsybl | ||
|
||
#endif // POWSYBL_IIDM_UTIL_ABSTRACTHALFLINEBOUNDARY_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
* Copyright (c) 2022, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#include <powsybl/iidm/util/AbstractHalfLineBoundary.hpp> | ||
|
||
#include <powsybl/iidm/Bus.hpp> | ||
#include <powsybl/iidm/HalfLine.hpp> | ||
#include <powsybl/iidm/Terminal.hpp> | ||
#include <powsybl/iidm/TieLine.hpp> | ||
#include <powsybl/iidm/util/SV.hpp> | ||
|
||
namespace powsybl { | ||
|
||
namespace iidm { | ||
|
||
namespace util { | ||
|
||
namespace half_line { | ||
|
||
AbstractHalfLineBoundary::AbstractHalfLineBoundary(tie_line::HalfLine& halfline, const Branch::Side& side) : | ||
m_parent(halfline), | ||
m_side(side) { | ||
} | ||
|
||
double AbstractHalfLineBoundary::getAngle() const { | ||
const Terminal& t = getTieLine().getTerminal(m_side); | ||
const auto& b = t.getBusView().getBus(); | ||
return SV(t.getP(), t.getQ(), Boundary::getV(b), Boundary::getAngle(b), m_side).otherSideA(m_parent); | ||
} | ||
|
||
double AbstractHalfLineBoundary::getP() const { | ||
const Terminal& t = getTieLine().getTerminal(m_side); | ||
const auto& b = t.getBusView().getBus(); | ||
return SV(t.getP(), t.getQ(), Boundary::getV(b), Boundary::getAngle(b), m_side).otherSideP(m_parent); | ||
} | ||
|
||
const tie_line::HalfLine& AbstractHalfLineBoundary::getParent() const { | ||
return m_parent; | ||
} | ||
|
||
tie_line::HalfLine& AbstractHalfLineBoundary::getParent() { | ||
return m_parent; | ||
} | ||
|
||
double AbstractHalfLineBoundary::getQ() const { | ||
const Terminal& t = getTieLine().getTerminal(m_side); | ||
const auto& b = t.getBusView().getBus(); | ||
return SV(t.getP(), t.getQ(), Boundary::getV(b), Boundary::getAngle(b), m_side).otherSideQ(m_parent); | ||
} | ||
|
||
stdcxx::optional<Branch::Side> AbstractHalfLineBoundary::getSide() const { | ||
return m_side; | ||
} | ||
|
||
const TieLine& AbstractHalfLineBoundary::getTieLine() const { | ||
return dynamic_cast<const TieLine&>(getConnectable()); | ||
} | ||
|
||
TieLine& AbstractHalfLineBoundary::getTieLine() { | ||
return dynamic_cast<TieLine&>(getConnectable()); | ||
} | ||
|
||
double AbstractHalfLineBoundary::getV() const { | ||
const Terminal& t = getTieLine().getTerminal(m_side); | ||
const auto& b = t.getBusView().getBus(); | ||
return SV(t.getP(), t.getQ(), Boundary::getV(b), Boundary::getAngle(b), m_side).otherSideU(m_parent); | ||
} | ||
|
||
const VoltageLevel& AbstractHalfLineBoundary::getVoltageLevel() const { | ||
return getTieLine().getTerminal(m_side).getVoltageLevel(); | ||
} | ||
|
||
VoltageLevel& AbstractHalfLineBoundary::getVoltageLevel() { | ||
return getTieLine().getTerminal(m_side).getVoltageLevel(); | ||
} | ||
|
||
} // namespace half_line | ||
|
||
} // namespace util | ||
|
||
} // namespace iidm | ||
|
||
} // namespace powsybl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters