Page MenuHomec4science

mhd_engine.py
No OneTemporary

File Metadata

Created
Mon, Jun 3, 14:21

mhd_engine.py

import numpy as np
import scipy.io as scio
import scipy.sparse as sp
from rrompy.hfengines.base import LinearAffineEngine, NumpyEngineBaseTensorized
class MHDEngine(LinearAffineEngine, NumpyEngineBaseTensorized):
"""
From Matrix Market: //math.nist.gov/MatrixMarket/data/NEP/mhd/mhd.html
"""
def __init__(self, ncol : int = 1, seed : int = 31415):
super().__init__()
self.npar = 1
self.nAs, self.nbs = 2, 1
self.nports = ncol
A0 = sp.csr_matrix(scio.mmread("mhd4800a.mtx"), dtype = np.complex)
self.As = [A0, - scio.mmread("mhd4800b.mtx").tocsr()]
np.random.seed(seed)
B = np.random.randn(self.As[0].shape[0], ncol)
self.bs[0] = (B / np.linalg.norm(B, axis = 0)).flatten()
def getPolesExact(self, k:int, sigma:np.complex):
return sp.linalg.eigs(self.As[0], k, - self.As[1], sigma,
return_eigenvectors = False)

Event Timeline