def test_gfc3d(): data_files = ('LMGC_GFC3D_CubeH8.hdf5', 'LMGC_GlobalFrictionContactProblem00046.hdf5') mark_as_failed = False sn.numerics_set_verbose(1) for d in data_files: full_path = data_dir + d if os.path.isfile(full_path): fcp = sn.globalFrictionContact_fclib_read(full_path) for s in solvers: res = solve_global(fcp, s) if res: print('Solver {:} on problem {:} failed with info = {:}'. format(sn.solver_options_id_to_name(s), d, res)) mark_as_failed = True else: print('Solver {:} on problem {:} is ok'.format( sn.solver_options_id_to_name(s), d)) fcp_reduced = condensed_from_global(fcp) for s in solvers_reduced1: res = solve_reduced(fcp_reduced, s) if res: print( 'Solver {:} on problem {:} in reduced form failed with info = {:}' .format(sn.solver_options_id_to_name(s), d, res)) mark_as_failed = True else: print('Solver {:} on problem {:} is ok'.format( sn.solver_options_id_to_name(s), d)) assert mark_as_failed is False
def test_fc3d(): data_files = ['Capsules-i125-1213.hdf5'] mark_as_failed = False for d in data_files: full_path = data_dir + d if os.path.isfile(full_path): sn.numerics_set_verbose(1) fcp = sn.frictionContact_fclib_read(full_path) for s in solvers_reduced3: res = solve_reduced(fcp, s) if res: print('Solver {:} on problem {:} failed with info = {:}'. format(sn.solver_options_id_to_name(s), d, res)) mark_as_failed = True else: print('Solver {:} on problem {:} is ok'.format( sn.solver_options_id_to_name(s), d)) assert mark_as_failed is False
def test_ncp_path(): ncp = SN.NCP(2, ncp_function, ncp_Nablafunction) z = np.array([0., 0.]) w = np.array([0., 0.]) SO = SN.SolverOptions(SN.SICONOS_NCP_PATH) info = SN.ncp_driver(ncp, z, w, SO) if siconos.WITH_PATHFERRIS: assert (np.linalg.norm(z - zsol) <= ztol) assert not info return else: assert info != 0 try: SN.ncp_path(ncp, z, w, SO) except RuntimeError: pass except: assert 0 if __name__ == "__main__": SN.numerics_set_verbose(3) test_ncp_newton_FBLSA() test_new() test_ncp_newton_minFBLSA() test_ncp_path()
print("z = ", z) print("w = ", w) #assert (np.linalg.norm(z-zsol) <= ztol) assert not info def test_mcp_newton_min_FBLSA_2(): n = 10 mcp = sn.MCP(n - 5, 5, mcp_function_2, mcp_Nablafunction_2) z = np.zeros(n) w = np.zeros(n) options = sn.SolverOptions(sn.SICONOS_MCP_NEWTON_MIN_FBLSA) options.iparam[sn.SICONOS_IPARAM_STOPPING_CRITERION] = \ sn.SICONOS_STOPPING_CRITERION_RESIDU sn.solver_options_print(options) info = sn.mcp_newton_min_FBLSA(mcp, z, w, options) print("z = ", z) print("w = ", w) #assert (np.linalg.norm(z-zsol) <= ztol) assert not info if __name__ == "__main__": sn.numerics_set_verbose(3) test_mcp_newton_FB_FBLSA() test_mcp_newton_min_FBLSA() test_mcp_newton_FB_FBLSA_2() test_mcp_newton_min_FBLSA_2()
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
#!/usr/bin/env python 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