Electrodynamics in Physics Module

288 views
Skip to first unread message

Rajath Shashidhara

unread,
Feb 10, 2014, 8:39:44 AM2/10/14
to sy...@googlegroups.com
Hello,

I'm interested in implementing electrodynamics in sympy.
Any thoughts about this?

I don't seem to find any documentation about grad, divergence, and curl.
Are they implemented?
I'm willing to do this as well.

Please give me feedback.

Thanks.

Rajath Shashidhara

unread,
Feb 10, 2014, 9:08:04 AM2/10/14
to sy...@googlegroups.com
It'd also be nice to have support for cylindrical and spherical coordinate systems in sympy.

Alan Bromborsky

unread,
Feb 10, 2014, 10:33:10 AM2/10/14
to sy...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.
In sympy/examples/galgebra look at physics_check_latex.py and spherical_latex.py

Jason Moore

unread,
Feb 10, 2014, 11:29:41 AM2/10/14
to sy...@googlegroups.com
Check out Sachin's work from last year. He has an electrodynamics module which is almost complete. Prasoon also has some branches with a vector calculus package which has the functions you are interested in, also with various coordinate systems. Both of these need work and improvements.

Rajath Shashidhara

unread,
Feb 10, 2014, 11:51:37 AM2/10/14
to sy...@googlegroups.com
Hello Jason,
Where do I find those branches?

Can't find it on github.

Jason Moore

unread,
Feb 10, 2014, 12:04:04 PM2/10/14
to sy...@googlegroups.com

Sachin Joglekar

unread,
Feb 11, 2014, 6:45:06 AM2/11/14
to sy...@googlegroups.com
To correct Jason, I had set out to build an electromagnetism module, but we realised many issues with the framework that needed to be solved first. Currently, I have an open PR that deals with the field functions you mentioned. It will be integrated into the new sympy.physics.vector module. I also have an open PR dealing with electrostatics, which you can contribute to. For electrodynamics, especially the E-M interactions, our vector framework would need to be beefed up, with advanced vector calculus. The idea for that is up here - https://pydy.org/gsoc_2014_ideas . About having support for spherical/cylindrical coordinates, Prasoon would be able to guide you better.
You can start by looking at how you would implement these enhancements to the core first, and then proceed. What would you like to see in the module you propose?


On Monday, February 10, 2014 7:09:44 PM UTC+5:30, Rajath Shashidhara wrote:

Rajath Shashidhara

unread,
Feb 11, 2014, 8:27:00 AM2/11/14
to sy...@googlegroups.com
Hi Sachin,

Some things I'd like to be there in the electrodynamics module:
1. Point Charges, Continuous charge distributions - Electric Field and Potential
2. Magnetic field - Magnetic Vector Potential
3. Maxwell's Equations
5. Energy, Momentum Conservations - Poynting Vector, Momentum Tensor
6. Relativistic Electrodynamics

are some broad fields that are in general useful.
The specifics, I guess I'll have to think about it.

Right now, I don't even see curl,grad and divergence in the sympy module. Also, support for curvilinear co-ordinates is lacking.

So, a lot of work needs to be done.


--
You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/77KcEdT6rXE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sympy+un...@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.



--
Rajath S,
M.Sc(Hons.) Physics, B.E.(Hons.) Computer Science
Birla Institute of Technology and Science - Pilani,
Pilani

Sachin Joglekar

unread,
Feb 11, 2014, 8:30:48 AM2/11/14
to sy...@googlegroups.com
As I mentioned, a PR for these functions is in the _pipeline_, which means you wont be able to see the commit changes in the master as yet. The earlier PR had to be closed due to the git conflicts caused by the creation of the new module. The features you suggest are a must for any such module. Do think on those lines and tell us your ideas.


On Monday, February 10, 2014 7:09:44 PM UTC+5:30, Rajath Shashidhara wrote:

Alan Bromborsky

unread,
Feb 11, 2014, 10:38:06 AM2/11/14
to sy...@googlegroups.com
Please note that the geometric algebra module has curl, div, and grad in various coordinate systems.  Python code and LaTeX output of relevant examples is attached -
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
physics_check_latex.pdf
physics_check_latex.py
spherical_latex.pdf
spherical_latex.py

Rajath Shashidhara

unread,
Feb 16, 2014, 3:58:44 PM2/16/14
to sy...@googlegroups.com
Hello,

Can some one brief me about the conflicts caused by the creation of this module? (Sachin mentioned it).
It'll give me a head start in contributing to this module.

Thank you.

Jason Moore

unread,
Feb 16, 2014, 4:15:10 PM2/16/14
to sy...@googlegroups.com
Electrodynamics can be computed with traditional vector calculus or as Alan shows with newer generalized methods of geometric algebra. Prasoon's work last year was to develop a general vector calculus package and a then to make use of this core for the existing mechanics package and the new electrodynamics package. If you want to have a nice electrodynamics package I'd suggest these possible paths:

