physicskit 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- physicskit/__init__.py +51 -0
- physicskit/astro/__init__.py +66 -0
- physicskit/astro/cosmic_web.py +395 -0
- physicskit/astro/galactic_dynamics.py +137 -0
- physicskit/astro/nbody.py +208 -0
- physicskit/astro/orbital_mechanics.py +220 -0
- physicskit/astro/stellar_dynamo.py +628 -0
- physicskit/astro/stellar_structure.py +198 -0
- physicskit/astro/tests/__init__.py +0 -0
- physicskit/astro/tests/conftest.py +7 -0
- physicskit/astro/tests/test_cosmic_web.py +159 -0
- physicskit/astro/tests/test_galactic_dynamics.py +46 -0
- physicskit/astro/tests/test_nbody.py +81 -0
- physicskit/astro/tests/test_orbital_mechanics.py +73 -0
- physicskit/astro/tests/test_stellar_dynamo.py +198 -0
- physicskit/astro/tests/test_stellar_structure.py +52 -0
- physicskit/astro/tests/test_visualizers.py +159 -0
- physicskit/astro/visualizers.py +628 -0
- physicskit/chaos/__init__.py +55 -0
- physicskit/chaos/core/__init__.py +3 -0
- physicskit/chaos/core/base_system.py +342 -0
- physicskit/chaos/core/integrators.py +40 -0
- physicskit/chaos/exceptions.py +24 -0
- physicskit/chaos/quantum/__init__.py +38 -0
- physicskit/chaos/quantum/billiards.py +274 -0
- physicskit/chaos/quantum/husimi.py +85 -0
- physicskit/chaos/quantum/maps.py +366 -0
- physicskit/chaos/systems/__init__.py +38 -0
- physicskit/chaos/systems/billiards.py +1131 -0
- physicskit/chaos/systems/continuous.py +1276 -0
- physicskit/chaos/systems/maps.py +557 -0
- physicskit/chaos/tests/__init__.py +0 -0
- physicskit/chaos/tests/test_basins.py +76 -0
- physicskit/chaos/tests/test_bifurcation.py +132 -0
- physicskit/chaos/tests/test_billiards.py +115 -0
- physicskit/chaos/tests/test_continuous.py +224 -0
- physicskit/chaos/tests/test_dimension.py +69 -0
- physicskit/chaos/tests/test_divergence.py +90 -0
- physicskit/chaos/tests/test_dynamic_plots.py +269 -0
- physicskit/chaos/tests/test_integrators.py +96 -0
- physicskit/chaos/tests/test_io.py +41 -0
- physicskit/chaos/tests/test_maps.py +110 -0
- physicskit/chaos/tests/test_metrics.py +115 -0
- physicskit/chaos/tests/test_phase_space.py +73 -0
- physicskit/chaos/tests/test_properties.py +116 -0
- physicskit/chaos/tests/test_quantum_billiards.py +94 -0
- physicskit/chaos/tests/test_quantum_maps.py +144 -0
- physicskit/chaos/tests/test_recurrence.py +51 -0
- physicskit/chaos/tests/test_repr_and_api_consistency.py +134 -0
- physicskit/chaos/tests/test_section.py +49 -0
- physicskit/chaos/tests/test_spectral.py +48 -0
- physicskit/chaos/tests/test_streamlit_app.py +45 -0
- physicskit/chaos/tests/test_timeseries.py +131 -0
- physicskit/chaos/tests/test_viewer3d.py +41 -0
- physicskit/chaos/utils/__init__.py +46 -0
- physicskit/chaos/utils/dimension.py +139 -0
- physicskit/chaos/utils/io.py +95 -0
- physicskit/chaos/utils/metrics.py +304 -0
- physicskit/chaos/utils/recurrence.py +122 -0
- physicskit/chaos/utils/spectral.py +69 -0
- physicskit/chaos/utils/timeseries.py +303 -0
- physicskit/chaos/visualizers/__init__.py +85 -0
- physicskit/chaos/visualizers/basins.py +185 -0
- physicskit/chaos/visualizers/bifurcation.py +273 -0
- physicskit/chaos/visualizers/divergence.py +374 -0
- physicskit/chaos/visualizers/dynamic_plots.py +1372 -0
- physicskit/chaos/visualizers/phase_space.py +133 -0
- physicskit/chaos/visualizers/quantum.py +299 -0
- physicskit/chaos/visualizers/recurrence.py +91 -0
- physicskit/chaos/visualizers/section.py +161 -0
- physicskit/chaos/visualizers/theme.py +31 -0
- physicskit/chaos/visualizers/viewer3d.py +82 -0
- physicskit/classical/__init__.py +55 -0
- physicskit/classical/core/__init__.py +17 -0
- physicskit/classical/core/base_system.py +510 -0
- physicskit/classical/core/integrators.py +397 -0
- physicskit/classical/systems/__init__.py +32 -0
- physicskit/classical/systems/chains.py +334 -0
- physicskit/classical/systems/hamiltonian.py +215 -0
- physicskit/classical/systems/lagrangian.py +308 -0
- physicskit/classical/systems/newtonian.py +536 -0
- physicskit/classical/systems/rotations.py +614 -0
- physicskit/classical/tests/__init__.py +0 -0
- physicskit/classical/tests/conftest.py +7 -0
- physicskit/classical/tests/test_base_system.py +113 -0
- physicskit/classical/tests/test_chains.py +84 -0
- physicskit/classical/tests/test_conservation.py +244 -0
- physicskit/classical/tests/test_conservation_utils.py +47 -0
- physicskit/classical/tests/test_hamiltonian.py +44 -0
- physicskit/classical/tests/test_integrators.py +123 -0
- physicskit/classical/tests/test_lagrangian.py +69 -0
- physicskit/classical/tests/test_newtonian.py +45 -0
- physicskit/classical/tests/test_rotations.py +160 -0
- physicskit/classical/tests/test_stepsize.py +149 -0
- physicskit/classical/tests/test_symbolic.py +125 -0
- physicskit/classical/tests/test_visualizers.py +172 -0
- physicskit/classical/utils/__init__.py +20 -0
- physicskit/classical/utils/conservation.py +126 -0
- physicskit/classical/utils/stepsize.py +187 -0
- physicskit/classical/utils/symbolic.py +235 -0
- physicskit/classical/visualizers/__init__.py +25 -0
- physicskit/classical/visualizers/animations.py +508 -0
- physicskit/classical/visualizers/interactive.py +113 -0
- physicskit/classical/visualizers/modal_analysis.py +97 -0
- physicskit/classical/visualizers/phase_space.py +214 -0
- physicskit/condensed/__init__.py +122 -0
- physicskit/condensed/anderson_localization.py +155 -0
- physicskit/condensed/correlated.py +284 -0
- physicskit/condensed/ginzburg_landau.py +220 -0
- physicskit/condensed/landau_levels.py +246 -0
- physicskit/condensed/laughlin.py +229 -0
- physicskit/condensed/models.py +627 -0
- physicskit/condensed/tests/__init__.py +0 -0
- physicskit/condensed/tests/test_condensed.py +518 -0
- physicskit/condensed/tests/test_visualizers.py +87 -0
- physicskit/condensed/tight_binding.py +445 -0
- physicskit/condensed/topological_insulator_3d.py +178 -0
- physicskit/condensed/topology.py +217 -0
- physicskit/condensed/visualizers.py +296 -0
- physicskit/condensed/weyl.py +180 -0
- physicskit/constants.py +184 -0
- physicskit/fields/__init__.py +111 -0
- physicskit/fields/electrodynamics.py +671 -0
- physicskit/fields/quantum_fields.py +510 -0
- physicskit/fields/solitons.py +527 -0
- physicskit/fields/tests/__init__.py +0 -0
- physicskit/fields/tests/conftest.py +7 -0
- physicskit/fields/tests/test_field_animations.py +154 -0
- physicskit/fields/tests/test_fields.py +439 -0
- physicskit/fields/tests/test_visualizers.py +101 -0
- physicskit/fields/visualizers.py +503 -0
- physicskit/fluids/__init__.py +134 -0
- physicskit/fluids/core/__init__.py +23 -0
- physicskit/fluids/core/grid.py +165 -0
- physicskit/fluids/core/timestepping.py +231 -0
- physicskit/fluids/exceptions.py +26 -0
- physicskit/fluids/systems/__init__.py +70 -0
- physicskit/fluids/systems/compressible_flow.py +281 -0
- physicskit/fluids/systems/instabilities.py +343 -0
- physicskit/fluids/systems/navier_stokes.py +221 -0
- physicskit/fluids/systems/potential_flow.py +440 -0
- physicskit/fluids/systems/viscous_flow.py +425 -0
- physicskit/fluids/systems/vortex_dynamics.py +304 -0
- physicskit/fluids/tests/__init__.py +0 -0
- physicskit/fluids/tests/conftest.py +7 -0
- physicskit/fluids/tests/test_compressible_flow.py +66 -0
- physicskit/fluids/tests/test_instabilities.py +115 -0
- physicskit/fluids/tests/test_navier_stokes.py +67 -0
- physicskit/fluids/tests/test_potential_flow.py +92 -0
- physicskit/fluids/tests/test_static_visualizers.py +91 -0
- physicskit/fluids/tests/test_utils.py +100 -0
- physicskit/fluids/tests/test_viscous_flow.py +110 -0
- physicskit/fluids/tests/test_visualizers.py +34 -0
- physicskit/fluids/tests/test_vortex_dynamics.py +88 -0
- physicskit/fluids/utils/__init__.py +18 -0
- physicskit/fluids/utils/dimensionless.py +239 -0
- physicskit/fluids/utils/spectral_analysis.py +142 -0
- physicskit/fluids/visualizers/__init__.py +14 -0
- physicskit/fluids/visualizers/compressible.py +39 -0
- physicskit/fluids/visualizers/flow_fields.py +252 -0
- physicskit/fluids/visualizers/potential_flow.py +51 -0
- physicskit/fluids/visualizers/spectra.py +62 -0
- physicskit/fluids/visualizers/theme.py +38 -0
- physicskit/integrators/__init__.py +52 -0
- physicskit/integrators/adaptive.py +199 -0
- physicskit/integrators/fixed_step.py +360 -0
- physicskit/integrators/tests/__init__.py +0 -0
- physicskit/integrators/tests/test_integrators.py +101 -0
- physicskit/optics/__init__.py +124 -0
- physicskit/optics/_compat.py +5 -0
- physicskit/optics/gaussian.py +382 -0
- physicskit/optics/quantum_optics.py +428 -0
- physicskit/optics/ray.py +469 -0
- physicskit/optics/tests/__init__.py +0 -0
- physicskit/optics/tests/test_diffraction_animation.py +38 -0
- physicskit/optics/tests/test_gaussian.py +170 -0
- physicskit/optics/tests/test_quantum_optics.py +147 -0
- physicskit/optics/tests/test_ray.py +177 -0
- physicskit/optics/tests/test_visualizers.py +58 -0
- physicskit/optics/tests/test_wave.py +146 -0
- physicskit/optics/visualizers.py +264 -0
- physicskit/optics/wave.py +365 -0
- physicskit/particle/__init__.py +152 -0
- physicskit/particle/collider.py +382 -0
- physicskit/particle/confinement.py +125 -0
- physicskit/particle/decays.py +357 -0
- physicskit/particle/electroweak.py +300 -0
- physicskit/particle/kinematics.py +271 -0
- physicskit/particle/neutrinos.py +84 -0
- physicskit/particle/nuclear.py +100 -0
- physicskit/particle/scattering.py +159 -0
- physicskit/particle/tests/__init__.py +0 -0
- physicskit/particle/tests/conftest.py +7 -0
- physicskit/particle/tests/test_collider.py +119 -0
- physicskit/particle/tests/test_confinement.py +42 -0
- physicskit/particle/tests/test_decays.py +112 -0
- physicskit/particle/tests/test_electroweak.py +97 -0
- physicskit/particle/tests/test_kinematics.py +138 -0
- physicskit/particle/tests/test_neutrinos.py +36 -0
- physicskit/particle/tests/test_nuclear.py +45 -0
- physicskit/particle/tests/test_scattering.py +64 -0
- physicskit/particle/tests/test_visualizers.py +214 -0
- physicskit/particle/visualizers/__init__.py +38 -0
- physicskit/particle/visualizers/animations.py +705 -0
- physicskit/particle/visualizers/static.py +101 -0
- physicskit/plasma/__init__.py +176 -0
- physicskit/plasma/acceleration.py +152 -0
- physicskit/plasma/instabilities.py +417 -0
- physicskit/plasma/kinetic.py +588 -0
- physicskit/plasma/mhd.py +463 -0
- physicskit/plasma/single_particle.py +562 -0
- physicskit/plasma/tests/__init__.py +0 -0
- physicskit/plasma/tests/conftest.py +7 -0
- physicskit/plasma/tests/test_new_time_domain_features.py +222 -0
- physicskit/plasma/tests/test_plasma.py +232 -0
- physicskit/plasma/tests/test_visualizers.py +79 -0
- physicskit/plasma/turbulence.py +219 -0
- physicskit/plasma/visualizers.py +868 -0
- physicskit/plasma/waves.py +549 -0
- physicskit/quantum/__init__.py +180 -0
- physicskit/quantum/_compat.py +20 -0
- physicskit/quantum/chapters/__init__.py +0 -0
- physicskit/quantum/chapters/entanglement.py +489 -0
- physicskit/quantum/chapters/harmonic_spin.py +517 -0
- physicskit/quantum/chapters/hydrogen_am.py +292 -0
- physicskit/quantum/chapters/perturbation.py +350 -0
- physicskit/quantum/chapters/potentials.py +997 -0
- physicskit/quantum/chapters/spin.py +306 -0
- physicskit/quantum/chapters/wave_packets.py +541 -0
- physicskit/quantum/core/__init__.py +0 -0
- physicskit/quantum/core/eigensolvers.py +311 -0
- physicskit/quantum/core/operators.py +296 -0
- physicskit/quantum/core/solvers.py +271 -0
- physicskit/quantum/tests/__init__.py +0 -0
- physicskit/quantum/tests/conftest.py +7 -0
- physicskit/quantum/tests/test_animations.py +225 -0
- physicskit/quantum/tests/test_compat.py +43 -0
- physicskit/quantum/tests/test_eigensolvers.py +24 -0
- physicskit/quantum/tests/test_entanglement.py +127 -0
- physicskit/quantum/tests/test_harmonic_spin.py +140 -0
- physicskit/quantum/tests/test_hydrogen_am.py +48 -0
- physicskit/quantum/tests/test_measure.py +110 -0
- physicskit/quantum/tests/test_operators.py +105 -0
- physicskit/quantum/tests/test_perturbation.py +112 -0
- physicskit/quantum/tests/test_physics_checks.py +131 -0
- physicskit/quantum/tests/test_potentials.py +191 -0
- physicskit/quantum/tests/test_solvers.py +70 -0
- physicskit/quantum/tests/test_spin.py +22 -0
- physicskit/quantum/tests/test_unitarity.py +84 -0
- physicskit/quantum/tests/test_wave_packets.py +53 -0
- physicskit/quantum/utils/__init__.py +0 -0
- physicskit/quantum/utils/measure.py +253 -0
- physicskit/quantum/visualizers/__init__.py +0 -0
- physicskit/quantum/visualizers/bloch_sphere.py +205 -0
- physicskit/quantum/visualizers/entanglement.py +58 -0
- physicskit/quantum/visualizers/orbitals.py +187 -0
- physicskit/quantum/visualizers/phase_space.py +179 -0
- physicskit/quantum/visualizers/wavefunctions.py +230 -0
- physicskit/relativity/__init__.py +61 -0
- physicskit/relativity/chapters/__init__.py +33 -0
- physicskit/relativity/chapters/cosmology.py +190 -0
- physicskit/relativity/chapters/gw_merger.py +399 -0
- physicskit/relativity/chapters/kerr.py +371 -0
- physicskit/relativity/chapters/lensing.py +196 -0
- physicskit/relativity/chapters/neutron_star.py +149 -0
- physicskit/relativity/chapters/schwarzschild.py +412 -0
- physicskit/relativity/chapters/timekeeping.py +133 -0
- physicskit/relativity/core/__init__.py +12 -0
- physicskit/relativity/core/geodesics.py +216 -0
- physicskit/relativity/core/kerr_raytracer.py +259 -0
- physicskit/relativity/core/raytracer.py +241 -0
- physicskit/relativity/core/tensors.py +468 -0
- physicskit/relativity/tests/__init__.py +0 -0
- physicskit/relativity/tests/test_conservations.py +54 -0
- physicskit/relativity/tests/test_constants.py +34 -0
- physicskit/relativity/tests/test_cosmology.py +61 -0
- physicskit/relativity/tests/test_gw_merger.py +117 -0
- physicskit/relativity/tests/test_kerr.py +116 -0
- physicskit/relativity/tests/test_kerr_raytracer.py +103 -0
- physicskit/relativity/tests/test_lensing.py +75 -0
- physicskit/relativity/tests/test_neutron_star.py +48 -0
- physicskit/relativity/tests/test_raytracer.py +67 -0
- physicskit/relativity/tests/test_schwarzschild.py +126 -0
- physicskit/relativity/tests/test_shadow_render.py +81 -0
- physicskit/relativity/tests/test_tensors.py +86 -0
- physicskit/relativity/tests/test_timekeeping.py +51 -0
- physicskit/relativity/tests/test_visualizers_misc.py +115 -0
- physicskit/relativity/utils/__init__.py +1 -0
- physicskit/relativity/utils/constants.py +232 -0
- physicskit/relativity/visualizers/__init__.py +46 -0
- physicskit/relativity/visualizers/interactive.py +127 -0
- physicskit/relativity/visualizers/shadow_render.py +367 -0
- physicskit/relativity/visualizers/spacetime_3d.py +92 -0
- physicskit/relativity/visualizers/spacetime_diagrams.py +198 -0
- physicskit/relativity/visualizers/wave_plots.py +185 -0
- physicskit/rmt/__init__.py +8 -0
- physicskit/rmt/ensembles/__init__.py +108 -0
- physicskit/rmt/ensembles/banded.py +114 -0
- physicskit/rmt/ensembles/base.py +135 -0
- physicskit/rmt/ensembles/bdg.py +218 -0
- physicskit/rmt/ensembles/chiral.py +308 -0
- physicskit/rmt/ensembles/circular.py +104 -0
- physicskit/rmt/ensembles/crossover.py +82 -0
- physicskit/rmt/ensembles/density_matrix.py +148 -0
- physicskit/rmt/ensembles/effective_hamiltonian.py +230 -0
- physicskit/rmt/ensembles/embedded.py +207 -0
- physicskit/rmt/ensembles/gaussian.py +153 -0
- physicskit/rmt/ensembles/ginibre.py +110 -0
- physicskit/rmt/ensembles/girko.py +190 -0
- physicskit/rmt/ensembles/graph_laplacian.py +92 -0
- physicskit/rmt/ensembles/haar.py +57 -0
- physicskit/rmt/ensembles/jacobi.py +182 -0
- physicskit/rmt/ensembles/poisson.py +77 -0
- physicskit/rmt/ensembles/polynomial.py +139 -0
- physicskit/rmt/ensembles/pt_symmetric.py +120 -0
- physicskit/rmt/ensembles/single_ring.py +170 -0
- physicskit/rmt/ensembles/sparse.py +95 -0
- physicskit/rmt/ensembles/syk.py +170 -0
- physicskit/rmt/ensembles/truncated_unitary.py +80 -0
- physicskit/rmt/ensembles/universality.py +92 -0
- physicskit/rmt/ensembles/wishart.py +88 -0
- physicskit/rmt/py.typed +0 -0
- physicskit/rmt/spectrum.py +82 -0
- physicskit/rmt/stats/__init__.py +160 -0
- physicskit/rmt/stats/characteristic_polynomial.py +77 -0
- physicskit/rmt/stats/circular_law.py +54 -0
- physicskit/rmt/stats/correlations.py +162 -0
- physicskit/rmt/stats/density.py +70 -0
- physicskit/rmt/stats/entanglement.py +36 -0
- physicskit/rmt/stats/free_probability.py +202 -0
- physicskit/rmt/stats/localization.py +338 -0
- physicskit/rmt/stats/marchenko_pastur.py +55 -0
- physicskit/rmt/stats/pt_symmetric.py +265 -0
- physicskit/rmt/stats/ratios.py +110 -0
- physicskit/rmt/stats/real_ginibre.py +134 -0
- physicskit/rmt/stats/rigidity.py +272 -0
- physicskit/rmt/stats/single_ring.py +95 -0
- physicskit/rmt/stats/spacing.py +150 -0
- physicskit/rmt/stats/tracy_widom.py +175 -0
- physicskit/rmt/stats/truncated_unitary.py +40 -0
- physicskit/rmt/stats/unfolding.py +37 -0
- physicskit/rmt/stats/wachter.py +67 -0
- physicskit/rmt/tests/__init__.py +0 -0
- physicskit/rmt/tests/cache_utils.py +107 -0
- physicskit/rmt/tests/conftest.py +8 -0
- physicskit/rmt/tests/test_banded.py +86 -0
- physicskit/rmt/tests/test_base.py +29 -0
- physicskit/rmt/tests/test_bdg.py +133 -0
- physicskit/rmt/tests/test_characteristic_polynomial.py +50 -0
- physicskit/rmt/tests/test_chiral.py +273 -0
- physicskit/rmt/tests/test_circular.py +225 -0
- physicskit/rmt/tests/test_crossover.py +72 -0
- physicskit/rmt/tests/test_density.py +23 -0
- physicskit/rmt/tests/test_density_matrix.py +181 -0
- physicskit/rmt/tests/test_effective_hamiltonian.py +140 -0
- physicskit/rmt/tests/test_embedded.py +169 -0
- physicskit/rmt/tests/test_free_probability.py +81 -0
- physicskit/rmt/tests/test_gaussian_ensembles.py +22 -0
- physicskit/rmt/tests/test_gaussian_semicircle.py +127 -0
- physicskit/rmt/tests/test_ginibre_circular_law.py +131 -0
- physicskit/rmt/tests/test_girko.py +178 -0
- physicskit/rmt/tests/test_graph_laplacian.py +102 -0
- physicskit/rmt/tests/test_haar.py +118 -0
- physicskit/rmt/tests/test_jacobi_wachter.py +136 -0
- physicskit/rmt/tests/test_localization.py +240 -0
- physicskit/rmt/tests/test_poisson.py +149 -0
- physicskit/rmt/tests/test_polynomial.py +107 -0
- physicskit/rmt/tests/test_pt_symmetric.py +178 -0
- physicskit/rmt/tests/test_random_state.py +19 -0
- physicskit/rmt/tests/test_real_ginibre.py +112 -0
- physicskit/rmt/tests/test_rigidity_universality.py +167 -0
- physicskit/rmt/tests/test_single_ring.py +132 -0
- physicskit/rmt/tests/test_spacing_and_ratios.py +122 -0
- physicskit/rmt/tests/test_sparse.py +71 -0
- physicskit/rmt/tests/test_spectrum.py +27 -0
- physicskit/rmt/tests/test_syk.py +136 -0
- physicskit/rmt/tests/test_tracy_widom.py +113 -0
- physicskit/rmt/tests/test_tridiagonal.py +41 -0
- physicskit/rmt/tests/test_truncated_unitary.py +80 -0
- physicskit/rmt/tests/test_validation_base.py +25 -0
- physicskit/rmt/tests/test_validation_misc.py +67 -0
- physicskit/rmt/tests/test_wishart_marchenko_pastur.py +120 -0
- physicskit/rmt/utils/__init__.py +0 -0
- physicskit/rmt/utils/haar.py +128 -0
- physicskit/rmt/utils/random_state.py +24 -0
- physicskit/rmt/utils/tridiagonal.py +167 -0
- physicskit/rmt/validation/__init__.py +36 -0
- physicskit/rmt/validation/base.py +126 -0
- physicskit/rmt/validation/circular_law.py +80 -0
- physicskit/rmt/validation/marchenko_pastur.py +53 -0
- physicskit/rmt/validation/ratio_distribution.py +53 -0
- physicskit/rmt/validation/real_ginibre.py +60 -0
- physicskit/rmt/validation/sine_kernel.py +57 -0
- physicskit/rmt/validation/single_ring.py +68 -0
- physicskit/rmt/validation/tracy_widom.py +89 -0
- physicskit/rmt/validation/universality.py +100 -0
- physicskit/rmt/validation/wachter.py +52 -0
- physicskit/rmt/validation/wigner_semicircle.py +40 -0
- physicskit/rmt/validation/wigner_surmise.py +58 -0
- physicskit/semiclassical/__init__.py +94 -0
- physicskit/semiclassical/_compat.py +5 -0
- physicskit/semiclassical/core/__init__.py +41 -0
- physicskit/semiclassical/core/gutzwiller.py +215 -0
- physicskit/semiclassical/core/path_integral.py +594 -0
- physicskit/semiclassical/core/propagators.py +579 -0
- physicskit/semiclassical/core/wkb.py +308 -0
- physicskit/semiclassical/systems/__init__.py +13 -0
- physicskit/semiclassical/systems/scarring.py +278 -0
- physicskit/semiclassical/tests/__init__.py +0 -0
- physicskit/semiclassical/tests/test_gutzwiller.py +35 -0
- physicskit/semiclassical/tests/test_path_integral.py +194 -0
- physicskit/semiclassical/tests/test_propagators.py +82 -0
- physicskit/semiclassical/tests/test_scarring.py +43 -0
- physicskit/semiclassical/tests/test_visualizers.py +89 -0
- physicskit/semiclassical/tests/test_wkb.py +30 -0
- physicskit/semiclassical/visualizers/__init__.py +17 -0
- physicskit/semiclassical/visualizers/gutzwiller.py +55 -0
- physicskit/semiclassical/visualizers/path_integral.py +195 -0
- physicskit/semiclassical/visualizers/propagators.py +89 -0
- physicskit/semiclassical/visualizers/scarring.py +146 -0
- physicskit/semiclassical/visualizers/wkb.py +55 -0
- physicskit/statphys/__init__.py +80 -0
- physicskit/statphys/chapters/__init__.py +43 -0
- physicskit/statphys/chapters/ehrenfest_urn.py +112 -0
- physicskit/statphys/chapters/ising_lattice.py +431 -0
- physicskit/statphys/chapters/kpz_growth.py +129 -0
- physicskit/statphys/chapters/molecular_dynamics.py +258 -0
- physicskit/statphys/chapters/nonequilibrium_work.py +146 -0
- physicskit/statphys/chapters/percolation.py +305 -0
- physicskit/statphys/chapters/random_walk.py +142 -0
- physicskit/statphys/chapters/renormalization.py +148 -0
- physicskit/statphys/chapters/sandpile.py +109 -0
- physicskit/statphys/chapters/spin_glass.py +275 -0
- physicskit/statphys/core/__init__.py +10 -0
- physicskit/statphys/core/kpz_engine.py +53 -0
- physicskit/statphys/core/md_engine.py +157 -0
- physicskit/statphys/core/monte_carlo.py +462 -0
- physicskit/statphys/core/random_walk_engine.py +68 -0
- physicskit/statphys/core/sandpile_engine.py +52 -0
- physicskit/statphys/tests/__init__.py +0 -0
- physicskit/statphys/tests/test_dynamics.py +66 -0
- physicskit/statphys/tests/test_ehrenfest_urn.py +44 -0
- physicskit/statphys/tests/test_finite_size_scaling.py +62 -0
- physicskit/statphys/tests/test_interactive.py +33 -0
- physicskit/statphys/tests/test_ising.py +68 -0
- physicskit/statphys/tests/test_kpz.py +55 -0
- physicskit/statphys/tests/test_landau_theory.py +49 -0
- physicskit/statphys/tests/test_md_engine.py +31 -0
- physicskit/statphys/tests/test_molecular_dynamics.py +72 -0
- physicskit/statphys/tests/test_nonequilibrium_work.py +33 -0
- physicskit/statphys/tests/test_partition_function.py +26 -0
- physicskit/statphys/tests/test_percolation.py +116 -0
- physicskit/statphys/tests/test_potts_model.py +46 -0
- physicskit/statphys/tests/test_random_walk.py +50 -0
- physicskit/statphys/tests/test_renormalization.py +44 -0
- physicskit/statphys/tests/test_sandpile.py +44 -0
- physicskit/statphys/tests/test_spin_glass.py +73 -0
- physicskit/statphys/tests/test_thermodynamics.py +121 -0
- physicskit/statphys/tests/test_xy_model.py +45 -0
- physicskit/statphys/utils/__init__.py +1 -0
- physicskit/statphys/utils/dynamics.py +100 -0
- physicskit/statphys/utils/finite_size_scaling.py +171 -0
- physicskit/statphys/utils/landau_theory.py +151 -0
- physicskit/statphys/utils/partition_function.py +109 -0
- physicskit/statphys/utils/thermodynamics.py +356 -0
- physicskit/statphys/visualizers/__init__.py +87 -0
- physicskit/statphys/visualizers/interactive.py +161 -0
- physicskit/statphys/visualizers/jarzynski_render.py +44 -0
- physicskit/statphys/visualizers/kpz_render.py +65 -0
- physicskit/statphys/visualizers/lattice_render.py +212 -0
- physicskit/statphys/visualizers/particle_render.py +121 -0
- physicskit/statphys/visualizers/random_walk_render.py +106 -0
- physicskit/statphys/visualizers/rg_render.py +45 -0
- physicskit/statphys/visualizers/sandpile_render.py +65 -0
- physicskit/statphys/visualizers/spin_glass_render.py +40 -0
- physicskit/statphys/visualizers/urn_render.py +38 -0
- physicskit/statphys/visualizers/vortex_render.py +84 -0
- physicskit/tests/__init__.py +0 -0
- physicskit/tests/test_constants.py +38 -0
- physicskit-0.1.0.dist-info/METADATA +196 -0
- physicskit-0.1.0.dist-info/RECORD +484 -0
- physicskit-0.1.0.dist-info/WHEEL +5 -0
- physicskit-0.1.0.dist-info/licenses/LICENSE +21 -0
- physicskit-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"""physicskit.quantum: a visual and computational tour of quantum mechanics.
|
|
2
|
+
|
|
3
|
+
- :mod:`physicskit.quantum.core.eigensolvers` -- the Numerov shooting-method
|
|
4
|
+
bound-state solver, plus ready-made potential wells (infinite, finite,
|
|
5
|
+
asymmetric step, linear-gravitational, double, harmonic).
|
|
6
|
+
- :mod:`physicskit.quantum.core.operators` -- spin, ladder, position, and
|
|
7
|
+
momentum operators as explicit matrices, the Pauli matrices, and generic
|
|
8
|
+
commutator/expectation-value/Hermiticity utilities.
|
|
9
|
+
- :mod:`physicskit.quantum.core.solvers` -- split-operator time propagation
|
|
10
|
+
for the time-dependent Schrodinger equation, in 1D and 2D.
|
|
11
|
+
- :mod:`physicskit.quantum.chapters.wave_packets` -- free and dispersing
|
|
12
|
+
Gaussian wave packets, the double-slit experiment, and quantum revivals.
|
|
13
|
+
- :mod:`physicskit.quantum.chapters.potentials` -- asymmetric/step wells,
|
|
14
|
+
the quantum bouncer, the double well, the finite square well, and 2D
|
|
15
|
+
quantum boxes (rectangle, circular dot, stadium billiard).
|
|
16
|
+
- :mod:`physicskit.quantum.chapters.hydrogen_am` -- the hydrogen atom's
|
|
17
|
+
exact radial and angular (spherical harmonic) wavefunctions.
|
|
18
|
+
- :mod:`physicskit.quantum.chapters.harmonic_spin` -- the quantum harmonic
|
|
19
|
+
oscillator (ladder operators, coherent states) and thermal (mixed) states.
|
|
20
|
+
- :mod:`physicskit.quantum.chapters.perturbation` -- the Zeeman and Stark
|
|
21
|
+
effects, and a Floquet-driven infinite square well.
|
|
22
|
+
- :mod:`physicskit.quantum.chapters.entanglement` -- Bell states and CHSH
|
|
23
|
+
correlations, and the Aharonov-Bohm ring.
|
|
24
|
+
|
|
25
|
+
See :mod:`physicskit.semiclassical` for WKB/EBK quantization, Van
|
|
26
|
+
Vleck/Herman-Kluk semiclassical propagators, the Gutzwiller trace
|
|
27
|
+
formula, and quantum scarring.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
__version__ = "0.1.0"
|
|
31
|
+
|
|
32
|
+
from physicskit.quantum.chapters.entanglement import (
|
|
33
|
+
AharonovBohmRing,
|
|
34
|
+
BellCorrelations,
|
|
35
|
+
IsingEntangler,
|
|
36
|
+
bell_state,
|
|
37
|
+
)
|
|
38
|
+
from physicskit.quantum.chapters.harmonic_spin import HarmonicOscillator, ThermalState
|
|
39
|
+
from physicskit.quantum.chapters.hydrogen_am import (
|
|
40
|
+
HydrogenOrbital,
|
|
41
|
+
orbital_superposition_density,
|
|
42
|
+
orbital_superposition_psi,
|
|
43
|
+
radial_wavefunction,
|
|
44
|
+
spherical_harmonic,
|
|
45
|
+
)
|
|
46
|
+
from physicskit.quantum.chapters.perturbation import (
|
|
47
|
+
FloquetDrivenBox,
|
|
48
|
+
StarkLevel,
|
|
49
|
+
linear_stark_shift,
|
|
50
|
+
stark_n2_quartet,
|
|
51
|
+
zeeman_spectrum,
|
|
52
|
+
zeeman_splitting,
|
|
53
|
+
)
|
|
54
|
+
from physicskit.quantum.chapters.potentials import (
|
|
55
|
+
Box2DEigenstate,
|
|
56
|
+
CircularBox2D,
|
|
57
|
+
CircularEigenstate,
|
|
58
|
+
DoubleWellResult,
|
|
59
|
+
DoubleWellSimulator,
|
|
60
|
+
FiniteSquareWell,
|
|
61
|
+
RectangularBox2D,
|
|
62
|
+
ScatteringResult,
|
|
63
|
+
StadiumBilliard2D,
|
|
64
|
+
airy_bouncer_energies,
|
|
65
|
+
airy_wavefunction,
|
|
66
|
+
asymmetric_well_states,
|
|
67
|
+
gravitational_bouncer_states,
|
|
68
|
+
)
|
|
69
|
+
from physicskit.quantum.chapters.spin import RabiProblem, SternGerlach
|
|
70
|
+
from physicskit.quantum.chapters.wave_packets import (
|
|
71
|
+
GaussianDispersion,
|
|
72
|
+
QuantumRevival,
|
|
73
|
+
TwinSlit,
|
|
74
|
+
double_slit_potential,
|
|
75
|
+
free_gaussian_wavepacket,
|
|
76
|
+
propagate_double_slit,
|
|
77
|
+
)
|
|
78
|
+
from physicskit.quantum.core.eigensolvers import (
|
|
79
|
+
EigenResult,
|
|
80
|
+
NumerovSolver,
|
|
81
|
+
asymmetric_step_well,
|
|
82
|
+
double_well,
|
|
83
|
+
finite_well,
|
|
84
|
+
harmonic_well,
|
|
85
|
+
infinite_well,
|
|
86
|
+
linear_gravitational_well,
|
|
87
|
+
)
|
|
88
|
+
from physicskit.quantum.core.operators import (
|
|
89
|
+
annihilation_operator,
|
|
90
|
+
anticommutator,
|
|
91
|
+
commutator,
|
|
92
|
+
creation_operator,
|
|
93
|
+
expectation,
|
|
94
|
+
identity2,
|
|
95
|
+
is_hermitian,
|
|
96
|
+
momentum_operator,
|
|
97
|
+
number_operator,
|
|
98
|
+
position_operator,
|
|
99
|
+
sigma_x,
|
|
100
|
+
sigma_y,
|
|
101
|
+
sigma_z,
|
|
102
|
+
spin_operator,
|
|
103
|
+
)
|
|
104
|
+
from physicskit.quantum.core.solvers import SplitOperatorSolver1D, SplitOperatorSolver2D
|
|
105
|
+
|
|
106
|
+
__all__ = [
|
|
107
|
+
"__version__",
|
|
108
|
+
# core.eigensolvers
|
|
109
|
+
"EigenResult",
|
|
110
|
+
"NumerovSolver",
|
|
111
|
+
"infinite_well",
|
|
112
|
+
"finite_well",
|
|
113
|
+
"asymmetric_step_well",
|
|
114
|
+
"linear_gravitational_well",
|
|
115
|
+
"double_well",
|
|
116
|
+
"harmonic_well",
|
|
117
|
+
# core.operators
|
|
118
|
+
"sigma_x",
|
|
119
|
+
"sigma_y",
|
|
120
|
+
"sigma_z",
|
|
121
|
+
"identity2",
|
|
122
|
+
"spin_operator",
|
|
123
|
+
"annihilation_operator",
|
|
124
|
+
"creation_operator",
|
|
125
|
+
"number_operator",
|
|
126
|
+
"position_operator",
|
|
127
|
+
"momentum_operator",
|
|
128
|
+
"commutator",
|
|
129
|
+
"anticommutator",
|
|
130
|
+
"expectation",
|
|
131
|
+
"is_hermitian",
|
|
132
|
+
# core.solvers
|
|
133
|
+
"SplitOperatorSolver1D",
|
|
134
|
+
"SplitOperatorSolver2D",
|
|
135
|
+
# chapters.wave_packets
|
|
136
|
+
"free_gaussian_wavepacket",
|
|
137
|
+
"GaussianDispersion",
|
|
138
|
+
"TwinSlit",
|
|
139
|
+
"QuantumRevival",
|
|
140
|
+
"double_slit_potential",
|
|
141
|
+
"propagate_double_slit",
|
|
142
|
+
# chapters.potentials
|
|
143
|
+
"asymmetric_well_states",
|
|
144
|
+
"gravitational_bouncer_states",
|
|
145
|
+
"airy_bouncer_energies",
|
|
146
|
+
"airy_wavefunction",
|
|
147
|
+
"DoubleWellResult",
|
|
148
|
+
"DoubleWellSimulator",
|
|
149
|
+
"ScatteringResult",
|
|
150
|
+
"FiniteSquareWell",
|
|
151
|
+
"Box2DEigenstate",
|
|
152
|
+
"RectangularBox2D",
|
|
153
|
+
"CircularEigenstate",
|
|
154
|
+
"CircularBox2D",
|
|
155
|
+
"StadiumBilliard2D",
|
|
156
|
+
# chapters.hydrogen_am
|
|
157
|
+
"spherical_harmonic",
|
|
158
|
+
"radial_wavefunction",
|
|
159
|
+
"HydrogenOrbital",
|
|
160
|
+
"orbital_superposition_psi",
|
|
161
|
+
"orbital_superposition_density",
|
|
162
|
+
# chapters.harmonic_spin
|
|
163
|
+
"HarmonicOscillator",
|
|
164
|
+
"ThermalState",
|
|
165
|
+
# chapters.perturbation
|
|
166
|
+
"zeeman_splitting",
|
|
167
|
+
"zeeman_spectrum",
|
|
168
|
+
"linear_stark_shift",
|
|
169
|
+
"StarkLevel",
|
|
170
|
+
"stark_n2_quartet",
|
|
171
|
+
"FloquetDrivenBox",
|
|
172
|
+
# chapters.entanglement
|
|
173
|
+
"bell_state",
|
|
174
|
+
"BellCorrelations",
|
|
175
|
+
"AharonovBohmRing",
|
|
176
|
+
"IsingEntangler",
|
|
177
|
+
# chapters.spin
|
|
178
|
+
"SternGerlach",
|
|
179
|
+
"RabiProblem",
|
|
180
|
+
]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Small compatibility shims.
|
|
2
|
+
|
|
3
|
+
numpy>=2.0 renamed trapz to trapezoid; scipy>=1.15 added sph_harm_y and
|
|
4
|
+
deprecated the older sph_harm, so on an installed scipy<1.15 (dependencies
|
|
5
|
+
only require scipy>=1.10) we fall back to sph_harm with its swapped
|
|
6
|
+
argument order and angle convention.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import numpy as np
|
|
10
|
+
|
|
11
|
+
trapz = np.trapezoid if hasattr(np, "trapezoid") else np.trapz
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
from scipy.special import sph_harm_y as sph_harm_y
|
|
15
|
+
except ImportError: # scipy < 1.15
|
|
16
|
+
from scipy.special import sph_harm as _sph_harm
|
|
17
|
+
|
|
18
|
+
def sph_harm_y(n, m, theta, phi):
|
|
19
|
+
"""``sph_harm_y(n, m, theta, phi)`` with theta=polar, phi=azimuthal."""
|
|
20
|
+
return _sph_harm(m, n, phi, theta)
|
|
File without changes
|
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
r"""Entanglement, Bell/EPR correlations, and the Aharonov-Bohm effect."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from itertools import product
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
|
|
10
|
+
from ..core.operators import sigma_x, sigma_z
|
|
11
|
+
|
|
12
|
+
__all__ = ["bell_state", "BellCorrelations", "AharonovBohmRing", "IsingEntangler"]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# --- Bell states -------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def bell_state(kind: str = "phi+") -> np.ndarray:
|
|
19
|
+
r"""One of the four maximally entangled two-qubit Bell states.
|
|
20
|
+
|
|
21
|
+
In the computational basis :math:`\lvert00\rangle, \lvert01\rangle,
|
|
22
|
+
\lvert10\rangle, \lvert11\rangle`:
|
|
23
|
+
|
|
24
|
+
.. math::
|
|
25
|
+
|
|
26
|
+
\lvert\Phi^\pm\rangle = \tfrac{1}{\sqrt2}(\lvert00\rangle \pm \lvert11\rangle),
|
|
27
|
+
\qquad
|
|
28
|
+
\lvert\Psi^\pm\rangle = \tfrac{1}{\sqrt2}(\lvert01\rangle \pm \lvert10\rangle).
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
kind : {'phi+', 'phi-', 'psi+', 'psi-'}, default='phi+'
|
|
33
|
+
Which Bell state to return. ``'psi-'`` is the spin singlet.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
numpy.ndarray
|
|
38
|
+
The 4-component state vector.
|
|
39
|
+
|
|
40
|
+
Raises
|
|
41
|
+
------
|
|
42
|
+
ValueError
|
|
43
|
+
If ``kind`` is not one of the four valid labels.
|
|
44
|
+
"""
|
|
45
|
+
s = 1 / np.sqrt(2)
|
|
46
|
+
states = {
|
|
47
|
+
"phi+": s * np.array([1, 0, 0, 1], dtype=complex),
|
|
48
|
+
"phi-": s * np.array([1, 0, 0, -1], dtype=complex),
|
|
49
|
+
"psi+": s * np.array([0, 1, 1, 0], dtype=complex),
|
|
50
|
+
"psi-": s * np.array([0, 1, -1, 0], dtype=complex), # the spin singlet
|
|
51
|
+
}
|
|
52
|
+
if kind not in states:
|
|
53
|
+
raise ValueError(f"kind must be one of {list(states)}")
|
|
54
|
+
return states[kind]
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _spin_projector(theta: float) -> np.ndarray:
|
|
58
|
+
"""Single-qubit measurement operator for spin along an axis at angle
|
|
59
|
+
theta from z in the x-z plane: cos(theta) sigma_z + sin(theta) sigma_x."""
|
|
60
|
+
return np.cos(theta) * sigma_z + np.sin(theta) * sigma_x
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@dataclass
|
|
64
|
+
class BellCorrelations:
|
|
65
|
+
r"""EPR correlations for the spin-1/2 singlet state.
|
|
66
|
+
|
|
67
|
+
.. math::
|
|
68
|
+
|
|
69
|
+
\lvert\psi^-\rangle = \frac{\lvert01\rangle - \lvert10\rangle}{\sqrt2}.
|
|
70
|
+
|
|
71
|
+
Reproduces the textbook result
|
|
72
|
+
:math:`E(a,b) = -\cos(\theta_a - \theta_b)` and the CHSH violation of
|
|
73
|
+
the classical (local hidden-variable) bound :math:`\lvert S\rvert \le 2`,
|
|
74
|
+
up to the quantum (Tsirelson) bound :math:`2\sqrt2`.
|
|
75
|
+
|
|
76
|
+
Parameters
|
|
77
|
+
----------
|
|
78
|
+
state : numpy.ndarray or None, optional
|
|
79
|
+
The two-qubit state to use; defaults to the singlet
|
|
80
|
+
:func:`bell_state`\ ``('psi-')``.
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
state: np.ndarray = None
|
|
84
|
+
|
|
85
|
+
def __post_init__(self):
|
|
86
|
+
if self.state is None:
|
|
87
|
+
self.state = bell_state("psi-")
|
|
88
|
+
|
|
89
|
+
def correlation(self, theta_a: float, theta_b: float) -> float:
|
|
90
|
+
r"""The spin correlation :math:`E(a,b) = \langle\psi\rvert
|
|
91
|
+
\hat A(\theta_a) \otimes \hat B(\theta_b) \lvert\psi\rangle`.
|
|
92
|
+
|
|
93
|
+
Parameters
|
|
94
|
+
----------
|
|
95
|
+
theta_a : float
|
|
96
|
+
Measurement angle for qubit 1 (from :math:`z`, in the x-z plane).
|
|
97
|
+
theta_b : float
|
|
98
|
+
Measurement angle for qubit 2.
|
|
99
|
+
|
|
100
|
+
Returns
|
|
101
|
+
-------
|
|
102
|
+
float
|
|
103
|
+
"""
|
|
104
|
+
A = _spin_projector(theta_a)
|
|
105
|
+
B = _spin_projector(theta_b)
|
|
106
|
+
op = np.kron(A, B)
|
|
107
|
+
return float(np.real(np.vdot(self.state, op @ self.state)))
|
|
108
|
+
|
|
109
|
+
def chsh_S(self, a: float, a_prime: float, b: float, b_prime: float) -> float:
|
|
110
|
+
r"""The CHSH combination
|
|
111
|
+
:math:`S = E(a,b) - E(a,b') + E(a',b) + E(a',b')`.
|
|
112
|
+
|
|
113
|
+
Parameters
|
|
114
|
+
----------
|
|
115
|
+
a, a_prime : float
|
|
116
|
+
The two measurement angles for qubit 1.
|
|
117
|
+
b, b_prime : float
|
|
118
|
+
The two measurement angles for qubit 2.
|
|
119
|
+
|
|
120
|
+
Returns
|
|
121
|
+
-------
|
|
122
|
+
float
|
|
123
|
+
"""
|
|
124
|
+
return self.correlation(a, b) - self.correlation(a, b_prime) + self.correlation(a_prime, b) + self.correlation(a_prime, b_prime)
|
|
125
|
+
|
|
126
|
+
def chsh_optimal(self) -> float:
|
|
127
|
+
r""":math:`\lvert S\rvert` at the standard optimal angles
|
|
128
|
+
:math:`(0, \pi/2, \pi/4, 3\pi/4)`.
|
|
129
|
+
|
|
130
|
+
Gives the Tsirelson bound :math:`\lvert S\rvert = 2\sqrt2 \approx
|
|
131
|
+
2.828`, violating the classical bound of 2 predicted by any local
|
|
132
|
+
hidden-variable theory.
|
|
133
|
+
|
|
134
|
+
Returns
|
|
135
|
+
-------
|
|
136
|
+
float
|
|
137
|
+
"""
|
|
138
|
+
return abs(self.chsh_S(0.0, np.pi / 2, np.pi / 4, 3 * np.pi / 4))
|
|
139
|
+
|
|
140
|
+
def measurement_probabilities(self, theta_a: float, theta_b: float) -> dict:
|
|
141
|
+
r"""Joint outcome probabilities for projective spin measurements.
|
|
142
|
+
|
|
143
|
+
Parameters
|
|
144
|
+
----------
|
|
145
|
+
theta_a : float
|
|
146
|
+
Measurement angle for qubit 1.
|
|
147
|
+
theta_b : float
|
|
148
|
+
Measurement angle for qubit 2.
|
|
149
|
+
|
|
150
|
+
Returns
|
|
151
|
+
-------
|
|
152
|
+
dict
|
|
153
|
+
Maps ``'++'``, ``'+-'``, ``'-+'``, ``'--'`` to their probabilities.
|
|
154
|
+
"""
|
|
155
|
+
|
|
156
|
+
# eigenvectors of the spin projector at angle theta (in +1/-1 order)
|
|
157
|
+
def eigvecs(theta):
|
|
158
|
+
c, s = np.cos(theta / 2), np.sin(theta / 2)
|
|
159
|
+
return np.array([c, s]), np.array([-s, c])
|
|
160
|
+
|
|
161
|
+
up_a, down_a = eigvecs(theta_a)
|
|
162
|
+
up_b, down_b = eigvecs(theta_b)
|
|
163
|
+
probs = {}
|
|
164
|
+
for (label_a, va), (label_b, vb) in product([("+", up_a), ("-", down_a)], [("+", up_b), ("-", down_b)]):
|
|
165
|
+
proj = np.kron(va, vb)
|
|
166
|
+
amp = np.vdot(proj, self.state)
|
|
167
|
+
probs[label_a + label_b] = float(np.abs(amp) ** 2)
|
|
168
|
+
return probs
|
|
169
|
+
|
|
170
|
+
def monte_carlo_correlation(self, theta_a: float, theta_b: float, n_trials: int = 20000, rng: np.random.Generator | None = None) -> float:
|
|
171
|
+
r"""Simulate joint measurements and return the empirical correlation.
|
|
172
|
+
|
|
173
|
+
Samples simulated joint measurement outcomes from the exact quantum
|
|
174
|
+
joint distribution and returns the empirical correlation
|
|
175
|
+
:math:`\langle AB\rangle`, statistically converging to
|
|
176
|
+
:meth:`correlation`\ ``(theta_a, theta_b)``.
|
|
177
|
+
|
|
178
|
+
Parameters
|
|
179
|
+
----------
|
|
180
|
+
theta_a : float
|
|
181
|
+
Measurement angle for qubit 1.
|
|
182
|
+
theta_b : float
|
|
183
|
+
Measurement angle for qubit 2.
|
|
184
|
+
n_trials : int, default=20000
|
|
185
|
+
Number of simulated measurement pairs.
|
|
186
|
+
rng : numpy.random.Generator or None, optional
|
|
187
|
+
Random number generator; a fresh default one is used if omitted.
|
|
188
|
+
|
|
189
|
+
Returns
|
|
190
|
+
-------
|
|
191
|
+
float
|
|
192
|
+
"""
|
|
193
|
+
rng = rng or np.random.default_rng()
|
|
194
|
+
probs = self.measurement_probabilities(theta_a, theta_b)
|
|
195
|
+
labels = list(probs.keys())
|
|
196
|
+
p = np.array([probs[k] for k in labels])
|
|
197
|
+
p /= p.sum()
|
|
198
|
+
draws = rng.choice(len(labels), size=n_trials, p=p)
|
|
199
|
+
outcomes = np.array([[1 if lbl[0] == "+" else -1, 1 if lbl[1] == "+" else -1] for lbl in labels])
|
|
200
|
+
samples = outcomes[draws]
|
|
201
|
+
return float(np.mean(samples[:, 0] * samples[:, 1]))
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
# --- Dynamical entanglement generation: Ising coupling ----------------------
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
@dataclass
|
|
208
|
+
class IsingEntangler:
|
|
209
|
+
r"""Two initially unentangled qubits, entangled by an Ising coupling.
|
|
210
|
+
|
|
211
|
+
Both qubits start in :math:`\lvert+\rangle = (\lvert0\rangle+\lvert1\rangle)/\sqrt2`
|
|
212
|
+
(an eigenstate of :math:`\sigma_x`, i.e. unentangled and unbiased in the
|
|
213
|
+
measurement basis), and evolve under
|
|
214
|
+
|
|
215
|
+
.. math::
|
|
216
|
+
|
|
217
|
+
\hat H = \hbar J\, \sigma_z^{(1)}\otimes\sigma_z^{(2)}.
|
|
218
|
+
|
|
219
|
+
Since :math:`\lvert+\rangle\otimes\lvert+\rangle` is a superposition of
|
|
220
|
+
all four :math:`\sigma_z\otimes\sigma_z` eigenstates,
|
|
221
|
+
:math:`e^{-i\hat Ht/\hbar}` accumulates a different phase on each
|
|
222
|
+
computational-basis term, generating genuine entanglement -- maximal
|
|
223
|
+
(a Bell-equivalent state) at :math:`Jt=\pi/4`.
|
|
224
|
+
|
|
225
|
+
Parameters
|
|
226
|
+
----------
|
|
227
|
+
J : float, default=1.0
|
|
228
|
+
Ising coupling strength.
|
|
229
|
+
hbar : float, default=1.0
|
|
230
|
+
Value of :math:`\hbar` to use.
|
|
231
|
+
"""
|
|
232
|
+
|
|
233
|
+
J: float = 1.0
|
|
234
|
+
hbar: float = 1.0
|
|
235
|
+
|
|
236
|
+
def initial_state(self) -> np.ndarray:
|
|
237
|
+
r"""The unentangled product state :math:`\lvert+\rangle\otimes\lvert+\rangle`.
|
|
238
|
+
|
|
239
|
+
Returns
|
|
240
|
+
-------
|
|
241
|
+
numpy.ndarray
|
|
242
|
+
The 4-component state vector.
|
|
243
|
+
"""
|
|
244
|
+
plus = np.array([1.0, 1.0], dtype=complex) / np.sqrt(2)
|
|
245
|
+
return np.kron(plus, plus)
|
|
246
|
+
|
|
247
|
+
def state(self, t: float) -> np.ndarray:
|
|
248
|
+
r"""The evolved two-qubit state :math:`e^{-i\hat Ht/\hbar}\lvert\psi_0\rangle`.
|
|
249
|
+
|
|
250
|
+
:math:`\hat H` is diagonal in the computational basis with
|
|
251
|
+
eigenvalues :math:`\hbar J` on :math:`\lvert00\rangle,\lvert11\rangle`
|
|
252
|
+
and :math:`-\hbar J` on :math:`\lvert01\rangle,\lvert10\rangle`, so
|
|
253
|
+
the propagator is applied as a plain phase per basis state.
|
|
254
|
+
|
|
255
|
+
Parameters
|
|
256
|
+
----------
|
|
257
|
+
t : float
|
|
258
|
+
Time.
|
|
259
|
+
|
|
260
|
+
Returns
|
|
261
|
+
-------
|
|
262
|
+
numpy.ndarray
|
|
263
|
+
The 4-component state vector, in the
|
|
264
|
+
:math:`\lvert00\rangle,\lvert01\rangle,\lvert10\rangle,\lvert11\rangle` basis.
|
|
265
|
+
"""
|
|
266
|
+
zz_eigenvalues = np.array([1.0, -1.0, -1.0, 1.0]) # sigma_z(x)sigma_z on |00>,|01>,|10>,|11>
|
|
267
|
+
phases = np.exp(-1j * self.J * zz_eigenvalues * t)
|
|
268
|
+
return phases * self.initial_state()
|
|
269
|
+
|
|
270
|
+
def state_trajectory(self, t_values: np.ndarray) -> np.ndarray:
|
|
271
|
+
"""Stack of :meth:`state` snapshots over a time grid.
|
|
272
|
+
|
|
273
|
+
Parameters
|
|
274
|
+
----------
|
|
275
|
+
t_values : numpy.ndarray
|
|
276
|
+
Times to evaluate at.
|
|
277
|
+
|
|
278
|
+
Returns
|
|
279
|
+
-------
|
|
280
|
+
numpy.ndarray
|
|
281
|
+
Complex-valued, shape ``(len(t_values), 4)``.
|
|
282
|
+
"""
|
|
283
|
+
return np.array([self.state(t) for t in t_values])
|
|
284
|
+
|
|
285
|
+
def reduced_density_matrix(self, psi: np.ndarray) -> np.ndarray:
|
|
286
|
+
r"""The reduced density matrix :math:`\rho_1=\mathrm{Tr}_2\lvert\psi\rangle\langle\psi\rvert`
|
|
287
|
+
of the first qubit.
|
|
288
|
+
|
|
289
|
+
Parameters
|
|
290
|
+
----------
|
|
291
|
+
psi : numpy.ndarray
|
|
292
|
+
The 4-component two-qubit state vector.
|
|
293
|
+
|
|
294
|
+
Returns
|
|
295
|
+
-------
|
|
296
|
+
numpy.ndarray
|
|
297
|
+
The :math:`2\times2` reduced density matrix.
|
|
298
|
+
"""
|
|
299
|
+
psi_mat = np.asarray(psi, dtype=complex).reshape(2, 2) # rows = qubit 1, cols = qubit 2
|
|
300
|
+
return psi_mat @ psi_mat.conj().T
|
|
301
|
+
|
|
302
|
+
def purity(self, psi: np.ndarray) -> float:
|
|
303
|
+
r"""The purity :math:`\mathrm{Tr}(\rho_1^2)` of the reduced state.
|
|
304
|
+
|
|
305
|
+
Equal to 1 for an unentangled (product) state and 1/2 (minimal, for
|
|
306
|
+
a single qubit) at maximal entanglement.
|
|
307
|
+
|
|
308
|
+
Parameters
|
|
309
|
+
----------
|
|
310
|
+
psi : numpy.ndarray
|
|
311
|
+
The 4-component two-qubit state vector.
|
|
312
|
+
|
|
313
|
+
Returns
|
|
314
|
+
-------
|
|
315
|
+
float
|
|
316
|
+
"""
|
|
317
|
+
rho = self.reduced_density_matrix(psi)
|
|
318
|
+
return float(np.real(np.trace(rho @ rho)))
|
|
319
|
+
|
|
320
|
+
def concurrence(self, psi: np.ndarray) -> float:
|
|
321
|
+
r"""The Wootters concurrence, a two-qubit entanglement measure.
|
|
322
|
+
|
|
323
|
+
For a pure state, :math:`C = 2\lvert\det\Psi\rvert` where
|
|
324
|
+
:math:`\Psi` is the state reshaped into a :math:`2\times2` matrix
|
|
325
|
+
(equivalently :math:`C=\sqrt{2(1-\mathrm{Tr}\,\rho_1^2)}`);
|
|
326
|
+
:math:`C=0` for a product state and :math:`C=1` for a maximally
|
|
327
|
+
entangled (Bell) state.
|
|
328
|
+
|
|
329
|
+
Parameters
|
|
330
|
+
----------
|
|
331
|
+
psi : numpy.ndarray
|
|
332
|
+
The 4-component two-qubit state vector.
|
|
333
|
+
|
|
334
|
+
Returns
|
|
335
|
+
-------
|
|
336
|
+
float
|
|
337
|
+
"""
|
|
338
|
+
psi_mat = np.asarray(psi, dtype=complex).reshape(2, 2)
|
|
339
|
+
return float(2 * np.abs(np.linalg.det(psi_mat)))
|
|
340
|
+
|
|
341
|
+
def concurrence_trajectory(self, t_values: np.ndarray) -> np.ndarray:
|
|
342
|
+
"""The concurrence :math:`C(t)` over a time grid.
|
|
343
|
+
|
|
344
|
+
Parameters
|
|
345
|
+
----------
|
|
346
|
+
t_values : numpy.ndarray
|
|
347
|
+
Times to evaluate at.
|
|
348
|
+
|
|
349
|
+
Returns
|
|
350
|
+
-------
|
|
351
|
+
numpy.ndarray
|
|
352
|
+
"""
|
|
353
|
+
return np.array([self.concurrence(self.state(t)) for t in t_values])
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
# --- Aharonov-Bohm effect ----------------------------------------------------
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
@dataclass
|
|
360
|
+
class AharonovBohmRing:
|
|
361
|
+
r"""A charged particle confined to a 1D ring threading a magnetic flux.
|
|
362
|
+
|
|
363
|
+
:math:`B=0` everywhere on the ring itself -- only the vector potential
|
|
364
|
+
:math:`A = \Phi/(2\pi R)` is nonzero there. The eigenspectrum
|
|
365
|
+
|
|
366
|
+
.. math::
|
|
367
|
+
|
|
368
|
+
E_n(\Phi) = \frac{\hbar^2}{2mR^2}\left(n - \frac{\Phi}{\Phi_0}\right)^2
|
|
369
|
+
|
|
370
|
+
shows the Aharonov-Bohm phase shift
|
|
371
|
+
:math:`\Delta\phi = (q/\hbar)\oint \mathbf A\cdot d\mathbf l = 2\pi\Phi/\Phi_0`
|
|
372
|
+
purely through boundary conditions, without the particle ever entering
|
|
373
|
+
a region where :math:`B\neq0`.
|
|
374
|
+
|
|
375
|
+
Parameters
|
|
376
|
+
----------
|
|
377
|
+
R : float, default=1.0
|
|
378
|
+
Ring radius.
|
|
379
|
+
m : float, default=1.0
|
|
380
|
+
Particle mass.
|
|
381
|
+
hbar : float, default=1.0
|
|
382
|
+
Value of :math:`\hbar` to use.
|
|
383
|
+
q : float, default=1.0
|
|
384
|
+
Particle charge.
|
|
385
|
+
"""
|
|
386
|
+
|
|
387
|
+
R: float = 1.0
|
|
388
|
+
m: float = 1.0
|
|
389
|
+
hbar: float = 1.0
|
|
390
|
+
q: float = 1.0
|
|
391
|
+
|
|
392
|
+
@property
|
|
393
|
+
def flux_quantum(self) -> float:
|
|
394
|
+
r"""float: The flux quantum :math:`\Phi_0 = 2\pi\hbar/q` (:math:`h/q`
|
|
395
|
+
in these units)."""
|
|
396
|
+
return 2 * np.pi * self.hbar / self.q
|
|
397
|
+
|
|
398
|
+
def energy(self, n, Phi: float) -> np.ndarray:
|
|
399
|
+
r"""Eigenenergy :math:`E_n(\Phi)`.
|
|
400
|
+
|
|
401
|
+
Parameters
|
|
402
|
+
----------
|
|
403
|
+
n : int or array_like
|
|
404
|
+
Angular-momentum quantum number(s).
|
|
405
|
+
Phi : float
|
|
406
|
+
Enclosed magnetic flux.
|
|
407
|
+
|
|
408
|
+
Returns
|
|
409
|
+
-------
|
|
410
|
+
numpy.ndarray
|
|
411
|
+
"""
|
|
412
|
+
n = np.asarray(n)
|
|
413
|
+
flux_ratio = Phi / self.flux_quantum
|
|
414
|
+
return (self.hbar**2 / (2 * self.m * self.R**2)) * (n - flux_ratio) ** 2
|
|
415
|
+
|
|
416
|
+
def spectrum(self, Phi: float, n_range: int = 5) -> np.ndarray:
|
|
417
|
+
"""Sorted energies for :math:`n \\in [-n_\\text{range}, n_\\text{range}]`.
|
|
418
|
+
|
|
419
|
+
Parameters
|
|
420
|
+
----------
|
|
421
|
+
Phi : float
|
|
422
|
+
Enclosed magnetic flux.
|
|
423
|
+
n_range : int, default=5
|
|
424
|
+
Range of angular-momentum quantum numbers to include.
|
|
425
|
+
|
|
426
|
+
Returns
|
|
427
|
+
-------
|
|
428
|
+
numpy.ndarray
|
|
429
|
+
"""
|
|
430
|
+
n = np.arange(-n_range, n_range + 1)
|
|
431
|
+
return np.sort(self.energy(n, Phi))
|
|
432
|
+
|
|
433
|
+
def aharonov_bohm_phase(self, Phi: float) -> float:
|
|
434
|
+
r"""The Aharonov-Bohm phase :math:`\Delta\phi = 2\pi\Phi/\Phi_0`.
|
|
435
|
+
|
|
436
|
+
The phase accumulated by a particle encircling the flux tube once.
|
|
437
|
+
|
|
438
|
+
Parameters
|
|
439
|
+
----------
|
|
440
|
+
Phi : float
|
|
441
|
+
Enclosed magnetic flux.
|
|
442
|
+
|
|
443
|
+
Returns
|
|
444
|
+
-------
|
|
445
|
+
float
|
|
446
|
+
"""
|
|
447
|
+
return 2 * np.pi * Phi / self.flux_quantum
|
|
448
|
+
|
|
449
|
+
def eigenstate(self, n: int, phi: np.ndarray) -> np.ndarray:
|
|
450
|
+
r"""Real-space ring wavefunction :math:`\psi_n(\phi) = e^{in\phi}/\sqrt{2\pi R}`.
|
|
451
|
+
|
|
452
|
+
Parameters
|
|
453
|
+
----------
|
|
454
|
+
n : int
|
|
455
|
+
Angular-momentum quantum number.
|
|
456
|
+
phi : numpy.ndarray
|
|
457
|
+
Angular positions around the ring.
|
|
458
|
+
|
|
459
|
+
Returns
|
|
460
|
+
-------
|
|
461
|
+
numpy.ndarray
|
|
462
|
+
Complex-valued.
|
|
463
|
+
"""
|
|
464
|
+
return np.exp(1j * n * phi) / np.sqrt(2 * np.pi * self.R)
|
|
465
|
+
|
|
466
|
+
def persistent_current(self, n: int, Phi: float, dPhi: float = 1e-6) -> float:
|
|
467
|
+
r"""Equilibrium persistent current carried by level :math:`n`.
|
|
468
|
+
|
|
469
|
+
.. math::
|
|
470
|
+
|
|
471
|
+
I_n(\Phi) = -\frac{dE_n}{d\Phi},
|
|
472
|
+
|
|
473
|
+
periodic in :math:`\Phi` with period :math:`\Phi_0` -- the direct
|
|
474
|
+
experimental signature of the Aharonov-Bohm phase.
|
|
475
|
+
|
|
476
|
+
Parameters
|
|
477
|
+
----------
|
|
478
|
+
n : int
|
|
479
|
+
Angular-momentum quantum number.
|
|
480
|
+
Phi : float
|
|
481
|
+
Enclosed magnetic flux.
|
|
482
|
+
dPhi : float, default=1e-6
|
|
483
|
+
Step size for the central-difference derivative.
|
|
484
|
+
|
|
485
|
+
Returns
|
|
486
|
+
-------
|
|
487
|
+
float
|
|
488
|
+
"""
|
|
489
|
+
return -(self.energy(n, Phi + dPhi) - self.energy(n, Phi - dPhi)) / (2 * dPhi)
|