Пример #1
0
    def test_startwerteEntkoppling(self):

        netHandler = nt.NetListHandler()

        input_data = netHandler.readFile("Test-Schaltung.txt")
        schaltung = nt.Schaltung(input_data)
        schaltung.initInzidenzMatritzen()

        solv = solver.Solver(schaltung)
        solv.createInzidenzMatrices()
        e_values = solv.startwertEntkopplung(solv.potencialList, 0)

        #in der Beispielschaltun gibt es keine v's und damit auch kein ev
        ec = e_values[1]
        er = e_values[2]
        el = e_values[3]

        summand1 = solv.q_v.dot(solv.p_c).dot(ec).transpose()
        summand2 = solv.q_v.dot(solv.q_c).dot(solv.p_r).dot(er)
        summand3 = solv.q_v.dot(solv.q_c).dot(solv.q_r).dot(el)

        sum = np.add(np.add(summand1,summand2),summand3)[0]

        for x in range(len(sum)):
            #self.assertAlmostEqual(sum[x], solv.potencialList[x], places=15, msg=None, delta=None)
            self.assertTrue(float(sum[x]) == float(solv.potencialList[x]))
Пример #2
0
    def __init__(self, *args, **kwargs):
        """Initialize the starting values"""
        super().__init__(*args, **kwargs)


        self.netHandler = nt.NetListHandler()
        self.solutionData = []

        """current_path = os.path.realpath(__file__)
        current_path = current_path.split("\\")
        pathToProgramm= current_path[:-2 or None]
        self.pathToRessources = ""
        for s in pathToProgramm:
            self.pathToRessources += s +"\\" 
        self.pathToRessources += "resources\\"""
        self.pathToRessources = "../resources/"
Пример #3
0
    def test_is(self):

        netHandler = nt.NetListHandler()

        input_data = netHandler.readFile("Test-Schaltung.txt")
        schaltung = nt.Schaltung(input_data)
        schaltung.initInzidenzMatritzen()

        solv = solver.Solver(schaltung)
        solv.createInzidenzMatrices()
        solv.startwertEntkopplung(solv.potencialList, 0)

        i_s = solv.i_s(0)

        expected_i_s = [23]

        self.assertAlmostEqual(i_s[0], expected_i_s[0], places=15, msg=None, delta=None)
Пример #4
0
    def testFunction1(self):

        netHandler = nt.NetListHandler()

        input_data = netHandler.readFile("Test-Schaltung.txt")
        schaltung = nt.Schaltung(input_data)
        schaltung.initInzidenzMatritzen()

        solv = solver.Solver(schaltung)
        solv.createInzidenzMatrices()
        solv.startwertEntkopplung(solv.potencialList, 0)

        func1 = solv.function1([-90], [0], [-999, -900], 0)

        expected_func1 = [-1.14]

        self.assertAlmostEqual(func1[0], expected_func1[0], places=15, msg=None, delta=None)
Пример #5
0
    def testMatrixMc(self):

        netHandler = nt.NetListHandler()

        input_data = netHandler.readFile("Test-Schaltung.txt")
        schaltung = nt.Schaltung(input_data)
        schaltung.initInzidenzMatritzen()

        solv = solver.Solver(schaltung)
        solv.createInzidenzMatrices()
        solv.startwertEntkopplung(solv.potencialList, 0)

        mc = solv.matrix_mc([-280], 1)

        expected_mc = [[2.86]]

        self.assertAlmostEqual(mc[0][0], expected_mc[0][0], places=15, msg=None, delta=None)
Пример #6
0
    def testc_nacht(self):

        netHandler = nt.NetListHandler()

        input_data = netHandler.readFile("Test-Schaltung.txt")
        schaltung = nt.Schaltung(input_data)
        schaltung.initInzidenzMatritzen()

        solv = solver.Solver(schaltung)
        solv.createInzidenzMatrices()
        solv.startwertEntkopplung(solv.potencialList, 0)

        abl_c_t = solv.ableitung_c_nacht([-90, -90], 0)

        expected_abl_c_t = [0, 0]

        self.assertAlmostEqual(abl_c_t[0], expected_abl_c_t[0], places=15, msg=None, delta=None)
        self.assertAlmostEqual(abl_c_t[1], expected_abl_c_t[1], places=15, msg=None, delta=None)
Пример #7
0
    def testG_r(self):

        netHandler = nt.NetListHandler()

        input_data = netHandler.readFile("Test-Schaltung.txt")
        schaltung = nt.Schaltung(input_data)
        schaltung.initInzidenzMatritzen()

        solv = solver.Solver(schaltung)
        solv.createInzidenzMatrices()
        solv.startwertEntkopplung(solv.potencialList, 0)

        g_r = solv.g_r([-9, -900], 0)

        expected_g_r = [1.14, 1.14]

        self.assertAlmostEqual(g_r[0], expected_g_r[0], places=15, msg=None, delta=None)
        self.assertAlmostEqual(g_r[1], expected_g_r[1], places=15, msg=None, delta=None)
Пример #8
0
    def testFunctionGXT(self):

        netHandler = nt.NetListHandler()

        input_data = netHandler.readFile("Test-Schaltung.txt")
        schaltung = nt.Schaltung(input_data)
        schaltung.initInzidenzMatritzen()

        solv = solver.Solver(schaltung)
        solv.createInzidenzMatrices()
        solv.startwertEntkopplung(solv.potencialList, 0)

        gxt = solv.g_xyt([0], [0,0], 0)

        expected_gxt = [-3.86, 0]

        self.assertAlmostEqual(gxt[0], expected_gxt[0], places=15, msg=None, delta=None)
        self.assertAlmostEqual(gxt[1], expected_gxt[1], places=15, msg=None, delta=None)
Пример #9
0
    def test_zurueckKoppler(self):

        netHandler = nt.NetListHandler()

        input_data = netHandler.readFile("Test-Schaltung.txt")
        schaltung = nt.Schaltung(input_data)
        schaltung.initInzidenzMatritzen()

        solv = solver.Solver(schaltung)
        solv.createInzidenzMatrices()

        e_values = solv.startwertEntkopplung(solv.potencialList, 0)

        #in der Beispielschaltun gibt es keine v's und damit auch kein ev
        ec = e_values[1]
        er = e_values[2]
        el = e_values[3]

        e = solv.zurueckcoppler(ec, er, 0)[0]

        for x in range(len(e)):
            
            #self.assertAlmostEqual(sum[x], solv.potencialList[x], places=15, msg=None, delta=None)
            self.assertTrue(float(e[x]) == float(solv.potencialList[x]))