artist.core.heliostat_ray_tracer

Attributes

log

A logger for the heliostat ray tracer.

Classes

DistortionsDataset

Initialize the dataset.

RestrictedDistributedSampler

Set up a custom distributed sampler to assign data to each rank or leave them idle.

HeliostatRayTracer

Initialize the heliostat ray tracer.

Module Contents

artist.core.heliostat_ray_tracer.log

A logger for the heliostat ray tracer.

class artist.core.heliostat_ray_tracer.DistortionsDataset(light_source: artist.scene.LightSource, number_of_points_per_heliostat: int, number_of_heliostats: int, random_seed: int = 7)

Bases: torch.utils.data.Dataset

Initialize the dataset.

This class implements a custom dataset according to the torch interface. The content of this dataset are the distortions. The distortions are used in our version of “heliostat”-tracing to indicate how each incoming ray must be multiplied and scattered on the heliostat. According to torch, this dataset must implement a function to return the length of the dataset and one function to retrieve an element through an index.

Parameters

light_sourceLightSource

The light source used to model the distortions.

number_of_points_per_heliostatint

The number of points on the heliostats for which distortions are created.

number_of_heliostatsint

The number of heliostats in the scenario.

random_seedint

The random seed used for generating the distortions (default is 7).

__len__() int

Calculate the length of the dataset, i.e., the number of items contained.

Returns

int

The length of the dataset.

__getitem__(idx: int) tuple[torch.Tensor, torch.Tensor]

Select an item from the dataset.

Parameters

idxint

The index of the item to select.

Returns

torch.Tensor

The distortions in the up direction for the given index.

torch.Tensor

The distortions in the east direction for the given index.

class artist.core.heliostat_ray_tracer.RestrictedDistributedSampler(number_of_samples: int, world_size: int = 1, rank: int = 0)

Bases: torch.utils.data.Sampler

Set up a custom distributed sampler to assign data to each rank or leave them idle.

Parameters

number_of_samplesint

The length of the dataset or total number of samples.

world_sizeint

The world size or total number of processes (default is 1).

rankint

The rank of the current process (default is 0).

number_of_samples
world_size = 1
rank = 0
number_of_active_ranks
number_of_samples_per_rank
__iter__() Iterator[int]

Generate a sequence of indices for the current rank’s portion of the dataset.

Returns

Iterator[int]

An iterator over indices for the current rank.

class artist.core.heliostat_ray_tracer.HeliostatRayTracer(scenario: artist.scenario.scenario.Scenario, heliostat_group: artist.field.heliostat_group.HeliostatGroup, world_size: int = 1, rank: int = 0, batch_size: int = 100, random_seed: int = 7, bitmap_resolution: torch.Tensor = torch.tensor([artist.util.index_mapping.bitmap_resolution, artist.util.index_mapping.bitmap_resolution]))

Initialize the heliostat ray tracer.

“Heliostat”-tracing is one kind of ray tracing applied in ARTIST. For this kind of ray tracing, the rays are initialized on the heliostats. The rays originate in the discrete surface points. There they are multiplied, distorted, and scattered, and then they are sent to the aim points. Letting the rays originate on the heliostats, drastically reduces the number of rays that need to be traced.

Parameters

scenarioScenario

The scenario used to perform ray tracing.

heliostat_groupHeliostatGroup

The selected heliostat group containing active heliostats.

world_sizeint

The world size i.e., the overall number of processes (default is 1).

rankint

The rank, i.e., individual process ID (default is 0).

batch_sizeint

The amount of samples (heliostats) processed in parallel within a single rank (default is 100).

random_seedint

The random seed used for generating the distortions (default is 7).

bitmap_resolutiontorch.Tensor

The resolution of the bitmap in both directions. (default is torch.tensor([256,256])). Tensor of shape [2].

scenario
heliostat_group
world_size = 1
rank = 0
batch_size = 100
light_source
distortions_dataset
distortions_sampler
distortions_loader
bitmap_resolution
trace_rays(incident_ray_directions: torch.Tensor, active_heliostats_mask: torch.Tensor, target_area_mask: torch.Tensor, device: torch.device | None = None) torch.Tensor

Perform heliostat ray tracing.

Scatter the rays according to the distortions, calculate the intersections with the target planes, and sample the resulting bitmaps on the target areas. The bitmaps are generated separately for each active heliostat and can be accessed individually or they can be combined to get the total flux density distribution for all heliostats on all target areas.

