{"id":31074423,"url":"https://github.com/ratwolfzero/schroedingers_cat","last_synced_at":"2025-09-16T02:46:10.615Z","repository":{"id":312101242,"uuid":"1046302050","full_name":"ratwolfzero/Schroedingers_Cat","owner":"ratwolfzero","description":"Schrödinger’s Cat Simulation","archived":false,"fork":false,"pushed_at":"2025-09-07T02:49:55.000Z","size":15620,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-07T04:26:32.851Z","etag":null,"topics":["coherence","decoherence","probability-density","python","quantum-physics","qutip","schrodinger-equation","schroedingers-cat","wave-function","wave-function-collapse"],"latest_commit_sha":null,"homepage":"https://github.com/ratwolfzero/Schroedingers_Cat","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ratwolfzero.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-28T13:40:58.000Z","updated_at":"2025-09-07T02:49:58.000Z","dependencies_parsed_at":"2025-08-28T21:32:50.604Z","dependency_job_id":"5197f801-13d8-4d8f-bca1-b8484147f3b0","html_url":"https://github.com/ratwolfzero/Schroedingers_Cat","commit_stats":null,"previous_names":["ratwolfzero/schroedingers_cat"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ratwolfzero/Schroedingers_Cat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratwolfzero%2FSchroedingers_Cat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratwolfzero%2FSchroedingers_Cat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratwolfzero%2FSchroedingers_Cat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratwolfzero%2FSchroedingers_Cat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ratwolfzero","download_url":"https://codeload.github.com/ratwolfzero/Schroedingers_Cat/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratwolfzero%2FSchroedingers_Cat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275352815,"owners_count":25449498,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-16T02:00:10.229Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coherence","decoherence","probability-density","python","quantum-physics","qutip","schrodinger-equation","schroedingers-cat","wave-function","wave-function-collapse"],"created_at":"2025-09-16T02:46:08.583Z","updated_at":"2025-09-16T02:46:10.597Z","avatar_url":"https://github.com/ratwolfzero.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Schrödinger’s Cat Simulation\n\nThis repository contains a **Python-based simulation of Schrödinger’s cat**, a famous quantum mechanics thought experiment, using the **QuTiP** library.\n\nThe simulation visualizes the quantum superposition of a cat being *alive* and *dead* in phase space via the **Wigner function**, showcasing:\n\n* **Coherent evolution**\n* **Decoherence**\n* **Wave function collapse**\n\n![Simulation](schrodinger_cat.gif)\n\n---\n\n## 📖 Overview\n\nErwin Schrödinger’s 1935 thought experiment illustrates the paradoxical nature of quantum superposition when applied to macroscopic objects:\n\n* A cat is sealed in a box with a radioactive atom, a Geiger counter, and a vial of poison.\n* If the atom decays (50% probability), the poison is released → the cat dies.\n* Until observed, quantum mechanics suggests the cat exists in a **superposition of alive and dead**.\n\nThis simulation models a **quantum analog of the cat state** using a **coherent state superposition** in a harmonic oscillator, visualized through the **Wigner function in phase space**.\n\nIt demonstrates:\n\n* Coherent evolution under a Kerr Hamiltonian → twisting interference patterns\n* Decoherence due to environmental interactions → fading quantum interference\n* Interactive collapse via key press → mimicking measurement\n\n---\n\n## 🧮 Mathematical Background\n\nThe simulation is based on a quantum harmonic oscillator with Hilbert space dimension:\n\n$$\nN = 30\n$$\n\n### Initial Cat State\n\nThe Schrödinger cat state is a superposition of two coherent states:\n\n$$\n|\\psi_\\text{cat}\\rangle = \\frac{1}{\\sqrt{2 \\,(1 + e^{-2|\\alpha|^2})}} \\Big( |\\alpha\\rangle + |-\\alpha\\rangle \\Big), \\quad \\alpha = 2.0\n$$\n\nwhere $|\\alpha\\rangle$ and $|-\\alpha\\rangle$ are coherent states with amplitudes $\\alpha$ and $-\\alpha$.\n\nThe corresponding density matrix is:\n\n$$\n\\rho_0 = |\\psi_\\text{cat}\\rangle \\langle \\psi_\\text{cat}|\n$$\n\n---\n\n### Wigner Function\n\nThe **Wigner function** $W(x,p)$ represents the quantum state in phase space, computed over a grid:\n\n$$\nx, p \\in [-5, 5]\n$$\n\n* Two Gaussian peaks → “Alive” ($x \\approx 2$) and “Dead” ($x \\approx -2$)\n* Interference fringes → signature of quantum superposition\n\nDecomposition of the Wigner function:\n\n$$\nW(x,p) = \\frac{1}{\\mathcal{N}^2} \\Big[ W_\\alpha(x,p) + W_{-\\alpha}(x,p) + W_\\text{interf}(x,p) \\Big]\n$$\n\nwhere:\n\n* $W_\\alpha(x,p)$ = Wigner function of $|\\alpha\\rangle$\n* $W_{-\\alpha}(x,p)$ = Wigner function of $|-\\alpha\\rangle$\n* $W_\\text{interf}(x,p)$ = interference term\n* $\\mathcal{N}^2 = 2(1 + e^{-2|\\alpha|^2})$\n\n![initial](initial_state.png)\n\n---\n\n## Simulation Phases\n\n### 1. Coherent Evolution (t = 2 → 10)\n\nThe state evolves under a **Kerr Hamiltonian**:\n\n$$\nH_\\text{Kerr} = \\kappa \\, (a^\\dagger a)^2, \\quad \\kappa = 0.1\n$$\n\n* Non-linear shearing causes interference fringes to **twist into spirals**\n* Gaussian blobs **distort** in phase space\n\n![Coherent](coherent_evolution.png)\n\n---\n\n### 2. Decoherence (t = 10 → 20)\n\nAfter resetting to $\\rho_0$, decoherence is applied via **amplitude damping**:\n\n$$\nc = \\sqrt{\\gamma} \\, a, \\quad \\gamma = 0.05\n$$\n\n* No Hamiltonian applied ($H = 0$)\n* Interference fringes **fade away**, leaving stationary blobs\n* System resembles a **classical mixture**:\n\n$$\n\\rho_\\text{decoh} \\approx \\frac{1}{2} \\Big( |\\alpha\\rangle \\langle \\alpha| + |-\\alpha\\rangle \\langle -\\alpha| \\Big)\n$$\n\n![Decoherence](decoherence.png)\n\n---\n\n### 3. Collapse (Interactive Measurement)\n\nPressing **“o”** collapses the wave function to:\n\n$$\n|\\psi_\\text{cat}\\rangle \\to\n\\begin{cases}\n|\\alpha\\rangle \u0026 \\text{\"Alive\"} \\\\\n|-\\alpha\\rangle \u0026 \\text{\"Dead\"}\n\\end{cases}\n$$\n\nThe plot updates with a single labeled blob: **Alive** or **Dead**.\n\n![Collapse](alive.png)\n\n---\n\n## 🔍 Interpreting the Results\n\n* **t = 0 → 2 (Static Display):**\n  Two blobs (“Alive” at $x \\approx 2$, “Dead” at $x \\approx -2$) with straight interference fringes.\n\n* **t = 2 → 10 (Coherent Evolution):**\n  Kerr Hamiltonian twists fringes into spirals, blobs distort.\n\n* **t = 10 → 20 (Decoherence):**\n  Fringes fade, blobs remain stationary → classical mixture.\n\n* **Collapse (press “o”):**\n  Single blob remains, labeled Alive or Dead.\n\n---\n\n## 🌌 Quantum Interpretations\n\n* **Copenhagen:** Collapse occurs on measurement (“o” key)\n* **Decoherence:** Environmental interaction destroys interference (phase 2)\n* **Other views:** Many-Worlds, Bohmian Mechanics, QBism also consistent but not explicitly modeled\n\n---\n\n## Quantum Mechanics Timeline\n\nThe following timeline summarizes key milestones in quantum mechanics, highlighting contributions directly relevant to Schrödinger’s Cat (🐱) and tools used in modern simulations like the one described above (🛠️).\n\n| Relevance       | Year | Figure                  | Contribution                                                      |\n| --------------- | ---- | ----------------------- | ----------------------------------------------------------------- |\n|                 | 1900 | Planck                  | Quantum Hypothesis (\"Revolutionary against his will\")             |\n|                 | 1905 | Einstein                | Photoelectric Effect (light as quanta)                            |\n|                 | 1913 | Bohr                    | Atomic Model (quantized orbits)                                   |\n|                 | 1925 | Heisenberg              | Matrix Mechanics (observables, not orbits)                        |\n| 🐱🛠️           | 1926 | Schrödinger             | Wave Mechanics (wavefunction dynamics)                            |\n| 🐱              | 1926 | Born                    | Probabilistic Interpretation (wavefunction → probability)         |\n| 🐱              | 1927 | Bohr/Heisenberg         | Copenhagen Interpretation (measurement \u0026 observer)                |\n|                 | 1928 | Dirac                   | Uniting QM with special relativity (prediction of antimatter)     |\n| 🐱              | 1932 | von Neumann             | Mathematical Foundations (axioms, measurement theory)             |\n| 🐱🛠️           | 1932 | Wigner                  | Phase-space interpretation (Wigner function, quasi-probabilities) |\n| 🐱              | 1935 | Einstein-Podolsky-Rosen | EPR Paradox (QM works, but is it complete? — still debated)       |\n| 🐱              | 1935 | Schrödinger             | Schrödinger’s Cat (paradox of superposition)                      |\n| 🐱🛠️           | 1970 | Zeh                     | Decoherence Theory (quantum-classical transition)                 |\n| 🐱🛠️           | 1980s–2003 | Zurek           | Decoherence and Quantum-Classical Transition (pointer states)     |\n\n**Legend**:  \n\n* 🐱: Directly relevant to Schrödinger’s Cat (superposition, measurement, entanglement).  \n* 🛠️: Relevant as a tool for modern simulations (e.g., wave mechanics, Wigner function, or decoherence used in QuTiP visualizations).\n\n---\n\n## 📚 References\n\n* N. Lambert et al., *QuTiP 5: The Quantum Toolbox in Python*, arXiv:2412.04705 (December 6, 2024). [https://arxiv.org/abs/2412.04705](https://arxiv.org/abs/2412.04705)\n* QuTiP: [https://qutip.org](https://qutip.org)\n* Schrödinger, E. (1980). *The present situation in quantum mechanics*.\n(J. D. Trimmer, Trans.).  \nProceedings of the American Philosophical Society, 124(5), 323–338. (Original work published 1935)\n* Wigner, E. P. (1932). On the quantum correction for thermodynamic equilibrium. Phys. Rev., 40, 749–759.\n* Zeh, H. D. (1970). *On the Interpretation of Measurement in Quantum Theory.* *Foundations of Physics* 1, 69–76.\n* Zurek, W. H. (2003). *Decoherence and the Transition from Quantum to Classical.* [https://doi.org/10.48550/arXiv.quant-ph/0306072](https://doi.org/10.48550/arXiv.quant-ph/0306072)\n* Becker R. (2025). Seeing Quantum Weirdness. Medium.  \n  \u003chttps://medium.com/@ratwolf/seeing-quantum-weirdness-e977d97a3214\u003e\n\n---\n\n## Schrödinger's Cat Simulation technical FAQ\n\n### Q: Why are the red blobs darker during decoherence?\n\nA: This is a visualization effect to highlight the transition, not a physical change. The darker red results from the color scaling (vmin and vmax based on the maximum absolute Wigner value), which emphasizes the remaining amplitude after interference fades.\n\n### Q: Why do the blobs shift slightly during decoherence?\n\nA: In the simulation, amplitude damping with gamma = 0.05 may cause a slight contraction or shift of the initial coherent states toward the origin due to energy loss, a physical decoherence effect. In reality, this effect might be much smaller, depending on the physical system's decoherence rate.\n\n### Q: Are the interference fringes correct?\n\nA: Yes, the sparse fringes reflect the Wigner function’s quantum interference for alpha = 2.0. Adjust alpha or grid size (x, p) in the parameters to explore.\n\n### Q: Is the time step (dt) accurate?\n\nA: With 200 timesteps over 20 units, dt (~0.1) is sufficient. Increase timesteps for higher precision\n\n### Q: Is amplitude damping the only decoherence model?\n\nA: In this simulation, amplitude damping is the default decoherence model, implemented with a collapse operator (c_ops_decoherence) and a damping rate of gamma = 0.05. However, you can modify c_ops_decoherence in the code to include other decoherence models, such as dephasing, to explore different dynamics.\n\n### Q: Is the Wigner function properly normalized?\n\nA: Yes, QuTiP’s wigner ensures normalization. The vmin and vmax in contourf capture the full range—see the plotting section.\n\n### Q: How does collapse work?\n\nA: Pressing 'o' randomly selects a pure state (psi1 or psi2), simulating measurement per the Copenhagen interpretation.\n\n### Q: Can I improve accuracy with higher N or grid resolution?\n\nA: Yes, increase N (currently 30) or x, p grid (currently 130) in the parameters, though it may slow performance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fratwolfzero%2Fschroedingers_cat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fratwolfzero%2Fschroedingers_cat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fratwolfzero%2Fschroedingers_cat/lists"}