本文整理匯總了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)
#.........這裏部分代碼省略.........