Skip to main content

Optical Tweezers Force Engine — Python port of the OTS toolbox (Phase 1: Mie sphere, non-paraxial focused-beam force)

Project description

fatcuda

fatcuda is an intent-first optical tweezers force and field engine. It starts from physical declarations - beam intent, optical system, particle or task, and device policy - then lowers them into auditable intermediate representations and verified CPU/CUDA/Metal execution paths.

The current production package lives in fatcuda/. The historical direct-port implementation is archived in fatcuda_old/ and is kept only as an oracle, comparison source, and history bundle.

Status

This project is still early. The current verified path focuses on homogeneous Mie spheres, non-paraxial Debye-Wolf focusing, multipole coefficients, field slices, force maps, and CPU/Metal/CUDA interface parity. APIs may still move while the package is prepared for a first public PyPI release.

Installation

After publication:

python -m pip install fatcuda
python -m pip install "fatcuda[metal]"   # Apple Silicon / MLX path
python -m pip install "fatcuda[cuda12]"  # CUDA 12 / CuPy path

For local development from this checkout:

python -m pip install -e ".[test,demo]"
python -m pip install -e ".[test,demo,metal]"
python -m pip install -e ".[test,demo,cuda12]"

The default portable execution path is CPU-only and depends on NumPy and SciPy.

Minimal Example

import numpy as np

from fatcuda import (
    ForceAtPositions,
    GaussianBeam,
    OpticalSystem,
    PupilGrid,
    Sphere,
    solve,
)

system = OpticalSystem(grid=PupilGrid(Nphi=32, Nr=16), power=1.0e-3)
beam = GaussianBeam(Ex0=1.0, Ey0=0.0)
sphere = Sphere(radius=0.2e-6, n_p=1.59, L=8)
task = ForceAtPositions(
    positions=np.array(
        [
            [0.0, 0.0, 0.0],
            [0.1e-6, 0.0, 0.0],
        ]
    ),
    particle=sphere,
)

result = solve(
    beam=beam,
    system=system,
    task=task,
    strategy="auto",
    device="cpu",
)

print(result.force)
print(result.torque)
print(result.audit.operator_plan)

Public API Shape

The recommended user flow is:

beam intent + optical system + particle/task + device/strategy -> auditable IR -> kernels

Common public declarations include:

Concept Examples
Beams GaussianBeam, LaguerreGaussBeam, HermiteGaussBeam, AiryBeam, VortexBeam, SLMPhaseBeam
System OpticalSystem, PupilGrid
Particles Sphere
Tasks ForceAtPositions, FieldSlice
Execution solve, compile_problem, DevicePolicy, OperatorStrategy, PrecisionPolicy

Verification

The repository uses MATLAB OTS fixtures, the current CPU NumPy path, and closed-form physics sanity checks as oracles. Typical local verification:

python -m pytest -q -p no:cacheprovider

CUDA numerical validation requires a CUDA machine. On macOS without CUDA, CUDA tests are limited to import, collection, skip behavior, and shared-interface non-breakage. Metal validation requires Apple Silicon with the metal extra installed and MLX reporting Metal availability.

Documentation

The detailed code-layer notes live under doc/obsidian/fatcuda/代码层/.

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

fatcuda-0.1.0.tar.gz (235.4 kB view details)

Uploaded Source

Built Distribution

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

fatcuda-0.1.0-py3-none-any.whl (296.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fatcuda-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4c4f28a79bb395f5318adec272455f9bdce6bb5047a23d2b4be370baeea8fa36
MD5 ffacef753adbd882d5aedf79f2af248c
BLAKE2b-256 f0ff96ab8db1916aff7a4e7849aba07866f30a998ac5ad2d906c1801bbd3fe60

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for fatcuda-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 24f17ded6b5ee16c20510952d98a403e0bbd2400835c13ad4fb9e3e5f81169ee
MD5 e9d1148a2575d9bbbb9c8960903614d6
BLAKE2b-256 23bc32ded2e1bcb426f3a8af726c19458c0f68fd98bd8ab40b0acf0706f9e9f4

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