diff --git a/tests/test_epic.py b/tests/test_epic.py index cf0aa08..761143b 100644 --- a/tests/test_epic.py +++ b/tests/test_epic.py @@ -1,57 +1,72 @@ # -*- 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 . 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.setElasticity(hertz_coarse.e_star, 0) + solver = tm.PolonskyKeerRey(model, hertz_coarse.surface, 1e-12, + request.param, + request.param) + solver.solve(hertz_coarse.load) -def test_epic(pkr): + 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 + model_elastic, hertz = pkr_coarse model = tm.ModelFactory.createModel( tm.model_type.volume_2d, [0.001, hertz.domain_size, hertz.domain_size], - [3, hertz.n, hertz.n] + [2, 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