コード例 #1
0
outputSize = 5  # number of variable to store at each time step

# Matrix declaration
A = zeros((ndof, ndof))
x0 = [Xinit, -Xinit]
sensorC = eye(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 = 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)
コード例 #2
0
# Matrix declaration
A = zeros((ndof, ndof))
x0 = [Xinit, -Xinit]
sensorC = eye(ndof)
Csurface = [[0, 1]]
Brel = [[0], [2]]
#Drel = [[0, 0]]
# Simple check
if h > hControl:
    print("hControl must be bigger than h")
    exit(1)

# Declaration of the Dynamical System
processDS = FirstOrderLinearDS(x0, A)
processDS.setComputebFunction("RelayPlugin", "computeB")

# Control simulation
sim = ControlZOHSimulation(t0, T, h)
sim.setSaveOnlyMainSimulation(True)
sim.addDynamicalSystem(processDS)
# Actuator, Sensor & ControlManager
sens = LinearSensor(processDS, sensorC)
sim.addSensor(sens, hControl)
act = LinearSMC(sens)
act.setCsurface(Csurface)
act.setB(Brel)
sim.addActuator(act, hControl)

# Initialization
sim.initialize()
コード例 #3
0
x0 = array([Vinit, -Vinit])
B = 2.0 * eye(2)
C = eye(2)
D = zeros((2, 2))

# Compilation of the C plugin with siconos
import os

print('Compilation of the C plugin with siconos')
from subprocess import call

call(['siconos', '--noexec', '.'], stdout=open(os.devnull, 'wb'))

# dynamical systems
process = FirstOrderLinearDS(x0, A)
process.setComputebFunction('plugins', 'computeB')
myNslaw = RelayNSL(2)
myProcessRelation = FirstOrderLinearR(C, B)
myProcessRelation.setComputeEFunction('plugins', 'computeE')
#myProcessRelation.setDPtr(D)

myProcessInteraction = Interaction(myNslaw, myProcessRelation)

simplerelay = NonSmoothDynamicalSystem(t0, T)
simplerelay.insertDynamicalSystem(process)
simplerelay.link(myProcessInteraction, process)

#myProcessRelation.computeJachx(0, x0, x0 , x0, C)

td = TimeDiscretisation(t0, h)
s = TimeStepping(simplerelay, td)