Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120055681
elasticity (arch) greedy.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, Jul 1, 15:52
Size
2 KB
Mime Type
text/x-python
Expires
Thu, Jul 3, 15:52 (2 d)
Engine
blob
Format
Raw Data
Handle
27132535
Attached To
R6746 RationalROMPy
elasticity (arch) greedy.py
View Options
import
numpy
as
np
from
rrompy.hfengines.vector_linear_problem
import
\
LinearElasticityHelmholtzArchwayFrequency
as
LEHAF
from
rrompy.reduction_methods.lagrange_greedy
import
\
ApproximantLagrangePadeGreedy
as
Pade
from
rrompy.reduction_methods.lagrange_greedy
import
\
ApproximantLagrangeRBGreedy
as
RB
verb
=
2
timed
=
True
algo
=
"Pade"
#algo = "RB"
polyBasis
=
"LEGENDRE"
#polyBasis = "CHEBYSHEV"
#polyBasis = "MONOMIAL"
errorEstimatorKind
=
"SIMPLIFIED"
errorEstimatorKind
=
"EXACT"
k0s
=
np
.
power
(
np
.
linspace
(
1e5
,
3e5
,
150
),
.
5
)
k0
=
np
.
mean
(
k0s
)
kl
,
kr
=
min
(
k0s
),
max
(
k0s
)
params
=
{
'muBounds'
:[
kl
,
kr
],
'nTrainingPoints'
:
500
,
'Delta'
:
0
,
'greedyTol'
:
1e-2
,
'nTestPoints'
:
2
,
'basis'
:
polyBasis
,
'errorEstimatorKind'
:
errorEstimatorKind
}
if
timed
:
verb
=
0
E
=
1e6
nu
=
.
47
lambda_
=
E
*
nu
/
(
1.
+
nu
)
/
(
1.
-
2.
*
nu
)
mu_
=
E
/
(
1.
+
nu
)
solver
=
LEHAF
(
kappa
=
k0
,
n
=
200
,
rho_
=
1.5e3
,
T
=
1e4
,
lambda_
=
lambda_
,
mu_
=
mu_
,
R
=
1.
,
r
=
.
85
,
verbosity
=
verb
)
solver
.
omega
=
np
.
real
(
k0
)
if
algo
==
"Pade"
:
approx
=
Pade
(
solver
,
mu0
=
k0
,
approxParameters
=
params
,
verbosity
=
verb
)
else
:
approx
=
RB
(
solver
,
mu0
=
k0
,
approxParameters
=
params
,
verbosity
=
verb
)
if
timed
:
from
time
import
clock
start_time
=
clock
()
approx
.
greedy
()
print
(
"Time: "
,
clock
()
-
start_time
)
else
:
approx
.
greedy
(
True
)
approx
.
samplingEngine
.
verbosity
=
0
approx
.
verbosity
=
0
from
matplotlib
import
pyplot
as
plt
normApp
=
np
.
zeros
(
len
(
k0s
))
norm
=
np
.
zeros_like
(
normApp
)
res
=
np
.
zeros_like
(
normApp
)
err
=
np
.
zeros_like
(
normApp
)
for
j
in
range
(
len
(
k0s
)):
normApp
[
j
]
=
approx
.
normApprox
(
k0s
[
j
])
norm
[
j
]
=
approx
.
normHF
(
k0s
[
j
])
res
[
j
]
=
(
approx
.
estNormer
.
norm
(
approx
.
getRes
(
k0s
[
j
]))
/
approx
.
estNormer
.
norm
(
approx
.
getRHS
(
k0s
[
j
])))
err
[
j
]
=
approx
.
normErr
(
k0s
[
j
])
/
approx
.
normHF
(
k0s
[
j
])
resApp
=
approx
.
errorEstimator
(
k0s
)
plt
.
figure
()
plt
.
semilogy
(
k0s
,
norm
)
plt
.
semilogy
(
k0s
,
normApp
,
'--'
)
plt
.
semilogy
(
np
.
real
(
approx
.
mus
),
1.25
*
np
.
max
(
norm
)
*
np
.
ones_like
(
approx
.
mus
,
dtype
=
float
),
'rx'
)
plt
.
xlim
([
kl
,
kr
])
plt
.
grid
()
plt
.
show
()
plt
.
close
()
plt
.
figure
()
plt
.
semilogy
(
k0s
,
res
)
plt
.
semilogy
(
k0s
,
resApp
,
'--'
)
plt
.
semilogy
(
np
.
real
(
approx
.
mus
),
4.
*
np
.
max
(
resApp
)
*
np
.
ones_like
(
approx
.
mus
,
dtype
=
float
),
'rx'
)
plt
.
xlim
([
kl
,
kr
])
plt
.
grid
()
plt
.
show
()
plt
.
close
()
plt
.
figure
()
plt
.
semilogy
(
k0s
,
err
)
plt
.
xlim
([
kl
,
kr
])
plt
.
grid
()
plt
.
show
()
plt
.
close
()
polesApp
=
approx
.
getPoles
()
mask
=
(
np
.
real
(
polesApp
)
<
kl
)
|
(
np
.
real
(
polesApp
)
>
kr
)
print
(
"Outliers:"
,
polesApp
[
mask
])
polesApp
=
polesApp
[
~
mask
]
plt
.
figure
()
plt
.
plot
(
np
.
real
(
polesApp
),
np
.
imag
(
polesApp
),
'kx'
)
plt
.
axis
(
'equal'
)
plt
.
grid
()
plt
.
show
()
plt
.
close
()
Event Timeline
Log In to Comment