Page MenuHomec4science

test_epic.py
No OneTemporary

File Metadata

Created
Wed, May 1, 12:21

test_epic.py

# -*- coding: utf-8 -*-
# @file
# @section LICENSE
#
# Copyright (©) 2016-2021 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 pytest
import tamaas as tm
from numpy.linalg import norm
from tamaas.nonlinear_solvers import DFSANESolver
@pytest.fixture(scope="module",
params=[tm.PolonskyKeerRey.pressure])
def pkr_coarse(hertz_coarse, request):
model = tm.ModelFactory.createModel(tm.model_type.basic_2d,
[hertz_coarse.domain_size,
hertz_coarse.domain_size],
[hertz_coarse.n, hertz_coarse.n])
model.E, model.nu = hertz_coarse.e_star, 0
solver = tm.PolonskyKeerRey(model, hertz_coarse.surface, 1e-12,
request.param,
request.param)
solver.solve(hertz_coarse.load)
return model, hertz_coarse
def test_epic(pkr_coarse):
"""Test the full elastic-plastic solve step in elasticity"""
# We use computed values from basic PKR to test
model_elastic, hertz = pkr_coarse
model = tm.ModelFactory.createModel(
tm.model_type.volume_2d,
[0.001, hertz.domain_size, hertz.domain_size],
[2, hertz.n, hertz.n]
)
model.E, model.nu = hertz.e_star, 0
residual = tm.ModelFactory.createResidual(
model,
sigma_y=1e2 * model.E,
hardening=0
)
epsolver = DFSANESolver(residual)
csolver = tm.PolonskyKeerRey(model, hertz.surface, 1e-12)
epic = tm.EPICSolver(csolver, epsolver, 1e-12)
epic.solve(hertz.load)
error = norm((model['traction'][..., 2] - model_elastic['traction'])
* (model['displacement'][0, ..., 2]
- model_elastic['displacement']))
error /= norm(hertz.pressure * hertz.displacement)
assert error < 1e-16

Event Timeline