Exemplo n.º 1
0
    def run_rom(self, system, algorithm, r, interpolation_point):
        rom = krylov.Krylov()
        rom_settings = {
            'algorithm': algorithm,
            'r': r,
            'frequency': interpolation_point
        }

        rom.initialise(in_settings=rom_settings)

        rom.run(system)

        return rom
Exemplo n.º 2
0
    def test_ct(self):
        """
        Continuous time system test. Ensures that all eigenvalues in the left hand plane are preserved.
        """
        A = TestSchurDecomposition.A
        eigsA = TestSchurDecomposition.eigsA

        rom = krylov.Krylov()
        TL, TR = rom.stable_realisation(A, ct=True)

        n_stable_fom = np.sum(eigsA.real <= 0)
        Ap = TL.T.dot(A.dot(TR))

        eigsAp = np.linalg.eigvals(Ap)
        n_stable_rom = np.sum(eigsAp.real <= 0)

        assert n_stable_rom == n_stable_fom, 'Number of stable eigenvalues not preserved during decomposition'
Exemplo n.º 3
0
    def test_dt(self):
        """
        Discrete time system test. Ensures that all eigenvalues inside the unit circle are preserved.
        """
        A = TestSchurDecomposition.A
        eigsA = TestSchurDecomposition.eigsA

        rom = krylov.Krylov()
        TL, TR = rom.stable_realisation(A, ct=False)

        n_stable_fom = np.sum(np.abs(eigsA) <= 1)
        Ap = TL.T.dot(A.dot(TR))

        eigsAp = np.linalg.eigvals(Ap)
        n_stable_rom = np.sum(np.abs(eigsAp) <= 1)

        assert n_stable_rom == n_stable_fom, 'Number of stable eigenvalues not preserved during decomposition'
Exemplo n.º 4
0
    def setUp(self):
        cout.cout_wrap.initialise(False, False)
        A = scio.loadmat(TestKrylov.test_dir + '/src/' + 'A.mat')
        B = scio.loadmat(TestKrylov.test_dir + '/src/' + 'B.mat')
        C = scio.loadmat(TestKrylov.test_dir + '/src/' + 'C.mat')
        A = libsp.csc_matrix(A['A'])
        B = B['B']
        C = C['C']
        D = np.zeros((B.shape[1], C.shape[0]))

        A = A.todense()

        self.ss = libss.ss(A, B, C, D)

        self.rom = krylov.Krylov()

        if not os.path.exists(self.test_dir + '/figs/'):
            os.makedirs(self.test_dir + '/figs/')