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ΒΆ
GPU-accelerated ray tracer for radiation calculations. |
FunctionsΒΆ
|
Ray-AABB intersection using slab method. |
|
3D-DDA ray marching to find first solid voxel hit. |
|
Trace ray through canopy computing Beer-Lambert absorption. |
|
3D-DDA ray marching with tree canopy transmissivity calculation. |
|
Trace ray from origin to target, checking for visibility. |
|
Compute transmissivity of radiation between two points through canopy. |
Generate a direction on the upper hemisphere. |
|
|
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.