Parameters

incident_ray_directionstorch.Tensor

The direction of the incident rays as seen from the heliostats. Tensor of shape [number_of_active_heliostats, 4].

active_heliostats_masktorch.Tensor

A mask where 0 indicates a deactivated heliostat and 1 an activated one. An integer greater than 1 indicates that this heliostat is regarded multiple times. Tensor of shape [number_of_heliostats].

target_area_masktorch.Tensor

The indices of the target areas for each active heliostat. Tensor of shape [number_of_active_heliostats].

devicetorch.device | None

The device on which to perform computations or load tensors and models (default is None). If None, ARTIST will automatically select the most appropriate device (CUDA or CPU) based on availability and OS.

Raises

ValueError

If not all heliostats used for ray tracing have been aligned.

Returns

torch.Tensor

The resulting bitmaps per heliostat. Tensor of shape [number_of_active_heliostats, bitmap_resolution_e, bitmap_resolution_u].

scatter_rays(distortion_u: torch.Tensor, distortion_e: torch.Tensor, original_ray_direction: torch.Tensor, device: torch.device | None = None) artist.scene.rays.Rays

Scatter the reflected rays around the preferred ray directions for each heliostat.

Parameters

distortion_utorch.Tensor

The distortions in up direction (angles for scattering). Tensor of shape [number_of_active_heliostats, number_of_rays, number_of_combined_surface_normals_all_facets].

distortion_etorch.Tensor

The distortions in east direction (angles for scattering). Tensor of shape [number_of_active_heliostats, number_of_rays, number_of_combined_surface_normals_all_facets].

original_ray_directiontorch.Tensor

The ray direction around which to scatter. Tensor of shape [number_of_active_heliostats, number_of_combined_surface_normals_all_facets, 4].

devicetorch.device | None

The device on which to perform computations or load tensors and models (default is None). If None, ARTIST will automatically select the most appropriate device (CUDA or CPU) based on availability and OS.

Returns

Rays

Scattered rays around the preferred reflection directions.

sample_bitmaps(intersections: torch.Tensor, absolute_intensities: torch.Tensor, active_heliostats_mask: torch.Tensor, target_area_mask: torch.Tensor, device: torch.device | None = None) torch.Tensor

Sample bitmaps (flux density distributions) of the reflected rays on the target areas.

The bitmaps are saved for each active heliostat separately.

Parameters

intersectionstorch.Tensor

The intersections of rays on the target area planes for each heliostat. Tensor of shape [number_of_active_heliostats, number_of_rays, number_of_combined_surface_points_all_facets, 4].

absolute_intensitiestorch.Tensor

The absolute intensities of the rays hitting the target planes for each heliostat. Tensor of shape [number_of_active_heliostats, number_of_rays, number_of_combined_surface_points_all_facets].

active_heliostats_masktorch.Tensor

Used to map bitmaps per heliostat to correct index. Tensor of shape [number_of_heliostats].

target_area_masktorch.Tensor

The indices of target areas on which each heliostat is raytraced. Tensor of shape [number_of_active_heliostats].

devicetorch.device | None

The device on which to perform computations or load tensors and models (default is None). If None, ARTIST will automatically select the most appropriate device (CUDA or CPU) based on availability and OS.

Returns

torch.Tensor

The flux density distributions of the reflected rays on the target areas for each active heliostat. Tensor of shape [number_of_active_heliostats, bitmap_resolution_e, bitmap_resolution_u].

get_bitmaps_per_target(bitmaps_per_heliostat: torch.Tensor, target_area_mask: torch.Tensor, device: torch.device | None = None) torch.Tensor

Transform bitmaps per heliostat to bitmaps per target area.

Parameters

bitmaps_per_heliostattorch.Tensor

Bitmaps per heliostat. Tensor of shape [number_of_active_heliostats, bitmap_resolution_e, bitmap_resolution_u].

target_area_masktorch.Tensor

The mapping from heliostat to target area. Tensor of shape [number_of_active_heliostats].

devicetorch.device | None

The device on which to perform computations or load tensors and models (default is None). If None, ARTIST will automatically select the most appropriate device (CUDA or CPU) based on availability and OS.

Returns

torch.Tensor

Bitmaps per target area. Tensor of shape [number_of_target_areas, bitmap_resolution_e, bitmap_resolution_u].