Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - Dirac Algebra #1635

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

WIP - Dirac Algebra #1635

wants to merge 2 commits into from

Conversation

Krastanov
Copy link
Member

http://en.wikipedia.org/wiki/Gamma_matrices

Only the simple rules (rule) are implemented in this initial commit.

The new rewrite rules framework is awesome for stuff like this.

This will speed up my QFT homeworks by a factor of 100 when it is done.

By using the new rewrite rules framework I implement simplification routines
for traces of matrices representing the Dirac algebra (concerning 4 spinors).
@Krastanov
Copy link
Member Author

on the wiki page see directly http://en.wikipedia.org/wiki/Gamma_matrices#Identities

@ellisonbg
Copy link
Member

It would be fantastic to have all of this!

I think that everything in sympy.physics that is related to quantum mechanics should use the classes in the quantum submodule (Operator, State, Commutator, etc). Really these matrices are quantum operators that are being represented in a given basis and should use the technology we have there. In particular, the matrix expressions stuff should not every be used in sympy.physics for quantum related things as it is basically a complete reimplementation of everything in sympy.physics.quantum that doesn't know about the quantum specific things such as representations in various bases, operator application, commutation relations etc. These classes will enable you to do a lot more that matrix expressions.

@ellisonbg
Copy link
Member

This would also enable you to easily handle the different representations of these operators.

@Krastanov
Copy link
Member Author

@ellisonbg, in most general terms I agree (there are details on which I do not, but those are for another discussion), but for the near future I will continue using the matrix module mostly because I know it better.

In order to calm down any fears that it would be too hard to move this from matrices to quantum I would like to point out that I only use one base class from matrices and nothing else. (btw, Trace is used in both matrices and quantum, right?)

@mrocklin
Copy link
Member

mrocklin commented Nov 1, 2012

These classes will enable you to do a lot more that matrix expressions

It may also be that sympy.physics would benefit from having this in it's ecosystem more than sympy.matrices.expressions would.

Don't get me wrong, I love seeing MatrixExprs be used by people and if you prefer them then go for it (I'd also love to see what you do with them). I'm just pointing out that if Brian is excited about this then maybe it's worth thinking about switching to the other side.

@mrocklin
Copy link
Member

mrocklin commented Nov 1, 2012

btw, Trace is used in both matrices and quantum, right?

Alas, there are two. Trace and Tr.

@Krastanov
Copy link
Member Author

Alas, there are two. Trace and Tr.

That may make the switch harder than what I have expected, but at least for the WIP phase I will continue this way. Before ever suggesting a merge I will try to move this to quantum. Anyway, this pull request should never get bigger than 200-300 lines excluding comments

Moving the discussion to another technical issue: @ellisonbg, do you have any ideas how to implement the Minkowski metric inside physics. For the moment I think about hardcoding the (-+++) convention in some Function subclass just like KroneckerDelta. However this is ugly. @mrocklin, it would be interesting to extend this to tensors in general, however I do not volunteer for the moment.

Another issue: there are gamma^mu and gamma_mu matrices. Do you have any preferred interface for the UP and DOWN indices.

@mrocklin
Copy link
Member

mrocklin commented Nov 1, 2012

it would be interesting to extend this to tensors in general, however I do not volunteer for the moment

Some day, when none of us have jobs, we will create the perfect tensor object on which we can all agree and from which we can all inherit....

Another issue: there are gamma^mu and gamma_mu matrices. Do you have any preferred interface for the UP and DOWN indices.

Everything in MatrixExprs is effectively rank (1, 1). You can have a rank (1, 1) with 1 row or with 1 col. I haven't thought much about which I consider to be which. I suspect that you're probably better equipped to make that decision anyway.

@ellisonbg
Copy link
Member

@Krastanov I just looked at your code and it will be extremely simple to convert this to use the quantum stuff add anti-commutators, etc.

For the metric tensor I would just use the simplest thing for now - something like KroneckerDelta.

It would be very fun and interesting to think about how to implement all of this using quantum stuff. We have some experience with the spin model handling sets of operators that have algebraic structure. Very interesting stuff and (as you are motivated towards) there is a huge potential for simplifying QFT calculations.

@Krastanov
Copy link
Member Author

Well, against my better judgment I started implementing a tensor object. I will provide a pr in a few days.

One more thing: one of the rules that I use here is wrong. I will correct it later.

@Krastanov
Copy link
Member Author

@ellisonbg, at which classes should I look concerning the quantum module? Do I need to define a new Hilbert space for the 4-spinors before defining the gammas?

@ellisonbg
Copy link
Member

@Krastanov I would start with Operator - or probably HermitianOperator. You don't have to define a Hilbert space - everything will work just fine without it. What Hilbert space is it though - just 4d complex Hilbert space? We already have that one defined - you just have to specify that. I would start out by making them print nicely and figuring out how to handle the co-contra difference. Will those be separate classes or an additional argument to the basic classes.

