Simulation logic

Navigation:  Introduction > Overview > SPRAY algorithm >

Simulation logic

Previous pageReturn to chapter overviewNext page

The basic algorithm is based on the following scheme which is given here almost like it is defined in the program's source code:

 

Repeat

Manager selects frequency. SPRAY starts with the high energy end of the selected spectral range.

Manager tells all objects the current frequency.

Objects do frequency dependent initialization if necessary.

Repeat

Manager tells light source to create a ray.

Light source creates ray with an initial position and direction depending on the type of the light source. The initial polarization is random. The ray travels in a certain material assigned to the light source. The material has a refractive index, an absorption coefficient and may contain small scattering and absorbing particles (which are simply called scatterers in SPRAY) in a user-defined concentration.

Repeat

Manager asks all objects wether they get hit by the present ray.

All objects determine if ray hits them and return position of hit.                

Manager selects closest hit point. If two objects report the same distance (within some tolerance) the one with higher priority wins.

Manager determines wether an absorption, scattering or fluorescence process occurs on the ray's path from its present position to the closest hit point (if the ray 'moves' in a material which may absorb, scatter or absorb and re-emit light)

If scattering occurs the ray is started at the position of the scattering event with a new direction which is determined by the scattering characteristics.

If fluorescence occurs the new frequency (lower than the current frequency) is computed according to the current fluorescence properties. The starting point of the new ray is added to a waiting queue of rays to be processed when the  lower frequency is going to be processed.

If no absorption, scattering or fluorescence occured:

Manager asks object with closest hit what happens with ray.

Object absorbes ray or changes its direction and/or possibly changes the material in which the ray moves (in case of an 'interface' object).

until ray is absorbed or no hit with one of the objects occurs.

until a user-defined number of rays has been processed

Repeat

Manager gets a ray from the 'fluorescence waiting queue' and starts it at its location in a random direction and with random polarization

Repeat

Manager asks all objects wether they get hit by the present ray.

All objects determine if ray hits them and return position of hit.                

Manager selects closest hit point. If two objects report the same distance (within some tolerance) the one with higher priority wins.

Manager determines wether an absorption, scattering or fluorescence process occurs on the ray's path from its present position to the closest hit point (if the ray 'moves' in a material which may absorb, scatter or absorb and re-emit light)

If scattering occurs the ray is started at the position of the scattering event with a new direction which is determined by the scattering characteristics.

If fluorescence occurs the new frequency (lower than the current frequency) is computed according to the current fluorescence properties. The starting point of the new ray is added to a waiting queue of rays to be processed when the  lower frequency is going to be processed.

If no absorption, scattering or fluorescence occured:

Manager asks object with closest hit what happens with ray.

Object absorbes ray or changes its direction and/or possibly changes the material in which the ray moves (in case of an 'interface' object).

until ray is absorbed or no hit with one of the objects occurs.

until all rays in the waiting queue (generated by fluorescence events) are finished.

Manager tells all objects that the current frequency simulation is done.

Objects do clean-up if necessary.

until all frequency positions have been processed.