Example #1
0
        public void ClebschGordonOrthonormalityMM()
        {
            int t00 = 0;
            int t01 = 0;
            int t1  = 1;

            foreach (Spin j1 in GenerateRandomSpins(0.0, 50.0, 4))
            {
                foreach (Spin j2 in GenerateRandomSpins(0.0, 50.0, 4))
                {
                    foreach (SpinState s1a in GenerateRandomSpinStates(j1, 4))
                    {
                        foreach (SpinState s1b in GenerateRandomSpinStates(j1, 4))
                        {
                            foreach (SpinState s2a in GenerateRandomSpinStates(j2, 4))
                            {
                                foreach (SpinState s2b in GenerateRandomSpinStates(j2, 4))
                                {
                                    // if the sum of M's are equal, all terms will be trivially zero
                                    if ((s1a.M + s2a.M) != (s1b.M + s2b.M))
                                    {
                                        continue;
                                    }

                                    // sum over j and m
                                    double s       = 0.0;
                                    bool   nonZero = false;

                                    double j_min = Math.Abs(j1.J - j2.J);
                                    double j_max = j1.J + j2.J;
                                    for (double j = j_min; j <= j_max; j = j + 1.0)
                                    {
                                        Spin j3 = new Spin(j);
                                        foreach (SpinState s3 in j3.States())
                                        {
                                            double ds = SpinMath.ClebschGodron(s1a, s2a, s3) * SpinMath.ClebschGodron(s1b, s2b, s3);
                                            if (ds != 0.0)
                                            {
                                                nonZero = true;
                                            }
                                            s += ds;
                                        }
                                    }

                                    if ((s1a.M == s1b.M) && (s2a.M == s2b.M))
                                    {
                                        Assert.IsTrue(TestUtilities.IsNearlyEqual(s, 1.0));
                                        t1++;
                                    }
                                    else
                                    {
                                        Assert.IsTrue(Math.Abs(s) < TestUtilities.TargetPrecision);
                                        if (nonZero)
                                        {
                                            t01++;
                                        }
                                        else
                                        {
                                            t00++;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            Console.WriteLine("Trivial zeros: {0}", t00);
            Console.WriteLine("Non-trivial zerios: {0}", t01);
            Console.WriteLine("Ones: {0}", t1);
        }
Example #2
0
        public void ClebschGordonSepcialCase()
        {
            // 0 x 0 => 0

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(0, 0), new SpinState(0, 0), new SpinState(0, 0)), 1.0));

            // 1/2 x 1/2 => 1

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(0.5, 0.5), new SpinState(0.5, 0.5), new SpinState(1.0, 1.0)), 1.0));

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(0.5, 0.5), new SpinState(0.5, -0.5), new SpinState(1.0, 0.0)), Math.Sqrt(1.0 / 2.0)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(0.5, -0.5), new SpinState(0.5, 0.5), new SpinState(1.0, 0.0)), Math.Sqrt(1.0 / 2.0)));

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(0.5, -0.5), new SpinState(0.5, -0.5), new SpinState(1.0, -1.0)), 1.0));

            // 1/2 x 1/2 => 0

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(0.5, 0.5), new SpinState(0.5, -0.5), new SpinState(0.0, 0.0)), Math.Sqrt(1.0 / 2.0)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(0.5, -0.5), new SpinState(0.5, 0.5), new SpinState(0.0, 0.0)), -Math.Sqrt(1.0 / 2.0)));

            // 1 x 1/2 => 3/2

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 1.0), new SpinState(0.5, 0.5), new SpinState(1.5, 1.5)), 1.0));

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 1.0), new SpinState(0.5, -0.5), new SpinState(1.5, 0.5)), Math.Sqrt(1.0 / 3.0)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 0.0), new SpinState(0.5, 0.5), new SpinState(1.5, 0.5)), Math.Sqrt(2.0 / 3.0)));

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 0.0), new SpinState(0.5, -0.5), new SpinState(1.5, -0.5)), Math.Sqrt(2.0 / 3.0)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, -1.0), new SpinState(0.5, 0.5), new SpinState(1.5, -0.5)), Math.Sqrt(1.0 / 3.0)));

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, -1.0), new SpinState(0.5, -0.5), new SpinState(1.5, -1.5)), 1.0));

            // 1 x 1/2 => 1/2

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 1.0), new SpinState(0.5, -0.5), new SpinState(0.5, 0.5)), Math.Sqrt(2.0 / 3.0)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 0.0), new SpinState(0.5, 0.5), new SpinState(0.5, 0.5)), -Math.Sqrt(1.0 / 3.0)));

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 0.0), new SpinState(0.5, -0.5), new SpinState(0.5, -0.5)), Math.Sqrt(1.0 / 3.0)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, -1.0), new SpinState(0.5, 0.5), new SpinState(0.5, -0.5)), -Math.Sqrt(2.0 / 3.0)));

            // 1 x 1 => 2

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 1.0), new SpinState(1.0, 1.0), new SpinState(2.0, 2.0)), 1.0));

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 1.0), new SpinState(1.0, 0.0), new SpinState(2.0, 1.0)), Math.Sqrt(1.0 / 2.0)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 0.0), new SpinState(1.0, 1.0), new SpinState(2.0, 1.0)), Math.Sqrt(1.0 / 2.0)));

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 1.0), new SpinState(1.0, -1.0), new SpinState(2.0, 0.0)), Math.Sqrt(1.0 / 6.0)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 0.0), new SpinState(1.0, 0.0), new SpinState(2.0, 0.0)), Math.Sqrt(2.0 / 3.0)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, -1.0), new SpinState(1.0, 1.0), new SpinState(2.0, 0.0)), Math.Sqrt(1.0 / 6.0)));

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 0.0), new SpinState(1.0, -1.0), new SpinState(2.0, -1.0)), Math.Sqrt(1.0 / 2.0)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, -1.0), new SpinState(1.0, 0.0), new SpinState(2.0, -1.0)), Math.Sqrt(1.0 / 2.0)));

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, -1.0), new SpinState(1.0, -1.0), new SpinState(2.0, -2.0)), 1.0));


            // 1 x 1=> 1

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 1.0), new SpinState(1.0, 0.0), new SpinState(1.0, 1.0)), Math.Sqrt(1.0 / 2.0)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 0.0), new SpinState(1.0, 1.0), new SpinState(1.0, 1.0)), -Math.Sqrt(1.0 / 2.0)));

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 1.0), new SpinState(1.0, -1.0), new SpinState(1.0, 0.0)), Math.Sqrt(1.0 / 2.0)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 0.0), new SpinState(1.0, 0.0), new SpinState(1.0, 0.0)), 0.0));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, -1.0), new SpinState(1.0, 1.0), new SpinState(1.0, 0.0)), -Math.Sqrt(1.0 / 2.0)));

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 0.0), new SpinState(1.0, -1.0), new SpinState(1.0, -1.0)), Math.Sqrt(1.0 / 2.0)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, -1.0), new SpinState(1.0, 0.0), new SpinState(1.0, -1.0)), -Math.Sqrt(1.0 / 2.0)));

            // 1 x 1=> 0

            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 1.0), new SpinState(1.0, -1.0), new SpinState(0.0, 0.0)), Math.Sqrt(1.0 / 3.0)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, 0.0), new SpinState(1.0, 0.0), new SpinState(0.0, 0.0)), -Math.Sqrt(1.0 / 3.0)));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(SpinMath.ClebschGodron(new SpinState(1.0, -1.0), new SpinState(1.0, 1.0), new SpinState(0.0, 0.0)), Math.Sqrt(1.0 / 3.0)));
        }
