Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61573724
trained_model_pivoted_reduced_basis.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, May 7, 13:17
Size
2 KB
Mime Type
text/x-python
Expires
Thu, May 9, 13:17 (2 d)
Engine
blob
Format
Raw Data
Handle
17530058
Attached To
R6746 RationalROMPy
trained_model_pivoted_reduced_basis.py
View Options
# Copyright (C) 2018 by the RROMPy authors
#
# This file is part of RROMPy.
#
# RROMPy is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RROMPy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with RROMPy. If not, see <http://www.gnu.org/licenses/>.
#
import
numpy
as
np
from
.trained_model_pivoted_general
import
TrainedModelPivotedGeneral
from
.trained_model_reduced_basis
import
TrainedModelReducedBasis
from
rrompy.utilities.base.types
import
HFEng
from
rrompy.utilities.poly_fitting.heaviside
import
affine2heaviside
from
rrompy.utilities.exception_manager
import
RROMPyAssert
__all__
=
[
'TrainedModelPivotedReducedBasis'
]
class
TrainedModelPivotedReducedBasis
(
TrainedModelPivotedGeneral
,
TrainedModelReducedBasis
):
"""
ROM approximant evaluation for pivoted RB approximant (with pole matching).
Attributes:
Data: dictionary with all that can be pickled.
"""
def
initializeFromAffine
(
self
,
HFEngine
:
HFEng
,
matchingWeight
:
float
=
1.
,
POD
:
bool
=
True
,
jSupp
:
int
=
1
):
"""Initialize Heaviside representation."""
RROMPyAssert
(
self
.
data
.
nparPivot
,
1
,
"Number of pivot parameters"
)
poles
,
coeffs
=
[],
[]
nbadpls
=
0
for
As
,
bs
in
zip
(
self
.
data
.
ARBsList
,
self
.
data
.
bRBsList
):
cfs
,
pls
,
basis
=
affine2heaviside
(
As
,
bs
,
jSupp
)
poles
+=
[
pls
]
coeffs
+=
[
cfs
]
nbadpls
=
max
(
nbadpls
,
np
.
sum
(
np
.
isinf
(
pls
)))
if
nbadpls
>
0
:
for
j
in
range
(
len
(
poles
)):
plsgood
=
np
.
argsort
(
np
.
abs
(
pls
))[:
-
nbadpls
]
poles
[
j
]
=
poles
[
j
][
plsgood
]
coeffs
[
j
]
=
coeffs
[
j
][
plsgood
,
:]
self
.
initializeFromLists
(
poles
,
coeffs
,
basis
,
HFEngine
,
matchingWeight
,
POD
)
Event Timeline
Log In to Comment