voxcity.simulator_gpu.solar.raytracingΒΆ

Ray tracing module for solar simulation.

This module provides the RayTracer class for GPU-accelerated radiation calculations. Shared ray tracing functions are imported from simulator_gpu.raytracing.

Usage:

from .raytracing import RayTracer, ray_voxel_first_hit, ray_canopy_absorption

ClassesΒΆ

RayTracer

GPU-accelerated ray tracer for radiation calculations.

FunctionsΒΆ

ray_aabb_intersect(ray_origin, ray_dir, box_min, ...)

Ray-AABB intersection using slab method.

ray_voxel_first_hit(ray_origin, ray_dir, is_solid, nx, ...)

3D-DDA ray marching to find first solid voxel hit.

ray_canopy_absorption(ray_origin, ray_dir, lad, ...)

Trace ray through canopy computing Beer-Lambert absorption.

ray_voxel_transmissivity(ray_origin, ray_dir, ...)

3D-DDA ray marching with tree canopy transmissivity calculation.

ray_trace_to_target(origin, target, is_solid, is_tree, ...)

Trace ray from origin to target, checking for visibility.

ray_point_to_point_transmissivity(pos_from, pos_to, ...)

Compute transmissivity of radiation between two points through canopy.

sample_hemisphere_direction(...)

Generate a direction on the upper hemisphere.

hemisphere_solid_angle(β†’ taichi.f32)

Calculate solid angle for a hemisphere segment.

Module ContentsΒΆ

voxcity.simulator_gpu.solar.raytracing.ray_aabb_intersect(ray_origin: voxcity.simulator_gpu.core.Vector3, ray_dir: voxcity.simulator_gpu.core.Vector3, box_min: voxcity.simulator_gpu.core.Vector3, box_max: voxcity.simulator_gpu.core.Vector3, t_min: taichi.f32, t_max: taichi.f32)ΒΆ

Ray-AABB intersection using slab method.

Parameters:
  • ray_origin – Ray origin point

  • ray_dir – Ray direction (normalized)

  • box_min – AABB minimum corner

  • box_max – AABB maximum corner

  • t_min – Minimum t value

  • t_max – Maximum t value

Returns:

Tuple of (hit, t_enter, t_exit)

voxcity.simulator_gpu.solar.raytracing.ray_voxel_first_hit(ray_origin: voxcity.simulator_gpu.core.Vector3, ray_dir: voxcity.simulator_gpu.core.Vector3, is_solid: ti.template(), nx: taichi.i32, ny: taichi.i32, nz: taichi.i32, dx: taichi.f32, dy: taichi.f32, dz: taichi.f32, max_dist: taichi.f32)ΒΆ

3D-DDA ray marching to find first solid voxel hit.

Parameters:
  • ray_origin – Ray origin

  • ray_dir – Ray direction (normalized)

  • is_solid – 3D field of solid cells

  • nx – Grid dimensions

  • ny – Grid dimensions

  • nz – Grid dimensions

  • dx – Cell sizes

  • dy – Cell sizes

  • dz – Cell sizes

  • max_dist – Maximum ray distance

Returns:

Tuple of (hit, t_hit, ix, iy, iz)

voxcity.simulator_gpu.solar.raytracing.ray_canopy_absorption(ray_origin: voxcity.simulator_gpu.core.Vector3, ray_dir: voxcity.simulator_gpu.core.Vector3, lad: ti.template(), is_solid: ti.template(), nx: taichi.i32, ny: taichi.i32, nz: taichi.i32, dx: taichi.f32, dy: taichi.f32, dz: taichi.f32, max_dist: taichi.f32, ext_coef: taichi.f32)ΒΆ

Trace ray through canopy computing Beer-Lambert absorption.

Parameters:
  • ray_origin – Ray origin

  • ray_dir – Ray direction (normalized)

  • lad – 3D field of Leaf Area Density

  • is_solid – 3D field of solid cells (buildings/terrain)

  • nx – Grid dimensions

  • ny – Grid dimensions

  • nz – Grid dimensions

  • dx – Cell sizes

  • dy – Cell sizes

  • dz – Cell sizes

  • max_dist – Maximum ray distance

  • ext_coef – Extinction coefficient

Returns:

Tuple of (transmissivity, path_length_through_canopy)

