wiki:TestObjects

Test Objects

Description

The Test object was created to run testing routines on a problem module. The Test object allows for a simple interface for setting the field to be tested as well as various image properties. The object (if used) must be created during the ProblemModuleInit subroutine.


Object Attributes

   TYPE TestDef
      INTEGER :: FieldID = Mass_Field
      INTEGER :: sumaxis = 3
      REAL(KIND=qPREC) :: plotmin = 0d0
      REAL(KIND=qPREC) :: plotmax = 1d0
      LOGICAL :: scaling = LINEARSCALE
      REAL(KIND=qPREC) :: errortolerance = 1d-4
      LOGICAL :: lcomparefields = .true.
      LOGICAL :: lgenerateimage = .true.
      INTEGER :: ObjId
   END TYPE TestDef

The default value for the FieldID is Mass_Field. See the fields.f90 file for a full list of available fields. In order to use the integer parameters instead of just integers for FieldID, then the problem module will need the USE Fields statement at the beginning.

The sumaxis parameter tells the routine which axis to sum over, because all images generated are 2D. The default sumaxis = 3 (the z-axis). This can be changed if you wish to sum over a different axis.

The default values for plotmin and plotmax are 0 and 1 respectively. These define the minimum and maximum values to be plotted during image generation. The scaling parameter (default = LINEARSCALE) sets whether the plot is on a linear or logarithmic scale (for log scale set scaling = LOGSCALE).

The errortolerance parameter (default is 1d-4) sets the maximum relative error tolerated to pass the test.

lcomparefields and lgenerateimage are switches that turn on/off the field comparison and image generation. Their default values are both true.

ObjID is an integer parameter used internally for object control. This should be left alone.


How to Use this Object

Firstly, the USE Tests statement will be required at the top of the module. Then, one just has to create the test object and modify its default values as necessary as follows…

SUBROUTINE ProblemModuleInit()
  TYPE(TestDef), POINTER :: Test

  IF (ltest) THEN
     CALL CreateTest(Test) 
     Test%plotmin = 1d0
     Test%plotmax = 2d0
  END IF

END SUBROUTINE ProblemModuleInit

This set up uses most of the defaults and only changes plotmin and plotmax. The IF (ltest) statement is required for proper implementation with the test suite.

The problem module also needs some reference data, and this should be in the form of a layout file named 'layout0000.dat'. The newly generated data will be compared to this data. If this file does not exist, astrobear will create one and the new data will be compared to itself. In other words, the errors will be identically zero, and the test will get a passing grade.


Output

If the layout0000.dat file exists and is in the correct format, astrobear will output a file named 'errors.data'. Here is an example of what the output in this file looks like:

Date: 02/24/2014  Time: 21:51:52
Errors for FieldID = 101
maximum relative error =     0.000000000000000E+00
maximum absolutee error =     0.000000000000000E+00
mean error =     0.000000000000000E+00
PASS

The test results are time-stamped, the FieldID that was tested is specified, and a few different values quantifying error are outputted as well. If the maximum relative error is less than the errortolerance set by the test object, then the last line will read PASS. Otherwise, the test would receive a failing grade, and the last line would read FAIL.

An image file is also generated named 'testimage.ppm'. Astrobear plots 2D data of the FieldID according to sumaxis, plotmin, plotmax, and scaling. In the test suite, this .ppm file is converted to a .png file so that it can be viewed on the wiki.

Last modified 11 years ago Last modified on 02/27/14 19:01:18
Note: See TracWiki for help on using the wiki.