本文整理汇总了Python中siconos.kernel.TimeStepping.nonSmoothDynamicalSystem方法的典型用法代码示例。如果您正苦于以下问题:Python TimeStepping.nonSmoothDynamicalSystem方法的具体用法?Python TimeStepping.nonSmoothDynamicalSystem怎么用?Python TimeStepping.nonSmoothDynamicalSystem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类siconos.kernel.TimeStepping
的用法示例。
在下文中一共展示了TimeStepping.nonSmoothDynamicalSystem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_serialization4
# 需要导入模块: from siconos.kernel import TimeStepping [as 别名]
# 或者: from siconos.kernel.TimeStepping import nonSmoothDynamicalSystem [as 别名]
def test_serialization4():
from siconos.kernel import LagrangianLinearTIDS, NewtonImpactNSL, \
LagrangianLinearTIR, Interaction, NonSmoothDynamicalSystem, \
MoreauJeanOSI, TimeDiscretisation, LCP, TimeStepping
from numpy import array, eye, empty
t0 = 0 # start time
T = 10 # end time
h = 0.005 # time step
r = 0.1 # ball radius
g = 9.81 # gravity
m = 1 # ball mass
e = 0.9 # restitution coeficient
theta = 0.5 # theta scheme
#
# dynamical system
#
x = array([1, 0, 0]) # initial position
v = array([0, 0, 0]) # initial velocity
mass = eye(3) # mass matrix
mass[2, 2] = 3./5 * r * r
# the dynamical system
ball = LagrangianLinearTIDS(x, v, mass)
# set external forces
weight = array([-m * g, 0, 0])
ball.setFExtPtr(weight)
#
# Interactions
#
# ball-floor
H = array([[1, 0, 0]])
nslaw = NewtonImpactNSL(e)
relation = LagrangianLinearTIR(H)
inter = Interaction(nslaw, relation)
#
# Model
#
first_bouncingBall = NonSmoothDynamicalSystem(t0, T)
# add the dynamical system to the non smooth dynamical system
first_bouncingBall.insertDynamicalSystem(ball)
# link the interaction and the dynamical system
first_bouncingBall.link(inter, ball)
#
# Simulation
#
# (1) OneStepIntegrators
OSI = MoreauJeanOSI(theta)
# (2) Time discretisation --
t = TimeDiscretisation(t0, h)
# (3) one step non smooth problem
osnspb = LCP()
# (4) Simulation setup with (1) (2) (3)
s = TimeStepping(first_bouncingBall, t)
s.insertIntegrator(OSI)
s.insertNonSmoothProblem(osnspb)
# end of model definition
#
# save and load data from xml and .dat
#
from siconos.io.io_base import save, load
save(s, "bouncingBall.xml")
s = load("bouncingBall.xml")
bouncingBall = s.nonSmoothDynamicalSystem()
ball = bouncingBall.dynamicalSystem(ball.number())
inter = bouncingBall.interaction(inter.number())
# the number of time steps
N = int((T-t0)/h+1)
# Get the values to be plotted
# ->saved in a matrix dataPlot
dataPlot = empty((N, 5))
#
# numpy pointers on dense Siconos vectors
#
q = ball.q()
v = ball.velocity()
p = ball.p(1)
lambda_ = inter.lambda_(1)
#.........这里部分代码省略.........