masfaraud / BMSpy

Python Block-Model Simulator. An alternative to simulink in python.
GNU Lesser General Public License v3.0
222 stars 36 forks source link

first_order.py example gives ZeroDivisionError #3

Closed aewallin closed 8 years ago

aewallin commented 8 years ago

Traceback (most recent call last): File "bms_ex1.py", line 23, in ds.Simulate() File "build/bdist.linux-x86_64/egg/bms/core.py", line 343, in Simulate File "build/bdist.linux-x86_64/egg/bms/blocks/continuous.py", line 145, in Solve File "build/bdist.linux-x86_64/egg/bms/blocks/continuous.py", line 140, in OutputMatrices File "build/bdist.linux-x86_64/egg/bms/blocks/continuous.py", line 128, in _get_M ZeroDivisionError: float division by zero

masfaraud commented 8 years ago

Is it a script you wrote? If yes, can you please attach the file?

darrell-rg commented 8 years ago

I had this same issue on windows, from any of the included examples, with python2. I was able to fix it by forcing the time step calculation to use float math. I changed core.py line 166:

self.ts=self.te/float(self.ns)# time step, make sure this is a float!

I think this may be a python2/python3 issue, as they changed how division works.

aewallin commented 8 years ago

the example I was trying is this: https://github.com/masfaraud/BMSpy/blob/master/examples/first_order.py

maybe you could automate testing with tox or a similar tool to catch buld/install problems on various platforms?

masfaraud commented 8 years ago

The problem was indeed a python2/python3 problem. I'll take a look at tox, thanks for the suggestion.