示例#1
0
        public void FixedFiftyFiftyTest()
        {
            Vector3D detectorAngle = VectorFactory.Create(0);
            Vector3D particleAngle = VectorFactory.Create(90);
            var      detector      = new Detector(detectorAngle);

            int count = 0;

            for (int i = 0; i < iterationCount; ++i)
            {
                var particle = new Particle(VectorFactory.Create());

                // Force the particle direction.
                particle.ExposeToField(particleAngle);

                if (detector.InDirectionOfDetector(particle))
                {
                    ++count;
                }
            }

            int expected = (int)(iterationCount * 0.50);

            Assert.AreEqual(expected, count, margin);
        }
示例#2
0
        // @see EPR paradox.
        public void JohnBellTest()
        {
            int count  = 0;
            var random = new Random(Guid.NewGuid().GetHashCode());

            for (int i = 0; i < iterationCount; ++i)
            {
                var particle1 = new Particle(VectorFactory.Create());
                var particle2 = new Particle(particle1);

                var detector1 = new Detector(VectorFactory.Create(random.Next(3) * 120));
                var detector2 = new Detector(VectorFactory.Create(random.Next(3) * 120));

                bool up1 = detector1.InDirectionOfDetector(particle1);
                bool up2 = detector2.InDirectionOfDetector(particle2);

                if (up1 != up2)
                {
                    ++count;
                }
            }

            int expected = (int)(iterationCount * 0.50);

            Assert.AreEqual(expected, count, margin);
        }
示例#3
0
        public void FortyFiveDegreesTest()
        {
            var detector1 = new Detector(VectorFactory.Create(0));
            var detector2 = new Detector(VectorFactory.Create(45));

            int count = 0;

            for (int i = 0; i < iterationCount; ++i)
            {
                var particle1 = new Particle(VectorFactory.Create());
                var particle2 = new Particle(particle1);

                bool up1 = detector1.InDirectionOfDetector(particle1);
                bool up2 = detector2.InDirectionOfDetector(particle2);

                if (up1 != up2)
                {
                    ++count;
                }
            }

            int expected = (int)(iterationCount * 0.85);

            Assert.AreEqual(expected, count, margin);
        }
示例#4
0
        static void Main(string[] args)
        {
            /*
             * Note: If both detectors have the same angle
             * the spin of the entangled particles
             * will be opposite 100% of the time.
             *
             * If the detectors are opposite the spin
             * will be equal 100% of the time.
             *
             * But, and this the point;
             * if the difference between the detectors
             * is 45 degrees (PI/4), the spin
             * will be opposite 85% of the time.
             * (not 75 as classical physics predicts)
             */

            var d1 = new Detector(new Vector3D(1, 0, 0));
            var d2 = new Detector(new Vector3D(0, 1, 0));

            int diffs = 0;

            for (int i = 0; i < 10000; ++i)
            {
                var p1 = new Particle(VectorFactory.Create());
                var p2 = new Particle(p1);

                bool up1 = false, up2 = false;

                bool async = true;
                if (async)
                {
                    Parallel.Invoke(
                        () => Detect(d1, p1, out up1),
                        () => Detect(d2, p2, out up2)
                        );
                }
                else
                {
                    Detect(d1, p1, out up1);
                    Detect(d2, p2, out up2);
                }

                Console.WriteLine(up1);
                Console.WriteLine(up2);

                if (up1 != up2)
                {
                    ++diffs;
                }

                Console.WriteLine();
            }

            Console.WriteLine(diffs);

            Console.ReadKey();
        }
示例#5
0
        public void OppositeDirectionTest()
        {
            Vector3D angle    = VectorFactory.Create(0);
            var      detector = new Detector(angle);

            for (int i = 0; i < 1000; ++i)
            {
                var particle1 = new Particle(VectorFactory.Create());
                var particle2 = new Particle(particle1);

                bool up1 = detector.InDirectionOfDetector(particle1);
                bool up2 = detector.InDirectionOfDetector(particle2);

                Assert.AreNotEqual(up1, up2);
            }
        }
示例#6
0
        public void RandomFiftyFiftyTest()
        {
            Vector3D angle    = VectorFactory.Create(0);
            var      detector = new Detector(angle);

            int count = 0;

            for (int i = 0; i < iterationCount; ++i)
            {
                var particle = new Particle(VectorFactory.Create());

                if (detector.InDirectionOfDetector(particle))
                {
                    ++count;
                }
            }

            int expected = (int)(iterationCount * 0.50);

            Assert.AreEqual(count, expected, margin);
        }
示例#7
0
        public void SixtyDegreesTest()
        {
            Vector3D detectorAngle = VectorFactory.Create(60);
            var      detector      = new Detector(detectorAngle);

            int count = 0;

            for (int i = 0; i < iterationCount; ++i)
            {
                Vector3D particleAngle = VectorFactory.Create(180);
                var      particle      = new Particle(particleAngle);

                bool up = detector.InDirectionOfDetector(particle);

                if (up)
                {
                    ++count;
                }
            }

            int expected = (int)(iterationCount * 0.75);

            Assert.AreEqual(expected, count, margin);
        }