Page MenuHomec4science

test_westergaard.py
No OneTemporary

File Metadata

Created
Thu, Jun 6, 16:22

test_westergaard.py

#!/usr/bin/env python
# coding: utf-8
# -----------------------------------------------------------------------------
# @author Lucas Frérot <lucas.frerot@epfl.ch>
#
# @section LICENSE
#
# Copyright (©) 2016 EPFL (Ecole Polytechnique Fédérale de
# Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
# Solides)
#
# Tamaas is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Tamaas 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 Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Tamaas. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------
import sys
import numpy as np
import matplotlib.pyplot as plt
from util_test import import_tamaas
def constructSinProfile(size, mode, amplitude):
x = np.linspace(0, 1, size)
y = np.linspace(0, 1, size)
x, y = np.meshgrid(x, y)
surface = amplitude * np.sin(2*np.pi*x*mode)
return surface.copy()
def main():
tm = import_tamaas()
grid_size = 256
mode = 1
delta = 0.1
effective_modulus = 1.
p_star = np.pi * effective_modulus * delta * mode # Full contact load
load = 0.4 * p_star
surface = constructSinProfile(grid_size, mode, delta)
bem = tm.BemPolonski(surface)
bem.setEffectiveModulus(effective_modulus)
bem.computeEquilibrium(1e-12, load)
tractions = bem.getTractions()
displacements = bem.getDisplacements()
# Testing contact area against Westergaard solution
contact_area = tm.SurfaceStatistics.computeContactArea(tractions)
westergaard_contact_size = 2. / (mode * np.pi) * np.arcsin(np.sqrt(load / p_star))
area_error = np.abs(contact_area - mode * westergaard_contact_size) / (mode * westergaard_contact_size)
print "Area error: {}".format(area_error)
# Testing displacements at full contact
load = 1.1 * p_star
bem.computeEquilibrium(1e-12, load)
contact_area = tm.SurfaceStatistics.computeContactArea(tractions)
print "Area at load > full contact : {}".format(contact_area)
# Testing pressure distribution at full contact
westergaard_pressure = constructSinProfile(grid_size, mode, p_star)
tractions_amplitude = tractions.max() - tractions.mean()
return 0
if __name__ == "__main__":
sys.exit(main())

Event Timeline