N = int((T - t0) / h) # matrices A = zeros((2, 2)) A[0, 1] = 1 x0 = array([1., 10.]) B = 500 * array([[alpha, 1 - alpha], [-(1 - alpha), alpha]]) C = eye(2) D = zeros((2, 2)) # dynamical systems process = FirstOrderLinearDS(x0, A) myProcessRelation = ZhuravlevTwistingR(C, B) myNslaw = RelayNSL(2) myNslaw.display() myProcessInteraction = Interaction(myNslaw, myProcessRelation) filippov = NonSmoothDynamicalSystem(t0, T) filippov.insertDynamicalSystem(process) filippov.link(myProcessInteraction, process) td = TimeDiscretisation(t0, h) s = TimeStepping(filippov, td) myIntegrator = EulerMoreauOSI(theta) s.insertIntegrator(myIntegrator) #TODO python <- SICONOS_RELAY_LEMKE
N = ceil((T-t0)/h) # matrices A = zeros((2,2)) A[0, 1] = 1 x0 = array([1.,10.]) B = 500*array([[alpha,1-alpha],[-(1-alpha),alpha]]) C = eye(2) D = zeros((2,2)) # dynamical systems process = FirstOrderLinearDS(x0, A) myProcessRelation = ZhuravlevTwistingR(C,B) myNslaw = RelayNSL(2) myNslaw.display() myProcessInteraction = Interaction(ninter, myNslaw, myProcessRelation) myNSDS = NonSmoothDynamicalSystem() myNSDS.insertDynamicalSystem(process) myNSDS.link(myProcessInteraction,process) filippov = Model(t0,T) filippov.setNonSmoothDynamicalSystemPtr(myNSDS) td = TimeDiscretisation(t0, h) s = TimeStepping(td)
LSRelayOscillator = FirstOrderLinearDS(init_state, A) # # Interactions # C = [[1.0, 0.0, 0.0]] D = [[0.0]] B = [[0.0], [0.0], [1.0]] LTIRRelayOscillator = FirstOrderLinearTIR(C, B) LTIRRelayOscillator.setDPtr(D) nslaw = RelayNSL(1) InterRelayOscillator = Interaction(nslaw, LTIRRelayOscillator) # # Model # relayOscillator = NonSmoothDynamicalSystem(t0, T) relayOscillator.setTitle(Modeltitle) # add the dynamical system in the non smooth dynamical system relayOscillator.insertDynamicalSystem(LSRelayOscillator) # link the interaction and the dynamical system relayOscillator.link(InterRelayOscillator, LSRelayOscillator) # # Simulation
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)