1. Complete the vector calculus package so that we have high quality general vector calc tools, then build your package on top of that.
2. Learn geometric algebra and build your package on top of that.

One nice thing about geometric algebra is that it isn't confined to 3 spacial dimensions. Traditional vector calc has limitations in this regard, but is what most people know and for most engineering problems the 3D issue is not a major concern.

If fact, I'd like to bring geometric algebra into the fold in the mechanics package, as it is the basis of more modern dynamics methods, such as the ones presented by Jain and Featherstone.

Rajath Shashidhara

unread,
Feb 17, 2014, 1:11:40 AM2/17/14
to sy...@googlegroups.com
Hello Jason,

Thanks for your inputs.

I'm looking into both prasoon's work and the geometric algebra module.

I believe use of geometric algebra is better as it is more general. But, to keep it simple, use of conventionally used 3D co-ordinate systems must be made easier.
What I mean to say is, a person who is working with electrodynamics might not be aware of differential geometry(metric tensor, curvilinear coordinate systems..). So, it'd be hard for him to use the geometric algebra module to set up the co-ordinate systems. We could support Cartesian, cylindrical and spherical systems by default and to use any other co-ordinate system the use of geometric algebra module should be used. (This might already be implemented in prasoon's work).

I think I'll have to go through the code to make any other comments.

Thank you.

Rajath Shashidhara

unread,
Feb 17, 2014, 6:57:46 AM2/17/14
to sy...@googlegroups.com
I looked into Prasoon's work.
He has provided support for Spherical, cylindrical and rectangular coordinate systems.

I'd like to know why Prasoon's work was not merged into sympy.
What are the bugs or potential problems of his work?
Are there any issues to be addressed in his work?

Thanks.

Sachin Joglekar

unread,
Feb 17, 2014, 7:06:07 AM2/17/14
to sy...@googlegroups.com
The problem was mainly delays and a lot of issues integrating it with the SymPy's core. The main problem we faced was incorporating vectorial-operation classes into the current SymPy hierarchy. I had tried to work on the same for Dyadics - assuming Prasoon's work as a base. The PR was eventually closed. Have a look at it here - https://github.com/sympy/sympy/pull/2306/files. I would love to see support for various types of coordinate systems in SymPy. As many of us @PyDy have discussed before, it would be great to have a vector calculus core for physics, that runs off SymPy's basic architecture. Prasoon's project was a step in that direction. I don't exactly know why it wasn't merged, maybe Stefan can answer that. However, feel free to extend his work and send a PR as get comfortable.

On Monday, February 10, 2014 7:09:44 PM UTC+5:30, Rajath Shashidhara wrote:

Rajath Shashidhara

