00001 #ifndef _POWERFLOW_TEST_H
00002 #define _POWERFLOW_TEST_H
00003 #define VALIDATE_THRESHOLD .0002
00004
00005 #include "gridlabd.h"
00006
00007 #ifndef _NO_CPPUNIT
00008
00009 #include "test_framework.h"
00010
00011 #include "test_callbacks.h"
00012
00013
00014 #include "node.h"
00015 #include "link.h"
00016
00017 class powerflow_test_helper : public test_helper
00018 {
00019 protected:
00020 static void test_powerflow_link(class link *test_link, double tolerance,
00021 set phases1, set phases2, const complex bs_V2_in[3],
00022 const complex bs_I2_in[3], const complex bs_I1_out[3],
00023 const complex fs_V1_in[3], const complex fs_I2_in[3],
00024 const complex fs_V2_out[3])
00025 {
00026 node *src_node = create_object<node>("node");
00027 load *load_node = create_object<load>("load");
00028
00029 src_node->phases = phases1;
00030 load_node->phases = phases2;
00031 load_node->phaseA_V = bs_V2_in[0];
00032 load_node->phaseB_V = bs_V2_in[1];
00033 load_node->phaseC_V = bs_V2_in[2];
00034 load_node->phaseA_I = bs_I2_in[0];
00035 load_node->phaseB_I = bs_I2_in[1];
00036 load_node->phaseC_I = bs_I2_in[2];
00037
00038 test_link->from = GETOBJECT(src_node);
00039 test_link->to = GETOBJECT(load_node);
00040
00041
00042 CPPUNIT_ASSERT(local_callbacks->init_objects() != FAILED);
00043
00044
00045 CPPUNIT_ASSERT(local_callbacks->setup_test_ranks() != FAILED);
00046
00047
00048 CPPUNIT_ASSERT(local_callbacks->sync_all(PC_PRETOPDOWN) != FAILED);
00049 CPPUNIT_ASSERT(local_callbacks->sync_all(PC_BOTTOMUP) != FAILED);
00050
00051 CPPUNIT_ASSERT((src_node->get_phaseA_I_in() - bs_I1_out[0]).IsZero(tolerance));
00052 CPPUNIT_ASSERT((src_node->get_phaseB_I_in() - bs_I1_out[1]).IsZero(tolerance));
00053 CPPUNIT_ASSERT((src_node->get_phaseC_I_in() - bs_I1_out[2]).IsZero(tolerance));
00054
00055 src_node->phaseA_V = fs_V1_in[0];
00056 src_node->phaseB_V = fs_V1_in[1];
00057 src_node->phaseC_V = fs_V1_in[2];
00058 load_node->phaseA_I = fs_I2_in[0];
00059 load_node->phaseB_I = fs_I2_in[1];
00060 load_node->phaseC_I = fs_I2_in[2];
00061
00062 CPPUNIT_ASSERT(local_callbacks->sync_all(PC_POSTTOPDOWN) != FAILED);
00063
00064
00065 CPPUNIT_ASSERT((load_node->phaseA_V - fs_V2_out[0]).IsZero(tolerance));
00066 CPPUNIT_ASSERT((load_node->phaseB_V - fs_V2_out[1]).IsZero(tolerance));
00067 CPPUNIT_ASSERT((load_node->phaseC_V - fs_V2_out[2]).IsZero(tolerance));
00068 }
00069 };
00070
00071
00072 #include "regulator_test.h"
00073 #include "transformer_test.h"
00074 #include "overheadline_test.h"
00075 #include "undergroundline_test.h"
00076 #include "relay_test.h"
00077 #include "meter_test.h"
00078 #include "triplexline_test.h"
00079
00080
00081
00082
00096
00097
00098
00099
00100
00101 CPPUNIT_TEST_SUITE_REGISTRATION(overhead_line_tests);
00102 CPPUNIT_TEST_SUITE_REGISTRATION(transformer_tests);
00103 CPPUNIT_TEST_SUITE_REGISTRATION(undergroundline_tests);
00104 CPPUNIT_TEST_SUITE_REGISTRATION(regulator_tests);
00105 CPPUNIT_TEST_SUITE_REGISTRATION(relay_tests);
00106 CPPUNIT_TEST_SUITE_REGISTRATION(meter_tests);
00107
00108
00109
00110 #endif
00111 #endif