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


Python Model.setSimulation方法代码示例

本文整理汇总了Python中siconos.kernel.Model.setSimulation方法的典型用法代码示例。如果您正苦于以下问题:Python Model.setSimulation方法的具体用法?Python Model.setSimulation怎么用?Python Model.setSimulation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在siconos.kernel.Model的用法示例。


在下文中一共展示了Model.setSimulation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TimeDiscretisation

# 需要导入模块: from siconos.kernel import Model [as 别名]
# 或者: from siconos.kernel.Model import setSimulation [as 别名]
td = TimeDiscretisation(t0, h)
s = TimeStepping(td)

myIntegrator = EulerMoreauOSI(theta)
s.insertIntegrator(myIntegrator)


#TODO python <- SICONOS_RELAY_LEMKE
# access dparam

osnspb = Relay()
s.insertNonSmoothProblem(osnspb)
s.setComputeResiduY(True)
s.setComputeResiduR(True)

filippov.setSimulation(s)
filippov.initialize()

# 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()):
     s.newtonSolve(1e-14, 30)
     dataPlot[k, 0] = s.nextTime()
     dataPlot[k, 1] = process.x()[0]
开发者ID:radarsat1,项目名称:siconos,代码行数:33,代码来源:ZhuravlevTwisting.py

示例2: test_serialization4

# 需要导入模块: from siconos.kernel import Model [as 别名]
# 或者: from siconos.kernel.Model import setSimulation [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()
#.........这里部分代码省略.........
开发者ID:radarsat1,项目名称:siconos,代码行数:103,代码来源:test_serialization.py

示例3: LCP

# 需要导入模块: from siconos.kernel import Model [as 别名]
# 或者: from siconos.kernel.Model import setSimulation [as 别名]
# (3) one step non smooth problem
osnspb = LCP()

# (4) Simulation setup with (1) (2) (3)
s = TimeStepping(t, OSI, osnspb)


# end of model definition

#
# computation
#

# simulation initialization
bouncingBall.setSimulation(s)
bouncingBall.initialize()


# the number of time steps
N = (T - t0) / h

# Get the values to be plotted
# ->saved in a matrix dataPlot

dataPlot = empty((N+1, 5))

#
# numpy pointers on dense Siconos vectors
#
q = ball.q()
开发者ID:radarsat1,项目名称:siconos,代码行数:32,代码来源:BouncingBallTS.py

示例4: TimeDiscretisation

# 需要导入模块: from siconos.kernel import Model [as 别名]
# 或者: from siconos.kernel.Model import setSimulation [as 别名]
aTiDisc = TimeDiscretisation(t0, h_step)

# (3) Non smooth problem
aLCP = LCP()

# (4) Simulation setup with (1) (2) (3)
aTS = TimeStepping(aTiDisc, aOSI, aLCP)

# end of model definition

#
# computation
#

# simulation initialization
DiodeBridge.setSimulation(aTS)
DiodeBridge.initialize()

k = 0
h = aTS.timeStep()
print("Timestep : ", h)
# Number of time steps
N = (T - t0) / h
print("Number of steps : ", N)

# Get the values to be plotted
# ->saved in a matrix dataPlot

from numpy import zeros
dataPlot = zeros([N, 8])
开发者ID:radarsat1,项目名称:siconos,代码行数:32,代码来源:DiodeBridge.py

示例5: test_diode_bridge

# 需要导入模块: from siconos.kernel import Model [as 别名]
# 或者: from siconos.kernel.Model import setSimulation [as 别名]
def test_diode_bridge():
    """Build diode bridge model"""
    # dynamical system
    bridge_ds = FirstOrderLinearDS(init_state, A)
    # interaction
    diode_bridge_relation = FirstOrderLinearTIR(C, B)
    diode_bridge_relation.setDPtr(D)

    nslaw = ComplementarityConditionNSL(4)
    bridge_interaction = Interaction(4, nslaw, diode_bridge_relation, 1)

    # Model
    diode_bridge = Model(t0, total_time, model_title)

    #  add the dynamical system in the non smooth dynamical system
    diode_bridge.nonSmoothDynamicalSystem().insertDynamicalSystem(bridge_ds)

    #   link the interaction and the dynamical system
    diode_bridge.nonSmoothDynamicalSystem().link(bridge_interaction, bridge_ds)

    # Simulation

    # (1) OneStepIntegrators
    theta = 0.5
    integrator = EulerMoreauOSI(theta)
    # (2) Time discretisation
    time_discretisation = TimeDiscretisation(t0, time_step)

    # (3) Non smooth problem
    non_smooth_problem = LCP()

    # (4) Simulation setup with (1) (2) (3)
    bridge_simulation = TimeStepping(time_discretisation,
                                     integrator, non_smooth_problem)

    # simulation initialization
    diode_bridge.setSimulation(bridge_simulation)
    diode_bridge.initialize()
    k = 0
    h = bridge_simulation.timeStep()
    # Number of time steps
    N = (total_time - t0) / h

    # Get the values to be plotted
    # ->saved in a matrix dataPlot
    data_plot = empty([N, 8])

    x = bridge_ds.x()
    print("Initial state : ", x)
    y = bridge_interaction.y(0)
    print("First y : ", y)
    lambda_ = bridge_interaction.lambda_(0)

    # For the initial time step:
    # time
    data_plot[k, 0] = t0

    #  inductor voltage
    data_plot[k, 1] = x[0]

    # inductor current
    data_plot[k, 2] = x[1]

    # diode R1 current
    data_plot[k, 3] = y[0]

    # diode R1 voltage
    data_plot[k, 4] = - lambda_[0]

    # diode F2 voltage
    data_plot[k, 5] = - lambda_[1]

    # diode F1 current
    data_plot[k, 6] = lambda_[2]

    # resistor current
    data_plot[k, 7] = y[0] + lambda_[2]

    k += 1
    while k < N:
        bridge_simulation.computeOneStep()
        #non_smooth_problem.display()
        data_plot[k, 0] = bridge_simulation.nextTime()
        #  inductor voltage
        data_plot[k, 1] = x[0]
        # inductor current
        data_plot[k, 2] = x[1]
        # diode R1 current
        data_plot[k, 3] = y[0]
        # diode R1 voltage
        data_plot[k, 4] = - lambda_[0]
        # diode F2 voltage
        data_plot[k, 5] = - lambda_[1]
        # diode F1 current
        data_plot[k, 6] = lambda_[2]
        # resistor current
        data_plot[k, 7] = y[0] + lambda_[2]
        k += 1
        bridge_simulation.nextStep()

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

