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

GPL-3.0-only - 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.1.tar.gz (49.9 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.1-py3-none-any.whl (53.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: raystrack-1.0.1.tar.gz
  • Upload date:
  • Size: 49.9 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.1.tar.gz
Algorithm Hash digest
SHA256 9d30d9d45feec5bebbb845b24fc9442767eabae76e3ba2d45a0ae58728513d51
MD5 eb380c21120d8c4816ab4311e8b7d0f6
BLAKE2b-256 fc857323aabf8a0db4632492ffd0f1510d3097a25fac1278aea65ba1bbfc78f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for raystrack-1.0.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: raystrack-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 53.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ed26c76a49a332fa42aee0f1b93dcabcd49a70f0555a43522b798e3fb9765c77
MD5 a822464e46feb030e45467197f9b205c
BLAKE2b-256 cbc7bcd2ec1b5b16362b9ddb28490ab330bd0ab781ac83bdfbe823a42ea5d58d

See more details on using hashes here.

Provenance

The following attestation bundles were made for raystrack-1.0.1-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