Objective:-
To implement all of the basic electrical, magnetics and gravitational concepts in SymPy
Eg, Beer-Lambert's Law, Gauss' Law etc.
git pull https://github.com/srjoglekar246/sympy electrical
Or view, comment on, or merge it at:
https://github.com/sympy/sympy/pull/1695
—
Reply to this email directly or view it on GitHub.
Not added any tests yet. Will add soon. Just the beginning :-)
In sympy/physics/electrical/electrical.py:
> @@ -0,0 +1,178 @@ > +__all__ = ['EField', 'ParticleCharge'] > + > +from sympy.physics.mechanics import Vector, Particle > +from sympy.physics.mechanics.essential import _check_vector > +from sympy import integrate > +from math import pi > + > +e0 = 8.854187817620 * 10 ** -12 > + > + > +class EField:
This should probably be subclasses from Basic.
In sympy/physics/electrical/electrical.py:
> + return (self.charge)/(4 * pi * e0 * abs(pos_vector.magnitude())) > + > + > +def _check_conservative(vector): > + """ > + Checks if 'vector' defines a field that is conservative. > + If yes, return True. > + Else, return False. > + """ > + > + from sympy import symbols > + x, y, z = symbols('x y z') > + dfdx = ((vector.args[0][0][0]).diff(y)).diff(z) > + dfdy = ((vector.args[0][0][1]).diff(x)).diff(z) > + dfdz = ((vector.args[0][0][2]).diff(x)).diff(y) > + if (dfdx == dfdy == dfdz):
Pure equality checking will not be sufficient here, because they could come out mathematically the same but in different forms. You should use something like simplify(dfdx - dfdy) == 0
In sympy/physics/electrical/electrical.py:
> @@ -0,0 +1,178 @@ > +__all__ = ['EField', 'ParticleCharge'] > + > +from sympy.physics.mechanics import Vector, Particle > +from sympy.physics.mechanics.essential import _check_vector > +from sympy import integrate > +from math import pi > + > +e0 = 8.854187817620 * 10 ** -12 > + > + > +class EField:
That will include overriding all methods of Basic right?
In sympy/physics/electrical/electrical.py:
> @@ -0,0 +1,178 @@ > +__all__ = ['EField', 'ParticleCharge'] > + > +from sympy.physics.mechanics import Vector, Particle > +from sympy.physics.mechanics.essential import _check_vector > +from sympy import integrate > +from math import pi > + > +e0 = 8.854187817620 * 10 ** -12 > + > + > +class EField:
No, it just means that you have to conform to the Basic interface, which more or less just means that you need to have a .args with all Basic members that you can use to reconstruct the class.
SymPy Bot Summary: Failed after merging srjoglekar246/electrical (e64e266) into master (d503614).
@srjoglekar246: Please fix the test failures.
PyPy 2.0.0-beta-1; 2.7.3-final-42: fail
Python 2.7.2-final-0: fail
Python 3.2.1-final-0: fail
Sphinx 1.1.3: pass
Docs build command: make clean && make html-errors && make latex && cd _build/latex && xelatex sympy-*.tex
SymPy Bot Summary: Failed after merging srjoglekar246/electrical (e64e266) into master (501534b).
@srjoglekar246: Please fix the test failures.
Python 2.5.0-final-0: fail
Python 2.6.6-final-0: fail
Python 2.7.2-final-0: fail
Python 2.6.8-final-0: fail
Python 2.7.3-final-0: fail
PyPy 2.0.0-beta-1; 2.7.3-final-42: fail
Python 3.2.2-final-0: fail
Python 3.3.0-final-0: fail
Python 3.2.3-final-0: fail
Python 3.3.0-final-0: fail
Python 3.3.0-final-0: fail
**Sphinx 1.1.3:** pass
@asmeurer ,
I realised I needed to define an arbitrary 'origin' for every ReferenceFrame and then define points with respect to it in terms of co-ordinates, for solving most vectorial problems. Could we just add .origin() and .get_point_at(x,y,z) methods to ReferenceFrame class to save us the trouble?
.origin() would return the point that has been arbitrarily taken to be the origin of the ReferenceFrame and .getpoint(x,y,z) would return the point at [x,y,z] with respect to the origin.
So, instead of doing
N = ReferenceFrame('N')
o = Point('o')
p = Point('p')
p.set_pos(o, a*N.x+b*N.y+c*N.z)
we could just do
p = N.get_point_at(a,b,c)
o = N.origin()