CustomMathScript

Custom math script data that can be plotted.

Example

app = pf.GetApplication()
app:NewProject()
app:OpenFile(FEKO_HOME..[[/shared/Resources/Automation/startup.fek]])

    -- Create a custom math script

customMathScript = app.MathScripts:Add(pf.Enums.MathScriptTypeEnum.Custom)

    -- Create the script that will be executed by the custom math script

script = 
[[
-- Create a new DataSet
    
customDataSet = pf.DataSet.New()

    -- Build the axes and quantities:
    --    Frequency axis spanning from 1GHz to 2GHz with 11 values
    --    Add a X axis spanning from -1m to 1m with 11 values
    --    Add a Y axis spanning from -1m to 1m with 11 values
    --    Add a Z axis spanning from -1m to 1m with 11 values
    
customDataSet.Axes:Add( pf.Enums.DataSetAxisEnum.Frequency, "GHz", 1 ,2 ,11)
customDataSet.Axes:Add( pf.Enums.DataSetAxisEnum.X,"m", -1, 1, 11)
customDataSet.Axes:Add( pf.Enums.DataSetAxisEnum.Y,"m", -1, 1, 11)
customDataSet.Axes:Add( pf.Enums.DataSetAxisEnum.Z,"m", -1, 1, 11)

    -- Add some quantities to the quantity collection
    
customDataSet.Quantities:Add( "Threshold", pf.Enums.DataSetQuantityTypeEnum.Scalar, "")
customDataSet.Quantities:Add( "TotalEField", pf.Enums.DataSetQuantityTypeEnum.Complex, "V/m")
customDataSet.Quantities:Add( "Impedance", pf.Enums.DataSetQuantityTypeEnum.Complex, "Ohm")

    -- An iterator function that is used by ForAllValues to populate the data set values
    
function initialise( index, customDataSet )
    indexedValue = customDataSet[index]
    freqValue = indexedValue:AxisValue("Frequency")
    xValue = indexedValue:AxisValue(pf.Enums.DataSetAxisEnum.X)
    yValue = indexedValue:AxisValue(pf.Enums.DataSetAxisEnum.Y)
    zValue = indexedValue:AxisValue(pf.Enums.DataSetAxisEnum.Z)
    r = math.sqrt((xValue*xValue)+(yValue*yValue)+(zValue*zValue))
    indexedValue.TotalEField = 1/r + j*(1/r)
    indexedValue.Threshold = 1
    indexedValue.Impedance = 50 + j*((-1.5+freqValue)*300)
end
pf.DataSet.ForAllValues( initialise, customDataSet )

return customDataSet
]]
customMathScript.Script = script

    -- Execute the math script

customMathScript:Run()

    -- Store the custom data set and plot it on a 3D view

customDataPlot = app.Views[1].Plots:Add(customMathScript)
customDataPlot.Quantity.Type = "TotalEField"
app.Views[1]:ZoomToExtents()

Inheritance

The CustomMathScript object is derived from the MathScript object.

Property List

DataSetAvailable
Valid result data exist. (Read only boolean)
Label
The object label. (Read/Write string)
Script
The script code to execute. (Read/Write string)
Type
The object type string. (Read only string)

Method List

Delete ()
Delete the math script.
Duplicate ()
Duplicate the math script. (Returns a MathScript object.)
GetDataSet ()
Returns a data set containing the math script values. (Returns a DataSet object.)
Run ()
Run the math script.

Property Details

DataSetAvailable
Valid result data exist.
Type
boolean
Access
Read only
Label
The object label.
Type
string
Access
Read/Write
Script
The script code to execute.
Type
string
Access
Read/Write
Type
The object type string.
Type
string
Access
Read only

Method Details

Delete ()
Delete the math script.
Duplicate ()
Duplicate the math script.
Return
MathScript
The duplicated math script.
GetDataSet ()
Returns a data set containing the math script values.
Return
DataSet
The data set containing the math script values.
Run ()
Run the math script.