Skip to main content

Electromagnetic S-matrix computation for periodic arrays of cylinders — NumPy/CuPy GPU-accelerated version

Project description

CyScat Python Translation

This is a Python translation of the MATLAB CyScat electromagnetic scattering code, maintaining numerical precision with the original implementation.

Setup

  1. Create a virtual environment:

    python3 -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    
  2. Install dependencies:

    pip install -r requirements.txt
    

Running the Test

cd CyScat
python sample_test.py

This will:

  • Generate random cylinder positions using Latin Hypercube sampling
  • Compute the S-matrix (scattering matrix) for the structure
  • Display the results and a visualization of the slab geometry

Key Files

  • sample_test.py - Main test script demonstrating the workflow
  • interface.py - Main interface for S-matrix computation
  • Scattering_Code/ - Core electromagnetic scattering algorithms
    • smatrix.py - S-matrix generation
    • transall.py - Translation matrix calculations
    • smatrix_parameters.py - Spectral parameter setup
    • vall.py - Plane wave to cylinder harmonics conversion
    • ky.py - Wave vector component calculations

Translation Notes

All numerical precision issues from MATLAB to Python have been resolved:

  • Complex number handling for evanescent modes
  • Spectral sum overflow protection
  • Array indexing differences (0-based vs 1-based)
  • Matrix multiplication semantics
  • Scalar extraction from numpy arrays

The code now produces results matching MATLAB within numerical precision.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cyscat_gpu-0.1.0.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cyscat_gpu-0.1.0-py3-none-any.whl (41.0 kB view details)

Uploaded Python 3

File details

Details for the file cyscat_gpu-0.1.0.tar.gz.

File metadata

  • Download URL: cyscat_gpu-0.1.0.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for cyscat_gpu-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5d27c6df54c0894aaf8cc75705a732140c42532caedab7be9153b4857e8bcdd4
MD5 6e7590df8985e9db3b792308273c3be2
BLAKE2b-256 3930d842971d795e9334d7dc9277ef82d498e036e63e28777743fc8180700471

See more details on using hashes here.

File details

Details for the file cyscat_gpu-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cyscat_gpu-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 41.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for cyscat_gpu-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3e00e0b695543be68f2eb30b8f8199a28267a6664b0e71046e96140b81aeb10b
MD5 bde432c6c567cb8b00382b050d99c18e
BLAKE2b-256 a2ea0297da5331dae8ad6b063e63a8785da6baab3fb4d42790c627f01b3bf606

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page