当前位置: 首页>>代码示例>>Python>>正文


Python TimeStepping.nonSmoothDynamicalSystem方法代码示例

本文整理汇总了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)

#.........这里部分代码省略.........
开发者ID:siconos,项目名称:siconos,代码行数:103,代码来源:test_serialization.py


注:本文中的siconos.kernel.TimeStepping.nonSmoothDynamicalSystem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。