Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F60922134
test_epic.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
Fri, May 3, 09:59
Size
2 KB
Mime Type
text/x-python
Expires
Sun, May 5, 09:59 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17440394
Attached To
rTAMAAS tamaas
test_epic.py
View Options
# -*- coding: utf-8 -*-
#
# Copyright (©) 2016-2022 EPFL (École Polytechnique Fédérale de Lausanne),
# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
# Copyright (©) 2020-2022 Lucas Frérot
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from
__future__
import
division
,
print_function
import
pytest
from
conftest
import
pkridfn
import
tamaas
as
tm
from
numpy.linalg
import
norm
from
tamaas.nonlinear_solvers
import
DFSANESolver
@pytest.fixture
(
scope
=
"module"
,
params
=
[
tm
.
PolonskyKeerRey
.
pressure
],
ids
=
pkridfn
)
def
model_setup
(
hertz_coarse
,
request
):
models
,
solvers
=
[],
[]
for
mtype
in
[
tm
.
model_type
.
basic_2d
,
tm
.
model_type
.
volume_2d
]:
dim
=
tm
.
type_traits
[
mtype
]
.
dimension
n
=
[
hertz_coarse
.
n
]
*
dim
d
=
[
hertz_coarse
.
domain_size
]
*
dim
if
dim
==
3
:
n
[
0
]
=
2
d
[
0
]
=
0.001
model
=
tm
.
ModelFactory
.
createModel
(
mtype
,
d
,
n
)
model
.
E
,
model
.
nu
=
hertz_coarse
.
e_star
,
0
solver
=
tm
.
PolonskyKeerRey
(
model
,
hertz_coarse
.
surface
,
1e-12
,
request
.
param
,
request
.
param
)
models
.
append
(
model
)
solvers
.
append
(
solver
)
epsolver
=
DFSANESolver
(
tm
.
ModelFactory
.
createResidual
(
model
,
sigma_y
=
1e2
*
model
.
E
,
hardening
=
0
))
solvers
[
1
]
=
tm
.
EPICSolver
(
solvers
[
1
],
epsolver
,
1e-12
)
for
solver
in
solvers
:
solver
.
solve
(
hertz_coarse
.
load
)
return
models
,
hertz_coarse
@pytest.mark.xfail
(
tm
.
TamaasInfo
.
backend
==
'tbb'
,
reason
=
'TBB reductions are unstable?'
)
def
test_energy
(
model_setup
):
"""Test the full elastic-plastic solve step in elasticity"""
# We use computed values from basic PKR to test
(
model_elastic
,
model_plastic
),
hertz
=
model_setup
error
=
norm
(
(
model_plastic
.
traction
[
...
,
2
]
-
model_elastic
.
traction
)
*
(
model_plastic
.
displacement
[
0
,
...
,
2
]
-
model_elastic
.
displacement
))
error
/=
norm
(
hertz
.
pressure
*
hertz
.
displacement
)
assert
error
<
1e-16
Event Timeline
Log In to Comment