simsun

Simulator for the design of solar heaters

Developed in collaboration with Ole Jorgen Nydal
Written by Paul Bourke
June 2008


The application "simsun" is intended to assist with the design of solar heating systems where the reflector units are made up of planar mirror faces. The basic algorithm involves tracing rays from the sun, seeing which object (reflector or absorber) they strike, accumulating formation about the intensity on surfaces, and tracing further reflected rays as necessary.

The sun is considered to be infinitely far away (defined only by a direction vector) and all the rays are parallel, no account is made for the finite sun disk. The projection of all the geometry (absorbers and reflectors) onto the plane normal to the sun vector defines the region for sun ray selection. For simplicity the bounding circle of this projection forms the region in which rays are randomly sampled.

Rays are traced through reflections until they either head in a direction in which they will strike no further objects (the most common situation), or their intensity drops below some threshold. On each reflection the ray is assumed to lose some intensity, this can be set for both the reflectors (usually very high values because the reflectors are typically mirrors) and the absorbers (generally a low value since the absorbers are designed to absorb as much light as possible). Only one reflected ray is considered per reflection, that is, no scattering is taken into account.


Identifying components in the graphical display (Note the ground plane serves no purpose other than providing a reference plane.)

For an absorber the difference between the incident and reflected light (if any) is added to the appropriate quad of the absorber. This is normalised by the quads area to give ray intensity per unit area. It is this value that is mapped to a colour scale when surface shading is enabled. For a reflector the reflected intensity contributes to the appropriate quad of the reflector. So in shaded mode the colour of quads making up reflectors indicates how much light is reflected, again normalised for the quad surface area.

Usage

The software is run from the command line (developed for Mac OS-X and Linux) reads a specification file that contains all the user selectable parameters of the model. The key elements include the sun vector, a description of the geometry of the receiver and absorber, and the reflection coefficients for both the receivers and absorbers. The receivers and absorbers are created solely from 4 vertex facets (quads) that must be coplanar, it is left up to the user to ensure they are planar.

Usage: simsun [options] specification_file
Options
   -h                           This text
   -d                           Debug/verbose mode
   -f                           Full screen

Interface
   Right mouse button           Popup menus
   Center mouse button          Roll camera
   Left mouse button            Rotate camera
   Arrow keys                   Rotate camera
   + -                          Zoom in/out
   i                            Toggle simulation info
   h                            Toggle help info
   r                            Toggle ray illustration
   c                            Toggle construction geometry
   s                            Toggle surfaces
   b                            Toggle wireframe borders
   p                            Toggle ray calculations
   P                            Perform single ray calculation
   R                            Reset simulation
   1,2,3,4,5                    Preset camera settings
   w                            Window dump to TGA file
   q                            Quit
Example of a model specification file

The following is a simple model file, it reads two meshes one for the absorber and one for the reflector. Note that multiple reflector or absorber meshes can be read, the corresponding reflection coefficients should be specified before the mesh is read, this allows reflectors and absorbers to have different coefficients. As indicated, a "#" at the start of the line is a comment, the rest of the line is ignored.

# This is a comment

# Sun directly overhead
sun 0 0 -1

# Reflector reflection coefficient, applies to future reflectors
rcoeff 0.9

# A reflector
reflector reflector.txt

# Absorber reflection coefficient, applies to future absorbers
acoeff 0

# An absorber
absorber absorber.txt

Example of a reflector (or absorber) data file

