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,97 @@
|
|
|
1
|
+
"""Live normal-mode energy diagnostics for lattice chains.
|
|
2
|
+
|
|
3
|
+
Wraps :meth:`physicskit.classical.systems.chains._ChainBase.modal_energies` in a bar
|
|
4
|
+
chart and a Matplotlib ``FuncAnimation`` that updates it frame-by-frame
|
|
5
|
+
-- the standard way to visualize the FPUT recurrence: energy initially
|
|
6
|
+
concentrated in a single low mode, spreading across many modes, and
|
|
7
|
+
then returning almost exactly to the starting mode.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import matplotlib.pyplot as plt
|
|
13
|
+
import numpy as np
|
|
14
|
+
from matplotlib.animation import FuncAnimation
|
|
15
|
+
|
|
16
|
+
__all__ = ["plot_modal_energy_bars", "animate_modal_energies"]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def plot_modal_energy_bars(system, q: np.ndarray, p: np.ndarray, ax=None, **kwargs):
|
|
20
|
+
"""Static bar chart of E_k for each normal mode k at one instant.
|
|
21
|
+
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
system : object
|
|
25
|
+
A lattice-chain system exposing ``modal_energies(q, p)``, e.g.
|
|
26
|
+
:class:`~physicskit.classical.systems.chains.HarmonicChain` or
|
|
27
|
+
:class:`~physicskit.classical.systems.chains.FPUTChain`.
|
|
28
|
+
q, p : ndarray
|
|
29
|
+
State to evaluate.
|
|
30
|
+
ax : matplotlib.axes.Axes, optional
|
|
31
|
+
Axes to draw on; a new figure is created if omitted.
|
|
32
|
+
**kwargs
|
|
33
|
+
Forwarded to ``ax.bar``.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
matplotlib.axes.Axes
|
|
38
|
+
"""
|
|
39
|
+
if ax is None:
|
|
40
|
+
_, ax = plt.subplots()
|
|
41
|
+
energies = system.modal_energies(q, p)
|
|
42
|
+
modes = np.arange(1, len(energies) + 1)
|
|
43
|
+
ax.bar(modes, energies, **kwargs)
|
|
44
|
+
ax.set_xlabel("normal mode k")
|
|
45
|
+
ax.set_ylabel("$E_k$")
|
|
46
|
+
ax.set_title("Modal energy distribution")
|
|
47
|
+
return ax
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def animate_modal_energies(system, result, stride: int = 1, interval: int = 30, fig=None, ax=None):
|
|
51
|
+
"""Animate the modal-energy bar chart across a full trajectory.
|
|
52
|
+
|
|
53
|
+
Parameters
|
|
54
|
+
----------
|
|
55
|
+
system : object
|
|
56
|
+
A lattice-chain system exposing ``modal_energies(q, p)``.
|
|
57
|
+
result : physicskit.classical.core.base_system.SimulationResult
|
|
58
|
+
Output of ``system.integrate(...)``.
|
|
59
|
+
stride : int
|
|
60
|
+
Render only every ``stride``-th recorded sample (for long runs).
|
|
61
|
+
interval : int
|
|
62
|
+
Delay between frames, in milliseconds.
|
|
63
|
+
fig : matplotlib.figure.Figure, optional
|
|
64
|
+
Figure to draw on; inferred from ``ax`` or created if omitted.
|
|
65
|
+
ax : matplotlib.axes.Axes, optional
|
|
66
|
+
Axes to draw on; a new figure is created if omitted.
|
|
67
|
+
|
|
68
|
+
Returns
|
|
69
|
+
-------
|
|
70
|
+
matplotlib.animation.FuncAnimation
|
|
71
|
+
"""
|
|
72
|
+
if ax is None:
|
|
73
|
+
fig, ax = plt.subplots()
|
|
74
|
+
elif fig is None:
|
|
75
|
+
fig = ax.figure
|
|
76
|
+
|
|
77
|
+
n_modes = result.q.shape[1]
|
|
78
|
+
modes = np.arange(1, n_modes + 1)
|
|
79
|
+
e0 = system.modal_energies(result.q[0], result.p[0])
|
|
80
|
+
bars = ax.bar(modes, e0)
|
|
81
|
+
ax.set_xlabel("normal mode k")
|
|
82
|
+
ax.set_ylabel("$E_k$")
|
|
83
|
+
y_max = max(1e-12, np.sum(e0)) * 1.1
|
|
84
|
+
ax.set_ylim(0, y_max)
|
|
85
|
+
title = ax.set_title(f"Modal energy at t = {result.t[0]:.3f}")
|
|
86
|
+
|
|
87
|
+
frame_indices = np.arange(0, len(result.t), stride)
|
|
88
|
+
|
|
89
|
+
def update(frame_i):
|
|
90
|
+
idx = frame_indices[frame_i]
|
|
91
|
+
energies = system.modal_energies(result.q[idx], result.p[idx])
|
|
92
|
+
for bar, e in zip(bars, energies):
|
|
93
|
+
bar.set_height(e)
|
|
94
|
+
title.set_text(f"Modal energy at t = {result.t[idx]:.3f}")
|
|
95
|
+
return list(bars) + [title]
|
|
96
|
+
|
|
97
|
+
return FuncAnimation(fig, update, frames=len(frame_indices), interval=interval, blit=False)
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"""Phase-space diagnostics: (q, p) portraits, Poincare sections, and the
|
|
2
|
+
SO(3) angular-momentum (Casimir) sphere for rigid bodies.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import matplotlib.pyplot as plt
|
|
8
|
+
import numpy as np
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"plot_phase_portrait",
|
|
12
|
+
"plot_phase_swarm",
|
|
13
|
+
"poincare_section",
|
|
14
|
+
"plot_poincare_section",
|
|
15
|
+
"plot_so3_momentum_sphere",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def plot_phase_portrait(q: np.ndarray, p: np.ndarray, ax=None, label=None, **kwargs):
|
|
20
|
+
"""Plot a single (q, p) trajectory in phase space.
|
|
21
|
+
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
q, p : ndarray
|
|
25
|
+
1D (a single degree of freedom over time) or 2D
|
|
26
|
+
(``(n_steps, ndof)``, in which case each column is drawn as
|
|
27
|
+
its own curve).
|
|
28
|
+
ax : matplotlib.axes.Axes, optional
|
|
29
|
+
Axes to draw on; a new figure is created if omitted.
|
|
30
|
+
label : str, optional
|
|
31
|
+
Legend label (per-DOF suffix added automatically for 2D input).
|
|
32
|
+
**kwargs
|
|
33
|
+
Forwarded to ``ax.plot``.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
matplotlib.axes.Axes
|
|
38
|
+
"""
|
|
39
|
+
if ax is None:
|
|
40
|
+
_, ax = plt.subplots()
|
|
41
|
+
q = np.asarray(q)
|
|
42
|
+
p = np.asarray(p)
|
|
43
|
+
if q.ndim == 1:
|
|
44
|
+
ax.plot(q, p, label=label, **kwargs)
|
|
45
|
+
else:
|
|
46
|
+
for i in range(q.shape[1]):
|
|
47
|
+
ax.plot(q[:, i], p[:, i], label=f"{label} dof {i}" if label else f"dof {i}", **kwargs)
|
|
48
|
+
ax.set_xlabel("q")
|
|
49
|
+
ax.set_ylabel("p")
|
|
50
|
+
ax.set_title("Phase portrait")
|
|
51
|
+
if label:
|
|
52
|
+
ax.legend()
|
|
53
|
+
return ax
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def plot_phase_swarm(q: np.ndarray, p: np.ndarray, ax=None, s=4, **kwargs):
|
|
57
|
+
"""Scatter an ensemble of phase points.
|
|
58
|
+
|
|
59
|
+
E.g. a :class:`physicskit.classical.systems.hamiltonian.PendulumSwarm` snapshot,
|
|
60
|
+
the standard way to visualize Liouville-theorem shearing of a
|
|
61
|
+
phase-space patch.
|
|
62
|
+
|
|
63
|
+
Parameters
|
|
64
|
+
----------
|
|
65
|
+
q, p : ndarray, shape (n,)
|
|
66
|
+
Phase-point positions and momenta.
|
|
67
|
+
ax : matplotlib.axes.Axes, optional
|
|
68
|
+
Axes to draw on; a new figure is created if omitted.
|
|
69
|
+
s : float
|
|
70
|
+
Marker size, forwarded to ``ax.scatter``.
|
|
71
|
+
**kwargs
|
|
72
|
+
Forwarded to ``ax.scatter``.
|
|
73
|
+
|
|
74
|
+
Returns
|
|
75
|
+
-------
|
|
76
|
+
matplotlib.axes.Axes
|
|
77
|
+
"""
|
|
78
|
+
if ax is None:
|
|
79
|
+
_, ax = plt.subplots()
|
|
80
|
+
ax.scatter(q, p, s=s, **kwargs)
|
|
81
|
+
ax.set_xlabel("q")
|
|
82
|
+
ax.set_ylabel("p")
|
|
83
|
+
ax.set_title("Phase-space swarm")
|
|
84
|
+
return ax
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def poincare_section(q: np.ndarray, p: np.ndarray, section_q: np.ndarray, section_p: np.ndarray, value: float = 0.0, direction: int = 1):
|
|
88
|
+
"""Compute Poincare-section crossing points.
|
|
89
|
+
|
|
90
|
+
Records ``(q, p)`` each time ``section_q`` crosses ``value`` moving
|
|
91
|
+
in the sign given by ``direction`` (+1 for increasing, -1 for
|
|
92
|
+
decreasing), linearly interpolating between the bracketing samples
|
|
93
|
+
for sub-step accuracy. Typical usage for Henon-Heiles: pass y as
|
|
94
|
+
``section_q``, take the section at y=0 with py>0 (direction=+1),
|
|
95
|
+
and record (x, px) crossings.
|
|
96
|
+
|
|
97
|
+
Parameters
|
|
98
|
+
----------
|
|
99
|
+
q, p : ndarray
|
|
100
|
+
Coordinates to record at each crossing.
|
|
101
|
+
section_q, section_p : ndarray
|
|
102
|
+
The coordinate (and its conjugate momentum) whose crossings of
|
|
103
|
+
``value`` define the section; same length as ``q``/``p``.
|
|
104
|
+
value : float
|
|
105
|
+
Crossing threshold.
|
|
106
|
+
direction : {1, -1}
|
|
107
|
+
+1 to record crossings where ``section_q`` is increasing
|
|
108
|
+
through ``value``, -1 for decreasing.
|
|
109
|
+
|
|
110
|
+
Returns
|
|
111
|
+
-------
|
|
112
|
+
crossings_q, crossings_p : ndarray
|
|
113
|
+
Interpolated ``(q, p)`` at each crossing.
|
|
114
|
+
"""
|
|
115
|
+
section_q = np.asarray(section_q)
|
|
116
|
+
section_p = np.asarray(section_p)
|
|
117
|
+
crossings_q = []
|
|
118
|
+
crossings_p = []
|
|
119
|
+
for i in range(len(section_q) - 1):
|
|
120
|
+
y0, y1 = section_q[i] - value, section_q[i + 1] - value
|
|
121
|
+
crosses = (y0 <= 0 < y1) if direction > 0 else (y0 >= 0 > y1)
|
|
122
|
+
if not crosses:
|
|
123
|
+
continue
|
|
124
|
+
if section_p[i] * direction < 0:
|
|
125
|
+
continue
|
|
126
|
+
frac = -y0 / (y1 - y0) if y1 != y0 else 0.0
|
|
127
|
+
crossings_q.append(q[i] + frac * (q[i + 1] - q[i]))
|
|
128
|
+
crossings_p.append(p[i] + frac * (p[i + 1] - p[i]))
|
|
129
|
+
return np.array(crossings_q), np.array(crossings_p)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def plot_poincare_section(q, p, section_q, section_p, value=0.0, direction=1, ax=None, **kwargs):
|
|
133
|
+
"""Scatter-plot the Poincare-section crossings of a trajectory.
|
|
134
|
+
|
|
135
|
+
Parameters
|
|
136
|
+
----------
|
|
137
|
+
q, p : ndarray
|
|
138
|
+
Coordinates to record at each crossing.
|
|
139
|
+
section_q, section_p : ndarray
|
|
140
|
+
The coordinate (and its conjugate momentum) whose crossings of
|
|
141
|
+
``value`` define the section.
|
|
142
|
+
value : float
|
|
143
|
+
Crossing threshold.
|
|
144
|
+
direction : {1, -1}
|
|
145
|
+
Crossing direction; see :func:`poincare_section`.
|
|
146
|
+
ax : matplotlib.axes.Axes, optional
|
|
147
|
+
Axes to draw on; a new figure is created if omitted.
|
|
148
|
+
**kwargs
|
|
149
|
+
Forwarded to ``ax.scatter``.
|
|
150
|
+
|
|
151
|
+
Returns
|
|
152
|
+
-------
|
|
153
|
+
matplotlib.axes.Axes
|
|
154
|
+
"""
|
|
155
|
+
cq, cp = poincare_section(q, p, section_q, section_p, value=value, direction=direction)
|
|
156
|
+
if ax is None:
|
|
157
|
+
_, ax = plt.subplots()
|
|
158
|
+
ax.scatter(cq, cp, s=2, **kwargs)
|
|
159
|
+
ax.set_xlabel("q")
|
|
160
|
+
ax.set_ylabel("p")
|
|
161
|
+
ax.set_title("Poincare section")
|
|
162
|
+
return ax
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def plot_so3_momentum_sphere(omega_trajectory: np.ndarray, I1: float, I2: float, I3: float, ax=None, n_grid: int = 40):
|
|
166
|
+
"""Plot a rigid body's body-frame angular-momentum trajectory on the Casimir sphere.
|
|
167
|
+
|
|
168
|
+
``L(t) = (I1*w1, I2*w2, I3*w3)`` on the SO(3) Casimir sphere
|
|
169
|
+
``|L| = |L(0)|``.
|
|
170
|
+
|
|
171
|
+
The wireframe sphere shown is the constant-``|L|`` Casimir surface; the
|
|
172
|
+
trajectory is additionally constrained to the (generally
|
|
173
|
+
non-spherical) constant-energy ellipsoid, so the two surfaces'
|
|
174
|
+
intersection traces out the actual admissible polhode curves --
|
|
175
|
+
this is the geometric picture behind the Intermediate Axis Theorem.
|
|
176
|
+
|
|
177
|
+
Parameters
|
|
178
|
+
----------
|
|
179
|
+
omega_trajectory : ndarray, shape (n_steps, 3)
|
|
180
|
+
Body-frame angular velocity trajectory, e.g.
|
|
181
|
+
``result.y[:, :3]`` from integrating an
|
|
182
|
+
:class:`~physicskit.classical.systems.rotations.EulerTop`.
|
|
183
|
+
I1, I2, I3 : float
|
|
184
|
+
Principal moments of inertia.
|
|
185
|
+
ax : mpl_toolkits.mplot3d.Axes3D, optional
|
|
186
|
+
Axes to draw on; a new 3D figure is created if omitted.
|
|
187
|
+
n_grid : int
|
|
188
|
+
Resolution of the wireframe sphere.
|
|
189
|
+
|
|
190
|
+
Returns
|
|
191
|
+
-------
|
|
192
|
+
mpl_toolkits.mplot3d.Axes3D
|
|
193
|
+
"""
|
|
194
|
+
omega_trajectory = np.asarray(omega_trajectory)
|
|
195
|
+
L = np.column_stack([I1 * omega_trajectory[:, 0], I2 * omega_trajectory[:, 1], I3 * omega_trajectory[:, 2]])
|
|
196
|
+
radius = np.linalg.norm(L[0])
|
|
197
|
+
|
|
198
|
+
if ax is None:
|
|
199
|
+
fig = plt.figure()
|
|
200
|
+
ax = fig.add_subplot(111, projection="3d")
|
|
201
|
+
|
|
202
|
+
u = np.linspace(0, 2 * np.pi, n_grid)
|
|
203
|
+
v = np.linspace(0, np.pi, n_grid)
|
|
204
|
+
xs = radius * np.outer(np.cos(u), np.sin(v))
|
|
205
|
+
ys = radius * np.outer(np.sin(u), np.sin(v))
|
|
206
|
+
zs = radius * np.outer(np.ones_like(u), np.cos(v))
|
|
207
|
+
ax.plot_wireframe(xs, ys, zs, color="lightgray", linewidth=0.3, alpha=0.5)
|
|
208
|
+
|
|
209
|
+
ax.plot(L[:, 0], L[:, 1], L[:, 2], color="crimson", linewidth=1.2)
|
|
210
|
+
ax.set_xlabel("L1")
|
|
211
|
+
ax.set_ylabel("L2")
|
|
212
|
+
ax.set_zlabel("L3")
|
|
213
|
+
ax.set_title("Body-frame angular momentum on the Casimir sphere")
|
|
214
|
+
return ax
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""Condensed matter physics: tight-binding models, topological band theory, and correlated electrons.
|
|
2
|
+
|
|
3
|
+
Typical usage::
|
|
4
|
+
|
|
5
|
+
import physicskit as pk
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
H = lambda k1, k2: pk.condensed.haldane_model(k1, k2, phi=np.pi / 2)
|
|
9
|
+
chern_numbers = pk.condensed.compute_chern_number(H, grid_size=30)
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from .anderson_localization import (
|
|
13
|
+
anderson_chain_hamiltonian,
|
|
14
|
+
inverse_participation_ratio,
|
|
15
|
+
localization_length,
|
|
16
|
+
)
|
|
17
|
+
from .correlated import (
|
|
18
|
+
bdg_bcs_hamiltonian,
|
|
19
|
+
bdg_spectrum,
|
|
20
|
+
hubbard_1d_exact_diagonalization,
|
|
21
|
+
hubbard_spin_correlations,
|
|
22
|
+
)
|
|
23
|
+
from .ginzburg_landau import (
|
|
24
|
+
ginzburg_landau_parameter,
|
|
25
|
+
gl_coherence_length,
|
|
26
|
+
gl_equilibrium_order_parameter,
|
|
27
|
+
gl_free_energy_density,
|
|
28
|
+
gl_order_parameter_profile,
|
|
29
|
+
gl_penetration_depth,
|
|
30
|
+
)
|
|
31
|
+
from .landau_levels import (
|
|
32
|
+
cyclotron_frequency,
|
|
33
|
+
filling_factor,
|
|
34
|
+
landau_degeneracy,
|
|
35
|
+
landau_density_of_states,
|
|
36
|
+
landau_level_energies,
|
|
37
|
+
magnetic_length,
|
|
38
|
+
)
|
|
39
|
+
from .laughlin import laughlin_metropolis_sweep, laughlin_pair_correlation, laughlin_radial_density
|
|
40
|
+
from .models import (
|
|
41
|
+
bhz_hamiltonian,
|
|
42
|
+
bhz_ribbon_hamiltonian,
|
|
43
|
+
graphene_hamiltonian,
|
|
44
|
+
graphene_lattice_hamiltonian,
|
|
45
|
+
haldane_lattice_hamiltonian,
|
|
46
|
+
haldane_model,
|
|
47
|
+
harper_hofstadter_hamiltonian,
|
|
48
|
+
kane_mele_hamiltonian,
|
|
49
|
+
kitaev_chain_bdg_real_space,
|
|
50
|
+
kitaev_chain_hamiltonian,
|
|
51
|
+
ssh_hamiltonian,
|
|
52
|
+
ssh_lattice_hamiltonian,
|
|
53
|
+
)
|
|
54
|
+
from .tight_binding import Hamiltonian, Lattice, apply_peierls_phase, build_ribbon
|
|
55
|
+
from .topological_insulator_3d import (
|
|
56
|
+
surface_dirac_hamiltonian,
|
|
57
|
+
topological_insulator_3d_hamiltonian,
|
|
58
|
+
topological_insulator_3d_slab_hamiltonian,
|
|
59
|
+
)
|
|
60
|
+
from .topology import compute_berry_curvature, compute_chern_number, z2_invariant, zak_phase
|
|
61
|
+
from .visualizers import (
|
|
62
|
+
plot_band_structure,
|
|
63
|
+
plot_berry_curvature,
|
|
64
|
+
plot_edge_state_density,
|
|
65
|
+
plot_fermi_surface_3d,
|
|
66
|
+
)
|
|
67
|
+
from .weyl import weyl_node_locations, weyl_semimetal_hamiltonian, weyl_semimetal_slab_hamiltonian
|
|
68
|
+
|
|
69
|
+
__all__ = [
|
|
70
|
+
"Lattice",
|
|
71
|
+
"Hamiltonian",
|
|
72
|
+
"build_ribbon",
|
|
73
|
+
"apply_peierls_phase",
|
|
74
|
+
"ssh_hamiltonian",
|
|
75
|
+
"ssh_lattice_hamiltonian",
|
|
76
|
+
"graphene_hamiltonian",
|
|
77
|
+
"graphene_lattice_hamiltonian",
|
|
78
|
+
"haldane_model",
|
|
79
|
+
"haldane_lattice_hamiltonian",
|
|
80
|
+
"kane_mele_hamiltonian",
|
|
81
|
+
"bhz_hamiltonian",
|
|
82
|
+
"bhz_ribbon_hamiltonian",
|
|
83
|
+
"kitaev_chain_hamiltonian",
|
|
84
|
+
"kitaev_chain_bdg_real_space",
|
|
85
|
+
"harper_hofstadter_hamiltonian",
|
|
86
|
+
"compute_berry_curvature",
|
|
87
|
+
"compute_chern_number",
|
|
88
|
+
"zak_phase",
|
|
89
|
+
"z2_invariant",
|
|
90
|
+
"cyclotron_frequency",
|
|
91
|
+
"magnetic_length",
|
|
92
|
+
"landau_level_energies",
|
|
93
|
+
"landau_degeneracy",
|
|
94
|
+
"landau_density_of_states",
|
|
95
|
+
"filling_factor",
|
|
96
|
+
"laughlin_metropolis_sweep",
|
|
97
|
+
"laughlin_pair_correlation",
|
|
98
|
+
"laughlin_radial_density",
|
|
99
|
+
"gl_free_energy_density",
|
|
100
|
+
"gl_equilibrium_order_parameter",
|
|
101
|
+
"gl_coherence_length",
|
|
102
|
+
"gl_penetration_depth",
|
|
103
|
+
"ginzburg_landau_parameter",
|
|
104
|
+
"gl_order_parameter_profile",
|
|
105
|
+
"anderson_chain_hamiltonian",
|
|
106
|
+
"inverse_participation_ratio",
|
|
107
|
+
"localization_length",
|
|
108
|
+
"topological_insulator_3d_hamiltonian",
|
|
109
|
+
"topological_insulator_3d_slab_hamiltonian",
|
|
110
|
+
"surface_dirac_hamiltonian",
|
|
111
|
+
"bdg_bcs_hamiltonian",
|
|
112
|
+
"bdg_spectrum",
|
|
113
|
+
"hubbard_1d_exact_diagonalization",
|
|
114
|
+
"hubbard_spin_correlations",
|
|
115
|
+
"plot_band_structure",
|
|
116
|
+
"plot_berry_curvature",
|
|
117
|
+
"plot_edge_state_density",
|
|
118
|
+
"plot_fermi_surface_3d",
|
|
119
|
+
"weyl_semimetal_hamiltonian",
|
|
120
|
+
"weyl_node_locations",
|
|
121
|
+
"weyl_semimetal_slab_hamiltonian",
|
|
122
|
+
]
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
r"""Anderson localization: the 1958 discovery that disorder can halt diffusion entirely.
|
|
2
|
+
|
|
3
|
+
Philip Anderson showed that a quantum particle hopping on a lattice with
|
|
4
|
+
sufficiently strong, random (quenched) onsite disorder does not diffuse at
|
|
5
|
+
all: interference between all the scattering paths off the random
|
|
6
|
+
potential can exponentially localize *every* eigenstate, at any disorder
|
|
7
|
+
strength, in one and two dimensions. This was the first demonstration that
|
|
8
|
+
disorder is not merely a small perturbative correction to a metal's
|
|
9
|
+
conductivity, but can drive a genuine transition -- absent in three
|
|
10
|
+
dimensions only above a critical disorder (the "mobility edge") -- from
|
|
11
|
+
extended, conducting states to localized, insulating ones. It underlies
|
|
12
|
+
the disorder-driven physics that makes real quantum Hall plateaus finite in
|
|
13
|
+
width (:mod:`physicskit.condensed.topology`) and the transport (or lack of
|
|
14
|
+
it) in every real, imperfect crystal.
|
|
15
|
+
|
|
16
|
+
Uses the same natural-unit convention (:math:`\hbar=e=1`) as the rest of
|
|
17
|
+
:mod:`physicskit.condensed`.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import numpy as np
|
|
23
|
+
|
|
24
|
+
__all__ = ["anderson_chain_hamiltonian", "inverse_participation_ratio", "localization_length"]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def anderson_chain_hamiltonian(n_sites: int, disorder_strength: float, t: float = 1.0, seed: int | None = None) -> np.ndarray:
|
|
28
|
+
r"""Real-space 1D Anderson model: a tight-binding chain with random onsite disorder.
|
|
29
|
+
|
|
30
|
+
.. math::
|
|
31
|
+
|
|
32
|
+
H = -t\sum_i \left(c_i^\dagger c_{i+1} + \text{h.c.}\right)
|
|
33
|
+
+ \sum_i \epsilon_i\, c_i^\dagger c_i, \qquad
|
|
34
|
+
\epsilon_i \sim \text{Uniform}\!\left(-\tfrac{W}{2}, \tfrac{W}{2}\right),
|
|
35
|
+
|
|
36
|
+
with open boundary conditions.
|
|
37
|
+
|
|
38
|
+
Parameters
|
|
39
|
+
----------
|
|
40
|
+
n_sites : int
|
|
41
|
+
Number of lattice sites.
|
|
42
|
+
disorder_strength : float
|
|
43
|
+
Disorder width :math:`W`. ``0`` recovers the clean chain.
|
|
44
|
+
t : float, default=1.0
|
|
45
|
+
Nearest-neighbor hopping amplitude.
|
|
46
|
+
seed : int, optional
|
|
47
|
+
Seed for the random onsite disorder, for reproducibility.
|
|
48
|
+
|
|
49
|
+
Returns
|
|
50
|
+
-------
|
|
51
|
+
ndarray, shape (n_sites, n_sites)
|
|
52
|
+
Real, symmetric Hamiltonian matrix.
|
|
53
|
+
|
|
54
|
+
Examples
|
|
55
|
+
--------
|
|
56
|
+
>>> H = anderson_chain_hamiltonian(n_sites=4, disorder_strength=0.0)
|
|
57
|
+
>>> H
|
|
58
|
+
array([[ 0., -1., 0., 0.],
|
|
59
|
+
[-1., 0., -1., 0.],
|
|
60
|
+
[ 0., -1., 0., -1.],
|
|
61
|
+
[ 0., 0., -1., 0.]])
|
|
62
|
+
"""
|
|
63
|
+
rng = np.random.default_rng(seed)
|
|
64
|
+
H = np.diag(rng.uniform(-disorder_strength / 2, disorder_strength / 2, size=n_sites))
|
|
65
|
+
idx = np.arange(n_sites - 1)
|
|
66
|
+
H[idx, idx + 1] = -t
|
|
67
|
+
H[idx + 1, idx] = -t
|
|
68
|
+
return H
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def inverse_participation_ratio(psi) -> float:
|
|
72
|
+
r"""Inverse participation ratio :math:`\text{IPR} = \sum_i|\psi_i|^4 / \left(\sum_i|\psi_i|^2\right)^2`.
|
|
73
|
+
|
|
74
|
+
A dimensionless measure of how many sites an eigenstate is spread
|
|
75
|
+
over: :math:`\text{IPR}\sim 1/N` for a state extended over all
|
|
76
|
+
:math:`N` sites, and :math:`\text{IPR} = O(1)`, independent of
|
|
77
|
+
:math:`N`, for a state localized on a handful of sites -- the
|
|
78
|
+
diagnostic Anderson used to distinguish the two regimes.
|
|
79
|
+
|
|
80
|
+
Parameters
|
|
81
|
+
----------
|
|
82
|
+
psi : array_like
|
|
83
|
+
Eigenvector components (need not be pre-normalized).
|
|
84
|
+
|
|
85
|
+
Returns
|
|
86
|
+
-------
|
|
87
|
+
float
|
|
88
|
+
|
|
89
|
+
Examples
|
|
90
|
+
--------
|
|
91
|
+
A state spread equally over ``N`` sites has IPR = 1/N:
|
|
92
|
+
|
|
93
|
+
>>> import numpy as np
|
|
94
|
+
>>> psi = np.ones(10) / np.sqrt(10)
|
|
95
|
+
>>> round(inverse_participation_ratio(psi), 6)
|
|
96
|
+
0.1
|
|
97
|
+
>>> psi_localized = np.zeros(10); psi_localized[0] = 1.0
|
|
98
|
+
>>> inverse_participation_ratio(psi_localized)
|
|
99
|
+
1.0
|
|
100
|
+
"""
|
|
101
|
+
psi = np.asarray(psi)
|
|
102
|
+
p = np.abs(psi) ** 2
|
|
103
|
+
return float(np.sum(p**2) / np.sum(p) ** 2)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def localization_length(psi, positions=None) -> float:
|
|
107
|
+
r"""Estimate an eigenstate's localization length from the decay of its envelope.
|
|
108
|
+
|
|
109
|
+
Fits :math:`\log|\psi_i|^2` linearly against position on either side of
|
|
110
|
+
the state's peak and returns :math:`\xi = -2/\text{slope}`, averaged
|
|
111
|
+
over both sides -- the length scale over which a localized state's
|
|
112
|
+
probability density decays as :math:`|\psi(x)|^2 \sim e^{-2|x-x_0|/\xi}`.
|
|
113
|
+
Returns ``inf`` for a state too extended (flat/non-monotonic envelope)
|
|
114
|
+
for the fit to detect exponential decay.
|
|
115
|
+
|
|
116
|
+
Parameters
|
|
117
|
+
----------
|
|
118
|
+
psi : array_like
|
|
119
|
+
Eigenvector components, indexed by site.
|
|
120
|
+
positions : array_like, optional
|
|
121
|
+
Site coordinates. Defaults to integer indices ``0, 1, ..., N-1``.
|
|
122
|
+
|
|
123
|
+
Returns
|
|
124
|
+
-------
|
|
125
|
+
float
|
|
126
|
+
|
|
127
|
+
Examples
|
|
128
|
+
--------
|
|
129
|
+
An exactly exponential envelope recovers its localization length:
|
|
130
|
+
|
|
131
|
+
>>> import numpy as np
|
|
132
|
+
>>> x = np.arange(200)
|
|
133
|
+
>>> xi_true = 5.0
|
|
134
|
+
>>> psi = np.exp(-np.abs(x - 100) / xi_true)
|
|
135
|
+
>>> round(localization_length(psi), 4)
|
|
136
|
+
5.0
|
|
137
|
+
"""
|
|
138
|
+
psi = np.asarray(psi)
|
|
139
|
+
positions = np.arange(len(psi)) if positions is None else np.asarray(positions, dtype=float)
|
|
140
|
+
log_density = np.log(np.abs(psi) ** 2 + 1e-300)
|
|
141
|
+
peak = int(np.argmax(log_density))
|
|
142
|
+
|
|
143
|
+
slopes = []
|
|
144
|
+
if peak > 1:
|
|
145
|
+
left_slope = np.polyfit(positions[: peak + 1], log_density[: peak + 1], 1)[0]
|
|
146
|
+
if left_slope > 0:
|
|
147
|
+
slopes.append(left_slope)
|
|
148
|
+
if peak < len(psi) - 2:
|
|
149
|
+
right_slope = np.polyfit(positions[peak:], log_density[peak:], 1)[0]
|
|
150
|
+
if right_slope < 0:
|
|
151
|
+
slopes.append(-right_slope)
|
|
152
|
+
|
|
153
|
+
if not slopes:
|
|
154
|
+
return float("inf")
|
|
155
|
+
return float(2.0 / np.mean(slopes))
|