applied-ai-018 commited on
Commit
0f3cb53
·
verified ·
1 Parent(s): f727435

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. ckpts/universal/global_step80/zero/11.post_attention_layernorm.weight/exp_avg.pt +3 -0
  2. ckpts/universal/global_step80/zero/14.input_layernorm.weight/exp_avg.pt +3 -0
  3. ckpts/universal/global_step80/zero/14.input_layernorm.weight/exp_avg_sq.pt +3 -0
  4. ckpts/universal/global_step80/zero/14.input_layernorm.weight/fp32.pt +3 -0
  5. ckpts/universal/global_step80/zero/14.mlp.dense_4h_to_h.weight/exp_avg.pt +3 -0
  6. ckpts/universal/global_step80/zero/14.mlp.dense_4h_to_h.weight/fp32.pt +3 -0
  7. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/__init__.cpython-310.pyc +0 -0
  8. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/anticommutator.cpython-310.pyc +0 -0
  9. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/boson.cpython-310.pyc +0 -0
  10. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/cartesian.cpython-310.pyc +0 -0
  11. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/cg.cpython-310.pyc +0 -0
  12. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/circuitplot.cpython-310.pyc +0 -0
  13. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/commutator.cpython-310.pyc +0 -0
  14. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/constants.cpython-310.pyc +0 -0
  15. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/dagger.cpython-310.pyc +0 -0
  16. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/density.cpython-310.pyc +0 -0
  17. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/fermion.cpython-310.pyc +0 -0
  18. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/gate.cpython-310.pyc +0 -0
  19. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/grover.cpython-310.pyc +0 -0
  20. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/hilbert.cpython-310.pyc +0 -0
  21. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/identitysearch.cpython-310.pyc +0 -0
  22. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/innerproduct.cpython-310.pyc +0 -0
  23. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/matrixcache.cpython-310.pyc +0 -0
  24. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/operator.cpython-310.pyc +0 -0
  25. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/operatorordering.cpython-310.pyc +0 -0
  26. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/operatorset.cpython-310.pyc +0 -0
  27. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/pauli.cpython-310.pyc +0 -0
  28. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/qapply.cpython-310.pyc +0 -0
  29. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/qft.cpython-310.pyc +0 -0
  30. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/represent.cpython-310.pyc +0 -0
  31. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/sho1d.cpython-310.pyc +0 -0
  32. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/spin.cpython-310.pyc +0 -0
  33. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/state.cpython-310.pyc +0 -0
  34. venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/tensorproduct.cpython-310.pyc +0 -0
  35. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__init__.py +0 -0
  36. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/__init__.cpython-310.pyc +0 -0
  37. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_anticommutator.cpython-310.pyc +0 -0
  38. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_cg.cpython-310.pyc +0 -0
  39. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_circuitutils.cpython-310.pyc +0 -0
  40. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_commutator.cpython-310.pyc +0 -0
  41. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_dagger.cpython-310.pyc +0 -0
  42. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_gate.cpython-310.pyc +0 -0
  43. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_pauli.cpython-310.pyc +0 -0
  44. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_printing.cpython-310.pyc +0 -0
  45. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_qft.cpython-310.pyc +0 -0
  46. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_tensorproduct.cpython-310.pyc +0 -0
  47. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/test_anticommutator.py +56 -0
  48. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/test_boson.py +50 -0
  49. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/test_cartesian.py +104 -0
  50. venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/test_cg.py +178 -0
