Skip to content

๐ŸŒŒ Advanced toolkit for simulating and analyzing turbulent polarization in astrophysical environments | Kolmogorov turbulence | Stokes parameters | Faraday rotation | Python/Fortran

Notifications You must be signed in to change notification settings

astrosander/AstroTurbulence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

AstroTurbulence ๐ŸŒŒ

Python License: MIT Astrophysics Plasma Physics

Advanced toolkit for simulating and analyzing turbulent polarization in astrophysical environments

Simulate Kolmogorov turbulence, generate polarization maps, analyze Faraday rotation, and compute structure functions for astrophysical research.

Polarization Maps

โœจ Features

๐ŸŒช๏ธ Turbulence Simulation

  • Kolmogorov Power Spectrum: Generate realistic 3D turbulent velocity fields
  • Solenoidal & Compressive: Support for both solenoidal and non-solenoidal turbulence
  • Configurable Resolution: From 256ยณ to 512ยณ grid points and beyond
  • Helmholtz Decomposition: Advanced vector field decomposition

๐Ÿ“ก Polarization Analysis

  • Stokes Parameters: Full I, Q, U parameter computation
  • Synchrotron Emission: Realistic synchrotron polarization modeling
  • Dust Polarization: Dust-based polarization prescriptions
  • Faraday Rotation: Screen effects and rotation measure analysis

๐Ÿ“Š Statistical Tools

  • Structure Functions: Angular structure function computation D_ฯ†(R)
  • Power Law Analysis: Automated slope fitting and validation
  • PDF Analysis: Single-point and two-point probability distributions
  • Correlation Analysis: Spatial correlation characterization

๐ŸŽฏ Research Applications

  • Interstellar Medium studies
  • Magnetohydrodynamic turbulence analysis
  • Cosmic ray propagation modeling
  • Radio astronomy data interpretation

๐Ÿš€ Quick Start

Installation

git clone https://github.com/astrosander/AstroTurbulence.git
cd AstroTurbulence
pip install -r requirements.txt

Basic Usage

Generate Turbulent Velocity Field

from turbulence_angles.turbulence_angles_full import generate_velocity_cube

# Generate 256ยณ solenoidal velocity field
u = generate_velocity_cube(N=256, solenoidal=True, seed=42)
print(f"Generated velocity cube: {u.shape}")

Compute Polarization Maps

# Synchrotron polarization
Q_syn = np.sum(u[:,:,:,0]**2 - u[:,:,:,1]**2, axis=2)
U_syn = np.sum(2 * u[:,:,:,0] * u[:,:,:,1], axis=2)
phi_syn = 0.5 * np.arctan2(U_syn, Q_syn)

Structure Function Analysis

from check_power_law import structure_function_2d

Rs = np.logspace(0, 2, 20).astype(int)
R_vals, D_phi = structure_function_2d(phi_syn, Rs)

# Should recover ~R^(5/3) Kolmogorov scaling

๐Ÿ“ Project Structure

AstroTurbulence/
โ”œโ”€โ”€ ๐ŸŒช๏ธ turbulence_angles/          # Core turbulence simulation
โ”‚   โ”œโ”€โ”€ turbulence_angles_full.py   # Main simulation engine
โ”‚   โ”œโ”€โ”€ single_PDF_vector.py        # Statistical analysis
โ”‚   โ””โ”€โ”€ figures/                    # Generated plots
โ”œโ”€โ”€ ๐Ÿ“ก faradays_angles_stats/       # Faraday rotation analysis
โ”‚   โ”œโ”€โ”€ faraday_screen_demo.py     # Faraday screen modeling
โ”‚   โ””โ”€โ”€ lp_structure_tests/         # Linear polarization tests
โ”œโ”€โ”€ ๐Ÿ“Š stokesMaps_velocity_kolmogorov_NoNorm/  # Stokes parameter maps
โ”‚   โ”œโ”€โ”€ read_and_plot.py           # Visualization tools
โ”‚   โ””โ”€โ”€ check_power_law.py         # Power law validation
โ”œโ”€โ”€ โšก spectrum_generation/         # Power spectrum analysis
โ””โ”€โ”€ ๐Ÿงฎ check_integration_factors/  # Numerical validation

๐Ÿ“ˆ Example Results

Polarization Structure Functions

The toolkit reproduces the expected Kolmogorov R^(5/3) scaling for turbulent polarization:

# Expected output:
# Stokes azimuth slope: 1.67 ยฑ 0.05
# Vector azimuth slope: 1.65 ยฑ 0.04

Faraday Rotation Analysis

Analyze how magnetic field turbulence affects polarization:

python faradays_angles_stats/faraday_screen_demo.py

๐Ÿ”ฌ Scientific Applications

This toolkit has been used for research in:

  • Interstellar Turbulence: Characterizing magnetohydrodynamic turbulence in the ISM
  • Pulsar Studies: Understanding scintillation and Faraday rotation effects
  • Galaxy Formation: Modeling magnetic field evolution in cosmic structure
  • Radio Astronomy: Interpreting polarization observations from SKA/LOFAR

๐Ÿ“š Documentation

Core Functions

Function Description Key Parameters
generate_velocity_cube() Generate 3D turbulent velocity field N, solenoidal, seed
structure_function_2d() Compute angular structure function field, Rs, max_pairs
angle_stokes() Calculate Stokes polarization angle u (velocity field)
sample_pairs_3d() Sample vector angle differences u, R, max_pairs

Mathematical Background

The toolkit implements several key astrophysical relations:

Synchrotron Polarization:

$$Q(x,y) = โˆซ dz (v_xยฒ - v_yยฒ) U(x,y) = โˆซ dz (2 v_x v_y)$$

Angular Structure Function:

$$D_ฯ†(R) = โŸจ[ฯ†(r+R) - ฯ†(r)]ยฒโŸฉ$$

Kolmogorov Spectrum:

$$E(k) โˆ k^{-5/3}$$

๐Ÿ› ๏ธ Requirements

  • Python 3.8+
  • NumPy (โ‰ฅ1.19)
  • SciPy (โ‰ฅ1.6)
  • Matplotlib (โ‰ฅ3.3)
  • h5py (โ‰ฅ3.0)
  • numba (โ‰ฅ0.54) - for performance
  • Fortran compiler (for I/O routines)

๐Ÿค Contributing

We welcome contributions! See our Contributing Guide for details.

Development Setup

git clone https://github.com/astrosander/AstroTurbulence.git
cd AstroTurbulence
pip install -e .
pre-commit install

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ“– Citation

If you use this toolkit in your research, please cite:

@software{astroturbulence2024,
  title={AstroTurbulence: Advanced Toolkit for Astrophysical Turbulence Analysis},
  author={Aliaksandr Melnichenka},
  year={2024},
  url={https://github.com/astrosander/AstroTurbulence}
}

๐ŸŒŸ Acknowledgments

  • Built for the astrophysics and plasma physics communities
  • Inspired by modern magnetohydrodynamic turbulence research
  • Optimized for high-performance scientific computing

โญ Star this repository if you find it useful for your astrophysics research!

๐Ÿ› Found a bug? Open an issue

๐Ÿ’ก Have a feature request? Start a discussion

About

๐ŸŒŒ Advanced toolkit for simulating and analyzing turbulent polarization in astrophysical environments | Kolmogorov turbulence | Stokes parameters | Faraday rotation | Python/Fortran

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages