Skip to content

Commit 3ca3b90

Browse files
committed
Add testing framework for the synchronous machine model
1 parent d942897 commit 3ca3b90

File tree

3 files changed

+95
-2
lines changed

3 files changed

+95
-2
lines changed

tests/UnitTests/PhasorDynamics/CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,25 @@ target_link_libraries(test_phasor_branch GRIDKIT::phasor_dynamics_branch
1414
add_executable(test_phasor_load runLoadTests.cpp)
1515
target_link_libraries(test_phasor_load GRIDKIT::phasor_dynamics_load
1616
GRIDKIT::phasor_dynamics_bus)
17-
17+
18+
add_executable(test_phasor_synchronous_machine runSynchronousMachineTests.cpp)
19+
target_link_libraries(test_phasor_synchronous_machine GRIDKIT::phasor_dynamics_synchronous_machine
20+
GRIDKIT::phasor_dynamics_bus)
21+
22+
1823
add_executable(test_phasor_system runSystemTests.cpp)
1924
target_link_libraries(test_phasor_system GRIDKIT::phasor_dynamics_load
2025
GRIDKIT::phasor_dynamics_branch
2126
GRIDKIT::phasor_dynamics_bus)
2227

2328
add_test(NAME PhasorDynamicsBusTest COMMAND $<TARGET_FILE:test_phasor_bus>)
2429
add_test(NAME PhasorDynamicsBranchTest COMMAND $<TARGET_FILE:test_phasor_branch>)
30+
add_test(NAME PhasorDynamicsSynchronousMachineTest COMMAND $<TARGET_FILE:test_phasor_synchronous_machine>)
2531
add_test(NAME PhasorDynamicsLoadTest COMMAND $<TARGET_FILE:test_phasor_load>)
2632
add_test(NAME PhasorDynamicsSystemTest COMMAND $<TARGET_FILE:test_phasor_system>)
2733

28-
install(TARGETS test_phasor_bus test_phasor_branch test_phasor_load test_phasor_system RUNTIME DESTINATION bin)
34+
install(TARGETS test_phasor_bus
35+
test_phasor_branch
36+
test_phasor_load
37+
test_phasor_synchronous_machine
38+
test_phasor_system RUNTIME DESTINATION bin)
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#include <iostream>
2+
#include <iomanip>
3+
4+
#include <Model/PhasorDynamics/Bus/Bus.hpp>
5+
#include <Model/PhasorDynamics/Bus/BusInfinite.hpp>
6+
#include <Model/PhasorDynamics/SynchronousMachine/SynchronousMachine.hpp>
7+
#include <Utilities/Testing.hpp>
8+
#include <Utilities/TestHelpers.hpp>
9+
10+
namespace GridKit
11+
{
12+
namespace Testing
13+
{
14+
15+
template<class ScalarT, typename IdxT>
16+
class SynchronousMachineTests
17+
{
18+
private:
19+
using real_type = typename PhasorDynamics::Component<ScalarT, IdxT>::real_type;
20+
21+
public:
22+
SynchronousMachineTests() = default;
23+
~SynchronousMachineTests() = default;
24+
25+
TestOutcome constructor()
26+
{
27+
TestStatus success = true;
28+
29+
auto* bus = new PhasorDynamics::Bus<ScalarT, IdxT>(1.0, 0.0);
30+
31+
PhasorDynamics::Component<ScalarT, IdxT>* machine =
32+
new PhasorDynamics::SynchronousMachine<ScalarT, IdxT>(bus);
33+
34+
success *= (machine != nullptr);
35+
36+
if (machine)
37+
{
38+
delete machine;
39+
}
40+
delete bus;
41+
42+
return success.report(__func__);
43+
}
44+
45+
TestOutcome residual()
46+
{
47+
TestStatus success = true;
48+
success.skipTest();
49+
50+
51+
return success.report(__func__);
52+
}
53+
54+
TestOutcome accessors()
55+
{
56+
TestStatus success = true;
57+
success.skipTest();
58+
59+
60+
return success.report(__func__);
61+
}
62+
}; // class SynchronousMachineTest
63+
64+
} // namespace Testing
65+
} // namespace GridKit
66+
67+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "SynchronousMachineTests.hpp"
2+
3+
int main()
4+
{
5+
using namespace GridKit;
6+
using namespace GridKit::Testing;
7+
8+
GridKit::Testing::TestingResults result;
9+
GridKit::Testing::SynchronousMachineTests<double, size_t> test;
10+
11+
result += test.constructor();
12+
result += test.accessors();
13+
result += test.residual();
14+
15+
return result.summary();
16+
}

0 commit comments

Comments
 (0)