unread,
Feb 17, 2014, 8:29:13 AM2/17/14
to sy...@googlegroups.com
If a new Vector module is made for sympy, it might increase the problem of distributed vector,tensor,matrices,diff geom,geom algebra problem. [https://github.com/sympy/sympy/wiki/Linear-Algebra-Vision]. I guess the problem pointed out by this wiki page will increase. The vector algebra we'll need is just a Linear Vector Space.

Also, Instead of adding a new vector module, what about increasing the functionality of the sympy.physics.vector module ?
So, any suggestions regarding this?


--
You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/77KcEdT6rXE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Sachin Joglekar

unread,
Feb 17, 2014, 9:22:18 AM2/17/14
to sy...@googlegroups.com
Thats definitely a plan. I am going to send a PR soon with the grad, curl, divergence and scalar potential functions that a basic electrostatics module would need. What further enhancements can you think of to the module? Have a look at the code and share your ideas.
About implementing a vector module for SymPy, there are various upsides to that. First off, having a core based on SymPy's architecture would probably be much faster than the current implementation (Provided we can provide it as much flexibility as the current one has, with the constraint of immutability). Second, we would like the physics vector-related stuff to be more homogeneous with the rest of SymPy, which it currently is not. However, last summer we did realise that's not an easy job. I would still suggest you look at Prasoon's code (and the the small amount I tried) and see whether you can build such a module.


On Monday, February 10, 2014 7:09:44 PM UTC+5:30, Rajath Shashidhara wrote:

Jason Moore

unread,
Feb 17, 2014, 10:46:35 AM2/17/14
to sy...@googlegroups.com
Another approach would be to write a traditional vector calculus module that uses the geometric algebra package in the background. I don't know enough about geometric algebra to know if that is actually possible. But maybe. Alan could probably comment.

The sympy.physics.vector module can be improved, but keep in mind that Prasoon's work is essentially what that is. We'd ideally need a vector calculus package that is in the top level name space of sympy which would replace sympy.physics.vector functionality. The main hurdle is the fact that we rely heavily on immutability in sympy.physics.vector and the new vector classes should be immutable and based on core SymPy classes.

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.

Alan Bromborsky

unread,
Feb 17, 2014, 11:39:28 AM2/17/14
to sy...@googlegroups.com
The main problem with the current GA module is that it only allows one instance of a geometric algebra at a time.  That is you can have a geometric algebra with space time coordinate system that is (t,x,y,z) or (t,r,theta,z) or (t,r,theta,phi) or any other by defining an appropriate metric tensor (you are also not limited to
space time 4D).  But only one instance of the algebra at a time is allowed in the current GA module (I am developing a revised GA module  that does not have this limitation).  The problem I see with this limitation is if one needs to map one coordinate system into another.

The map from geometric algebra/calculus to 3d vector calculus is simple.  When the geometric algebra is instantiated  a special vector 'grad' and the pseudo scalar 'I' is defined and the operations dot (|), wedge (^), and geometric (*) products implemented.  Then if U(x) and V(x) are vector fields and f(x) is a scalar field we have -

1. U \cdot V = U|V  (dot product)
2. U \times V = -I*(U^V) (vector product)
3. \nabla \cdot U = grad|U (divergence)
4. \nabla \times U = -I*(grad ^ U) (curl)
5. \nabla f = grad*f (gradient of scalar function)

Of course 2 and 3 are only valid in a 3d vector space and with dealing with relativity it is much nicer to deal with a 4d Minkowski space.

My new implementation is functional and includes some new objects such as multivector differential operators.  I have not made a branch of it yet since the api has changed some and I need to fix the documentation.  My biggest problem in revising the GA module is doing the documentation in Sphinx.  I have been using LaTeX for 30 years and writing docs in Sphinx makes me feel like I am documenting while wearing blinders.

If anyone is interested the new code is at https://github.com/brombo/GA and includes documentation in LaTeX and a set of introductory notes (in progress) for geometric algebra and calculus.

I would be very interested in what you (plural) think should be the functionality required for a physics module.  I think the only thing currently missing from my new GA module is a mapping from one instance (coordinate system) of a geometric algebra to another, assuming each geometric algebra are based on the same vector space (dimension and signature).




 

Aaron Meurer

unread,
Feb 17, 2014, 8:11:36 PM2/17/14
to sy...@googlegroups.com
Tools like pandoc claim to be able to convert any markup format to any
other markup format. I wonder if it would produce anything useful if
you told it to convert LaTeX to rst. It may at least tell you about
some feature of rst that you didn't know about.

I agree that rst can be hard to work with. There's a nice little
cheatsheet at http://openalea.gforge.inria.fr/doc/openalea/doc/_build/html/source/sphinx/rest_syntax.html.

Aaron Meurer

>
> If anyone is interested the new code is at https://github.com/brombo/GA and
> includes documentation in LaTeX and a set of introductory notes (in
> progress) for geometric algebra and calculus.
>
> I would be very interested in what you (plural) think should be the
> functionality required for a physics module. I think the only thing
> currently missing from my new GA module is a mapping from one instance
> (coordinate system) of a geometric algebra to another, assuming each
> geometric algebra are based on the same vector space (dimension and
> signature).
>
>
>
>
>
>

Jason Moore

unread,
Feb 17, 2014, 8:49:35 PM2/17/14
to sy...@googlegroups.com
Here is an example of a math heavy page I wrote in with rst + Sphinx:

https://raw2.github.com/moorepants/dissertation/master/eom.rst

:math:`...` is the same as \(...\) or $...$

and

.. math:: gives you the amsmath align environment.

It worked out pretty well, ended up with a nice html and latex document.

pandoc does an ok job converting latex to rst, but I've found it misses a lot too and/or outputs poor rst representations of what you want.

Rajath Shashidhara

unread,
Feb 18, 2014, 8:16:34 AM2/18/14
to sy...@googlegroups.com
Hello Sachin,

In addition to the features you have mentioned, (vector integration is implemented in prasoon's PR),
I think divergence theorem, and stokes theorem must also be supported. Also, a module for solving/simplifying vector equations might also help. [support for BAC-CAB rule, div of curl, grad of div, .... ].



--
You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/77KcEdT6rXE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sympy+un...@googlegroups.com.

To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.



--

Alan Bromborsky

unread,
Feb 18, 2014, 9:01:42 AM2/18/14
to sy...@googlegroups.com
What do you mean in regard to divergence theorem, and stokes theorem being supported.  In the multiple integral section docs for sympy definite multidimensional integrals are only supported on rectangular integration ranges.  That is limits of integration are independent of each other along each axis.  This restriction would severely limit the application of the divergence theorem, and stokes theorem.  In order to compute a surface integral you would need the metric tensor for that surface and then you would still be restricted to a integrating over a rectangular coordinate patch.

Rajath Shashidhara

unread,
Feb 19, 2014, 7:49:37 AM2/19/14
to sy...@googlegroups.com
Hello Alan,

I don't understand what you mean.

I mean to say, sympy must be able to symbolically convert a surface integral into volume integral(vice versa) using divergence theorem(line integral to area integral using stokes theorem). In this case, I'm talking about prasoon's vector module. Using the geometric algebra module, as you have mentioned, this would be equivalent to moving to a coordinate set on the surface and integrating over a rectangular patch. 

Sorry, if I have misunderstood. [I'm only a student and still inexperienced].

Rajath Shashidhara

unread,
Feb 20, 2014, 6:47:59 AM2/20/14
to sy...@googlegroups.com
Hello,

I'd like to know which one of the two paths that Jason mentioned, is more useful for the project. It'll help me choose the right path and start work. 
I need feedback and guidance to start work on this. 

I have my exams coming up in a few days. I'll get back to work after that.

Thanks. 
 

Sachin Joglekar

unread,
Feb 20, 2014, 7:00:52 AM2/20/14
to sy...@googlegroups.com
As I see it, you essentially have two options-
1) Extend Prasoon's work and make a vector calculus module for SymPy
2) Extend sympy.physics.vector and beef it up to support advanced functionality

The first one may be quite tricky to pull off, considering the immutability constraint, though it's not impossible. But its also something many of us looked forward to, last summer. A vector package that gels with the rest of sympy is a very appealing prospect. But this time, you will have to be very careful and think about how you would go about it, if you decide to take it up.
You should probably have a good look at Prasoon's work, and try to get it into SymPy. I can probably help you with getting the bugs solved. Once you are successful with that, you can start building up on it for your project.
@Jason, what do you think?


On Monday, February 10, 2014 7:09:44 PM UTC+5:30, Rajath Shashidhara wrote:

Sachin Joglekar

unread,
Feb 28, 2014, 12:48:43 PM2/28/14
to sy...@googlegroups.com
Hello again.
Jason and I had a talk about this a few days back, and we agreed that it would be better if, according to your original plan, your proposal would focus on-
1) Improving the sympy.physics.vector module with the functionalities you plan to implement
2) Building up an E-M module

