本文整理汇总了Python中siconos.kernel.Model.currentTime方法的典型用法代码示例。如果您正苦于以下问题:Python Model.currentTime方法的具体用法?Python Model.currentTime怎么用?Python Model.currentTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类siconos.kernel.Model
的用法示例。
在下文中一共展示了Model.currentTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: while
# 需要导入模块: from siconos.kernel import Model [as 别名]
# 或者: from siconos.kernel.Model import currentTime [as 别名]
# initial data
#
dataPlot[0, 0] = t0
dataPlot[0, 1] = q[2]
dataPlot[0, 2] = v[2]
k = 1
# time loop
while(simulation.hasNextEvent()):
# Add a second box dynamically to the simulation
if k == 100:
broadphase.addDynamicObject(makeBox(pos=3), simulation)
broadphase.buildInteractions(bouncingBox.currentTime())
simulation.computeOneStep()
dataPlot[k, 0] = simulation.nextTime()
dataPlot[k, 1] = q[2]
dataPlot[k, 2] = v[2]
if (broadphase.collisionWorld().getDispatcher().getNumManifolds() > 0):
if bouncingBox.nonSmoothDynamicalSystem().topology().\
numberOfIndexSet() > 1:
index1 = sk.interactions(simulation.indexSet(1))
if (len(index1) == 4):
dataPlot[k, 3] = norm(index1[0].lambda_(1)) + \
norm(index1[1].lambda_(1)) + norm(index1[2].lambda_(1)) + \
norm(index1[3].lambda_(1))
示例2: run
# 需要导入模块: from siconos.kernel import Model [as 别名]
# 或者: from siconos.kernel.Model import currentTime [as 别名]
#.........这里部分代码省略.........
"""
from siconos.kernel import \
Model, MoreauJeanOSI, TimeDiscretisation,\
GenericMechanical, FrictionContact, NewtonImpactFrictionNSL
from siconos.numerics import SICONOS_FRICTION_3D_ONECONTACT_NSN_AC
from siconos.mechanics.contact_detection.bullet import \
btConvexHullShape, btCollisionObject, \
btBoxShape, btQuaternion, btTransform, btConeShape, \
BulletSpaceFilter, cast_BulletR, \
BulletWeightedShape, BulletDS, BulletTimeStepping
if set_external_forces is not None:
self._set_external_forces = set_external_forces
if time_stepping is None:
time_stepping = BulletTimeStepping
if space_filter is None:
space_filter = BulletSpaceFilter
# Model
#
model = Model(t0, T)
# (1) OneStepIntegrators
joints = list(self.joints())
self._osi = MoreauJeanOSI(theta)
# (2) Time discretisation --
timedisc = TimeDiscretisation(t0, h)
if len(joints) > 0:
osnspb = GenericMechanical(SICONOS_FRICTION_3D_ONECONTACT_NSN_AC)
else:
osnspb = FrictionContact(3, solver)
osnspb.numericsSolverOptions().iparam[0] = itermax
osnspb.numericsSolverOptions().dparam[0] = tolerance
osnspb.setMaxSize(16384)
osnspb.setMStorageType(1)
#osnspb.setNumericsVerboseMode(False)
# keep previous solution
osnspb.setKeepLambdaAndYState(True)
# (5) broadphase contact detection
self._broadphase = space_filter(model)
if not multipoints_iterations:
print("""
ConvexConvexMultipointIterations and PlaneConvexMultipointIterations are unset
""")
else:
if hasattr(self._broadphase, 'collisionConfiguration'):
self._broadphase.collisionConfiguration().\
setConvexConvexMultipointIterations()
self._broadphase.collisionConfiguration().\
setPlaneConvexMultipointIterations()
# (6) Simulation setup with (1) (2) (3) (4) (5)
simulation = time_stepping(timedisc)
simulation.insertIntegrator(self._osi)
simulation.insertNonSmoothProblem(osnspb)
simulation.setNewtonMaxIteration(Newton_max_iter)
k = 1
self.importScene(body_class, shape_class, face_class, edge_class)
model.initialize(simulation)
self.outputStaticObjects()
self.outputDynamicObjects()
while simulation.hasNextEvent():
print ('step', k)
log(self._broadphase.buildInteractions, with_timer)\
(model.currentTime())
log(simulation.computeOneStep, with_timer)()
log(self.outputDynamicObjects, with_timer)()
log(self.outputVelocities, with_timer)()
log(self.outputContactForces, with_timer)()
log(self.outputSolverInfos, with_timer)()
log(simulation.nextStep, with_timer)()
log(self._out.flush)()
print ('')
k += 1