Comment #12 on issue 537 by [email protected]: sympy <-> numpy
interoperation
http://code.google.com/p/sympy/issues/detail?id=537
I am not sure how to check the progress on this old issue - here on google
or on the new github site?
Anyway, I do have a workaround that allowed my use case: Substituting
numpy.array and quantities.constants into sympy formulas (see example 2
below). It works by delaying all array operations until there is no more
symbol to substitute. Very limited, but maybe could give some ideas on a
more generic solution.
Example 1: Solving for parameters in an expression
>>> charging = System('E == (n - C V/e)^2 e^2/(2 C)'); charging.E
-V*e*n + 0.5*C*V**2 + 0.5*e**2*n**2/C
>>> E = charging.E(V=0); E
0.5*e**2*n**2/C
Example 2: Using physical constants, uncertainties and arrays
>>> from quantities import constants, F, eV
>>> from numpy import array
>>> dE = System( E(n=1) - E(n=0), constants); dE #showing temporary
symbols
1.28348474774783e-38*_A**2*_s**2/C /. _s=UnitTime('second', 's'),
_A=UnitCurrent('ampere', 'A')
>>> dE(C = array([1,2,3])*1e-18*F).rescale(eV)
array([ 0.08010882, 0.04005441, 0.02670294]) * eV
See
https://github.com/joakimbits/Quflow-and-Perfeco-tools/blob/master/algebra.py
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.