[sympy] WIP : Sub-module for physics dealing with electrical concepts (#1695)

5 weergaven
Naar het eerste ongelezen bericht

Sachin Joglekar

ongelezen,
17 dec 2012, 12:14:3717-12-2012
aan sympy/sympy

Objective:-
To implement all of the basic electrical, magnetics and gravitational concepts in SymPy
Eg, Beer-Lambert's Law, Gauss' Law etc.


You can merge this Pull Request by running:

  git pull https://github.com/srjoglekar246/sympy electrical

Or view, comment on, or merge it at:

  https://github.com/sympy/sympy/pull/1695

Commit Summary

  • First push, added EField and ParticleCharge

File Changes

  • A sympy/physics/electrical/__init__.py (5)
  • A sympy/physics/electrical/electrical.py (178)

Patch Links


Reply to this email directly or view it on GitHub.

Sachin Joglekar

ongelezen,
17 dec 2012, 12:15:1117-12-2012
aan sympy/sympy

Not added any tests yet. Will add soon. Just the beginning :-)

Aaron Meurer

ongelezen,
17 dec 2012, 15:14:1917-12-2012
aan sympy/sympy

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.

Aaron Meurer

ongelezen,
17 dec 2012, 15:18:2117-12-2012
aan sympy/sympy

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

Sachin Joglekar

ongelezen,
18 dec 2012, 11:55:5818-12-2012
aan sympy/sympy

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?

Aaron Meurer

ongelezen,
18 dec 2012, 16:35:5818-12-2012
aan sympy/sympy

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.

Julien Rioux

ongelezen,
19 dec 2012, 17:48:3119-12-2012
aan sympy/sympy

SymPy Bot Summary: :red_circle: Failed after merging srjoglekar246/electrical (e64e266) into master (d503614).
@srjoglekar246: Please fix the test failures.
:red_circle:PyPy 2.0.0-beta-1; 2.7.3-final-42: fail
:red_circle:Python 2.7.2-final-0: fail
:red_circle:Python 3.2.1-final-0: fail
:eight_spoked_asterisk:Sphinx 1.1.3: pass
Docs build command: make clean && make html-errors && make latex && cd _build/latex && xelatex sympy-*.tex

Aaron Meurer

ongelezen,
19 dec 2012, 19:42:0819-12-2012
aan sympy/sympy

SymPy Bot Summary: :red_circle: Failed after merging srjoglekar246/electrical (e64e266) into master (501534b).


@srjoglekar246: Please fix the test failures.

:red_circle:Python 2.5.0-final-0: fail
:red_circle:Python 2.6.6-final-0: fail


:red_circle:Python 2.7.2-final-0: fail

:red_circle:Python 2.6.8-final-0: fail
:red_circle:Python 2.7.3-final-0: fail


:red_circle:PyPy 2.0.0-beta-1; 2.7.3-final-42: fail

:red_circle:Python 3.2.2-final-0: fail
:red_circle:Python 3.3.0-final-0: fail
:red_circle:Python 3.2.3-final-0: fail
:red_circle:Python 3.3.0-final-0: fail
:red_circle:Python 3.3.0-final-0: fail
:eight_spoked_asterisk:**Sphinx 1.1.3:** pass

Sachin Joglekar

ongelezen,
22 dec 2012, 01:16:0822-12-2012
aan sympy/sympy

@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()

Allen beantwoorden
Auteur beantwoorden
Doorsturen
0 nieuwe berichten