Exemplo n.º 1
0
def test_fc3dnsgs():
    N.setNumericsVerbose(2)
    FCP = N.FrictionContactProblem(3,M,q,mu)
    SO=N.SolverOptions(N.SICONOS_FRICTION_3D_NSGS)
    r=N.fc3d_nsgs(FCP, reactions, velocities, SO)
    assert SO.dparam[1] < 1e-10
    assert not r
Exemplo n.º 2
0
def test_fc3dfischer():
    N.setNumericsVerbose(2)
    FCP = N.FrictionContactProblem(3,M,q,mu)
    SO=N.SolverOptions(N.SICONOS_FRICTION_3D_NSN_FB)

    r = N.fc3d_nonsmooth_Newton_FischerBurmeister(FCP, reactions, velocities, SO)
    assert SO.dparam[1] < 1e-10
    assert not r
Exemplo n.º 3
0
def test_fc3dlocalac():
    N.setNumericsVerbose(2)
    FCP = N.FrictionContactProblem(3,M,q,mu)
    SO=N.SolverOptions(N.SICONOS_FRICTION_3D_NSN_AC)

    r = N.fc3d_nonsmooth_Newton_AlartCurnier(FCP, reactions, velocities, SO)
    assert SO.dparam[1] < 1e-10
    assert not r
Exemplo n.º 4
0
def condensed_from_global(fcp):
    # spsolve expect the indices to be cint aka 32 bits int
    # Hence, we do some magic to cirumvent those issues.
    Mcoo = scipy.sparse.coo_matrix(fcp.M)
    Mcsc = scipy.sparse.csc_matrix(Mcoo)
    Hcoo = scipy.sparse.coo_matrix(fcp.H)
    Hcsc = scipy.sparse.csc_matrix(Hcoo)
    WW = Hcsc.T.dot(scipy.sparse.linalg.spsolve(Mcsc, Hcsc))
    qprime = fcp.H.T.dot(scipy.sparse.linalg.spsolve(Mcsc, fcp.q))

    fcp_reduced = sn.FrictionContactProblem()
    fcp_reduced.dimension = fcp.dimension
    fcp_reduced.numberOfContacts = fcp.numberOfContacts

    # this is a hack to deal with the inability of fc3d solvers to work with
    # sparse matrices
    _, Wsbm = sn.SBM_from_csparse(3, WW)
    fcp_reduced.M = Wsbm
    fcp_reduced.mu = fcp.mu
    fcp_reduced.q = fcp.b + qprime
    return fcp_reduced
Exemplo n.º 5
0
# Number of contacts
nc = 3
# W matrix
w_shape = (3 * nc, 3 * nc)
W = np.zeros(w_shape, dtype=np.float64)

W.flat[...] = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]

# q vector
q = np.zeros(3 * nc, dtype=np.float64)
q[...] = [-1, 1, 3, -1, 1, 3, -1, 1, 3]

# Friction coeff
mu = [0.1, 0.1, 0.1]

fc3d = sn.FrictionContactProblem(3, nc, W, q, mu)


# Case 2 : use fclib-library, read hdf5 file




# --- Set solver options ---

# Check Friction_cst.h for a list of solvers ids.
solver_options = sn.SolverOptions(sn.SICONOS_FRICTION_3D_NSGS)#sn.SICONOS_FRICTION_3D_FPP)

eps = np.finfo(np.float64).eps
solver_options.dparam[0] = 100 * eps
Exemplo n.º 6
0
import numpy as np
import siconos.numerics as sn

NC = 1

M = np.eye(3 * NC)

q = np.array([-1., 1., 3.])

mu = np.array([0.1])

reactions = np.array([0., 0., 0.])
velocities = np.array([0., 0., 0.])
sn.numerics_set_verbose(2)
FCP = sn.FrictionContactProblem(3, M, q, mu)


def solve(problem, solver, options):
    """Solve problem for a given solver
    """
    reactions[...] = 0.0
    velocities[...] = 0.0
    r = solver(problem, reactions, velocities, options)
    assert options.dparam[1] < options.dparam[0]
    assert not r


def test_fc3dnsgs():
    """Non-smooth Gauss Seidel, default
    """