voxcity.simulator_gpu.solar.raytracing.ray_voxel_transmissivity(ray_origin: voxcity.simulator_gpu.core.Vector3, ray_dir: voxcity.simulator_gpu.core.Vector3, is_solid: ti.template(), is_tree: ti.template(), nx: taichi.i32, ny: taichi.i32, nz: taichi.i32, dx: taichi.f32, dy: taichi.f32, dz: taichi.f32, max_dist: taichi.f32, tree_k: taichi.f32, tree_lad: taichi.f32)ΒΆ

3D-DDA ray marching with tree canopy transmissivity calculation.

Parameters:
  • ray_origin – Ray origin

  • ray_dir – Ray direction (normalized)

  • is_solid – 3D field of solid cells (buildings, ground)

  • is_tree – 3D field of tree cells

  • nx – Grid dimensions

  • ny – Grid dimensions

  • nz – Grid dimensions

  • dx – Cell sizes

  • dy – Cell sizes

  • dz – Cell sizes

  • max_dist – Maximum ray distance

  • tree_k – Tree extinction coefficient

  • tree_lad – Leaf area density

Returns:

Tuple of (blocked_by_solid, transmissivity) - blocked_by_solid: 1 if ray hit solid, 0 otherwise - transmissivity: 0-1 fraction of light that gets through trees

voxcity.simulator_gpu.solar.raytracing.ray_trace_to_target(origin: voxcity.simulator_gpu.core.Vector3, target: voxcity.simulator_gpu.core.Vector3, is_solid: ti.template(), is_tree: ti.template(), nx: taichi.i32, ny: taichi.i32, nz: taichi.i32, dx: taichi.f32, dy: taichi.f32, dz: taichi.f32, tree_att: taichi.f32, att_cutoff: taichi.f32)ΒΆ

Trace ray from origin to target, checking for visibility.

Parameters:
  • origin – Start position (in voxel coordinates)

  • target – End position (in voxel coordinates)

  • is_solid – 3D field of solid cells

  • is_tree – 3D field of tree cells

  • nx – Grid dimensions

  • ny – Grid dimensions

  • nz – Grid dimensions

  • dx – Cell sizes (typically all 1.0 for voxel coords)

  • dy – Cell sizes (typically all 1.0 for voxel coords)

  • dz – Cell sizes (typically all 1.0 for voxel coords)

  • tree_att – Attenuation factor per voxel for trees

  • att_cutoff – Minimum transmissivity before considering blocked

Returns:

1 if target is visible, 0 otherwise

voxcity.simulator_gpu.solar.raytracing.ray_point_to_point_transmissivity(pos_from: voxcity.simulator_gpu.core.Vector3, pos_to: voxcity.simulator_gpu.core.Vector3, lad: ti.template(), is_solid: ti.template(), nx: taichi.i32, ny: taichi.i32, nz: taichi.i32, dx: taichi.f32, dy: taichi.f32, dz: taichi.f32, ext_coef: taichi.f32)ΒΆ

Compute transmissivity of radiation between two points through canopy.

This is used for surface-to-surface reflections where reflected radiation must pass through any intervening vegetation.

Parameters:
  • pos_from – Start position (emitting surface center)

  • pos_to – End position (receiving surface center)

  • lad – 3D field of Leaf Area Density

  • is_solid – 3D field of solid cells (buildings/terrain)

  • nx – Grid dimensions

  • ny – Grid dimensions

  • nz – Grid dimensions

  • dx – Cell sizes

  • dy – Cell sizes

  • dz – Cell sizes

  • ext_coef – Extinction coefficient

Returns:

Tuple of (transmissivity, blocked_by_solid) - transmissivity: 0-1 fraction of radiation that gets through - blocked_by_solid: 1 if ray hits a solid cell, 0 otherwise

voxcity.simulator_gpu.solar.raytracing.sample_hemisphere_direction(i_azim: taichi.i32, i_elev: taichi.i32, n_azim: taichi.i32, n_elev: taichi.i32) voxcity.simulator_gpu.core.Vector3ΒΆ

Generate a direction on the upper hemisphere.

Parameters:
  • i_azim – Azimuthal index (0 to n_azim-1)

  • i_elev – Elevation index (0 to n_elev-1)

  • n_azim – Number of azimuthal divisions

  • n_elev – Number of elevation divisions

Returns:

Unit direction vector

voxcity.simulator_gpu.solar.raytracing.hemisphere_solid_angle(i_elev: taichi.i32, n_azim: taichi.i32, n_elev: taichi.i32) taichi.f32ΒΆ

Calculate solid angle for a hemisphere segment.