- This topic has 11 replies, 4 voices, and was last updated 6 years, 10 months ago by Christopher Dirdal.
-
AuthorPosts
-
-
September 29, 2016 at 9:04 am #41385Paulo LourencoParticipant
Hi there.
I would like to use a script like the one on “Calculate Power Transmittance and Reflection using VBScript” but on a 3D design. I have tried to adapt the script but with no success. Mainly, what I need is to get the power that goes through an observation area. I altered the power function on the script to CalculatePowerRatioCW() but although there are no errors when I test the script, I have not been able to run it…
Any help would be much appreciated. Thank you. -
October 1, 2016 at 5:40 pm #41408Tamer SalehParticipant
Hi,
Try to run the script for 2D example at first, because sometime there is mismatch for the name of observation between script and the layout -
October 1, 2016 at 11:29 pm #41409Paulo LourencoParticipant
Thx Tamer for your answer. Already done it and 2D script simulation goes on with no errors (I had to include an observation line for 2D sim…) and completes the process. Only 3D simulation gets stuck. I am attaching the print screen…
-
October 2, 2016 at 3:08 am #41410Tamer SalehParticipant
Good work and good day Paulo
-
October 2, 2016 at 2:56 pm #41415Paulo LourencoParticipant
Thanks Tamer, I think I will need it :-)…
Same to you. -
October 3, 2016 at 12:30 am #41416Paulo LourencoParticipant
Hi again.
I really need help with this script for my 64bit license is almost finishing and I do not understand why this is not working. Layout script works when there is no tick on “Simulate using script” and when I test the script with a larger NumIterations, I can observe the effect of radius variable on the layout designer; looks like there is something wrong in file creation instructions…
Const NumIterations=1
For x=1 to NumIterations
ParamMgr.SetParam "radius",13-x*0.1
ParamMgr.SimulateCall Sub_PowerAtCenterWavelength("ObservationArea1", x, True)
WGMgr.Sleep(50)
Next' Simulation and VB-post-data- analysis finished
'''''Start of sample code for the power calculation'''''''''
''''''''''''Calculate the Power At Center Wavelength'''''''''''''''''
'LineName - String - The name of the observation line
'IterationNum - Integer - The current iteration number in case of sweep simulation
'OutputIterationNum - Boolean - Indicate if the iteration number should be stored into the file.
'Sample: Call Sub_PowerAtCenterWavelength("ObservationLine1", nIteration, True)
Sub Sub_PowerAtCenterWavelength( AreaName, IterationNum, OutputIterationNum )
Dim error_msg 'for error handling
Dim fhs, ios 'for the output of the result
Dim power_val 'the Power At Center Wavelength
Dim observation_area 'The line object to the LineName.
Dim file_for_output 'The file name for storing the result.
Dim P_total'Get the observation area.
Set observation_area = ObservePtMgr.GetObjFromID(AreaName)
'Calcualte the power at center wavelength.
P_total = observation_area.GetPowerTypeID(1)
power_val = observation_area.CalculatePowerRatioCWTotal()'Save the result to the file.
If AppMgr.RunsInSimulator() = True Then
'Prepare the file for output.
Set fhs = CreateObject("Scripting.FileSystemObject")
file_for_output = GetOutputFileName("_PowerAtCenterWavelength.txt")
'Open for appending
Set ios = fhs.OpenTextFile(file_for_output, 8, True)'Is there an error during the calculation?
' If observation_area.HasErrorsInPowerCalc() = True Then
' error_msg = observation_area.GetErrorMsg()
' ios.WriteLine( error_msg )
' Else
If OutputIterationNum Then
ios.WriteLine(CStr(power_val))
Else
ios.WriteLine(CStr(power_val))
End If
ios.Close 'Close the file
End If' End If
End Sub'Helper function
'Postfix - String - will be appended to the file(of FDT) name.
'Sample: file_name = GetOutputFileName("ThePower.txt")
Function GetOutputFileName( Postfix )
Dim project_folder
Dim file_nameproject_folder = AppMgr.GetProjectFolderName()
file_name = AppMgr.GetProjectFileName()
file_name = Left(file_name, Len(file_name) - 4)
file_name = file_name&PostFix
GetOutputFileName = project_folder&file_name
End Function
'''''End of sample code the for power calculatioWhenever I run the script, no matter what value NumIterations has, I can not get past the attached print screen.
Any help would be much appreciated. Thank you up front… -
October 3, 2016 at 10:00 am #41424Damian MarekParticipant
Paulo,
Can you attach the FDT project file as well?
Damian
-
October 3, 2016 at 1:59 pm #41430Paulo LourencoParticipant
Yes, will do for sure. Thx Damian…
Note: each iteration of the script takes more than one hour on an i7, 8GB ram.
-
October 6, 2016 at 1:13 pm #41441Paulo LourencoParticipant
Hi guys.
Attached the project file…
Thank you.
-
-
October 11, 2016 at 9:32 am #41460Damian MarekParticipant
Paulo,
Thanks for your patience, I have found the problem and it seems to be originating from the mode solving and the Input Plane. The waveguide is made of high contrast materials and the default ADI mode solver is not finding the propagating modes of the structure. That’s where the error is coming from.
The bad news is I cannot find a way through scripting to change the default mode solver! The work around I found is to set the input plane via the interface and not touching it from the script. Therefore, comment out the
InputPlaneMgr.DeleteAll
line and the
Dim InputPlane1
Set InputPlane1 = InputPlaneMgr.CreateInputObj ( “Continuous”, “Mode”, “InputPlane1”, “Vertical” )
‘Common data for 2D and 3D.
InputPlane1.SetPosition 1
InputPlane1.SetDirection “Forward”
InputPlane1.SetWaveLength “1.5”
InputPlane1.SetEnabled True
‘Data for 2D.
InputPlane1.SetAmplitudeOrPower “Amplitude”, “1.0”
InputPlane1.SetModeIdx 0
InputPlane1.AddModalWG “Linear1”
‘Data for 3D.
InputPlane1.SetAmplitudeExpr3D “1.0”
InputPlane1.SetModeIdx3D 0
InputPlane1.AddModalWG3D “Linear1”
InputPlane1.RefreshInputFieldlines. You can then add or edit the input plane that is in the layout and save the project. It’s position and other details will be saved in the project file. Since you are not modifying the input plane settings in the different iterations, this will not impact your results.
The other important step is to change the mode solver from the ADI to the Finite Difference. Navigate to Input Field Properties, by double clicking “InputPlane1”, under the 3D Transverse tab click “Find Modes…”. Choose the Finite Difference Method with the radial button and hit “Calculate Modes …”. Finally either preform the calculation or accept the changes with OK all the way back to the layout.
Regards,
Damian -
October 13, 2016 at 1:17 pm #41462Paulo LourencoParticipant
Hi Damian.
Thank you for your efforts on solving this issue.
Best regards.
-
January 30, 2018 at 8:41 am #47599Christopher DirdalParticipant
Hi!
I would like to use this script to obtain the spectrum instead.
I’ve tried changing ‘power_val = observation_area.CalculatePowerRatioCWTotal()’ to
‘power_val = observation_area.alculatePowerSpectrumTotal()’But it doesn’t give me any data. There has to be some simple way to obtain the spectrum instead of a point value?
Any help is much appreciated.
-
-
AuthorPosts
- You must be logged in to reply to this topic.