ckpts/universal/global_step80/zero/11.post_attention_layernorm.weight/exp_avg.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e35beea959e0bf46011784b5e739c29b481e5f858f76cc62c8614fd25f1b51d3
3
+ size 9372
ckpts/universal/global_step80/zero/14.input_layernorm.weight/exp_avg.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c3e3ec079e9b2e4baad6c0986e0373ad174a8e497a19302998fa97b8231f20c
3
+ size 9372
ckpts/universal/global_step80/zero/14.input_layernorm.weight/exp_avg_sq.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:124aafcd1c3868fd04807e54d0f562305c700ceb3ec038993ab7ad7657d0c779
3
+ size 9387
ckpts/universal/global_step80/zero/14.input_layernorm.weight/fp32.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3277c40f2539b4f594bec7bf3f99e15231ceab32584e9333fb89919281ddd73e
3
+ size 9293
ckpts/universal/global_step80/zero/14.mlp.dense_4h_to_h.weight/exp_avg.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5bf2bd61430b94eaaacfdfd48255ee58675944ac470c1fee566c90f9a2a77550
3
+ size 33555612
ckpts/universal/global_step80/zero/14.mlp.dense_4h_to_h.weight/fp32.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d9b053b392da5a6c102ca3d032113a89e7b1eb853dae552dcfc921bcb03feea2
3
+ size 33555533
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (1.61 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/anticommutator.cpython-310.pyc ADDED
Binary file (4.74 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/boson.cpython-310.pyc ADDED
Binary file (8.48 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/cartesian.cpython-310.pyc ADDED
Binary file (11.3 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/cg.cpython-310.pyc ADDED
Binary file (22 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/circuitplot.cpython-310.pyc ADDED
Binary file (10.7 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/commutator.cpython-310.pyc ADDED
Binary file (6.3 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/constants.cpython-310.pyc ADDED
Binary file (1.79 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/dagger.cpython-310.pyc ADDED
Binary file (2.86 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/density.cpython-310.pyc ADDED
Binary file (10.4 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/fermion.cpython-310.pyc ADDED
Binary file (5.74 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/gate.cpython-310.pyc ADDED
Binary file (34.6 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/grover.cpython-310.pyc ADDED
Binary file (9.64 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/hilbert.cpython-310.pyc ADDED
Binary file (19.3 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/identitysearch.cpython-310.pyc ADDED
Binary file (21.7 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/innerproduct.cpython-310.pyc ADDED
Binary file (4.29 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/matrixcache.cpython-310.pyc ADDED
Binary file (3.73 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/operator.cpython-310.pyc ADDED
Binary file (19.8 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/operatorordering.cpython-310.pyc ADDED
Binary file (7.18 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/operatorset.cpython-310.pyc ADDED
Binary file (7.9 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/pauli.cpython-310.pyc ADDED
Binary file (18.9 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/qapply.cpython-310.pyc ADDED
Binary file (5.03 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/qft.cpython-310.pyc ADDED
Binary file (7.22 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/represent.cpython-310.pyc ADDED
Binary file (15.2 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/sho1d.cpython-310.pyc ADDED
Binary file (22 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/spin.cpython-310.pyc ADDED
Binary file (72.1 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/state.cpython-310.pyc ADDED
Binary file (30.7 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/__pycache__/tensorproduct.cpython-310.pyc ADDED
Binary file (13.5 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__init__.py ADDED
File without changes
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (195 Bytes). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_anticommutator.cpython-310.pyc ADDED
Binary file (2.36 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_cg.cpython-310.pyc ADDED
Binary file (7.04 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_circuitutils.cpython-310.pyc ADDED
Binary file (8.82 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_commutator.cpython-310.pyc ADDED
Binary file (3.46 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_dagger.cpython-310.pyc ADDED
Binary file (2.94 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_gate.cpython-310.pyc ADDED
Binary file (12 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_pauli.cpython-310.pyc ADDED
Binary file (5.32 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_printing.cpython-310.pyc ADDED
Binary file (27.6 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_qft.cpython-310.pyc ADDED
Binary file (2.57 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/__pycache__/test_tensorproduct.cpython-310.pyc ADDED
Binary file (4.42 kB). View file
 
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/test_anticommutator.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from sympy.core.numbers import Integer
2
+ from sympy.core.symbol import symbols
3
+
4
+ from sympy.physics.quantum.dagger import Dagger
5
+ from sympy.physics.quantum.anticommutator import AntiCommutator as AComm
6
+ from sympy.physics.quantum.operator import Operator
7
+
8
+
9
+ a, b, c = symbols('a,b,c')
10
+ A, B, C, D = symbols('A,B,C,D', commutative=False)
11
+
12
+
13
+ def test_anticommutator():
14
+ ac = AComm(A, B)
15
+ assert isinstance(ac, AComm)
16
+ assert ac.is_commutative is False
17
+ assert ac.subs(A, C) == AComm(C, B)
18
+
19
+
20
+ def test_commutator_identities():
21
+ assert AComm(a*A, b*B) == a*b*AComm(A, B)
22
+ assert AComm(A, A) == 2*A**2
23
+ assert AComm(A, B) == AComm(B, A)
24
+ assert AComm(a, b) == 2*a*b
25
+ assert AComm(A, B).doit() == A*B + B*A
26
+
27
+
28
+ def test_anticommutator_dagger():
29
+ assert Dagger(AComm(A, B)) == AComm(Dagger(A), Dagger(B))
30
+
31
+
32
+ class Foo(Operator):
33
+
34
+ def _eval_anticommutator_Bar(self, bar):
35
+ return Integer(0)
36
+
37
+
38
+ class Bar(Operator):
39
+ pass
40
+
41
+
42
+ class Tam(Operator):
43
+
44
+ def _eval_anticommutator_Foo(self, foo):
45
+ return Integer(1)
46
+
47
+
48
+ def test_eval_commutator():
49
+ F = Foo('F')
50
+ B = Bar('B')
51
+ T = Tam('T')
52
+ assert AComm(F, B).doit() == 0
53
+ assert AComm(B, F).doit() == 0
54
+ assert AComm(F, T).doit() == 1
55
+ assert AComm(T, F).doit() == 1
56
+ assert AComm(B, T).doit() == B*T + T*B
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/test_boson.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from math import prod
2
+
3
+ from sympy.core.numbers import Rational
4
+ from sympy.functions.elementary.exponential import exp
5
+ from sympy.functions.elementary.miscellaneous import sqrt
6
+ from sympy.physics.quantum import Dagger, Commutator, qapply
7
+ from sympy.physics.quantum.boson import BosonOp
8
+ from sympy.physics.quantum.boson import (
9
+ BosonFockKet, BosonFockBra, BosonCoherentKet, BosonCoherentBra)
10
+
11
+
12
+ def test_bosonoperator():
13
+ a = BosonOp('a')
14
+ b = BosonOp('b')
15
+
16
+ assert isinstance(a, BosonOp)
17
+ assert isinstance(Dagger(a), BosonOp)
18
+
19
+ assert a.is_annihilation
20
+ assert not Dagger(a).is_annihilation
21
+
22
+ assert BosonOp("a") == BosonOp("a", True)
23
+ assert BosonOp("a") != BosonOp("c")
24
+ assert BosonOp("a", True) != BosonOp("a", False)
25
+
26
+ assert Commutator(a, Dagger(a)).doit() == 1
27
+
28
+ assert Commutator(a, Dagger(b)).doit() == a * Dagger(b) - Dagger(b) * a
29
+
30
+ assert Dagger(exp(a)) == exp(Dagger(a))
31
+
32
+
33
+ def test_boson_states():
34
+ a = BosonOp("a")
35
+
36
+ # Fock states
37
+ n = 3
38
+ assert (BosonFockBra(0) * BosonFockKet(1)).doit() == 0
39
+ assert (BosonFockBra(1) * BosonFockKet(1)).doit() == 1
40
+ assert qapply(BosonFockBra(n) * Dagger(a)**n * BosonFockKet(0)) \
41
+ == sqrt(prod(range(1, n+1)))
42
+
43
+ # Coherent states
44
+ alpha1, alpha2 = 1.2, 4.3
45
+ assert (BosonCoherentBra(alpha1) * BosonCoherentKet(alpha1)).doit() == 1
46
+ assert (BosonCoherentBra(alpha2) * BosonCoherentKet(alpha2)).doit() == 1
47
+ assert abs((BosonCoherentBra(alpha1) * BosonCoherentKet(alpha2)).doit() -
48
+ exp((alpha1 - alpha2) ** 2 * Rational(-1, 2))) < 1e-12
49
+ assert qapply(a * BosonCoherentKet(alpha1)) == \
50
+ alpha1 * BosonCoherentKet(alpha1)
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/test_cartesian.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for cartesian.py"""
2
+
3
+ from sympy.core.numbers import (I, pi)
4
+ from sympy.core.singleton import S
5
+ from sympy.core.symbol import symbols
6
+ from sympy.functions.elementary.exponential import exp
7
+ from sympy.functions.elementary.miscellaneous import sqrt
8
+ from sympy.functions.special.delta_functions import DiracDelta
9
+ from sympy.sets.sets import Interval
10
+
11
+ from sympy.physics.quantum import qapply, represent, L2, Dagger
12
+ from sympy.physics.quantum import Commutator, hbar
13
+ from sympy.physics.quantum.cartesian import (
14
+ XOp, YOp, ZOp, PxOp, X, Y, Z, Px, XKet, XBra, PxKet, PxBra,
15
+ PositionKet3D, PositionBra3D
16
+ )
17
+ from sympy.physics.quantum.operator import DifferentialOperator
18
+
19
+ x, y, z, x_1, x_2, x_3, y_1, z_1 = symbols('x,y,z,x_1,x_2,x_3,y_1,z_1')
20
+ px, py, px_1, px_2 = symbols('px py px_1 px_2')
21
+
22
+
23
+ def test_x():
24
+ assert X.hilbert_space == L2(Interval(S.NegativeInfinity, S.Infinity))
25
+ assert Commutator(X, Px).doit() == I*hbar
26
+ assert qapply(X*XKet(x)) == x*XKet(x)
27
+ assert XKet(x).dual_class() == XBra
28
+ assert XBra(x).dual_class() == XKet
29
+ assert (Dagger(XKet(y))*XKet(x)).doit() == DiracDelta(x - y)
30
+ assert (PxBra(px)*XKet(x)).doit() == \
31
+ exp(-I*x*px/hbar)/sqrt(2*pi*hbar)
32
+ assert represent(XKet(x)) == DiracDelta(x - x_1)
33
+ assert represent(XBra(x)) == DiracDelta(-x + x_1)
34
+ assert XBra(x).position == x
35
+ assert represent(XOp()*XKet()) == x*DiracDelta(x - x_2)
36
+ assert represent(XOp()*XKet()*XBra('y')) == \
37
+ x*DiracDelta(x - x_3)*DiracDelta(x_1 - y)
38
+ assert represent(XBra("y")*XKet()) == DiracDelta(x - y)
39
+ assert represent(
40
+ XKet()*XBra()) == DiracDelta(x - x_2) * DiracDelta(x_1 - x)
41
+
42
+ rep_p = represent(XOp(), basis=PxOp)
43
+ assert rep_p == hbar*I*DiracDelta(px_1 - px_2)*DifferentialOperator(px_1)
44
+ assert rep_p == represent(XOp(), basis=PxOp())
45
+ assert rep_p == represent(XOp(), basis=PxKet)
46
+ assert rep_p == represent(XOp(), basis=PxKet())
47
+
48
+ assert represent(XOp()*PxKet(), basis=PxKet) == \
49
+ hbar*I*DiracDelta(px - px_2)*DifferentialOperator(px)
50
+
51
+
52
+ def test_p():
53
+ assert Px.hilbert_space == L2(Interval(S.NegativeInfinity, S.Infinity))
54
+ assert qapply(Px*PxKet(px)) == px*PxKet(px)
55
+ assert PxKet(px).dual_class() == PxBra
56
+ assert PxBra(x).dual_class() == PxKet
57
+ assert (Dagger(PxKet(py))*PxKet(px)).doit() == DiracDelta(px - py)
58
+ assert (XBra(x)*PxKet(px)).doit() == \
59
+ exp(I*x*px/hbar)/sqrt(2*pi*hbar)
60
+ assert represent(PxKet(px)) == DiracDelta(px - px_1)
61
+
62
+ rep_x = represent(PxOp(), basis=XOp)
63
+ assert rep_x == -hbar*I*DiracDelta(x_1 - x_2)*DifferentialOperator(x_1)
64
+ assert rep_x == represent(PxOp(), basis=XOp())
65
+ assert rep_x == represent(PxOp(), basis=XKet)
66
+ assert rep_x == represent(PxOp(), basis=XKet())
67
+
68
+ assert represent(PxOp()*XKet(), basis=XKet) == \
69
+ -hbar*I*DiracDelta(x - x_2)*DifferentialOperator(x)
70
+ assert represent(XBra("y")*PxOp()*XKet(), basis=XKet) == \
71
+ -hbar*I*DiracDelta(x - y)*DifferentialOperator(x)
72
+
73
+
74
+ def test_3dpos():
75
+ assert Y.hilbert_space == L2(Interval(S.NegativeInfinity, S.Infinity))
76
+ assert Z.hilbert_space == L2(Interval(S.NegativeInfinity, S.Infinity))
77
+
78
+ test_ket = PositionKet3D(x, y, z)
79
+ assert qapply(X*test_ket) == x*test_ket
80
+ assert qapply(Y*test_ket) == y*test_ket
81
+ assert qapply(Z*test_ket) == z*test_ket
82
+ assert qapply(X*Y*test_ket) == x*y*test_ket
83
+ assert qapply(X*Y*Z*test_ket) == x*y*z*test_ket
84
+ assert qapply(Y*Z*test_ket) == y*z*test_ket
85
+
86
+ assert PositionKet3D() == test_ket
87
+ assert YOp() == Y
88
+ assert ZOp() == Z
89
+
90
+ assert PositionKet3D.dual_class() == PositionBra3D
91
+ assert PositionBra3D.dual_class() == PositionKet3D
92
+
93
+ other_ket = PositionKet3D(x_1, y_1, z_1)
94
+ assert (Dagger(other_ket)*test_ket).doit() == \
95
+ DiracDelta(x - x_1)*DiracDelta(y - y_1)*DiracDelta(z - z_1)
96
+
97
+ assert test_ket.position_x == x
98
+ assert test_ket.position_y == y
99
+ assert test_ket.position_z == z
100
+ assert other_ket.position_x == x_1
101
+ assert other_ket.position_y == y_1
102
+ assert other_ket.position_z == z_1
103
+
104
+ # TODO: Add tests for representations
venv/lib/python3.10/site-packages/sympy/physics/quantum/tests/test_cg.py ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from sympy.concrete.summations import Sum
2
+ from sympy.core.numbers import Rational
3
+ from sympy.core.singleton import S
4
+ from sympy.core.symbol import symbols
5
+ from sympy.functions.elementary.miscellaneous import sqrt
6
+ from sympy.physics.quantum.cg import Wigner3j, Wigner6j, Wigner9j, CG, cg_simp
7
+ from sympy.functions.special.tensor_functions import KroneckerDelta
8
+
9
+
10
+ def test_cg_simp_add():
11
+ j, m1, m1p, m2, m2p = symbols('j m1 m1p m2 m2p')
12
+ # Test Varshalovich 8.7.1 Eq 1
13
+ a = CG(S.Half, S.Half, 0, 0, S.Half, S.Half)
14
+ b = CG(S.Half, Rational(-1, 2), 0, 0, S.Half, Rational(-1, 2))
15
+ c = CG(1, 1, 0, 0, 1, 1)
16
+ d = CG(1, 0, 0, 0, 1, 0)
17
+ e = CG(1, -1, 0, 0, 1, -1)
18
+ assert cg_simp(a + b) == 2
19
+ assert cg_simp(c + d + e) == 3
20
+ assert cg_simp(a + b + c + d + e) == 5
21
+ assert cg_simp(a + b + c) == 2 + c
22
+ assert cg_simp(2*a + b) == 2 + a
23
+ assert cg_simp(2*c + d + e) == 3 + c
24
+ assert cg_simp(5*a + 5*b) == 10
25
+ assert cg_simp(5*c + 5*d + 5*e) == 15
26
+ assert cg_simp(-a - b) == -2
27
+ assert cg_simp(-c - d - e) == -3
28
+ assert cg_simp(-6*a - 6*b) == -12
29
+ assert cg_simp(-4*c - 4*d - 4*e) == -12
30
+ a = CG(S.Half, S.Half, j, 0, S.Half, S.Half)
31
+ b = CG(S.Half, Rational(-1, 2), j, 0, S.Half, Rational(-1, 2))
32
+ c = CG(1, 1, j, 0, 1, 1)
33
+ d = CG(1, 0, j, 0, 1, 0)
34
+ e = CG(1, -1, j, 0, 1, -1)
35
+ assert cg_simp(a + b) == 2*KroneckerDelta(j, 0)
36
+ assert cg_simp(c + d + e) == 3*KroneckerDelta(j, 0)
37
+ assert cg_simp(a + b + c + d + e) == 5*KroneckerDelta(j, 0)
38
+ assert cg_simp(a + b + c) == 2*KroneckerDelta(j, 0) + c
39
+ assert cg_simp(2*a + b) == 2*KroneckerDelta(j, 0) + a
40
+ assert cg_simp(2*c + d + e) == 3*KroneckerDelta(j, 0) + c
41
+ assert cg_simp(5*a + 5*b) == 10*KroneckerDelta(j, 0)
42
+ assert cg_simp(5*c + 5*d + 5*e) == 15*KroneckerDelta(j, 0)
43
+ assert cg_simp(-a - b) == -2*KroneckerDelta(j, 0)
44
+ assert cg_simp(-c - d - e) == -3*KroneckerDelta(j, 0)
45
+ assert cg_simp(-6*a - 6*b) == -12*KroneckerDelta(j, 0)
46
+ assert cg_simp(-4*c - 4*d - 4*e) == -12*KroneckerDelta(j, 0)
47
+ # Test Varshalovich 8.7.1 Eq 2
48
+ a = CG(S.Half, S.Half, S.Half, Rational(-1, 2), 0, 0)
49
+ b = CG(S.Half, Rational(-1, 2), S.Half, S.Half, 0, 0)
50
+ c = CG(1, 1, 1, -1, 0, 0)
51
+ d = CG(1, 0, 1, 0, 0, 0)
52
+ e = CG(1, -1, 1, 1, 0, 0)
53
+ assert cg_simp(a - b) == sqrt(2)
54
+ assert cg_simp(c - d + e) == sqrt(3)
55
+ assert cg_simp(a - b + c - d + e) == sqrt(2) + sqrt(3)
56
+ assert cg_simp(a - b + c) == sqrt(2) + c
57
+ assert cg_simp(2*a - b) == sqrt(2) + a
58
+ assert cg_simp(2*c - d + e) == sqrt(3) + c
59
+ assert cg_simp(5*a - 5*b) == 5*sqrt(2)
60
+ assert cg_simp(5*c - 5*d + 5*e) == 5*sqrt(3)
61
+ assert cg_simp(-a + b) == -sqrt(2)
62
+ assert cg_simp(-c + d - e) == -sqrt(3)
63
+ assert cg_simp(-6*a + 6*b) == -6*sqrt(2)
64
+ assert cg_simp(-4*c + 4*d - 4*e) == -4*sqrt(3)
65
+ a = CG(S.Half, S.Half, S.Half, Rational(-1, 2), j, 0)
66
+ b = CG(S.Half, Rational(-1, 2), S.Half, S.Half, j, 0)
67
+ c = CG(1, 1, 1, -1, j, 0)
68
+ d = CG(1, 0, 1, 0, j, 0)
69
+ e = CG(1, -1, 1, 1, j, 0)
70
+ assert cg_simp(a - b) == sqrt(2)*KroneckerDelta(j, 0)
71
+ assert cg_simp(c - d + e) == sqrt(3)*KroneckerDelta(j, 0)
72
+ assert cg_simp(a - b + c - d + e) == sqrt(
73
+ 2)*KroneckerDelta(j, 0) + sqrt(3)*KroneckerDelta(j, 0)
74
+ assert cg_simp(a - b + c) == sqrt(2)*KroneckerDelta(j, 0) + c
75
+ assert cg_simp(2*a - b) == sqrt(2)*KroneckerDelta(j, 0) + a
76
+ assert cg_simp(2*c - d + e) == sqrt(3)*KroneckerDelta(j, 0) + c
77
+ assert cg_simp(5*a - 5*b) == 5*sqrt(2)*KroneckerDelta(j, 0)
78
+ assert cg_simp(5*c - 5*d + 5*e) == 5*sqrt(3)*KroneckerDelta(j, 0)
79
+ assert cg_simp(-a + b) == -sqrt(2)*KroneckerDelta(j, 0)
80
+ assert cg_simp(-c + d - e) == -sqrt(3)*KroneckerDelta(j, 0)
81
+ assert cg_simp(-6*a + 6*b) == -6*sqrt(2)*KroneckerDelta(j, 0)
82
+ assert cg_simp(-4*c + 4*d - 4*e) == -4*sqrt(3)*KroneckerDelta(j, 0)
83
+ # Test Varshalovich 8.7.2 Eq 9
84
+ # alpha=alphap,beta=betap case
85
+ # numerical
86
+ a = CG(S.Half, S.Half, S.Half, Rational(-1, 2), 1, 0)**2
87
+ b = CG(S.Half, S.Half, S.Half, Rational(-1, 2), 0, 0)**2
88
+ c = CG(1, 0, 1, 1, 1, 1)**2
89
+ d = CG(1, 0, 1, 1, 2, 1)**2
90
+ assert cg_simp(a + b) == 1
91
+ assert cg_simp(c + d) == 1
92
+ assert cg_simp(a + b + c + d) == 2
93
+ assert cg_simp(4*a + 4*b) == 4
94
+ assert cg_simp(4*c + 4*d) == 4
95
+ assert cg_simp(5*a + 3*b) == 3 + 2*a
96
+ assert cg_simp(5*c + 3*d) == 3 + 2*c
97
+ assert cg_simp(-a - b) == -1
98
+ assert cg_simp(-c - d) == -1
99
+ # symbolic
100
+ a = CG(S.Half, m1, S.Half, m2, 1, 1)**2
101
+ b = CG(S.Half, m1, S.Half, m2, 1, 0)**2
102
+ c = CG(S.Half, m1, S.Half, m2, 1, -1)**2
103
+ d = CG(S.Half, m1, S.Half, m2, 0, 0)**2
104
+ assert cg_simp(a + b + c + d) == 1
105
+ assert cg_simp(4*a + 4*b + 4*c + 4*d) == 4
106
+ assert cg_simp(3*a + 5*b + 3*c + 4*d) == 3 + 2*b + d
107
+ assert cg_simp(-a - b - c - d) == -1
108
+ a = CG(1, m1, 1, m2, 2, 2)**2
109
+ b = CG(1, m1, 1, m2, 2, 1)**2
110
+ c = CG(1, m1, 1, m2, 2, 0)**2
111
+ d = CG(1, m1, 1, m2, 2, -1)**2
112
+ e = CG(1, m1, 1, m2, 2, -2)**2
113
+ f = CG(1, m1, 1, m2, 1, 1)**2
114
+ g = CG(1, m1, 1, m2, 1, 0)**2
115
+ h = CG(1, m1, 1, m2, 1, -1)**2
116
+ i = CG(1, m1, 1, m2, 0, 0)**2
117
+ assert cg_simp(a + b + c + d + e + f + g + h + i) == 1
118
+ assert cg_simp(4*(a + b + c + d + e + f + g + h + i)) == 4
119
+ assert cg_simp(a + b + 2*c + d + 4*e + f + g + h + i) == 1 + c + 3*e
120
+ assert cg_simp(-a - b - c - d - e - f - g - h - i) == -1
121
+ # alpha!=alphap or beta!=betap case
122
+ # numerical
123
+ a = CG(S.Half, S(
124
+ 1)/2, S.Half, Rational(-1, 2), 1, 0)*CG(S.Half, Rational(-1, 2), S.Half, S.Half, 1, 0)
125
+ b = CG(S.Half, S(
126
+ 1)/2, S.Half, Rational(-1, 2), 0, 0)*CG(S.Half, Rational(-1, 2), S.Half, S.Half, 0, 0)
127
+ c = CG(1, 1, 1, 0, 2, 1)*CG(1, 0, 1, 1, 2, 1)
128
+ d = CG(1, 1, 1, 0, 1, 1)*CG(1, 0, 1, 1, 1, 1)
129
+ assert cg_simp(a + b) == 0
130
+ assert cg_simp(c + d) == 0
131
+ # symbolic
132
+ a = CG(S.Half, m1, S.Half, m2, 1, 1)*CG(S.Half, m1p, S.Half, m2p, 1, 1)
133
+ b = CG(S.Half, m1, S.Half, m2, 1, 0)*CG(S.Half, m1p, S.Half, m2p, 1, 0)
134
+ c = CG(S.Half, m1, S.Half, m2, 1, -1)*CG(S.Half, m1p, S.Half, m2p, 1, -1)
135
+ d = CG(S.Half, m1, S.Half, m2, 0, 0)*CG(S.Half, m1p, S.Half, m2p, 0, 0)
136
+ assert cg_simp(a + b + c + d) == KroneckerDelta(m1, m1p)*KroneckerDelta(m2, m2p)
137
+ a = CG(1, m1, 1, m2, 2, 2)*CG(1, m1p, 1, m2p, 2, 2)
138
+ b = CG(1, m1, 1, m2, 2, 1)*CG(1, m1p, 1, m2p, 2, 1)
139
+ c = CG(1, m1, 1, m2, 2, 0)*CG(1, m1p, 1, m2p, 2, 0)
140
+ d = CG(1, m1, 1, m2, 2, -1)*CG(1, m1p, 1, m2p, 2, -1)
141
+ e = CG(1, m1, 1, m2, 2, -2)*CG(1, m1p, 1, m2p, 2, -2)
142
+ f = CG(1, m1, 1, m2, 1, 1)*CG(1, m1p, 1, m2p, 1, 1)
143
+ g = CG(1, m1, 1, m2, 1, 0)*CG(1, m1p, 1, m2p, 1, 0)
144
+ h = CG(1, m1, 1, m2, 1, -1)*CG(1, m1p, 1, m2p, 1, -1)
145
+ i = CG(1, m1, 1, m2, 0, 0)*CG(1, m1p, 1, m2p, 0, 0)
146
+ assert cg_simp(
147
+ a + b + c + d + e + f + g + h + i) == KroneckerDelta(m1, m1p)*KroneckerDelta(m2, m2p)
148
+
149
+
150
+ def test_cg_simp_sum():
151
+ x, a, b, c, cp, alpha, beta, gamma, gammap = symbols(
152
+ 'x a b c cp alpha beta gamma gammap')
153
+ # Varshalovich 8.7.1 Eq 1
154
+ assert cg_simp(x * Sum(CG(a, alpha, b, 0, a, alpha), (alpha, -a, a)
155
+ )) == x*(2*a + 1)*KroneckerDelta(b, 0)
156
+ assert cg_simp(x * Sum(CG(a, alpha, b, 0, a, alpha), (alpha, -a, a)) + CG(1, 0, 1, 0, 1, 0)) == x*(2*a + 1)*KroneckerDelta(b, 0) + CG(1, 0, 1, 0, 1, 0)
157
+ assert cg_simp(2 * Sum(CG(1, alpha, 0, 0, 1, alpha), (alpha, -1, 1))) == 6
158
+ # Varshalovich 8.7.1 Eq 2
159
+ assert cg_simp(x*Sum((-1)**(a - alpha) * CG(a, alpha, a, -alpha, c,
160
+ 0), (alpha, -a, a))) == x*sqrt(2*a + 1)*KroneckerDelta(c, 0)
161
+ assert cg_simp(3*Sum((-1)**(2 - alpha) * CG(
162
+ 2, alpha, 2, -alpha, 0, 0), (alpha, -2, 2))) == 3*sqrt(5)
163
+ # Varshalovich 8.7.2 Eq 4
164
+ assert cg_simp(Sum(CG(a, alpha, b, beta, c, gamma)*CG(a, alpha, b, beta, cp, gammap), (alpha, -a, a), (beta, -b, b))) == KroneckerDelta(c, cp)*KroneckerDelta(gamma, gammap)
165
+ assert cg_simp(Sum(CG(a, alpha, b, beta, c, gamma)*CG(a, alpha, b, beta, c, gammap), (alpha, -a, a), (beta, -b, b))) == KroneckerDelta(gamma, gammap)
166
+ assert cg_simp(Sum(CG(a, alpha, b, beta, c, gamma)*CG(a, alpha, b, beta, cp, gamma), (alpha, -a, a), (beta, -b, b))) == KroneckerDelta(c, cp)
167
+ assert cg_simp(Sum(CG(
168
+ a, alpha, b, beta, c, gamma)**2, (alpha, -a, a), (beta, -b, b))) == 1
169
+ assert cg_simp(Sum(CG(2, alpha, 1, beta, 2, gamma)*CG(2, alpha, 1, beta, 2, gammap), (alpha, -2, 2), (beta, -1, 1))) == KroneckerDelta(gamma, gammap)
170
+
171
+
172
+ def test_doit():
173
+ assert Wigner3j(S.Half, Rational(-1, 2), S.Half, S.Half, 0, 0).doit() == -sqrt(2)/2
174
+ assert Wigner6j(1, 2, 3, 2, 1, 2).doit() == sqrt(21)/105
175
+ assert Wigner6j(3, 1, 2, 2, 2, 1).doit() == sqrt(21) / 105
176
+ assert Wigner9j(
177
+ 2, 1, 1, Rational(3, 2), S.Half, 1, S.Half, S.Half, 0).doit() == sqrt(2)/12
178
+ assert CG(S.Half, S.Half, S.Half, Rational(-1, 2), 1, 0).doit() == sqrt(2)/2