Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F84743099
mhd_engine.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Sep 24, 15:52
Size
942 B
Mime Type
text/x-python
Expires
Thu, Sep 26, 15:52 (2 d)
Engine
blob
Format
Raw Data
Handle
21079706
Attached To
R6746 RationalROMPy
mhd_engine.py
View Options
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
Log In to Comment