示例6: TimeDiscretisation

# 需要导入模块: from siconos.kernel import Model [as 别名]
# 或者: from siconos.kernel.Model import setSimulation [as 别名]
aTiDisc = TimeDiscretisation(t0, h_step)

# (3) Non smooth problem
aLCP = LCP()

# (4) Simulation setup with (1) (2) (3)
aTS = TimeStepping(aTiDisc, aOSI, aLCP)

# end of model definition

#
# computation
#

# simulation initialization
DiodeBridgeCapFilter.setSimulation(aTS)
DiodeBridgeCapFilter.initialize()

k = 0
h = aTS.timeStep()
print("Timestep : ", h)
# Number of time steps
N = (T - t0) / h
print("Number of steps : ", N)

# Get the values to be plotted
# ->saved in a matrix dataPlot

from numpy import zeros
dataPlot = zeros([N-1, 10])
开发者ID:radarsat1,项目名称:siconos,代码行数:32,代码来源:DiodeBridgeCapFilter-ThetaGammaSchemes.py

示例7: TimeDiscretisation

# 需要导入模块: from siconos.kernel import Model [as 别名]
# 或者: from siconos.kernel.Model import setSimulation [as 别名]
aTiDisc = TimeDiscretisation(t0,h_step)

# (3) Non smooth problem
aRelay = Relay()

# (4) Simulation setup with (1) (2) (3)
aTS = TimeStepping(aTiDisc,aOSI,aRelay)

# end of model definition

#
# computation
#

# simulation initialization
RelayOscillator.setSimulation(aTS)
RelayOscillator.initialize()

k = 0
h = aTS.timeStep();
print("Timestep : ",h)
# Number of time steps
N = (T-t0)/h
print("Number of steps : ",N)

# Get the values to be plotted
# ->saved in a matrix dataPlot

from numpy import empty
dataPlot = empty([N+1,8])
开发者ID:radarsat1,项目名称:siconos,代码行数:32,代码来源:RelayOscillator.py

示例8: with

# 需要导入模块: from siconos.kernel import Model [as 别名]
# 或者: from siconos.kernel.Model import setSimulation [as 别名]
broadphase.collisionConfiguration().setConvexConvexMultipointIterations()
broadphase.collisionConfiguration().setPlaneConvexMultipointIterations()

# The ground is a static object
# we give it a group contactor id : 0
broadphase.addStaticObject(ground, 0)

# (6) Simulation setup with (1) (2) (3) (4) (5)
simulation = BulletTimeStepping(timedisc)
#simulation.setNewtonOptions(1)
simulation.insertIntegrator(osi)
simulation.insertNonSmoothProblem(osnspb)


# simulation initialization
bouncingBox.setSimulation(simulation)
bouncingBox.initialize()

# Get the values to be plotted
# ->saved in a matrix dataPlot

N = (T - t0) / h
dataPlot = zeros((N+1, 4))

#
# numpy pointers on dense Siconos vectors
#
q = body.q()
v = body.velocity()

#
开发者ID:radarsat1,项目名称:siconos,代码行数:33,代码来源:BulletBouncingBoxDynamic.py

示例9: TimeDiscretisation

# 需要导入模块: from siconos.kernel import Model [as 别名]
# 或者: from siconos.kernel.Model import setSimulation [as 别名]
aTiDisc = TimeDiscretisation(t0, h_step)

# (3) Non smooth problem
aLCP = LCP()

# (4) Simulation setup with (1) (2) (3)
aTS = TimeStepping(aTiDisc, aOSI, aLCP)

# end of model definition

#
# computation
#

# simulation initialization
CircuitRLCD.setSimulation(aTS)
CircuitRLCD.initialize()

k = 0
h = aTS.timeStep()
print("Timestep : ", h)
# Number of time steps
N = (T - t0) / h
print("Number of steps : ", N)

# Get the values to be plotted
# ->saved in a matrix dataPlot

from numpy import zeros
dataPlot = zeros([N+1, 6])
开发者ID:radarsat1,项目名称:siconos,代码行数:32,代码来源:CircuitRLCD.py


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