Jump to content

Plane Wave Controls in Lua API

Recommended Posts

I am working on a Lua script that involves creating a number of plane waves with different parameters. While I could find how to modify the direction of a plane wave easily, I can't find documentation on how to modify the phase and amplitude from the Lua API. I'm sure there's an easy way to do this, I couldn't find anything in the manual or example guide that explained this.


Thanks in advance,


Share this post

Link to post
Share on other sites

Hello Christopherson,


You are indeed correct that this is easy. There are two ways to go about finding out how to do things in the CADFEKO API. The one is to find the object in the API and see what options it provides (properties, methods) or using the example for that object if it does roughly what you need. The other way is to use script recording - record the actions and then see the code it generated and modify it to your requirements.


Below is a section that I script recorded. I simply created a plane wave source with default options and then modified it, changing the magnitude, phase and also angles of incidence.

app = cf.GetApplication()
project = app.Project

-- Created solution entity: PlaneWaveSource1
properties = cf.PlaneWave.GetDefaultProperties()
properties.Label = "PlaneWaveSource1"
PlaneWaveSource1 = project.SolutionConfigurations["StandardConfiguration1"].Sources:AddPlaneWave(properties)

-- Modified solution entity: PlaneWaveSource1
properties = PlaneWaveSource1:GetProperties()
properties.DefinitionMethod = cf.Enums.PlaneWaveDefinitionMethodEnum.Multiple
properties.EndPhi = "45"
properties.EndTheta = "90"
properties.Magnitude = "2"
properties.Phase = "20"
properties.PhiIncrement = "5"
properties.ThetaIncrement = "10"

If you look at the "PlaneWave" object in the API reference, you will see similar info (obviously the links won't work in my extract below):





A plane wave may be defined as a source in a model.


app = cf.GetApplication()
project = app:NewProject()

    -- Create a plane wave source
configuration = project.SolutionConfigurations[1]
planeWave = configuration.Sources:AddPlaneWave(0,0)


The PlaneWave object is derived from the SolutionEntity object.

Parent Collection List

The following collections contain the PlaneWave object:

Property List

Calculate orthogonal polarisations. (Read/Write boolean)
The plane wave definition method. (Read/Write PlaneWaveDefinitionMethodEnum)
Ellipticity (between 0 and 1). (Read/Write Expression)
The end phi angle (degrees). (Read/Write Expression)
The end theta angle (degrees). (Read/Write Expression)
The plane wave workplane. (Read only LocalWorkplane)
The source magnitude (V/m). (Read/Write Expression)
The source phase (degrees). (Read/Write Expression)
The phi angle increment (degrees). (Read/Write Expression)
The polarisation angle (degrees). (Read/Write Expression)
The plane wave type specified by the PlaneWavePolarityTypeEnum, e.g. LeftHand, Linear, etc. (Read/Write PlaneWavePolarityTypeEnum)
The start phi angle (degrees). (Read/Write Expression)
The start theta angle (degrees). (Read/Write Expression)
The theta angle increment (degrees). (Read/Write Expression)
The object type string. (Read only string)

Method List

GetProperties ()
Returns a table of properties representing the state of the object. The properties table can be used with the SetProperties method to change multiple properties of the object in one step. (Returns a table object.)
SetProperties (properties table)
Modifies the state of the object using the provided table of properties. This method is used to modify multiple properties of the object in a single step.

Static Function List

GetDefaultProperties ()
Creates a table containing the default settings to create an object. (Returns a table object.)



I hope the info helps.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...