Step 1 would ensure that a proper vector module is in place for the E-M module to build up on.

About the sympy.vector idea, it would probably be best for me to look into it, since I have already done some work with helping Prasoon with that last summer. So I would have a nice head start with knowing the physics.vector module in and out, and having some ideas about building a similar core with SymPy's architecture. Once I have built a stable foundation, we can then work together after the summer into basing mechanics and E-M off that core. Have you looked at the physics.vector module yet?

Rajath Shashidhara

unread,
Feb 28, 2014, 1:39:13 PM2/28/14
to sy...@googlegroups.com
Hello Sachin,
I have my mid-semester exams going on. Right now, I have very limited time to spend on this. I'll definitely get back to you after my exams. 

I look forward to work with you.

Thanks.  


--
You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/77KcEdT6rXE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.

For more options, visit https://groups.google.com/groups/opt_out.

Rajath Shashidhara

unread,
Mar 1, 2014, 1:33:33 AM3/1/14
to sy...@googlegroups.com
On Fri, Feb 28, 2014 at 11:18 PM, Sachin Joglekar <srjogl...@gmail.com> wrote:
Hello again.
Jason and I had a talk about this a few days back, and we agreed that it would be better if, according to your original plan, your proposal would focus on-
1) Improving the sympy.physics.vector module with the functionalities you plan to implement
2) Building up an E-M module


Do you mean a proposal for GSoC? 
 
Step 1 would ensure that a proper vector module is in place for the E-M module to build up on.

About the sympy.vector idea, it would probably be best for me to look into it, since I have already done some work with helping Prasoon with that last summer. So I would have a nice head start with knowing the physics.vector module in and out, and having some ideas about building a similar core with SymPy's architecture. Once I have built a stable foundation, we can then work together after the summer into basing mechanics and E-M off that core. Have you looked at the physics.vector module yet?


On Monday, February 10, 2014 7:09:44 PM UTC+5:30, Rajath Shashidhara wrote:
Hello,

I'm interested in implementing electrodynamics in sympy.
Any thoughts about this?

I don't seem to find any documentation about grad, divergence, and curl.
Are they implemented?
I'm willing to do this as well.

Please give me feedback.

Thanks.

--
You received this message because you are subscribed to a topic in the Google Groups "sympy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sympy/77KcEdT6rXE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
Reply all
Reply to author
Forward
0 new messages