本文整理汇总了Python中siconos.kernel.TimeStepping.insertNonSmoothProblem方法的典型用法代码示例。如果您正苦于以下问题:Python TimeStepping.insertNonSmoothProblem方法的具体用法?Python TimeStepping.insertNonSmoothProblem怎么用?Python TimeStepping.insertNonSmoothProblem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类siconos.kernel.TimeStepping
的用法示例。
在下文中一共展示了TimeStepping.insertNonSmoothProblem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_serialization4
# 需要导入模块: from siconos.kernel import TimeStepping [as 别名]
# 或者: from siconos.kernel.TimeStepping import insertNonSmoothProblem [as 别名]
def test_serialization4():
from siconos.kernel import LagrangianLinearTIDS, NewtonImpactNSL, \
LagrangianLinearTIR, Interaction, Model, 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(1, nslaw, relation)
#
# Model
#
first_bouncingBall = Model(t0, T)
# add the dynamical system to the non smooth dynamical system
first_bouncingBall.nonSmoothDynamicalSystem().insertDynamicalSystem(ball)
# link the interaction and the dynamical system
first_bouncingBall.nonSmoothDynamicalSystem().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(t)
s.insertIntegrator(OSI)
s.insertNonSmoothProblem(osnspb)
# end of model definition
#
# computation
#
# simulation initialization
first_bouncingBall.setSimulation(s)
first_bouncingBall.initialize()
#
# save and load data from xml and .dat
#
from siconos.io.io_base import save, load
save(first_bouncingBall, "bouncingBall.xml")
bouncingBall = load("bouncingBall.xml")
# the number of time steps
N = (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()
#.........这里部分代码省略.........
示例2: Model
# 需要导入模块: from siconos.kernel import TimeStepping [as 别名]
# 或者: from siconos.kernel.TimeStepping import insertNonSmoothProblem [as 别名]
filippov = Model(t0,T)
filippov.setNonSmoothDynamicalSystemPtr(myNSDS)
td = TimeDiscretisation(t0, h)
s = TimeStepping(td)
myIntegrator = EulerMoreauOSI(process, theta)
s.insertIntegrator(myIntegrator)
#TODO python <- SICONOS_RELAY_LEMKE
# access dparam
osnspb = Relay()
s.insertNonSmoothProblem(osnspb)
s.setComputeResiduY(True)
s.setComputeResiduR(True)
filippov.initialize(s);
# matrix to save data
dataPlot = empty((N+1,5))
control = empty((N+1,))
dataPlot[0, 0] = t0
dataPlot[0, 1:3] = process.x()
dataPlot[0, 3] = myProcessInteraction.lambda_(0)[0]
dataPlot[0, 4] = myProcessInteraction.lambda_(0)[1]
# time loop
k = 1
while(s.hasNextEvent()):