示例#1
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);
        }
示例#2
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);
        }
示例#3
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)));
        }