1"""Tests for python interface of friction contact solvers in numerics. 2""" 3#!/usr/bin/env python 4 5import numpy as np 6import siconos.numerics as sn 7 8 9NC = 1 10 11M = np.eye(3 * NC) 12 13q = np.array([-1., 1., 3.]) 14 15mu = np.array([0.1]) 16 17reactions = np.array([0., 0., 0.]) 18velocities = np.array([0., 0., 0.]) 19sn.numerics_set_verbose(2) 20FCP = sn.FrictionContactProblem(3, M, q, mu) 21 22 23def solve(problem, solver, options): 24 """Solve problem for a given solver 25 """ 26 reactions[...] = 0.0 27 velocities[...] = 0.0 28 r = solver(problem, reactions, velocities, options) 29 assert options.dparam[1] < options.dparam[0] 30 assert not r 31 32 33def test_fc3dnsgs(): 34 """Non-smooth Gauss Seidel, default 35 """ 36 SO = sn.SolverOptions(sn.SICONOS_FRICTION_3D_NSGS) 37 solve(FCP, sn.fc3d_nsgs, SO) 38 39 40def test_fc3dlocalac(): 41 """Non-smooth Gauss Seidel, Alart-Curnier as local solver. 42 """ 43 SO = sn.SolverOptions(sn.SICONOS_FRICTION_3D_NSN_AC) 44 solve(FCP, sn.fc3d_nonsmooth_Newton_AlartCurnier, SO) 45 46 47def test_fc3dfischer(): 48 """Non-smooth Newton, Fischer-Burmeister. 49 """ 50 SO = sn.SolverOptions(sn.SICONOS_FRICTION_3D_NSN_FB) 51 solve(FCP, sn.fc3d_nonsmooth_Newton_FischerBurmeister, SO) 52