n_col=n_col, x_shift=1.8, roca_size=0.1, top=3, rate=0.2, density=density) io.add_Newton_impact_friction_nsl('contact', mu=1.0, e=0.01) run_options = MechanicsHdf5Runner_run_options() run_options['t0'] = 0 run_options['T'] = T run_options['h'] = hstep run_options['theta'] = 1.0 bullet_options = SiconosBulletOptions() bullet_options.perturbationIterations = 0. #bullet_options.minimumPointsPerturbationThreshold = 0. run_options['bullet_options'] = bullet_options run_options['solver_options'] = options run_options['constraint_activation_threshold'] = 1e-05 run_options['end_run_iteration_hook'] = dh run_options['Newton_options'] = sk.SICONOS_TS_LINEAR run_options['skip_last_update_output'] = True run_options['skip_reset_lambdas'] = True #run_options['osns_assembly_type']= sk.REDUCED_DIRECT
translation=[4 * math.sqrt(2), 2.], orientation=[math.pi / 4.0], velocity=[0, 0, -1.0], mass=1., inertia=2.0) # the ground object made with the ground shape. As the mass is # not given, it is a static object only involved in contact # detection. io.add_object('ground', [Contactor('Ground')], translation=[0, -.5]) # Run the simulation from the inputs previously defined and add # results to the hdf5 file. The visualisation of the output may be done # with the vview command. bullet_options = SiconosBulletOptions() bullet_options.worldScale = 1.0 bullet_options.contactBreakingThreshold = 0.04 bullet_options.dimension = SICONOS_BULLET_2D bullet_options.perturbationIterations = 0 bullet_options.minimumPointsPerturbationThreshold = 0 options = sk.solver_options_create(sn.SICONOS_FRICTION_2D_NSGS) options.iparam[sn.SICONOS_IPARAM_MAX_ITER] = 100000 options.dparam[sn.SICONOS_DPARAM_TOL] = 1e-8 T = 2.0 if restart: T = 2.0 #T=1*0.001 hstep = 0.01
# ./mkspheres.py <n> # ./spheres_in_a_box.py coors-<n>.txt radii-<n>.txt from siconos.mechanics.collision.tools import Contactor from siconos.io.mechanics_run import MechanicsHdf5Runner from siconos.io.FrictionContactTrace import FrictionContactTraceParams import siconos.numerics as sn import siconos.kernel as sk from siconos.mechanics.collision.bullet import SiconosBulletOptions from math import pi import numpy import sys import mkspheres bullet_options = SiconosBulletOptions() bullet_options.worldScale = 1000 bullet_options.contactBreakingThreshold = 0.0002 bullet_options.perturbationIterations = 0 bullet_options.minimumPointsPerturbationThreshold = 0 hstep = 0.001 theta = 0.50001 itermax = 1000 tolerance = 1e-7 lx = mkspheres.lx ly = mkspheres.ly lz = mkspheres.lz margin_ratio=1.e-5 wthick = mkspheres.lz/10 zoffset = -wthick/2
io.add_object('disk', [Contactor('Disk')], translation=[0, 5.], velocity=[0, 0, 0.5], mass=1., inertia=2.0) # the ground object made with the ground shape. As the mass is # not given, it is a static object only involved in contact # detection. io.add_object('ground', [Contactor('Ground_disk')], translation=[0, -4.0]) # Run the simulation from the inputs previously defined and add # results to the hdf5 file. The visualisation of the output may be done # with the vview command. bullet_options = SiconosBulletOptions() bullet_options.worldScale = 1.0 bullet_options.contactBreakingThreshold = 0.04 bullet_options.dimension = 1 options = sk.solver_options_create(sn.SICONOS_FRICTION_2D_NSGS) options.iparam[sn.SICONOS_IPARAM_MAX_ITER] = 100000 options.dparam[sn.SICONOS_DPARAM_TOL] = 1e-8 with MechanicsHdf5Runner(mode='r+') as io: # By default earth gravity is applied and the units are those # of the International System of Units. io.run(verbose=True, with_timer=False, bullet_options=bullet_options,
#!/usr/bin/env python # Various object types sliding, rolling, and sitting still. from siconos.mechanics.collision.tools import Contactor from siconos.io.mechanics_run import MechanicsHdf5Runner from siconos.mechanics.collision.convexhull import ConvexHull from siconos.mechanics.collision.bullet import SiconosBulletOptions import siconos.numerics as sn import siconos.kernel as sk bullet_options = SiconosBulletOptions() bullet_options.worldScale = 1.0 # Control the number of perturbations applied to generate multipoint # surface-surface contact manifolds. Default is 5 and 5. bullet_options.perturbationIterations = 5 bullet_options.minimumPointsPerturbationThreshold = 5 # Creation of the hdf5 file for input/output with MechanicsHdf5Runner() as io: # Definition of a tetrahedron as a convex shape. # Bottom purposely not even. import numpy pts = numpy.array([(-1.0, 1.0, -1.0), (1.0, -1.0, -0.5), (-1.0, -1.0, -0.7), (0.0, 0.0, 1.0)]) io.add_convex_shape('Tetra', pts - pts.mean(0)) io.add_primitive_shape('Cyl', 'Cylinder', [1, 1])
#!/usr/bin/env python # # Example of one object under gravity with one contactor and a ground # using the Siconos proposed mechanics API # from siconos.mechanics.collision.tools import Contactor from siconos.io.mechanics_io import Hdf5 import siconos.numerics as Numerics import siconos.io.mechanics_io from siconos.mechanics.collision.bullet import SiconosBulletOptions options = SiconosBulletOptions() options.worldScale = 1.0 options.contactBreakingThreshold = 0.04 # Creation of the hdf5 file for input/output with Hdf5() as io: # Definition of a sphere io.addPrimitiveShape('Sphere', 'Sphere', (2, ), insideMargin=0.2, outsideMargin=0.3) # Definition of the ground shape io.addPrimitiveShape('Ground', 'Box', (10, 10, 0.1), insideMargin=0.05, outsideMargin=0.1)
# oscillation if integrated with a fully implicit version of the # classical time-stepping method. Reducing the step-size led to # different results as the divergence or deadening was weakened." mu = 0.3 m = 6*1e-3 # kg r1 = 1.5 # cm r2 = 0.5 # cm a1 = 0.3 # cm a2 = 1.6 # cm I1 = 8*1e-3 # kg . cm^2 I3 = 7*1e-3 # kg . cm^2 # Bullet: do not generate extra contact points for convex pairs by # rotational purterbation method. bullet_options = SiconosBulletOptions() bullet_options.perturbationIterations = 0 bullet_options.minimumPointsPerturbationThreshold = 0 with MechanicsHdf5Runner() as io: io.add_primitive_shape('Body1', 'Sphere', (r1,)) io.add_primitive_shape('Body2', 'Cylinder', (r2, a2)) io.add_primitive_shape('Body3', 'Sphere', (r2,)) io.add_primitive_shape('Ground', 'Box', (100, 100, .5)) io.add_Newton_impact_friction_nsl('contact', mu=mu) io.add_object('ground', [Contactor('Ground')], translation=[0, 0, 0]) io.add_object('tippe-top', [Contactor('Body1', relative_translation=[0, 0, a1]),
# # Here we demonstrate the use of two very small cubes simulated with # geometry at 1000x its scale. Without scaling, contact detection is # incorrect for an object of this size. When contact detection is # performed with scaled-up geometries, the contact points are # correctly generated and used by Siconos. # from siconos.mechanics.collision.tools import Contactor from siconos.io.mechanics_run import MechanicsHdf5Runner import siconos.numerics as Numerics # We need to pass some options to the Bullet backend from siconos.mechanics.collision.bullet import SiconosBulletOptions options = SiconosBulletOptions() options.worldScale = 1000.0 # Creation of the hdf5 file for input/output with MechanicsHdf5Runner() as io: # Definition of a cube as a convex shape io.add_convex_shape('CubeCH', [(-0.001, 0.001, -0.001), (-0.001, -0.001, -0.001), (-0.001, -0.001, 0.001), (-0.001, 0.001, 0.001), (0.001, 0.001, 0.001), (0.001, 0.001, -0.001), (0.001, -0.001, -0.001), (0.001, -0.001, 0.001)]) # Definition of a cube as a primitive shape io.add_primitive_shape('CubeP', 'Box', (0.002, 0.002, 0.002))
io.add_object('cubeP', [Contactor('CubeP')], translation=[0, -0.003, 0.005], velocity=[0.1, 0, 0, 1, 1, 1], mass=0.1) # the ground object made with the ground shape. As the mass is # not given, it is a static object only involved in contact # detection. io.add_object('ground', [Contactor('Ground')], translation=[0, 0, -0.005]) # Run the simulation from the inputs previously defined and add # results to the hdf5 file. The visualisation of the output may be done # with the vview command. from siconos.mechanics.collision.bullet import SiconosBulletOptions bullet_options = SiconosBulletOptions() bullet_options.worldScale = 1000.0 bullet_options.contactBreakingThreshold = 0.001 options = sk.solver_options_create(sn.SICONOS_FRICTION_3D_NSGS) options.iparam[sn.SICONOS_IPARAM_MAX_ITER] = 10000 options.dparam[sn.SICONOS_DPARAM_TOL] = 1e-8 with MechanicsHdf5Runner(mode='r+') as io: # By default earth gravity is applied and the units are those # of the International System of Units. # Because of fixed collision margins used in the collision detection, # sizes of small objects may need to be expressed in cm or mm. io.run(with_timer=False, bullet_options=bullet_options,