Plane Wave Controls in Lua API
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,
CE
Answers
-
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' PlaneWaveSource1:SetProperties(properties)
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):
PlaneWave
A plane wave may be defined as a source in a model.
Example
app = cf.GetApplication() project = app:NewProject() -- Create a plane wave source configuration = project.SolutionConfigurations[1] planeWave = configuration.Sources:AddPlaneWave(0,0)
Inheritance
The PlaneWave object is derived from the SolutionEntity object.
Parent Collection List
The following collections contain the PlaneWave object:
Property List
- CalculateOrthogonalPolarisationsEnabled
- Calculate orthogonal polarisations. (Read/Write boolean)
- DefinitionMethod
- The plane wave definition method. (Read/Write PlaneWaveDefinitionMethodEnum)
- Ellipticity
- Ellipticity (between 0 and 1). (Read/Write Expression)
- EndPhi
- The end phi angle (degrees). (Read/Write Expression)
- EndTheta
- The end theta angle (degrees). (Read/Write Expression)
- LocalWorkplane
- The plane wave workplane. (Read only LocalWorkplane)
- Magnitude
- The source magnitude (V/m). (Read/Write Expression)
- Phase
- The source phase (degrees). (Read/Write Expression)
- PhiIncrement
- The phi angle increment (degrees). (Read/Write Expression)
- PolarisationAngle
- The polarisation angle (degrees). (Read/Write Expression)
- PolarityType
- The plane wave type specified by the PlaneWavePolarityTypeEnum, e.g. LeftHand, Linear, etc. (Read/Write PlaneWavePolarityTypeEnum)
- StartPhi
- The start phi angle (degrees). (Read/Write Expression)
- StartTheta
- The start theta angle (degrees). (Read/Write Expression)
- ThetaIncrement
- The theta angle increment (degrees). (Read/Write Expression)
- Type
- 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.
0