Ejemplo n.º 1
0
 def test_switches(self):
     """
     This tests that the switches are actually turned when override.
     """
     f = lambda t,x,xd,sw: N.array([xd[0]- 1.0])
     state_events = lambda t,x,xd,sw: N.array([x[0]-1.])
     def handle_event(solver, event_info):
         solver.sw = [False] #Override the switches to point to another instance
     
     mod = Implicit_Problem(f, [0.0],[1.0])
     mod.f = f
     mod.sw0 = [True]
     mod.state_events = state_events
     mod.handle_event = handle_event
     
     sim = IDA(mod)
     assert sim.sw[0] == True
     sim.simulate(3)
     assert sim.sw[0] == False
Ejemplo n.º 2
0
 def test_switches(self):
     """
     This tests that the switches are actually turned when override.
     """
     f = lambda t,x,xd,sw: N.array([xd[0]- 1.0])
     state_events = lambda t,x,xd,sw: N.array([x[0]-1.])
     def handle_event(solver, event_info):
         solver.sw = [False] #Override the switches to point to another instance
     
     mod = Implicit_Problem(f, [0.0],[1.0])
     mod.f = f
     mod.sw0 = [True]
     mod.state_events = state_events
     mod.handle_event = handle_event
     
     sim = IDA(mod)
     assert sim.sw[0] == True
     sim.simulate(3)
     assert sim.sw[0] == False