Page MenuHomec4science

test_epic.py
No OneTemporary

File Metadata

Created
Thu, May 2, 10:57

test_epic.py

# -*- 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
from numpy.linalg import norm
from tamaas.nonlinear_solvers import DFSANESolver
def test_epic(pkr):
"""Test the full elastic-plastic solve step in elasticity"""
# We use computed values from basic PKR to test
model_elastic, hertz = pkr
model = tm.ModelFactory.createModel(
tm.model_type.volume_2d,
[0.001, hertz.domain_size, hertz.domain_size],
[3, hertz.n, hertz.n]
)
model.setElasticity(hertz.e_star, 0)
residual = tm.ModelFactory.createResidual(
model,
sigma_y=1e2 * model.E,
hardening=0
)
epsolver = DFSANESolver(residual, model)
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