本文整理汇总了Python中siconos.kernel.TimeStepping.setName方法的典型用法代码示例。如果您正苦于以下问题:Python TimeStepping.setName方法的具体用法?Python TimeStepping.setName怎么用?Python TimeStepping.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类siconos.kernel.TimeStepping
的用法示例。
在下文中一共展示了TimeStepping.setName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exit
# 需要导入模块: from siconos.kernel import TimeStepping [as 别名]
# 或者: from siconos.kernel.TimeStepping import setName [as 别名]
print "hControl must be bigger than h"
exit(1)
# Declaration of the Dynamical System
processDS = FirstOrderLinearDS(x0, A)
processDS.setComputebFunction("RelayPlugin", "computeB")
# Model
process = Model(t0, T)
process.nonSmoothDynamicalSystem().insertDynamicalSystem(processDS)
# time discretisation
processTD = TimeDiscretisation(t0, h)
tSensor = TimeDiscretisation(t0, hControl)
tActuator = TimeDiscretisation(t0, hControl)
# Creation of the Simulation
processSimulation = TimeStepping(processTD, 0)
processSimulation.setName("plant simulation")
# Declaration of the integrator
processIntegrator = ZeroOrderHoldOSI(processDS)
processSimulation.insertIntegrator(processIntegrator)
# Actuator, Sensor & ControlManager
control = ControlManager(process)
sens = LinearSensor(tSensor, processDS, sensorC)
control.addSensorPtr(sens)
act = LinearSMCOT2(tActuator, processDS)
act.setCsurfacePtr(Csurface)
act.addSensorPtr(sens)
control.addActuatorPtr(act)
# Initialization
process.initialize(processSimulation)
control.initialize()
示例2: test_smc1
# 需要导入模块: from siconos.kernel import TimeStepping [as 别名]
# 或者: from siconos.kernel.TimeStepping import setName [as 别名]
def test_smc1():
from siconos.kernel import FirstOrderLinearDS, Model, TimeDiscretisation, \
TimeStepping, ZeroOrderHoldOSI, TD_EVENT
from siconos.control.simulation import ControlManager
from siconos.control.sensor import LinearSensor
from siconos.control.controller import LinearSMCOT2
from numpy import eye, empty, zeros
import numpy as np
from math import ceil, sin
# Derive our own version of FirstOrderLinearDS
class MyFOLDS(FirstOrderLinearDS):
def computeb(self, time):
t = sin(50*time)
# XXX fix this !
u = [t, -t]
self.setb(u)
# variable declaration
ndof = 2 # Number of degrees of freedom of your system
t0 = 0.0 # start time
T = 1 # end time
h = 1.0e-4 # time step for simulation
hControl = 1.0e-2 # time step for control
Xinit = 1.0 # initial position
N = ceil((T-t0)/h + 10) # number of time steps
outputSize = 4 # number of variable to store at each time step
# Matrix declaration
A = zeros((ndof, ndof))
x0 = [Xinit, -Xinit]
Brel = np.array([[0], [1]])
sensorC = eye(ndof)
sensorD = zeros((ndof, ndof))
Csurface = [[0, 1.0]]
# Simple check
if h > hControl:
print("hControl must be bigger than h")
exit(1)
# Declaration of the Dynamical System
processDS = MyFOLDS(x0, A)
# XXX b is not automatically created ...
# processDS.setb([0, 0])
# Model
process = Model(t0, T)
process.nonSmoothDynamicalSystem().insertDynamicalSystem(processDS)
# time discretization
processTD = TimeDiscretisation(t0, h)
tSensor = TimeDiscretisation(t0, hControl)
tActuator = TimeDiscretisation(t0, hControl)
# Creation of the Simulation
processSimulation = TimeStepping(processTD, 0)
processSimulation.setName("plant simulation")
# Declaration of the integrator
processIntegrator = ZeroOrderHoldOSI()
process.nonSmoothDynamicalSystem().setOSI(processDS, processIntegrator)
processSimulation.insertIntegrator(processIntegrator)
# Actuator, Sensor & ControlManager
control = ControlManager(processSimulation)
sens = LinearSensor(processDS, sensorC, sensorD)
control.addSensorPtr(sens, tSensor)
act = LinearSMCOT2(sens)
act.setCsurface(Csurface)
act.setB(Brel)
control.addActuatorPtr(act, tActuator)
# Initialization.
process.initialize(processSimulation)
control.initialize(process)
# This is not working right now
# eventsManager = s.eventsManager()
# Matrix for data storage
dataPlot = empty((3*(N+1), outputSize))
dataPlot[0, 0] = t0
dataPlot[0, 1] = processDS.x()[0]
dataPlot[0, 2] = processDS.x()[1]
dataPlot[0, 3] = act.u()[0]
# Main loop
k = 1
while processSimulation.hasNextEvent():
if processSimulation.eventsManager().nextEvent().getType() == TD_EVENT:
processSimulation.computeOneStep()
dataPlot[k, 0] = processSimulation.nextTime()
dataPlot[k, 1] = processDS.x()[0]
dataPlot[k, 2] = processDS.x()[1]
dataPlot[k, 3] = act.u()[0]
k += 1
processSimulation.nextStep()
# print processSimulation.nextTime()
# Resize matrix
dataPlot.resize(k, outputSize)