-
-
July 8, 2021 at 10:04 am
zhenjiehan
SubscriberHi,
Does this code only set X boundary condition to PML, while not modifying original y boundary condition?
lumapi.evalScript(_globals.FDTD, " set('name','%s'); set('direction', '%s'); set('number of field profile samples', %s); updateportmodes(%s); select('FDTD'); set('%s','PML'); ?'Added pin: %s, set %s to PML'; " % (p.pin_name, p.direction, FDTD_settings['frequency_points_expansion'], mode_selection_index, port_dict[p.rotation], p.pin_name, port_dict[p.rotation] ) )
I am confused with it. Who know this?
Thank you in advance!
July 14, 2021 at 5:32 pmTaylor Robertson
Ansys EmployeeHello Zhenjiehan
This seems to be a python issue and not a Lumerical issue. The evalScript will simply evaluate the string as lsf code. You are passing this string %s repeatedly? Since you have not define s here I cannot say exactly what this doing. The question seems to be what is the command?
select('FDTD'); set('%s','PML');
To update all the BC you should call set for set each boundary x, y, z.
select('FDTD'); set('x min bc','PML');set('x max bc','PML');set('y min bc','PML');set('y max bc','PML'); ...
A more efficient way of doing this may be to do this may be to pass a struct (LSF) or dictionary (python). When using the API I think it is best practice to use the python methods rather then evaluating long strings as LSF code. There should be a 1-1 correspondence between lumapi methods and lsf commands. The following is how I would set all BC to PML in FDTD.
PML = 'PML'
bc_dict = {"x min bc" : PML, "x max bc" : PML, "y min bc" : PML , "y max bc" : PML, "z min bc" : PML, "z max bc", PML}
fdtd.setnamed("FDTD",bc_dict)
I hope this helps. I think reading up on string formatting, and dictionary datatypes would also be valuable.
BestJuly 16, 2021 at 6:12 amzhenjiehan
SubscriberHi,@troberts Thank you very much. There are sentences before this script.
Their architecture is showed as followed:
lumapi.evalScript(_globals.FDTD, " \
newproject; closeall; \
addfdtd; set('x min',%s); set('x max',%s); set('y min',%s); set('y max',%s); set('z span',%s);\
set('force symmetric z mesh', 1); set('mesh accuracy',1); \
set('x min bc','Metal'); set('x max bc','Metal'); \
set('y min bc','Metal'); set('y max bc','Metal'); \
set('z min bc','%s'); set('z max bc','%s'); \
setglobalsource('wavelength start',%s); setglobalsource('wavelength stop', %s); \
setglobalmonitor('frequency points',%s); set('simulation time', %s/c+1500e-15); \
addmesh; set('override x mesh',0); set('override y mesh',0); set('override z mesh',1); set('z span', 0); set('dz', %s); set('z', %s); \
?'FDTD solver with mesh override added'; " % ( FDTDxmin,FDTDxmax,FDTDymin,FDTDymax,FDTDzspan, \
Z_symmetry, FDTD_settings['Initial_Z-Boundary-Conditions'], \
wavelength_start,wavelength_stop, \
FDTD_settings['frequency_points_monitor'], sim_time, \
FDTD_settings['thickness_Si']/4, FDTD_settings['thickness_Si']/2) )
........
lumapi.evalScript(_globals.FDTD, " \
set('name','%s'); set('direction', '%s'); set('number of field profile samples', %s); updateportmodes(%s); \
select('FDTD'); set('%s','PML'); \
?'Added pin: %s, set %s to PML'; " % (p.pin_name, p.direction, FDTD_settings['frequency_points_expansion'], mode_selection_index, \
port_dict[p.rotation], p.pin_name, port_dict[p.rotation] ) )
Finally, y boundary condition is Metal, so I have the question in title.
So´╝îdoes this mean I am passing this string%srepeatedly?
Beside, thank you for the methods you mentioned, I will use the method when I need it.
July 21, 2021 at 4:37 pmTaylor Robertson
Ansys EmployeeHello It seems to me that the string s is being passed repeatedly. I would look into what this variable is defined as to understand what is going on here.
Best RegardsJuly 30, 2021 at 6:37 amAugust 9, 2021 at 6:41 pmTaylor Robertson
Ansys Employee
You haven't defined s here, so I cannot comment on this case. Additionally we cannot necessarily debug your python code, but we are happy to answer questions on Lumerical solvers. I would suggest using the API calls instead of eval method, which will be easier to determine where the error may be.
Viewing 5 reply threads- The topic ‘Does this only set x boudary condition to PML?’ is closed to new replies.
Ansys Innovation SpaceTrending discussionsTop Contributors-
3467
-
1057
-
1051
-
929
-
896
Top Rated Tags© 2025 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.
-

Ansys Assistant

Welcome to Ansys Assistant!
An AI-based virtual assistant for active Ansys Academic Customers. Please login using your university issued email address.

Hey there, you are quite inquisitive! You have hit your hourly question limit. Please retry after '10' minutes. For questions, please reach out to ansyslearn@ansys.com.
RETRY