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,106 @@
|
|
|
1
|
+
"""Visualizations of random walk trajectories and diffusive scaling."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
__all__ = ["plot_clt_histogram", "plot_msd", "plot_trajectories_2d"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def plot_trajectories_2d(walk, ax=None, n_show=20):
|
|
12
|
+
"""Plot a subset of a 2D random walk ensemble's trajectories.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
walk : RandomWalk
|
|
17
|
+
A walk instance with ``dim=2``; run automatically if not already.
|
|
18
|
+
ax : matplotlib.axes.Axes, optional
|
|
19
|
+
Axes to draw into. A new figure and axes are created if not given.
|
|
20
|
+
n_show : int, default=20
|
|
21
|
+
Number of individual trajectories to draw.
|
|
22
|
+
|
|
23
|
+
Returns
|
|
24
|
+
-------
|
|
25
|
+
matplotlib.axes.Axes
|
|
26
|
+
"""
|
|
27
|
+
if walk.dim != 2:
|
|
28
|
+
raise ValueError("plot_trajectories_2d requires a RandomWalk with dim=2")
|
|
29
|
+
if walk.trajectories is None:
|
|
30
|
+
walk.run()
|
|
31
|
+
if ax is None:
|
|
32
|
+
_, ax = plt.subplots(figsize=(5, 5))
|
|
33
|
+
n_show = min(n_show, walk.n_walkers)
|
|
34
|
+
for w in range(n_show):
|
|
35
|
+
ax.plot(walk.trajectories[:, w, 0], walk.trajectories[:, w, 1], alpha=0.6, linewidth=0.8)
|
|
36
|
+
ax.set_xlabel("x")
|
|
37
|
+
ax.set_ylabel("y")
|
|
38
|
+
ax.set_aspect("equal")
|
|
39
|
+
ax.set_title(f"{n_show} random walk trajectories")
|
|
40
|
+
return ax
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def plot_msd(walk, ax=None, show_theory=True):
|
|
44
|
+
"""Plot the ensemble mean squared displacement against the Einstein-relation prediction.
|
|
45
|
+
|
|
46
|
+
Parameters
|
|
47
|
+
----------
|
|
48
|
+
walk : RandomWalk
|
|
49
|
+
Walk instance to summarize.
|
|
50
|
+
ax : matplotlib.axes.Axes, optional
|
|
51
|
+
Axes to draw into.
|
|
52
|
+
show_theory : bool, default=True
|
|
53
|
+
Whether to overlay the fitted line :math:`2 d D t`.
|
|
54
|
+
|
|
55
|
+
Returns
|
|
56
|
+
-------
|
|
57
|
+
matplotlib.axes.Axes
|
|
58
|
+
"""
|
|
59
|
+
t, msd = walk.mean_squared_displacement()
|
|
60
|
+
if ax is None:
|
|
61
|
+
_, ax = plt.subplots(figsize=(5, 4))
|
|
62
|
+
ax.plot(t, msd, label="simulation")
|
|
63
|
+
if show_theory:
|
|
64
|
+
D = walk.diffusion_coefficient()
|
|
65
|
+
ax.plot(t, 2 * walk.dim * D * t, linestyle="--", label=f"$2dDt$, D={D:.3f}")
|
|
66
|
+
ax.set_xlabel("t")
|
|
67
|
+
ax.set_ylabel("MSD(t)")
|
|
68
|
+
ax.legend()
|
|
69
|
+
return ax
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def plot_clt_histogram(walk, ax=None, axis=0, bins=40):
|
|
73
|
+
"""Histogram the final-time displacement against the Gaussian predicted by the CLT.
|
|
74
|
+
|
|
75
|
+
Parameters
|
|
76
|
+
----------
|
|
77
|
+
walk : RandomWalk
|
|
78
|
+
Walk instance to summarize.
|
|
79
|
+
ax : matplotlib.axes.Axes, optional
|
|
80
|
+
Axes to draw into.
|
|
81
|
+
axis : int, default=0
|
|
82
|
+
Spatial axis to histogram.
|
|
83
|
+
bins : int, default=40
|
|
84
|
+
Number of histogram bins.
|
|
85
|
+
|
|
86
|
+
Returns
|
|
87
|
+
-------
|
|
88
|
+
matplotlib.axes.Axes
|
|
89
|
+
"""
|
|
90
|
+
from physicskit.statphys.utils.thermodynamics import maxwell_boltzmann_component_pdf
|
|
91
|
+
|
|
92
|
+
centers, density = walk.final_displacement_histogram(axis=axis, bins=bins)
|
|
93
|
+
if ax is None:
|
|
94
|
+
_, ax = plt.subplots(figsize=(5, 4))
|
|
95
|
+
ax.bar(centers, density, width=(centers[1] - centers[0]), alpha=0.6, label="simulation")
|
|
96
|
+
|
|
97
|
+
if walk.trajectories is None:
|
|
98
|
+
walk.run()
|
|
99
|
+
var = np.var(walk.trajectories[-1, :, axis])
|
|
100
|
+
xs = np.linspace(centers.min(), centers.max(), 200)
|
|
101
|
+
gaussian = maxwell_boltzmann_component_pdf(xs, temperature=var, mass=1.0, kB=1.0)
|
|
102
|
+
ax.plot(xs, gaussian, color="crimson", label="Gaussian (CLT)")
|
|
103
|
+
ax.set_xlabel(f"final displacement (axis {axis})")
|
|
104
|
+
ax.set_ylabel("density")
|
|
105
|
+
ax.legend()
|
|
106
|
+
return ax
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Visualization of block-spin renormalization group flows."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
|
|
7
|
+
__all__ = ["plot_rg_flow"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def plot_rg_flow(grids, titles=None, cmap="coolwarm"):
|
|
11
|
+
"""Plot a sequence of coarse-grained lattices side by side.
|
|
12
|
+
|
|
13
|
+
Parameters
|
|
14
|
+
----------
|
|
15
|
+
grids : list of ndarray
|
|
16
|
+
Sequence of spin configurations at increasing coarse-graining
|
|
17
|
+
levels, e.g. the output of ``BlockSpinRG.iterate``.
|
|
18
|
+
titles : list of str, optional
|
|
19
|
+
One title per panel. Defaults to ``"L = {size}"`` for each grid.
|
|
20
|
+
cmap : str, default="coolwarm"
|
|
21
|
+
Matplotlib colormap name.
|
|
22
|
+
|
|
23
|
+
Returns
|
|
24
|
+
-------
|
|
25
|
+
ndarray of matplotlib.axes.Axes
|
|
26
|
+
|
|
27
|
+
Examples
|
|
28
|
+
--------
|
|
29
|
+
>>> from physicskit.statphys.chapters import BlockSpinRG
|
|
30
|
+
>>> rg = BlockSpinRG(L=16, T=2.269, seed=0)
|
|
31
|
+
>>> axes = plot_rg_flow(rg.iterate())
|
|
32
|
+
"""
|
|
33
|
+
n = len(grids)
|
|
34
|
+
_fig, axes = plt.subplots(1, n, figsize=(3 * n, 3))
|
|
35
|
+
if n == 1:
|
|
36
|
+
axes = [axes]
|
|
37
|
+
if titles is None:
|
|
38
|
+
titles = [f"L = {g.shape[0]}" for g in grids]
|
|
39
|
+
for ax, grid, title in zip(axes, grids, titles):
|
|
40
|
+
ax.imshow(grid, cmap=cmap, interpolation="nearest")
|
|
41
|
+
ax.set_title(title)
|
|
42
|
+
ax.set_xticks([])
|
|
43
|
+
ax.set_yticks([])
|
|
44
|
+
plt.tight_layout()
|
|
45
|
+
return axes
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Visualizations of the BTW sandpile: pile heights and avalanche statistics."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
__all__ = ["plot_avalanche_size_distribution", "plot_sandpile_heights"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def plot_sandpile_heights(sandpile, ax=None, cmap="viridis"):
|
|
12
|
+
"""Render the current pile heights as a heatmap.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
sandpile : BTWSandpile
|
|
17
|
+
Sandpile instance to render.
|
|
18
|
+
ax : matplotlib.axes.Axes, optional
|
|
19
|
+
Axes to draw into. A new figure and axes are created if not given.
|
|
20
|
+
cmap : str, default="viridis"
|
|
21
|
+
Matplotlib colormap name.
|
|
22
|
+
|
|
23
|
+
Returns
|
|
24
|
+
-------
|
|
25
|
+
matplotlib.axes.Axes
|
|
26
|
+
"""
|
|
27
|
+
if ax is None:
|
|
28
|
+
_, ax = plt.subplots(figsize=(5, 5))
|
|
29
|
+
im = ax.imshow(sandpile.heights, cmap=cmap, vmin=0, vmax=sandpile.threshold - 1, interpolation="nearest")
|
|
30
|
+
plt.colorbar(im, ax=ax, fraction=0.046, pad=0.04, label="height")
|
|
31
|
+
ax.set_xticks([])
|
|
32
|
+
ax.set_yticks([])
|
|
33
|
+
ax.set_title(f"Sandpile: {sandpile.total_grains()} grains")
|
|
34
|
+
return ax
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def plot_avalanche_size_distribution(sizes, ax=None, bins=40):
|
|
38
|
+
"""Log-log histogram of avalanche sizes, the self-organized-criticality power-law signature.
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
sizes : array_like
|
|
43
|
+
Avalanche sizes, e.g. from :meth:`BTWSandpile.run`.
|
|
44
|
+
ax : matplotlib.axes.Axes, optional
|
|
45
|
+
Axes to draw into.
|
|
46
|
+
bins : int, default=40
|
|
47
|
+
Number of logarithmically spaced bins.
|
|
48
|
+
|
|
49
|
+
Returns
|
|
50
|
+
-------
|
|
51
|
+
matplotlib.axes.Axes
|
|
52
|
+
"""
|
|
53
|
+
sizes = np.asarray(sizes)
|
|
54
|
+
sizes = sizes[sizes > 0]
|
|
55
|
+
if ax is None:
|
|
56
|
+
_, ax = plt.subplots(figsize=(5, 4))
|
|
57
|
+
log_bins = np.logspace(0, np.log10(sizes.max()), bins)
|
|
58
|
+
counts, edges = np.histogram(sizes, bins=log_bins, density=True)
|
|
59
|
+
centers = np.sqrt(edges[:-1] * edges[1:])
|
|
60
|
+
mask = counts > 0
|
|
61
|
+
ax.loglog(centers[mask], counts[mask], marker="o", ms=3, linestyle="none")
|
|
62
|
+
ax.set_xlabel("avalanche size s")
|
|
63
|
+
ax.set_ylabel("P(s)")
|
|
64
|
+
ax.set_title("Avalanche size distribution (SOC power law)")
|
|
65
|
+
return ax
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Visualizations of spin-glass replica overlaps."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
__all__ = ["plot_overlap_distribution"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def plot_overlap_distribution(samples, ax=None, bins=40, label=None):
|
|
12
|
+
"""Histogram the replica-overlap samples P(q).
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
samples : array_like
|
|
17
|
+
Overlap samples in ``[-1, 1]``, e.g. from
|
|
18
|
+
:meth:`SherringtonKirkpatrick.overlap_distribution`.
|
|
19
|
+
ax : matplotlib.axes.Axes, optional
|
|
20
|
+
Axes to draw into. A new figure and axes are created if not given.
|
|
21
|
+
bins : int, default=40
|
|
22
|
+
Number of histogram bins.
|
|
23
|
+
label : str, optional
|
|
24
|
+
Legend label for this histogram (useful when overlaying several
|
|
25
|
+
temperatures on the same axes).
|
|
26
|
+
|
|
27
|
+
Returns
|
|
28
|
+
-------
|
|
29
|
+
matplotlib.axes.Axes
|
|
30
|
+
"""
|
|
31
|
+
samples = np.asarray(samples)
|
|
32
|
+
if ax is None:
|
|
33
|
+
_, ax = plt.subplots(figsize=(6, 4))
|
|
34
|
+
ax.hist(samples, bins=bins, range=(-1, 1), density=True, alpha=0.6, label=label)
|
|
35
|
+
ax.set_xlabel("overlap q")
|
|
36
|
+
ax.set_ylabel("P(q)")
|
|
37
|
+
ax.set_xlim(-1, 1)
|
|
38
|
+
if label is not None:
|
|
39
|
+
ax.legend()
|
|
40
|
+
return ax
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Visualization of the Ehrenfest urn model's relaxation to equilibrium."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
|
|
7
|
+
__all__ = ["plot_ehrenfest_history"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def plot_ehrenfest_history(history, n_balls, ax=None):
|
|
11
|
+
"""Plot the box occupancy and entropy history of an Ehrenfest urn run.
|
|
12
|
+
|
|
13
|
+
Parameters
|
|
14
|
+
----------
|
|
15
|
+
history : dict of str -> ndarray
|
|
16
|
+
Output of :meth:`EhrenfestUrn.run`.
|
|
17
|
+
n_balls : int
|
|
18
|
+
Total ball count, used to mark the equilibrium level N/2.
|
|
19
|
+
ax : ndarray of matplotlib.axes.Axes, optional
|
|
20
|
+
A pair of axes to draw into; a new figure is created if not given.
|
|
21
|
+
|
|
22
|
+
Returns
|
|
23
|
+
-------
|
|
24
|
+
ndarray of matplotlib.axes.Axes
|
|
25
|
+
"""
|
|
26
|
+
if ax is None:
|
|
27
|
+
_, ax = plt.subplots(1, 2, figsize=(10, 4))
|
|
28
|
+
ax[0].plot(history["t"], history["n_left"], linewidth=0.8)
|
|
29
|
+
ax[0].axhline(n_balls / 2, color="k", linestyle="--", linewidth=1, alpha=0.6)
|
|
30
|
+
ax[0].set_xlabel("step")
|
|
31
|
+
ax[0].set_ylabel("balls in left box")
|
|
32
|
+
ax[0].set_title("Relaxation to equilibrium")
|
|
33
|
+
|
|
34
|
+
ax[1].plot(history["t"], history["entropy"], color="crimson")
|
|
35
|
+
ax[1].set_xlabel("step")
|
|
36
|
+
ax[1].set_ylabel("entropy $S/k_B$")
|
|
37
|
+
ax[1].set_title("Monotonic entropy growth")
|
|
38
|
+
return ax
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""Visualizations of the XY model: spin vector fields and topological vortices."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
__all__ = ["plot_vortices", "plot_xy_vector_field"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def plot_xy_vector_field(theta, ax=None, step=1, cmap="hsv"):
|
|
12
|
+
"""Draw the XY model's planar spins as a quiver plot, colored by angle.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
theta : ndarray of shape (L, L)
|
|
17
|
+
Spin angles in radians, e.g. ``XYModel2D.theta``.
|
|
18
|
+
ax : matplotlib.axes.Axes, optional
|
|
19
|
+
Axes to draw into. A new figure and axes are created if not given.
|
|
20
|
+
step : int, default=1
|
|
21
|
+
Subsample every ``step``-th spin along each axis, useful for large
|
|
22
|
+
lattices where a dense quiver plot is unreadable.
|
|
23
|
+
cmap : str, default="hsv"
|
|
24
|
+
Colormap used to color arrows by their angle (a cyclic colormap is
|
|
25
|
+
the natural choice for a periodic quantity).
|
|
26
|
+
|
|
27
|
+
Returns
|
|
28
|
+
-------
|
|
29
|
+
matplotlib.axes.Axes
|
|
30
|
+
"""
|
|
31
|
+
if ax is None:
|
|
32
|
+
_, ax = plt.subplots(figsize=(5, 5))
|
|
33
|
+
L = theta.shape[0]
|
|
34
|
+
idx = np.arange(0, L, step)
|
|
35
|
+
ii, jj = np.meshgrid(idx, idx, indexing="ij")
|
|
36
|
+
sub_theta = theta[np.ix_(idx, idx)]
|
|
37
|
+
u = np.cos(sub_theta)
|
|
38
|
+
v = np.sin(sub_theta)
|
|
39
|
+
ax.quiver(jj, ii, u, v, sub_theta, cmap=cmap, pivot="mid", angles="xy", clim=(0, 2 * np.pi))
|
|
40
|
+
ax.set_xlim(-1, L)
|
|
41
|
+
ax.set_ylim(-1, L)
|
|
42
|
+
ax.set_aspect("equal")
|
|
43
|
+
ax.invert_yaxis()
|
|
44
|
+
ax.set_xticks([])
|
|
45
|
+
ax.set_yticks([])
|
|
46
|
+
return ax
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def plot_vortices(theta, vorticity=None, ax=None, threshold=0.5, step=1):
|
|
50
|
+
"""Overlay the XY spin field with markers at vortex and antivortex cores.
|
|
51
|
+
|
|
52
|
+
Parameters
|
|
53
|
+
----------
|
|
54
|
+
theta : ndarray of shape (L, L)
|
|
55
|
+
Spin angles in radians.
|
|
56
|
+
vorticity : ndarray of shape (L, L), optional
|
|
57
|
+
Precomputed plaquette vorticity (see
|
|
58
|
+
:func:`physicskit.statphys.core.monte_carlo.xy_plaquette_vorticity`); computed
|
|
59
|
+
from ``theta`` if not given.
|
|
60
|
+
ax : matplotlib.axes.Axes, optional
|
|
61
|
+
Axes to draw into.
|
|
62
|
+
threshold : float, default=0.5
|
|
63
|
+
Minimum ``|vorticity|`` to mark as a topological charge.
|
|
64
|
+
step : int, default=1
|
|
65
|
+
Subsampling for the underlying vector field, forwarded to
|
|
66
|
+
:func:`plot_xy_vector_field`.
|
|
67
|
+
|
|
68
|
+
Returns
|
|
69
|
+
-------
|
|
70
|
+
matplotlib.axes.Axes
|
|
71
|
+
"""
|
|
72
|
+
if vorticity is None:
|
|
73
|
+
from physicskit.statphys.core.monte_carlo import xy_plaquette_vorticity
|
|
74
|
+
|
|
75
|
+
vorticity = xy_plaquette_vorticity(theta)
|
|
76
|
+
|
|
77
|
+
ax = plot_xy_vector_field(theta, ax=ax, step=step)
|
|
78
|
+
vi, vj = np.nonzero(vorticity > threshold)
|
|
79
|
+
ai, aj = np.nonzero(vorticity < -threshold)
|
|
80
|
+
ax.scatter(vj + 0.5, vi + 0.5, c="red", marker="o", s=60, label="vortex (+1)", zorder=5)
|
|
81
|
+
ax.scatter(aj + 0.5, ai + 0.5, c="blue", marker="x", s=60, label="antivortex (-1)", zorder=5)
|
|
82
|
+
if len(vi) or len(ai):
|
|
83
|
+
ax.legend(loc="upper right", fontsize=8, framealpha=0.9)
|
|
84
|
+
return ax
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Tests for physicskit.constants."""
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
import physicskit.constants as const
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_speed_of_light_exact():
|
|
9
|
+
assert const.C == 299_792_458.0
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test_energy_temperature_roundtrip():
|
|
13
|
+
T = 300.0
|
|
14
|
+
E = const.temperature_to_energy(T)
|
|
15
|
+
assert const.energy_to_temperature(E) == pytest.approx(T)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_ev_joule_roundtrip():
|
|
19
|
+
E_ev = 13.6
|
|
20
|
+
assert const.joules_to_ev(const.ev_to_joules(E_ev)) == pytest.approx(E_ev)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_electronvolt_matches_elementary_charge():
|
|
24
|
+
# 1 eV is, by definition, the elementary charge times 1 volt.
|
|
25
|
+
assert const.ELECTRONVOLT == pytest.approx(const.ELEMENTARY_CHARGE)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_gravitational_unit_system_consistent_with_G():
|
|
29
|
+
units = const.gravitational_unit_system(length_m=const.PARSEC_M, mass_kg=const.SOLAR_MASS_KG)
|
|
30
|
+
# G_SI = length_m^3 / (mass_kg * time_s^2) should reproduce G by construction.
|
|
31
|
+
recovered_G = units["length_m"] ** 3 / (units["mass_kg"] * units["time_s"] ** 2)
|
|
32
|
+
assert recovered_G == pytest.approx(const.G)
|
|
33
|
+
assert units["velocity_m_s"] == pytest.approx(units["length_m"] / units["time_s"])
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_gravitational_unit_system_rejects_nonpositive_inputs():
|
|
37
|
+
with pytest.raises(ZeroDivisionError):
|
|
38
|
+
const.gravitational_unit_system(length_m=1.0, mass_kg=0.0)
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: physicskit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Unified scientific toolkit for computational physics: General Relativity, Quantum Mechanics, Chaos, Random Matrix Theory, Statistical Mechanics, Classical Dynamics, and Condensed Matter.
|
|
5
|
+
Author-email: Charles Poli <cpoli374@gmail.com>
|
|
6
|
+
Maintainer-email: Charles Poli <cpoli374@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/cpoli/physicskit
|
|
9
|
+
Project-URL: Issues, https://github.com/cpoli/physicskit/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/cpoli/physicskit/blob/main/CHANGELOG.md
|
|
11
|
+
Project-URL: Documentation, https://physicskit.readthedocs.io
|
|
12
|
+
Keywords: physics,condensed-matter,general-relativity,quantum-mechanics,chaos,random-matrix-theory,statistical-mechanics,classical-mechanics
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: numpy>=1.24
|
|
27
|
+
Requires-Dist: scipy>=1.10
|
|
28
|
+
Requires-Dist: matplotlib>=3.6
|
|
29
|
+
Requires-Dist: numba>=0.58
|
|
30
|
+
Requires-Dist: plotly>=5.15
|
|
31
|
+
Requires-Dist: sympy>=1.11
|
|
32
|
+
Requires-Dist: tqdm>=4.65
|
|
33
|
+
Provides-Extra: test
|
|
34
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
35
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
36
|
+
Requires-Dist: pytest-xdist>=3.0; extra == "test"
|
|
37
|
+
Requires-Dist: hypothesis>=6.90; extra == "test"
|
|
38
|
+
Requires-Dist: pillow>=9.0; extra == "test"
|
|
39
|
+
Provides-Extra: docs
|
|
40
|
+
Requires-Dist: sphinx>=7.0; extra == "docs"
|
|
41
|
+
Requires-Dist: pydata-sphinx-theme>=0.15; extra == "docs"
|
|
42
|
+
Requires-Dist: sphinx-autodoc-typehints>=1.25; extra == "docs"
|
|
43
|
+
Requires-Dist: myst-parser>=2.0; extra == "docs"
|
|
44
|
+
Requires-Dist: sphinx-gallery>=0.15; extra == "docs"
|
|
45
|
+
Requires-Dist: sphinx-design>=0.6; extra == "docs"
|
|
46
|
+
Provides-Extra: dev
|
|
47
|
+
Requires-Dist: physicskit[docs,test]; extra == "dev"
|
|
48
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
49
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
50
|
+
Requires-Dist: pre-commit>=3.7; extra == "dev"
|
|
51
|
+
Dynamic: license-file
|
|
52
|
+
|
|
53
|
+
# physicskit
|
|
54
|
+
|
|
55
|
+
| | |
|
|
56
|
+
|:--|:-:|
|
|
57
|
+
| Package | [](https://pypi.org/project/physicskit/) [](https://pypi.org/project/physicskit/) |
|
|
58
|
+
| Quality | [](https://github.com/cpoli/physicskit/blob/main/LICENSE) [](https://github.com/cpoli/physicskit/actions/workflows/ci.yml) [](https://codecov.io/gh/cpoli/physicskit) |
|
|
59
|
+
| Documentation | [](https://physicskit.readthedocs.io) |
|
|
60
|
+
| Code style | [](https://github.com/astral-sh/ruff) |
|
|
61
|
+
| Downloads | [](https://pepy.tech/project/physicskit) [](https://pepy.tech/project/physicskit) |
|
|
62
|
+
| Community | [](https://github.com/cpoli/physicskit) [](https://github.com/cpoli/physicskit) [](https://github.com/cpoli/physicskit/graphs/contributors) [](https://github.com/cpoli/physicskit/commits/main) |
|
|
63
|
+
|
|
64
|
+
A unified scientific toolkit for computational physics, spanning the
|
|
65
|
+
field end to end: the quantum mechanics of a single hydrogen atom, the
|
|
66
|
+
numerical relativity of colliding black holes, turbulent fluid
|
|
67
|
+
instabilities, topological superconductors, magnetically confined
|
|
68
|
+
plasmas, and chaotic quantum billiards -- with each domain's docs
|
|
69
|
+
tracing the field's own foundational breakthroughs in chronological,
|
|
70
|
+
pedagogical order, every historical milestone linked directly to the
|
|
71
|
+
runnable code that reproduces it. 14 domain subpackages, one consistent
|
|
72
|
+
NumPy-based API, sharing common ODE integrators and physical constants
|
|
73
|
+
throughout. Conventionally imported as `pk`.
|
|
74
|
+
|
|
75
|
+
## Install
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
python -m venv .venv && source .venv/bin/activate
|
|
79
|
+
pip install -e ".[dev]"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Quick start
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import physicskit as pk
|
|
86
|
+
import numpy as np
|
|
87
|
+
|
|
88
|
+
H = lambda k1, k2: pk.condensed.haldane_model(k1, k2, phi=np.pi / 2)
|
|
89
|
+
chern_numbers = pk.condensed.compute_chern_number(H, grid_size=30)
|
|
90
|
+
print(chern_numbers) # [1, -1]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Every subpackage below links to its worked examples; see
|
|
94
|
+
[Subpackages](#subpackages) for the full list, or browse the docs at
|
|
95
|
+
<https://physicskit.readthedocs.io>.
|
|
96
|
+
|
|
97
|
+
## Subpackages
|
|
98
|
+
|
|
99
|
+
Domain subpackages, each with runnable examples linked below:
|
|
100
|
+
|
|
101
|
+
- [`physicskit.astro`](https://physicskit.readthedocs.io/en/latest/examples/astro.html) -- stellar structure (Tolman-Oppenheimer-Volkoff, polytropes), N-body dynamics, orbital mechanics, galactic rotation curves, stellar convection and the magnetic dynamo.
|
|
102
|
+
- [`physicskit.chaos`](https://physicskit.readthedocs.io/en/latest/examples/chaos.html) -- chaotic dynamical systems and 2D quantum billiards.
|
|
103
|
+
- [`physicskit.classical`](https://physicskit.readthedocs.io/en/latest/examples/classical.html) -- classical mechanics: Newtonian, Lagrangian, Hamiltonian, lattice, and rigid-body dynamics.
|
|
104
|
+
- [`physicskit.condensed`](https://physicskit.readthedocs.io/en/latest/examples/condensed.html) -- tight-binding models, topological band theory (Chern numbers, edge states), correlated-electron superconductivity.
|
|
105
|
+
- [`physicskit.fields`](https://physicskit.readthedocs.io/en/latest/examples/fields.html) -- FDTD electrodynamics, KdV/NLS/Sine-Gordon solitons, BEC vortex lattices.
|
|
106
|
+
- [`physicskit.fluids`](https://physicskit.readthedocs.io/en/latest/examples/fluids.html) -- potential flow, viscous exact solutions, point-vortex dynamics, Kelvin-Helmholtz and Rayleigh-Taylor instabilities, compressible shocks, and the 2D incompressible Navier-Stokes solver underlying them.
|
|
107
|
+
- [`physicskit.optics`](https://physicskit.readthedocs.io/en/latest/examples/optics.html) -- ray, wave, and Gaussian-beam optics; quantum optics (squeezed states, Wigner functions).
|
|
108
|
+
- [`physicskit.particle`](https://physicskit.readthedocs.io/en/latest/examples/particle.html) -- relativistic kinematics, particle decays and scattering, nuclear physics.
|
|
109
|
+
- [`physicskit.plasma`](https://physicskit.readthedocs.io/en/latest/examples/plasma.html) -- Boris-pusher single-particle motion, guiding-center drifts, Grad-Shafranov MHD equilibrium, magnetic reconnection, cold-plasma wave dispersion, particle-in-cell Vlasov-Poisson kinetics.
|
|
110
|
+
- [`physicskit.quantum`](https://physicskit.readthedocs.io/en/latest/examples/quantum.html) -- quantum mechanics: wave packets, potentials, hydrogen, entanglement, measurement.
|
|
111
|
+
- [`physicskit.relativity`](https://physicskit.readthedocs.io/en/latest/examples/relativity.html) -- numerical general relativity: black holes, lensing, gravitational waves, cosmology.
|
|
112
|
+
- [`physicskit.rmt`](https://physicskit.readthedocs.io/en/latest/examples/rmt.html) -- random matrix theory, organized around Dyson's threefold way.
|
|
113
|
+
- [`physicskit.semiclassical`](https://physicskit.readthedocs.io/en/latest/examples/semiclassical.html) -- WKB/EBK quantization, Van Vleck/Herman-Kluk semiclassical propagators, the Gutzwiller trace formula, and quantum scarring.
|
|
114
|
+
- [`physicskit.statphys`](https://physicskit.readthedocs.io/en/latest/examples/statphys.html) -- statistical mechanics: lattice models, molecular dynamics, criticality, disordered systems.
|
|
115
|
+
|
|
116
|
+
Shared infrastructure, used across the subpackages above rather than
|
|
117
|
+
standalone toolkits:
|
|
118
|
+
|
|
119
|
+
- `physicskit.constants` -- SI physical constants shared across subpackages, plus a few well-defined unit conversions (energy/temperature, eV/joules, gravitational G=1 unit systems).
|
|
120
|
+
- `physicskit.integrators` -- shared numerical ODE integrators (RK4, leapfrog, Yoshida4, adaptive Dormand-Prince) used across the other subpackages.
|
|
121
|
+
|
|
122
|
+
## Test
|
|
123
|
+
|
|
124
|
+
Tests live alongside each subpackage, at `physicskit/<name>/tests/`.
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
pytest # everything
|
|
128
|
+
pytest physicskit/rmt/tests # a single subpackage
|
|
129
|
+
|
|
130
|
+
# docstring examples, across every subpackage (pyvista's 3D viewer is
|
|
131
|
+
# optional and skipped rather than installed as a hard test dependency):
|
|
132
|
+
MPLBACKEND=Agg pytest --doctest-modules physicskit \
|
|
133
|
+
--ignore-glob="*/tests/*" \
|
|
134
|
+
--ignore=physicskit/chaos/visualizers/viewer3d.py
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Both commands, plus `ruff check`/`ruff format --check`, run in CI on
|
|
138
|
+
every PR (`.github/workflows/ci.yml`) across Python 3.10-3.12 on Linux and
|
|
139
|
+
macOS. See [CONTRIBUTING.md](CONTRIBUTING.md) before opening a PR.
|
|
140
|
+
|
|
141
|
+
### Coverage
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
MPLBACKEND=Agg pytest -q -n auto --cov=physicskit --cov-report=term
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
1,720 tests, 96% line coverage overall. Per-subpackage coverage:
|
|
148
|
+
|
|
149
|
+
| Subpackage | Coverage | | Subpackage | Coverage |
|
|
150
|
+
|:--|--:|---|:--|--:|
|
|
151
|
+
| `astro` | 100% | | `plasma` | 99% |
|
|
152
|
+
| `chaos` | 87% | | `quantum` | 96% |
|
|
153
|
+
| `classical` | 100% | | `relativity` | 99% |
|
|
154
|
+
| `condensed` | 100% | | `rmt` | 100% |
|
|
155
|
+
| `fields` | 100% | | `semiclassical` | 99% |
|
|
156
|
+
| `fluids` | 100% | | `statphys` | 86% |
|
|
157
|
+
| `integrators` | 100% | | `constants` | 100% |
|
|
158
|
+
| `optics` | 100% | | | |
|
|
159
|
+
| `particle` | 100% | | | |
|
|
160
|
+
|
|
161
|
+
Every subpackage is at 100% coverage outside `visualizers/` modules (99.9%
|
|
162
|
+
in aggregate — six rare bootstrap-loop edge cases remain uncovered across
|
|
163
|
+
`statphys.chapters.percolation` and `rmt.stats`). `chaos`, `quantum`, and
|
|
164
|
+
`statphys` still sit lower overall because their `visualizers/` modules
|
|
165
|
+
are smoke-tested only (correct return type/shape, or that `anim.save()`
|
|
166
|
+
succeeds) rather than covered line-by-line, per the testing convention in
|
|
167
|
+
[CLAUDE.md](CLAUDE.md). `@njit`-compiled lines are excluded from coverage
|
|
168
|
+
entirely (`pyproject.toml`, `[tool.coverage.report]`) since
|
|
169
|
+
`coverage.py` cannot trace into numba-compiled native code.
|
|
170
|
+
|
|
171
|
+
## Docs
|
|
172
|
+
|
|
173
|
+
Built docs are hosted at <https://physicskit.readthedocs.io>. To build
|
|
174
|
+
locally:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
pip install -e ".[docs]"
|
|
178
|
+
cd docs && make html
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
See `docs/source/history/` for a chronology of each field's foundational
|
|
182
|
+
breakthroughs, linked to the corresponding implementation at each step.
|
|
183
|
+
|
|
184
|
+
## Citation
|
|
185
|
+
|
|
186
|
+
If you use physicskit in your research, please cite it — see
|
|
187
|
+
[CITATION.cff](CITATION.cff).
|
|
188
|
+
|
|
189
|
+
## Contributing
|
|
190
|
+
|
|
191
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). Please note that this project
|
|
192
|
+
follows the [Contributor Covenant](CODE_OF_CONDUCT.md).
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
MIT -- see [LICENSE](LICENSE).
|