private void AddLeptons() { // ADD ELECTRON Electron e = new Electron(); particles.Add(e); // ADD MUON Muon muon = new Muon(); particles.Add(muon); // ADD TAUON Tauon tau = new Tauon(); particles.Add(tau); // ADD ELECTRON NEUTRINO ElectronNeutrino nu_e = new ElectronNeutrino(); particles.Add(nu_e); // ADD MUON NEUTRINO MuonNeutrino nu_muon = new MuonNeutrino(); particles.Add(nu_muon); // ADD TAUON NEUTRINO TauonNeutrino nu_tau = new TauonNeutrino(); particles.Add(nu_tau); }
public void UntrackElectron(Electron electron) { unanalyzedElectrons.Remove(electron); analyzedElectrons.Remove(electron); AnalyzeElectrons(); }
public static async Task Main(string[] args) { IWebHostBuilder builder; #if DEBUG var webPort = Electron.Experimental.FreeTcpPort(); await Electron.Experimental.StartElectronForDevelopment(webPort); builder = CreateWebHostBuilder(args); // check for the content folder if its exists in base director otherwise no need to include // It was used before because we are publishing the project which copies everything to bin folder and contentroot wwwroot was folder there. // now we have implemented the live reload if app is run using /watch then we need to use the default project path. if (Directory.Exists($"{AppDomain.CurrentDomain.BaseDirectory}\\wwwroot")) { builder.UseContentRoot(AppDomain.CurrentDomain.BaseDirectory); } builder.UseUrls("http://localhost:" + webPort); #else builder = CreateWebHostBuilder(args); Debugger.Launch(); Electron.ReadAuth(); builder.UseElectron(args); #endif await builder.Build().RunAsync(); }
public void Verify_Entangled_Electrons_Maintain_Entanglement() { Electron one = new Electron(); Electron two = new Electron(); int count_diff = 0; int count_all = 0; // measure them both on the X axis for (int i = 0; i < 1000; ++i) { one.Randomize(); two.EntangleSpins(one); // measure them both on the X axis - a bunch of times! for (int j = 0; j < 1000; ++j) { ++count_all; if (one.Spin(SPIN_AXIS.SPIN_AXIS_X) != two.Spin(SPIN_AXIS.SPIN_AXIS_X)) { ++count_diff; } } } // measure them both on the Y axis for (int i = 0; i < 1000; ++i) { one.Randomize(); two.EntangleSpins(one); // measure them both on the Y axis - a bunch of times! for (int j = 0; j < 1000; ++j) { ++count_all; if (one.Spin(SPIN_AXIS.SPIN_AXIS_Y) != two.Spin(SPIN_AXIS.SPIN_AXIS_Y)) { ++count_diff; } } } // measure them both on the Z axis for (int i = 0; i < 1000; ++i) { one.Randomize(); two.EntangleSpins(one); // measure them both on the Z axis - a bunch of times! for (int j = 0; j < 1000; ++j) { ++count_all; if (one.Spin(SPIN_AXIS.SPIN_AXIS_Z) != two.Spin(SPIN_AXIS.SPIN_AXIS_Z)) { ++count_diff; } } } Assert.True(count_diff == count_all, "Must allways be anti-correlated."); }
/// <summary> /// Populates the <see cref="Orbital"/> with an electron. /// </summary> public void Populate() { if (this[0] == null) { this[0] = new Electron(ElectronSpin.Up); return; } this[1] = new Electron(ElectronSpin.Down); }
//As electron is spawned, analyze its projectile data and give it a call-back to update analysis if it bounces public void TrackElectron(Electron electron) { if (!unanalyzedElectrons.Contains(electron)) { unanalyzedElectrons.Add(electron); } electron.SetBounceCallback(UpdateTrackedElectron); AnalyzeElectrons(); }
public void Verify_Entangled_Electrons_Decohere() { Electron one = new Electron(); Electron two = new Electron(); int count_diff = 0; int count_all = 0; // measure them both on the X axis for (int i = 0; i < 1000; ++i) { one.Randomize(); two.EntangleSpins(one); ++count_all; bool measure_once = one.Spin(SPIN_AXIS.SPIN_AXIS_Z) != two.Spin(SPIN_AXIS.SPIN_AXIS_Z); // measurement on Z should break entanglement on X if (one.Spin(SPIN_AXIS.SPIN_AXIS_X) != two.Spin(SPIN_AXIS.SPIN_AXIS_X)) { ++count_diff; } } // measure them both on the Y axis for (int i = 0; i < 1000; ++i) { one.Randomize(); two.EntangleSpins(one); ++count_all; bool measure_once = one.Spin(SPIN_AXIS.SPIN_AXIS_X) != two.Spin(SPIN_AXIS.SPIN_AXIS_X); // measurement on X should break entanglement on Y if (one.Spin(SPIN_AXIS.SPIN_AXIS_Y) != two.Spin(SPIN_AXIS.SPIN_AXIS_Y)) { ++count_diff; } } // measure them both on the Z axis for (int i = 0; i < 1000; ++i) { one.Randomize(); two.EntangleSpins(one); ++count_all; bool measure_once = one.Spin(SPIN_AXIS.SPIN_AXIS_Y) != two.Spin(SPIN_AXIS.SPIN_AXIS_Y); // measurement on Y should break entanglement on Z if (one.Spin(SPIN_AXIS.SPIN_AXIS_Z) != two.Spin(SPIN_AXIS.SPIN_AXIS_Z)) { ++count_diff; } } Assert.False(count_diff == count_all, "Must not always be anti-correlated."); }
public void UpdateTrackedElectron(Electron electron) { //When an electron bounces, its projectile data is now useless and we should recalculate it analyzedElectrons.Remove(electron); if (!unanalyzedElectrons.Contains(electron)) { unanalyzedElectrons.Add(electron); } AnalyzeElectrons(); }
void SpawnElectron(int index) { GameObject elecObj = GameObject.Instantiate(electronTemp); elecObj.transform.parent = electronContainer.transform; elecObj.transform.localPosition = Vector3.zero; Electron electron = elecObj.GetComponent <Electron> (); ElectronData data = CalculateElectronData(index); electron.SetElectronLocation(data.position); electron.SetRotation(sphere.transform.position, data.normal, speed); elecObj.SetActive(true); }
public void generateElectron(Vector3 pos, float r, int shell) { GameObject electron = (GameObject)Instantiate(Resources.Load("Electron")); electron.name = "Electron"; electron.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f); electron.transform.position = pos; electron.transform.parent = GameObject.Find("Shell " + shell).transform; GameObject.Destroy(electron.GetComponent <SphereCollider>()); Electron e = electron.AddComponent <Electron>(); e.radius = r; e.centre = transform; e.rotationSpeed = 8 + (10 * shell); }
//TODO: the Launcher shouldn't own the logic to bind the Bot's tracking to the individual Electrons //this may be better done in whatever manager takes care of pooling the Electrons //all of the pooled Electrons could be given the callback once at scene start public void FireElectron(Vector3 firingForce) { GameObject elecObj = Instantiate <GameObject>(electronPrefab, electronParent, true); elecObj.name = "Electron " + id++; elecObj.transform.position = electronSpawn.position; Rigidbody elecRB = elecObj.GetComponent <Rigidbody>(); elecRB.velocity = firingForce; //elecRB.AddForce(firingForce); Electron electron = elecObj.GetComponent <Electron>(); UpdateBotTracking(electron); }
public void Verify_Randomized_Electrons_Not_Entangled() { Electron one = new Electron(); Electron two = new Electron(); int count_diff = 0; // we count anti-correlation int count_all = 0; // measure them both on the X axis for (int i = 0; i < 1000; ++i) { one.Randomize(); two.Randomize(); ++count_all; if (one.Spin(SPIN_AXIS.SPIN_AXIS_X) != two.Spin(SPIN_AXIS.SPIN_AXIS_X)) { ++count_diff; } } // measure them both on the Y axis for (int i = 0; i < 1000; ++i) { one.Randomize(); two.Randomize(); ++count_all; if (one.Spin(SPIN_AXIS.SPIN_AXIS_Y) != two.Spin(SPIN_AXIS.SPIN_AXIS_Y)) { ++count_diff; } } // measure them both on the Z axis for (int i = 0; i < 1000; ++i) { one.Randomize(); two.Randomize(); ++count_all; if (one.Spin(SPIN_AXIS.SPIN_AXIS_Z) != two.Spin(SPIN_AXIS.SPIN_AXIS_Z)) { ++count_diff; } } Assert.False(count_diff == count_all, "Should not all be anti-correlated."); }
void MakeOrbits(int electrons, int orbitCount) { int elRest = electrons; for (int i = 0; i <= orbitCount; i++) { GameObject orbit = new GameObject(); orbit.name = "Orbit" + i; orbit.transform.parent = transform; orbit.transform.localPosition = Vector3.zero; CircleLine myRing = Instantiate <CircleLine>(ring); myRing.SetOrbitCapacity(elAndO[i, 0]); myRing.SetElectronCount(elAndO[i, 1]); myRing.CreatePoints(orbitRadius * (i + 1)); myRing.transform.parent = transform; myRing.transform.localPosition = Vector3.zero; //Shell for Orbit GameObject Shell = Instantiate <GameObject>(pulseObj); Shell.transform.parent = orbit.transform; Shell.transform.localPosition = Vector3.zero; float sr = (i + 1) * orbitRadius * 2f; Shell.transform.localScale = new Vector3(sr, sr, sr); //Electrons for (int j = 0; j < orbitThreshold[i]; j++) { Electron ele = Instantiate <Electron>(myElectron); ele.transform.parent = orbit.transform; float partinCircle = (float)j / orbitThreshold[i]; ele.Arrange(i, orbitRadius, partinCircle); elRest--; if (elRest <= 0) { return; } } } }
void Start() { Camera camera = Camera.main; limitX = camera.orthographicSize * camera.aspect; limitY = camera.orthographicSize; for (int i = 0; i < count; ++i) { Electron electron = new Electron(); electron.gameObject = Instantiate<GameObject>(prefab); electron.gameObject.transform.SetParent(transform, false); electrons.Add(electron); electron.position = new Vector2( (Random.value - 0.5f) * 2f * limitX, (Random.value - 0.5f) * 2f * limitY ); } }
public void FireElectron() { GameObject elecObj = Instantiate <GameObject>(electronPrefab, electronParent, true); elecObj.name = "Electron " + id++; elecObj.transform.position = electronSpawn.position; Vector3 randomForce = new Vector3( Random.Range(minFiringForce.x, maxFiringForce.x), Random.Range(minFiringForce.y, maxFiringForce.y), 0); Rigidbody elecRB = elecObj.GetComponent <Rigidbody>(); elecRB.velocity = randomForce; //elecRB.AddForce(randomForce); Electron electron = elecObj.GetComponent <Electron>(); UpdateBotTracking(electron); }
private ProjectileTrajectoryData AnalyzeTarget(Electron proj, Vector3 currentCatcherPosition) { //Calculate an electron's landing time and position based on its velocity //Store this in ProjectileTrajectoryData so we don't have to recalculate anything until a collision occurs float timeToGround; if (proj.rb.velocity.y > 0) { float timeToRise = proj.rb.velocity.y / -Physics.gravity.y; float maxHeight = proj.transform.position.y + proj.rb.velocity.y * timeToRise - (0.5f * -Physics.gravity.y * Mathf.Pow(timeToRise, 2)); float timeToFall = Mathf.Sqrt((2f * (maxHeight - landingPlaneHeight)) / -Physics.gravity.y); timeToGround = timeToRise + timeToFall; //Debug.Log("Upward projectile analysis for " + proj.gameObject.name + ": timeToGround = " + timeToGround + //", maxHeight = " + maxHeight + ", timeToFall = " + timeToFall); } else { timeToGround = (-proj.rb.velocity.y - Mathf.Sqrt(Mathf.Abs(Mathf.Pow(proj.rb.velocity.y, 2) - (2f * Physics.gravity.y * -(landingPlaneHeight - proj.transform.position.y))))) / Physics.gravity.y; //Debug.Log("Falling projectile analysis for " + proj.gameObject.name + ": timeToGround = " + timeToGround + //", y0 = " + proj.transform.position.y + ", Vy0 = " + proj.rb.velocity.y); } Vector3 landingLocation = new Vector3( proj.rb.velocity.x * timeToGround + proj.rb.position.x, landingPlaneHeight, proj.rb.velocity.z * timeToGround + proj.rb.position.z); float distance = Vector3.Distance(landingLocation, currentCatcherPosition); float timeToCatch = distance / moveSpeed; ProjectileTrajectoryData projectileData = new ProjectileTrajectoryData(); projectileData.landingTimestamp = timeToGround + Time.time; projectileData.landingLocation = landingLocation; projectileData.catchable = IsCatchable(projectileData, currentCatcherPosition); return(projectileData); }
/// <summary> Helper method to calculate correlation on chosen axes. </summary> /// <param name="A"> The spin axis for Alice. </param> /// <param name="B"> The spin axis for Bob. </param> /// <param name="count"> The optional number of tests to run. Default 1000. </param> public static double CorrelateElectronsOnAxes(SPIN_AXIS A, SPIN_AXIS B, int count = 1000) { Electron one = new Electron(); Electron two = new Electron(); double count_same = 0.0; double count_diff = 0.0; double count_all = 0.0; for (int i = 0; i < count; ++i) { one.Randomize(); two.EntangleSpins(one); int isA = one.Spin(A); int isB = two.Spin(B); count_all += 1.0; if (isA == isB) { count_same += 1.0; } else { count_diff += 1.0; } } // sadly, I forget where I saw this equation for calculating the correlation. // usually it is more like: // // C = (num_pp + num_mm - num_pm - num_mp) / (num_pp + num_mm + num_pm + num_mp) // // but this is arithmetically equivalent. ( when strictly using real numbers. ) // return((count_same - count_diff) / count_all); }
private void UpdateBotTracking(Electron electron) { bot.TrackElectron(electron); electron.SetDisableCallback(bot.UntrackElectron); }
/// <summary> /// Run the three axes Bell Inequality Test against Sinnable Electrons. /// </summary> /// <remarks> /// See https://en.wikipedia.org/wiki/Sakurai%27s_Bell_inequality /// </remarks> internal static void BellTriAxisElectronSpinTest() { SPIN_AXIS[] filters = { SPIN_AXIS.SPIN_AXIS_X, SPIN_AXIS.SPIN_AXIS_Y, SPIN_AXIS.SPIN_AXIS_Z }; // every test works with two photons. Electron one = new Electron(); Electron two = new Electron(); // various counts of the tests that pass the spin question. int count_same = 0; int count_same_XY = 0; int count_same_YZ = 0; int count_same_ZX = 0; int count_all = 0; int count_all_XY = 0; int count_all_YZ = 0; int count_all_ZX = 0; for (int i = 0; i < 1000; ++i) { // force them to pick different filters // X + Y, Y + Z, Z + X int index_A = (i + 0) % 3; int index_B = (i + 1) % 3; SPIN_AXIS A = filters[index_A]; SPIN_AXIS B = filters[index_B]; // each test starts with a randomized particle one.Randomize(); // and a particle in _perfect_ entanglement with it. two.EntangleSpins(one); int answer_A = one.Spin(A); int answer_B = two.Spin(B); count_all++; // so we can know how many on each filter. switch (index_A) { case 0: ++count_all_XY; break; case 1: ++count_all_YZ; break; case 2: ++count_all_ZX; break; } // count when they are in agreement. if (answer_A == answer_B) { ++count_same; // and again, on each filter. switch (index_A) { case 0: ++count_same_XY; break; case 1: ++count_same_YZ; break; case 2: ++count_same_ZX; break; } } } // correlation regardless of axes choice double CE = (2.0 * count_same - count_all) / count_all; // correlation on specific axes choice double Cxy = (2.0 * count_same_XY - count_all_XY) / count_all_XY; double Cyz = (2.0 * count_same_YZ - count_all_YZ) / count_all_YZ; double Czx = (2.0 * count_same_ZX - count_all_ZX) / count_all_ZX; // estimate of correlation combined. double Ch = Cxy - Cyz - Czx; bool spooky = (Ch >= 1.0); Console.WriteLine(String.Format("Ce={0} Ch={1}, from {2} == {3}", CE, Ch, count_all, spooky ? "Spooky" : "Classic")); }
public Orbital(IOrbitalGroup of) { Of = of ?? throw new ArgumentNullException(nameof(of)); SpinUp = new Electron(); SpinDown = new Electron(); }
public void Spawn() { randomLocation = Random.Range(0, 9); electron = Instantiate(electronPrefab, spawnLocation[randomLocation], Quaternion.identity) as Electron; }