error using scimath errors in scipy.optimize.fsolve
- Dominant language
- Python
- Stars
- 66
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
I thought this should work, but it did not.
import numpy as np
from scimath.units.volume import liter
from scimath.units.substance import mol
from scimath.units.time import second
from scipy.optimize import fsolve
# mol, liter, second = 1,1,1
CA0 = 1.0 \* mol / liter
CA = 0.01 \* mol / liter
k = 1.0 / second
t0 = 2.3 \* second
exponential = np.exp
def func(t):
z = CA - CA0 \* exponential(-k*t)
return z
print fsolve(func, t0)
Leads to this error:
Traceback (most recent call last):
File "C:\Users\jkitchin\Desktop\untitled0.py", line 27, in
print fsolve(func, t0)
File "C:\Python27\lib\site-packages\scipy\optimize\minpack.py", line 115, in fsolve
_check_func('fsolve', 'func', func, x0, args, n, (n,))
File "C:\Python27\lib\site-packages\scipy\optimize\minpack.py", line 13, in _check_func
res = atleast_1d(thefunc(_((x0[:numinputs],) + args)))
File "C:\Users\jkitchin\Desktop\untitled0.py", line 24, in func
z = CA - CA0 \* exponential(-k_t)
AttributeError: exp
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.