enthought / enthought/scimath

error with scimath and odeint

Open
#12 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
66
Forks
13
PR merge metrics
No merged PRs in 30d

Description

```
import numpy as np
from scipy.integrate import odeint

from scimath.units.volume import liter
from scimath.units.substance import mol
from scimath.units.time import second

CA0 = 1.0 \* mol / liter
k = 1.0 / second

def myode(Ca, t):
dCdt = -k \* Ca
return dCdt

print(myode(CA0, 0_second))
print(odeint(myode, CA0, np.linspace(0.0, 9.0)_second))
```

gives this error:

```
-1000.0_m__-3_s**-1_mol
Traceback (most recent call last):
File "C:\Users\jkitchin\Desktop\untitled2.py", line 24, in
print odeint(myode, CA0, np.linspace(0.0, 9.0)_second)
File "C:\Python27\lib\site-packages\scipy\integrate\odepack.py", line 143, in odeint
ixpr, mxstep, mxhnil, mxordn, mxords)
File "C:\Python27\lib\site-packages\scimath\units\unit.py", line 144, in **float**
raise InvalidConversion(self)
scimath.units.unit.InvalidConversion: dimensional quantities ('m**-3*mol') cannot be converted to scalars
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.