The format for the quads making up the receiver or absorber is a simple text file with one quad element per line. Each line therefore contains 4 triples, the 4 vertices of the quad. Each vertex or element of the vertex can be separated by any white space character (typically space or tab), or any number of white space characters. There is no requirement on the ordering of the quad vertices, clockwise or anticlockwise about the normal of the plane, but in general it is good form to order the quads consistently. It is however very important that the 4 vertices all lie on the same plane, noting that in general 4 vertices will not be on the same plane.

   0.1000   0.0000   0.0031   0.0924   0.0383   0.0031   0.3465   0.1435   0.0439   0.3750   0.0000   0.0439 
   0.0924   0.0383   0.0031   0.0707   0.0707   0.0031   0.2652   0.2652   0.0439   0.3465   0.1435   0.0439 
   0.0707   0.0707   0.0031   0.0383   0.0924   0.0031   0.1435   0.3465   0.0439   0.2652   0.2652   0.0439 
   0.0383   0.0924   0.0031   0.0000   0.1000   0.0031   0.0000   0.3750   0.0439   0.1435   0.3465   0.0439 
   0.0000   0.1000   0.0031  -0.0383   0.0924   0.0031  -0.1435   0.3465   0.0439   0.0000   0.3750   0.0439 
  -0.0383   0.0924   0.0031  -0.0707   0.0707   0.0031  -0.2652   0.2652   0.0439  -0.1435   0.3465   0.0439 
  -0.0707   0.0707   0.0031  -0.0924   0.0383   0.0031  -0.3465   0.1435   0.0439  -0.2652   0.2652   0.0439 
  -0.0924   0.0383   0.0031  -0.1000   0.0000   0.0031  -0.3750   0.0000   0.0439  -0.3465   0.1435   0.0439 
  -0.1000   0.0000   0.0031  -0.0924  -0.0383   0.0031  -0.3465  -0.1435   0.0439  -0.3750   0.0000   0.0439 
  -0.0924  -0.0383   0.0031  -0.0707  -0.0707   0.0031  -0.2652  -0.2652   0.0439  -0.3465  -0.1435   0.0439 
  -0.0707  -0.0707   0.0031  -0.0383  -0.0924   0.0031  -0.1435  -0.3465   0.0439  -0.2652  -0.2652   0.0439 
  -0.0383  -0.0924   0.0031  -0.0000  -0.1000   0.0031  -0.0000  -0.3750   0.0439  -0.1435  -0.3465   0.0439 
  -0.0000  -0.1000   0.0031   0.0383  -0.0924   0.0031   0.1435  -0.3465   0.0439  -0.0000  -0.3750   0.0439 
   0.0383  -0.0924   0.0031   0.0707  -0.0707   0.0031   0.2652  -0.2652   0.0439   0.1435  -0.3465   0.0439 
   0.0707  -0.0707   0.0031   0.0924  -0.0383   0.0031   0.3465  -0.1435   0.0439   0.2652  -0.2652   0.0439 
   0.0924  -0.0383   0.0031   0.1000  -0.0000   0.0031   0.3750  -0.0000   0.0439   0.3465  -0.1435   0.0439 
   0.3750   0.0000   0.0439   0.3465   0.1435   0.0439   0.6005   0.2487   0.1320   0.6500   0.0000   0.1320 
   0.3465   0.1435   0.0439   0.2652   0.2652   0.0439   0.4596   0.4596   0.1320   0.6005   0.2487   0.1320 
   0.2652   0.2652   0.0439   0.1435   0.3465   0.0439   0.2487   0.6005   0.1320   0.4596   0.4596   0.1320 
   0.1435   0.3465   0.0439   0.0000   0.3750   0.0439   0.0000   0.6500   0.1320   0.2487   0.6005   0.1320 
   0.0000   0.3750   0.0439  -0.1435   0.3465   0.0439  -0.2487   0.6005   0.1320   0.0000   0.6500   0.1320 
  -0.1435   0.3465   0.0439  -0.2652   0.2652   0.0439  -0.4596   0.4596   0.1320  -0.2487   0.6005   0.1320 
  -0.2652   0.2652   0.0439  -0.3465   0.1435   0.0439  -0.6005   0.2487   0.1320  -0.4596   0.4596   0.1320 
  -0.3465   0.1435   0.0439  -0.3750   0.0000   0.0439  -0.6500   0.0000   0.1320  -0.6005   0.2487   0.1320 
  -0.3750   0.0000   0.0439  -0.3465  -0.1435   0.0439  -0.6005  -0.2487   0.1320  -0.6500   0.0000   0.1320 
  -0.3465  -0.1435   0.0439  -0.2652  -0.2652   0.0439  -0.4596  -0.4596   0.1320  -0.6005  -0.2487   0.1320 
  -0.2652  -0.2652   0.0439  -0.1435  -0.3465   0.0439  -0.2487  -0.6005   0.1320  -0.4596  -0.4596   0.1320 
  -0.1435  -0.3465   0.0439  -0.0000  -0.3750   0.0439  -0.0000  -0.6500   0.1320  -0.2487  -0.6005   0.1320 
  -0.0000  -0.3750   0.0439   0.1435  -0.3465   0.0439   0.2487  -0.6005   0.1320  -0.0000  -0.6500   0.1320 
   0.1435  -0.3465   0.0439   0.2652  -0.2652   0.0439   0.4596  -0.4596   0.1320   0.2487  -0.6005   0.1320 
   0.2652  -0.2652   0.0439   0.3465  -0.1435   0.0439   0.6005  -0.2487   0.1320   0.4596  -0.4596   0.1320 
   0.3465  -0.1435   0.0439   0.3750  -0.0000   0.0439   0.6500  -0.0000   0.1320   0.6005  -0.2487   0.1320 
   0.6500   0.0000   0.1320   0.6005   0.2487   0.1320   0.8546   0.3540   0.2674   0.9250   0.0000   0.2674 
   0.6005   0.2487   0.1320   0.4596   0.4596   0.1320   0.6541   0.6541   0.2674   0.8546   0.3540   0.2674 
   0.4596   0.4596   0.1320   0.2487   0.6005   0.1320   0.3540   0.8546   0.2674   0.6541   0.6541   0.2674 
   0.2487   0.6005   0.1320   0.0000   0.6500   0.1320   0.0000   0.9250   0.2674   0.3540   0.8546   0.2674 
   0.0000   0.6500   0.1320  -0.2487   0.6005   0.1320  -0.3540   0.8546   0.2674   0.0000   0.9250   0.2674 
  -0.2487   0.6005   0.1320  -0.4596   0.4596   0.1320  -0.6541   0.6541   0.2674  -0.3540   0.8546   0.2674 
  -0.4596   0.4596   0.1320  -0.6005   0.2487   0.1320  -0.8546   0.3540   0.2674  -0.6541   0.6541   0.2674 
  -0.6005   0.2487   0.1320  -0.6500   0.0000   0.1320  -0.9250   0.0000   0.2674  -0.8546   0.3540   0.2674 
  -0.6500   0.0000   0.1320  -0.6005  -0.2487   0.1320  -0.8546  -0.3540   0.2674  -0.9250   0.0000   0.2674 
  -0.6005  -0.2487   0.1320  -0.4596  -0.4596   0.1320  -0.6541  -0.6541   0.2674  -0.8546  -0.3540   0.2674 
  -0.4596  -0.4596   0.1320  -0.2487  -0.6005   0.1320  -0.3540  -0.8546   0.2674  -0.6541  -0.6541   0.2674 
  -0.2487  -0.6005   0.1320  -0.0000  -0.6500   0.1320  -0.0000  -0.9250   0.2674  -0.3540  -0.8546   0.2674 
  -0.0000  -0.6500   0.1320   0.2487  -0.6005   0.1320   0.3540  -0.8546   0.2674  -0.0000  -0.9250   0.2674 
   0.2487  -0.6005   0.1320   0.4596  -0.4596   0.1320   0.6541  -0.6541   0.2674   0.3540  -0.8546   0.2674 
   0.4596  -0.4596   0.1320   0.6005  -0.2487   0.1320   0.8546  -0.3540   0.2674   0.6541  -0.6541   0.2674 
   0.6005  -0.2487   0.1320   0.6500  -0.0000   0.1320   0.9250  -0.0000   0.2674   0.8546  -0.3540   0.2674 
   0.9250   0.0000   0.2674   0.8546   0.3540   0.2674   1.1087   0.4592   0.4500   1.2000   0.0000   0.4500 
   0.8546   0.3540   0.2674   0.6541   0.6541   0.2674   0.8485   0.8485   0.4500   1.1087   0.4592   0.4500 
   0.6541   0.6541   0.2674   0.3540   0.8546   0.2674   0.4592   1.1087   0.4500   0.8485   0.8485   0.4500 
   0.3540   0.8546   0.2674   0.0000   0.9250   0.2674   0.0000   1.2000   0.4500   0.4592   1.1087   0.4500 
   0.0000   0.9250   0.2674  -0.3540   0.8546   0.2674  -0.4592   1.1087   0.4500   0.0000   1.2000   0.4500 
  -0.3540   0.8546   0.2674  -0.6541   0.6541   0.2674  -0.8485   0.8485   0.4500  -0.4592   1.1087   0.4500 
  -0.6541   0.6541   0.2674  -0.8546   0.3540   0.2674  -1.1087   0.4592   0.4500  -0.8485   0.8485   0.4500 
  -0.8546   0.3540   0.2674  -0.9250   0.0000   0.2674  -1.2000   0.0000   0.4500  -1.1087   0.4592   0.4500 
  -0.9250   0.0000   0.2674  -0.8546  -0.3540   0.2674  -1.1087  -0.4592   0.4500  -1.2000   0.0000   0.4500 
  -0.8546  -0.3540   0.2674  -0.6541  -0.6541   0.2674  -0.8485  -0.8485   0.4500  -1.1087  -0.4592   0.4500 
  -0.6541  -0.6541   0.2674  -0.3540  -0.8546   0.2674  -0.4592  -1.1087   0.4500  -0.8485  -0.8485   0.4500 
  -0.3540  -0.8546   0.2674  -0.0000  -0.9250   0.2674  -0.0000  -1.2000   0.4500  -0.4592  -1.1087   0.4500 
  -0.0000  -0.9250   0.2674   0.3540  -0.8546   0.2674   0.4592  -1.1087   0.4500  -0.0000  -1.2000   0.4500 
   0.3540  -0.8546   0.2674   0.6541  -0.6541   0.2674   0.8485  -0.8485   0.4500   0.4592  -1.1087   0.4500 
   0.6541  -0.6541   0.2674   0.8546  -0.3540   0.2674   1.1087  -0.4592   0.4500   0.8485  -0.8485   0.4500 
   0.8546  -0.3540   0.2674   0.9250  -0.0000   0.2674   1.2000  -0.0000   0.4500   1.1087  -0.4592   0.4500
Inbuilt absorber or reflector geometries

In addition to the meshes above which provide the most general form of mesh description, there are a number of builtin geometric primitives that can be chosen. At the time of writing these are "sphere", "cylinder", and "parabola". A sphere is described by its center and radius, see example below. A cylinder is described by two vertices and a radius. The parabola is defined by the origin, the normal, and parameter "a" (in 2D this is y = a x2), the focal point along the normal axis is 1/(4a). Note the length of the normal determines the "height" of the parabola. So in the following example the sphere is at the focal point. Note the the builtin geometries can be intermixed with meshes.

sun 0 0 -1
rcoeff 1
reflector parabola 0 0 0 0 0 0.5 0.5
acoeff 0
absorber sphere 0 0 0.5 0.25

Sphere primitive defined by center and radius.

Cylinder primitive defined by 2 points and radius.

Parabola defined by position, normal, and scalar.

Menus

The right mouse button gives a popup menu with various options, most of which have speed keys. The model illustrated below corresponds to the model file described above.

Sample model files: samples.zip