Example #3
0
        public void ClebschGordonOrthonormalityJM()
        {
            int t00 = 0;
            int t01 = 0;
            int t1  = 0;

            foreach (Spin j1 in GenerateRandomSpins(0.0, 50.0, 4))
            {
                foreach (Spin j2 in GenerateRandomSpins(0.0, 50.0, 4))
                {
                    foreach (Spin j3a in GenerateRandomCombinedSpins(j1, j2, 4))
                    {
                        foreach (Spin j3b in GenerateRandomCombinedSpins(j1, j2, 4))
                        {
                            foreach (SpinState s3a in GenerateRandomSpinStates(j3a, 4))
                            {
                                foreach (SpinState s3b in GenerateRandomSpinStates(j3b, 4))
                                {
                                    // skip the trivial zeros; if the sums of the Ms for each coefficient
                                    // are not the same, no term can be non-zero
                                    if (s3a.M != s3b.M)
                                    {
                                        continue;
                                    }


                                    // sum over m1 and m2
                                    double s       = 0.0;
                                    bool   nonZero = false;

                                    foreach (SpinState s1 in j1.States())
                                    {
                                        foreach (SpinState s2 in j2.States())
                                        {
                                            double ds = SpinMath.ClebschGodron(s1, s2, s3a) * SpinMath.ClebschGodron(s1, s2, s3b);
                                            if (ds != 0.0)
                                            {
                                                nonZero = true;
                                            }
                                            s += ds;
                                        }
                                    }

                                    // check orthonormality
                                    if ((s3a.J == s3b.J) && (s3a.M == s3b.M))
                                    {
                                        Assert.IsTrue(TestUtilities.IsNearlyEqual(s, 1.0));
                                        t1++;
                                    }
                                    else
                                    {
                                        Assert.IsTrue(Math.Abs(s) <= TestUtilities.TargetPrecision);
                                        if (nonZero)
                                        {
                                            t01++;
                                        }
                                        else
                                        {
                                            t00++;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            Console.WriteLine("Trivial zeros: {0}", t00);
            Console.WriteLine("Non-trivial zerios: {0}", t01);
            Console.WriteLine("Ones: {0}", t1);
        }
Example #4
0
        public void SixJThreeJRelation()
        {
            SixJSymbol[] symbols = GenerateRandomSixJSymbols(50.0, 5);
            foreach (SixJSymbol symbol in symbols)
            {
                Spin a = symbol.J1;
                Spin b = symbol.J2;
                Spin c = symbol.J3;
                Spin d = symbol.J4;
                Spin e = symbol.J5;
                Spin f = symbol.J6;

                SpinState[] ams = GenerateRandomSpinStates(a, 2);
                SpinState[] bms = GenerateRandomSpinStates(b, 2);
                foreach (SpinState am in ams)
                {
                    foreach (SpinState bm in bms)
                    {
                        if (Math.Abs(am.M + bm.M) > c.J)
                        {
                            continue;
                        }
                        SpinState cm = new SpinState(c, -(am.M + bm.M));

                        double g1 = SpinMath.ThreeJ(am, bm, cm);
                        double g2 = SpinMath.SixJ(a, b, c, d, e, f);
                        double p  = g1 * g2;

                        double        q   = 0.0;
                        List <double> ts  = new List <double>();
                        SpinState[]   dms = d.States();
                        foreach (SpinState dm in dms)
                        {
                            if (Math.Abs(dm.M + cm.M) > e.J)
                            {
                                continue;
                            }
                            SpinState em  = new SpinState(e, dm.M + cm.M);
                            SpinState mem = new SpinState(e, -em.M);
                            double    f1  = SpinMath.ThreeJ(dm, mem, cm);

                            if (Math.Abs(em.M + am.M) > f.J)
                            {
                                continue;
                            }
                            SpinState fm  = new SpinState(f, em.M + am.M);
                            SpinState mfm = new SpinState(f, -fm.M);
                            double    f2  = SpinMath.ThreeJ(em, mfm, am);

                            SpinState mdm = new SpinState(d, -dm.M);
                            double    f3  = SpinMath.ThreeJ(fm, mdm, bm);

                            double t = f1 * f2 * f3;

                            int s = (int)Math.Round(dm.J + dm.M + em.J + em.M + fm.J + fm.M);
                            if (s % 2 != 0)
                            {
                                t = -t;
                            }

                            q += t;
                            ts.Add(t);
                        }

                        Console.WriteLine("{0} v. {1}", p, q);
                        //Assert.IsTrue(TestUtilities.IsNearlyEqual(p, q));
                        Assert.IsTrue(TestUtilities.IsSumNearlyEqual(ts, p));
                    }
                }
            }
        }