|
|
@@ -92,7 +92,7 @@ class Model(CoupledDEVS):
|
|
|
"v0": 0.0, "y0": 100
|
|
|
}, False, {
|
|
|
"height": ">0"
|
|
|
- }, hybrid.CrossingDetection.linear))
|
|
|
+ }, hybrid.CrossingDetection.ITP))
|
|
|
self.coll = self.addSubModel(Collector())
|
|
|
self.bounce = self.addSubModel(Bouncer())
|
|
|
|
|
|
@@ -115,17 +115,17 @@ def bounce(e, t, model):
|
|
|
if __name__ == '__main__':
|
|
|
from pyCBD.simulator import Simulator as CBDsim
|
|
|
from pyCBD.state_events import StateEvent, Direction
|
|
|
- from pyCBD.state_events.locators import ITPStateEventLocator
|
|
|
+ from pyCBD.state_events.locators import LinearStateEventLocator
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
plt.plot([0, 10], [0, 0], 'k--', zorder=0, lw=0.5)
|
|
|
|
|
|
cbd = BouncingBall()
|
|
|
csim = CBDsim(cbd)
|
|
|
- csim.setStateEventLocator(ITPStateEventLocator())
|
|
|
+ csim.setStateEventLocator(LinearStateEventLocator())
|
|
|
csim.registerStateEvent(StateEvent("height", direction=Direction.FROM_ABOVE, event=bounce))
|
|
|
csim.setDeltaT(0.1)
|
|
|
- csim.run(10)
|
|
|
+ csim.run(10.1)
|
|
|
CBD_POINTS.extend(cbd.getSignalHistory("height"))
|
|
|
ct, cy = [x[0] for x in CBD_POINTS], [x[1] for x in CBD_POINTS]
|
|
|
plt.plot(ct, cy, '-o', label="CBD", zorder=1)
|
|
|
@@ -143,5 +143,6 @@ if __name__ == '__main__':
|
|
|
t, y = [x[0] for x in ty], [x[1] for x in ty]
|
|
|
plt.plot(t, y, '.', label="atomic DEVS", zorder=2)
|
|
|
|
|
|
+ plt.tight_layout()
|
|
|
plt.legend()
|
|
|
plt.show()
|