Home Forums FDTD Script 3D

Viewing 10 reply threads
  • Author
    Posts
    • #41385
      Paulo Lourenco
      Participant

      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.

    • #41408
      Tamer Saleh
      Participant

      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

    • #41409
      Paulo Lourenco
      Participant

      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…

    • #41410
      Tamer Saleh
      Participant

      Good work and good day Paulo

    • #41415
      Paulo Lourenco
      Participant

      Thanks Tamer, I think I will need it :-)…
      Same to you.

    • #41416
      Paulo Lourenco
      Participant

      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.Simulate

      Call 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_name

      project_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 calculatio

      Whenever 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…

      Attachments:
    • #41424
      Damian Marek
      Participant

      Paulo,

      Can you attach the FDT project file as well?

      Damian

    • #41430
      Paulo Lourenco
      Participant

      Yes, will do for sure. Thx Damian…

      Note: each iteration of the script takes more than one hour on an i7, 8GB ram.

    • #41460
      Damian Marek
      Participant

      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.RefreshInputField

      lines. 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

    • #41462
      Paulo Lourenco
      Participant

      Hi Damian.

      Thank you for your efforts on solving this issue.

      Best regards.

    • #47599
      Christopher Dirdal
      Participant

      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.

Viewing 10 reply threads
  • You must be logged in to reply to this topic.