Skip to content

Script functions

ilescener edited this page Mar 16, 2017 · 17 revisions

Tonatiuh has de capability to design and run the simulations using the scripting. To use the scripting open the script editor in Automation>Script Editor.

Main functions

Through the functions that are implemented it is possible to build and simulate optic systems. All these functions are collected herein, they have been sorted based on an functionality and alphabetic order.

Dealing with Tonatiuh files

  • New(): Opens an empty Tonatiuh scene.

  • Open( QString fileName ): Opens the fileName file.

  • Save(): Saves the current system.

  • SaveAs( QString fileName ): Saves the current system into fileName.

Building and managing nodes

  • Copy(): Copies the selected node to the clipboard.

  • Copy( QString nodeURL ): Copies the node defined by nodeURL to the clipboard.

  • CreateGroupNode(): Creates a separator node as a child of the current selected node.

  • CreateComponentNode( QString componentType, QString nodeName, int numberOfParameters, QVector< QVariant > parametersList ): Creates a component structure using componentType . The node that groups the component will be called nodeName. The parameters needed for the component are defined in parametersList and numberOfParameters is the length of the previous mentioned list.

  • CreateMaterial( QString materialType ): Creates material node of type materialType as a child of current selected node.

  • CreateShape( QString shapeType ): Creates a new shape node of type shapeType as a child of current selected node.

  • CreateSurfaceNode(): Creates a Surface node as a child of current selected node.

  • CreateTracker( QString trackerType ): Creates a new tracker of type trackerType as child of the current selected node.

  • Cut(): Cuts the selected node and saves it at the clipboard.

  • Cut( QString nodeURL ): Cuts the node defined as nodeURL and saves it at the clipboard.

  • Delete(): Deletes selected node.

  • Delete( QString nodeURL ): Deletes the node defined as nodeURL and the children of this node form the scene.

  • InsertFileComponent( QString componentFileName ): Inserts as a child of the selected node the Tonatiuh component saved at the file componentFileName.

  • Paste( QString nodeURL, QString pasteType ): Pastes the node allocated on the clipboard as a child of nodeURL. The second argument, pasteType, indicates the type of paste, Shared or Copied.

  • PasteCopy(): Pastes the node allocated on the clipboard as a new child of the selected node.

  • PasteLink(): Pastes the node allocated on the clipboard as a child of the selected node. Instead a new node, this function creates a new pointer to the physical node.

  • SelectNode( QString nodeURL ): Selects the nodeURL.

  • SetAimingPointAbsolute(): Sets the AimingPoint parameter value to Absolute value.

  • SetAimingPointRelative(): Sets the AimingPoint parameter value to Relative value.

  • SetNodeName( QString nodeName ): Changes the selected node name to nodeName.

  • SetValue( QString nodeURL,QString parameter, QString value): Sets the parameter with the name parameter of the node nodeURL, to the value defined into value.

Setting the environment

  • ChangeSunPosition(double azimuth, double elevation): Sets the sun azimuth and sun elevation to those new values. The sun will be automatically updated.

  • ChangeSunPosition( int year, int month, int day, double hours, double minutes, double seconds, double latitude, double longitude ): Changes the sun position to the defined position for a location ( latitude and longitude in degrees) and an time in UT.

  • SetRandomDeviateType( QString typeName ): Sets the type of random number generator to typeName. Current Tonatiuh version has available Mersenne Twister and Rng Stream generators.

  • SetRayCastingGrid(int widthDivisions, int heightDivisions): Sets the number of sun divisions.

  • SetSunshape( QString sunshapeType ): Sets the sunshape type to sunshapeType if it is valid type. Currently Buie_Sunshape and Pillbox_Sunshape.

  • SetSunshapeParameter( QString parameter, QString value ): Assigns value to the sun parameter parameter.

  • SetTransmissivity( QString transmissivityType ): Sets the scene transmissivity to transmissivityType. The following types are available currently:

    • Default Transmissivity
    • Ballestrin Transmissivity
    • Mirval Transmissivity
    • Sengupta-NREL Transmissivity
    • VantHull Transmissivity
    • VittitoeBiggs Transmissivity
  • SetTransmissivityParameter( QString parameter, QString value ): Assings the value into value to the parameter into the current defined transmissivity.

Run and simulation setting

  • AddExportSurfaceURL( QString nodeURL ) : Adds the surface with the URL nodeURL to the export surfaces list. The nodeURL is the tree node name of the surface node ( the node that contains the surface shape and material) starting form the root ("\SunNode\ROOTNODENAME ", where ROOTNODENAME is the name of the root node in the scene ).

  • Run(): Runs the ray tracer for the current scene.

  • RunFluxAnalysis( QString nodeURL, QString sufaceSide, unsigned int rays, int heightDivisions, int widthDivisions, QString directory, QString filename, bool saveCoords ): Runs ray trace to calculate a flux distribution map in the surface of the node nodeURL related to the side surfaceSide. The map will be calculated with the parameters nOfRays, heightDivisions and heightDivisions. The results will save in a file called filename allocated in the directory. The coordinates of the cells will be saved depending on the variable saveCoord.

  • SetExportAllPhotonMap(): Sets to save all intersection photons.

  • SetExportCoordinates( bool enabled, bool global ): If enabled is false the photons coordintates will not be saved into simulations results. Otherwise, the coordinates will be saved into scene coordinates if global is true or in local coordinates relative to intersection surface.

  • SetExportIntersectionSurface( bool enabled ): If enabled is true the intersection surface will be saved for all photons. Otherwise, this information will not be saved.

  • SetExportIntersectionSurfaceSide( bool enabled ): If enabled is true the side of the surface where ray has been intersected. Otherwise, this information will not be saved.

  • SetExportPhotonMapType( QString exportModeType ): Sets the export photon type to exportModeType. Currently the SQL_Database, Binary_file and Not export are available.

  • SetExportPreviousNextPhotonID( bool enabled ): If enabled is true the photon previous and next photons ID will be saved. Otherwise, this information will not be saved.

  • SetExportTypeParameterValue( QString parameterName, QString parameterValue ): Sets to current selected export type parameter called parameterName the value parameterValue.

    • For Binary_file the parameters are:
      • ExportDirectory: the directory path to store binary files.
      • ExportFile: the binary files root name.
      • FileSize: the maximum photons that can be stored into a file. Use "-1" to save into a one file.
    • For SQL_Database the parameters are:
      • ExportDirectory: the path of directory where the DB will be stored.
      • DBFilename: The file name for the database.
  • SetIncreasePhotonMap( bool increase ): Decides whether increase the photonMap or not for consecutive ray tracer executions.

  • SetPhotonMapBufferSize( unsigned int nPhotons ): Sets to nPhotons the maximum number of photons that the photon map can store.

  • SetRaysDrawingOptions( bool drawRays, bool drawPhotons ): Sets to draw rays and photons after simulations.

  • SetRaysPerIteration( unsigned int rays ): Sets the number of rays to trace per each ray trace execution.

In the Tutorials section there is an example of how use this functions to create a tower system a simulate it. Go to Small heliostats Tower using script.


User's Guide | Wiki Home

Clone this wiki locally