Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F79327739
test_westergaard.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
Sun, Aug 25, 20:46
Size
2 KB
Mime Type
text/x-python
Expires
Tue, Aug 27, 20:46 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20167161
Attached To
rTAMAAS tamaas
test_westergaard.py
View Options
# -*- coding: utf-8 -*-
# @file
# @section LICENSE
#
# Copyright (©) 2016-2020 EPFL (École Polytechnique Fédérale de Lausanne),
# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# 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
tamaas
as
tm
import
pytest
from
numpy.linalg
import
norm
@pytest.fixture
(
scope
=
"module"
,
params
=
[
tm
.
PolonskyKeerRey
.
pressure
,
tm
.
PolonskyKeerRey
.
gap
])
def
pkr
(
westergaard
,
request
):
loads
=
{
tm
.
PolonskyKeerRey
.
pressure
:
westergaard
.
load
,
tm
.
PolonskyKeerRey
.
gap
:
0.06697415181446396
}
model
=
tm
.
ModelFactory
.
createModel
(
tm
.
model_type
.
basic_1d
,
[
1.
],
[
westergaard
.
n
])
model
.
setElasticity
(
westergaard
.
e_star
,
0
)
solver
=
tm
.
PolonskyKeerRey
(
model
,
westergaard
.
surface
,
1e-12
,
request
.
param
,
request
.
param
)
solver
.
setMaxIterations
(
5000
)
solver
.
solve
(
loads
[
request
.
param
])
return
model
,
westergaard
def
test_energy
(
pkr
):
model
,
sol
=
pkr
traction
,
displacement
=
model
.
getTraction
(),
model
.
getDisplacement
()
error
=
norm
((
traction
-
sol
.
pressure
)
*
(
displacement
-
sol
.
displacement
))
error
/=
norm
(
sol
.
pressure
*
sol
.
displacement
)
assert
error
<
4e-6
def
test_pkr_multi
(
westergaard
):
model_basic
=
tm
.
ModelFactory
.
createModel
(
tm
.
model_type
.
basic_1d
,
[
1.
],
[
westergaard
.
n
])
model_volume
=
tm
.
ModelFactory
.
createModel
(
tm
.
model_type
.
volume_1d
,
[
1.
,
1.
],
[
20
,
westergaard
.
n
])
pressures
=
{}
for
model
in
[
model_basic
,
model_volume
]:
print
(
model
)
solver
=
tm
.
PolonskyKeerRey
(
model
,
westergaard
.
surface
,
1e-12
,
tm
.
PolonskyKeerRey
.
pressure
,
tm
.
PolonskyKeerRey
.
pressure
)
solver
.
solve
(
westergaard
.
load
)
pressures
[
model
]
=
model
.
getTraction
()
error
=
norm
(
pressures
[
model_basic
]
-
pressures
[
model_volume
][:,
1
])
\
/
westergaard
.
load
assert
error
<
1e-16
if
__name__
==
"__main__"
:
print
(
"Test is meant to run with pytest"
)
Event Timeline
Log In to Comment