Skip to main content

Lightweight Monte-Carlo view-factor solver with CPU, CUDA and BVH paths

Project description

Raystrack

Raystrack icon

Lightweight Monte-Carlo view-factor solver for polygonal meshes.

Raystrack computes radiative view factors F(i->j) between triangulated surfaces using quasi-Monte-Carlo ray tracing. It runs on CPU, can leverage Numba/CUDA on NVIDIA GPUs when available, and optionally accelerates ray intersection with a BVH. The repository also ships a pure-Python API you can use outside Rhino.

Features

  • Efficient Monte-Carlo view factors: front/back hits, optional reciprocity
  • CPU and optional CUDA GPU backends (Numba)
  • Optional BVH acceleration structures
  • Python API plus Grasshopper components (Rhino installer coming soon)

Installation

Python package

Use Raystrack as a normal Python package outside Rhino or Grasshopper.

From a local clone of this repository:

pip install .

Or from an absolute path:

pip install /path/to/raystrack

Requirements: Python 3.9+, numpy, numba. CUDA acceleration is enabled automatically when numba.cuda detects a compatible GPU.

Rhino / Grasshopper status

The Rhino 8 Grasshopper installers are not yet published. Follow this README or the issue tracker for updates when a tested Rhino workflow becomes available.

Examples

All examples live in examples/. Start by running ex00_street_canyon_geometry to generate street_canyon.json; subsequent scripts expect that file. Each Python example now documents its own inputs and parameters inline, so open the scripts directly for usage guidance and tunable options.

Quick start (Python)

import numpy as np
from raystrack import view_factor_matrix, MatrixParams

# Each mesh is a tuple: (name: str, V: (N,3) float32, F: (M,3) int32)
V_a = np.array([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]], dtype=np.float32)
F_a = np.array([[0, 1, 2], [0, 2, 3]], dtype=np.int32)  # two triangles

V_b = np.array([[0, 0, 1], [1, 0, 1], [1, 1, 1], [0, 1, 1]], dtype=np.float32)
F_b = F_a.copy()

meshes = [
    ("A", V_a, F_a),
    ("B", V_b, F_b),
]

params = MatrixParams(
    samples=256,   # sampling density per unit area (QMC grid)
    rays=256,      # rays per cell
    bvh="builtin", # optional BVH acceleration (auto|off|builtin)
    reciprocity=True,
)

res = view_factor_matrix(meshes, params=params)

print(res["A"])  # e.g. {"B_front": 0.5, "B_back": 0.0, ...}

To persist a matrix without directional suffixes in the saved JSON:

from raystrack import save_vf_matrix_json

save_vf_matrix_json(res, "vf_matrix.json", strip_dir=True)

This collapses receiver keys like "B_front" and "B_back" into "B" and sums both values per sender row.

Parameter presets

Raystrack uses two parameter containers to keep configuration consistent:

  • MatrixParams: controls the scene-to-scene view-factor solve (sampling, BVH, device selection, convergence tolerances, and reciprocity enforcement).
  • SkyParams: controls the sky view-factor solve (sampling, device selection, and convergence tolerances, plus discrete=True for 145 sky patches or False for a single merged "Sky" output).

Typical usage:

from raystrack import MatrixParams, SkyParams, view_factor_matrix, view_factor_to_tregenza_sky

matrix_params = MatrixParams(samples=32, rays=256, reciprocity=True, flip_faces=False)
sky_params = SkyParams(samples=32, rays=256)

vf_scene = view_factor_matrix(meshes, params=matrix_params)
vf_sky = view_factor_to_tregenza_sky(meshes, params=sky_params)

License

MIT - see LICENSE.

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

raystrack-1.0.2.tar.gz (38.5 kB view details)

Uploaded Source

Built Distribution

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

raystrack-1.0.2-py3-none-any.whl (41.9 kB view details)

Uploaded Python 3

File details

Details for the file raystrack-1.0.2.tar.gz.

File metadata

  • Download URL: raystrack-1.0.2.tar.gz
  • Upload date:
  • Size: 38.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for raystrack-1.0.2.tar.gz
Algorithm Hash digest
SHA256 8ebd07ca16e2d62d6592118057bf89f00a08d919a57ca0c1145458050631f45a
MD5 9595e5dc8dd90d93c728b5c19de8d8d3
BLAKE2b-256 07d0a2d4ac5a9273060cc1ddc56611998e74112eb89458e28f9ef84e39b3a195

See more details on using hashes here.

Provenance

The following attestation bundles were made for raystrack-1.0.2.tar.gz:

Publisher: publish.yml on philip-ba/raystrack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file raystrack-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: raystrack-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 41.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for raystrack-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9494762a31d26bf6150a69d1d3ac0d2380e956d49906ca2f23b7b47dc8d18d7b
MD5 f09573886df73e8e02c02a1d68569a87
BLAKE2b-256 c548740b2ea416645a702b24d0c64cd7d32c961d27fe54a7558716e067ff13bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for raystrack-1.0.2-py3-none-any.whl:

Publisher: publish.yml on philip-ba/raystrack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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