Skip to content

Commit

Permalink
Add units in documentation for getIpMax/setIpMax and add missing chec…
Browse files Browse the repository at this point in the history
…k for nan values in setIpMax

Signed-off-by: Sébastien LAIGRE <[email protected]>
  • Loading branch information
sebalaig committed May 24, 2022
1 parent 93507f9 commit 5a62104
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class IdentifiableShortCircuit : public Extension {

public:
/**
* Get maximum allowable peak short-circuit current
* Get maximum allowable peak short-circuit current [A]
*/
double getIpMax() const;

Expand All @@ -38,7 +38,7 @@ class IdentifiableShortCircuit : public Extension {
double getIpMin() const;

/**
* Set maximum allowable peak short-circuit current
* Set maximum allowable peak short-circuit current [A]
*/
IdentifiableShortCircuit& setIpMax(double ipMax);

Expand Down
3 changes: 3 additions & 0 deletions extensions/iidm/src/IdentifiableShortCircuit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const std::type_index& IdentifiableShortCircuit::getType() const {
}

IdentifiableShortCircuit& IdentifiableShortCircuit::setIpMax(double ipMax) {
if (std::isnan(ipMax)) {
throw PowsyblException("Undefined ipMax");
}
m_ipMax = ipMax;
return *this;
}
Expand Down
1 change: 1 addition & 0 deletions extensions/iidm/test/IdentifiableShortCircuitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ BOOST_AUTO_TEST_CASE(identifiableShortCircuit) {
BOOST_CHECK(stdcxx::areSame(extension, extension.setIpMin(11.1)));
BOOST_CHECK_CLOSE(11.1, extension.getIpMin(), std::numeric_limits<double>::epsilon());

POWSYBL_ASSERT_THROW(extension.setIpMax(stdcxx::nan()), PowsyblException, "Undefined ipMax");
BOOST_CHECK(stdcxx::areSame(extension, extension.setIpMax(22.2)));
BOOST_CHECK_CLOSE(22.2, extension.getIpMax(), std::numeric_limits<double>::epsilon());
}
Expand Down

0 comments on commit 5a62104

Please sign in to comment.