Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

<functionVariable>

It allows to define the default values of a function defined by xy points. The parameters are as follows,
n - Name used to reference the field, especially when writing the .dat file.
pn - Label that will be visualized by the user. It can be translated.
variable - Name of the variable shown in the GUI.
units - Its value is the default unit shown in the GUI, which could be changed, if desired.

Example:

Code Block
languagexml
<value n="dens" pn="Density" min_two_pnts="1" help="Density of Steel" unit_magnitude="M/L^3" units="kg/m^3" function="[density_function]" function_func="" v="1.0">
   <function>
    <functionVariable n="interpolator_func" pn="Interpolation function" variable="x" units="°C">
            <value n="point" pn="Point" v="20.0,7830.0"/>
            <value n="point" pn="Point" v="600.0,7644.0"/>
         </functionVariable>
      </function>
</value>

<procs>
    <proc n='density_function' args='args'>
      <![CDATA[
      MyDensityFunction $domNode $args      
      ]]>
    </proc>
</procs>



In this example the proc density_function referenced by the 'function' attribute is implemented in the xml .spd file but it is very simple and only invokes another procedure named MyDensityFunction adding some arguments. The body of the tcl procedure could be implemented separately in a .tcl file (sourced in the problemtype), this facilitate its edition and debug.

Code Block
proc MyDensityFunction { domNode args } {
    set result [join [list scalar [list interpolator_func x x Temp]] ,]
    return $result
}

The proc referenced by the 'function' must return as value something like this:
scalar, interpolator_func x x Temp

where scalar is a keyword,
interpolator_func is the same name used in <functionVariable n="interpolator_func" ...
x is the same variable name used in <functionVariable ... variable="x" ...
Temp is the magnitude according to the units used in <functionVariable ... units="°C">

The graphical interface will show something like this

and pressing the right button will open a window to edit the xy graph:

Interpolation function window