You could implement _eval_trace and use the other trace.

From there I would look in spin.py to see how to handle representations and anticommutation relations. You will probably need to to implement the metric tensor.

One thing though - as we think about creating a solid tensor class, we really need to think carefully about how to do that, because the individual elements of the tensor in quantum mechanics are often operators. That makes things pretty weird. But to be useful we will have to handle that case well.

@jrioux
Copy link
Member

jrioux commented Nov 2, 2012

SymPy Bot Summary: 🔴 Failed after merging Krastanov/diracalgebra (96e4342) into master (f860de8).
@Krastanov: Please fix the test failures.
🔴 Python 2.7.2-final-0: fail

@Krastanov
Copy link
Member Author

One thing though - as we think about creating a solid tensor class, we really need to think carefully about how to do that, because the individual elements of the tensor in quantum mechanics are often operators. That makes things pretty weird. But to be useful we will have to handle that case well.

This is an abuse of notation that I dislike. The compoments of the tensor are not operators, rather the tensor itself is not just Lorentz tensor or Dirac tensor but a tensor living on the product of these two spaces.

However, the rewrite rules permit very nicely this abuse of notation, so it will be supported given how widespread it is. At least in the prototype.

No updates to this PR yet. Probably during the weekend.

@jrioux
Copy link
Member

jrioux commented Nov 20, 2012

SymPy Bot Summary: 🔴 Failed after merging Krastanov/diracalgebra (96e4342) into master (211f0f7).
@Krastanov: Please fix the test failures.
🔴 Python 2.7.2-final-0: fail
🔴 Python 3.2.1-final-0: fail
✳️ Sphinx 1.1.3: pass

@asmeurer
Copy link
Member

SymPy Bot Summary: 🔴 Failed after merging Krastanov/diracalgebra (96e4342) into master (34137fa).
@Krastanov: Please fix the test failures.
🔴 Python 2.5.6-final-0: fail
🔴 Python 2.6.8-final-0: fail
🔴 Python 2.7.3-final-0: fail
🔴 Python 3.2.3-final-0: fail
✳️ Sphinx 1.1.3: pass

@asmeurer
Copy link
Member

SymPy Bot Summary: ✅ Passed after merging Krastanov/diracalgebra (96e4342) into master (00a0a1e).
Sphinx 1.2b1: pass
Doc Coverage: unchanged
36.58% of functions have doctests (compared to 36.58% in master)
40.97% of functions are imported into Sphinx (compared to 40.97% in master)

@jrioux
Copy link
Member

jrioux commented Jul 7, 2013

SymPy Bot Summary: ❗ There were merge conflicts (could not merge Krastanov/diracalgebra (4b1ea97) into master (5d459d5)); could not test the branch.
@Krastanov: Please rebase or merge your branch with master. See the report for a list of the merge conflicts.

@Upabjojr
Copy link
Contributor

Regarding the simplification of contractions of the Gamma matrices, are you aware of this algorithm for the 4-dim case:

http://jmp.aip.org/resource/1/jmapaq/v9/i10/p1732_s1?isAuthorized=no

the paper does not cover the algorithmic complexity, but I guess it's almost linear over the number of gamma matrices in the expression.

And this other one which works in any dimension:

http://dl.acm.org/citation.cfm?id=70929

@Krastanov
Copy link
Member Author

The code here is nothing fancy. It is just a few rewrite rules applied in succession. It is not optimized for speed in any way (I have not even bothered to think about complexity) because it is not meant for simplification of gigantic expression. So probably it is not something on par with algorithms worthy of a publication.

On the other hand it is ridiculously short, simple and easy to extend.

However this pull request is not the best way forward. We should "just" fix the issue with the tensor module, and get the rewrite-rules working for it.

@Upabjojr
Copy link
Contributor

The article in the Kahane paper provides a really simple algorithm, which is very efficient. Have a look at it.

@Upabjojr
Copy link
Contributor

Well, I think this package can be integrated with the tensor module. The only drawback is that soon valued tensors will become numpy-dependant, but I think we could just subclass abstract tensors and avoid setting a base in the gamma matrix space.

@Krastanov
Copy link
Member Author

Could you send the articles on the mailing list? I am not currently at a campus with access to these publications.

@czgdp1807
Copy link
Member

@Krastanov @Upabjojr @asmeurer Any plans for completing this PR? If no, then can we add this in ideas list for GSoC 2020?

@Krastanov
Copy link
Member Author

I would not be able to work on completing this myself, but if any student needs help with implementing it, I would be happy to advise.

@Upabjojr
Copy link
Contributor

Any plans for completing this PR? If no, then can we add this in ideas list for GSoC 2020?

I would recommend using MatchPy for the Dirac algebra. MatchPy was not available a few years ago.

It is closely compatible with Mathematica's pattern matcher, therefore allowing to easily translate Mathematica packages into SymPy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants