Chris Chase
Subscriber
I see that if there are 2 dbrs back to back, the mesh size is set internally to a common value even though mesh sizes are overridden in 2 dbrs individually by mesh override region, for integer number of mesh cells per period. Is it a bug or there is some other way to get desired value. My python script is below :
 
 
 
import importlib.util 
spec_win = importlib.util.spec_from_file_location('lumapi', 'C:\\Program Files\\Lumerical\\v222\\api\\python\\lumapi.py')
import numpy as np
lumapi = importlib.util.module_from_spec(spec_win) 
spec_win.loader.exec_module(lumapi)
if not ( 'fdtd' in locals()  or 'fdtd' in globals()  ):
    fdtd = lumapi.FDTD("A")   
##############################################    
N_DBR1=4
N_DBR2=3
n1= 3.487
n2= 2.941
n3= 2.990
NUM_MESH_PER_DBR_PERIOD=6
################################################
fdtd.switchtolayout();
fdtd.deleteall();
##################   declare simulation, structure and mesh groups
props={"dimension":"2D","x": 0, "x span" :2e-6, "y min": 0, "y max": 4e-6,
       "z": 0, "mesh accuracy":1,"set simulation bandwidth":1,
       "simulation wavelength min":1e-6,"simulation wavelength max":1.1e-6} 
fdtd.addfdtd (properties=props);
props={"x": 0,"y": 0, "z": 0,"name":"epilayer_struct"} 
fdtd.addstructuregroup(properties=props);
props={"x": 0,"y": 0, "z": 0,"name":"mesh_group",} 
fdtd.addgroup (properties=props);
################# draw substrate
y_pos=0e-6; 
t=2e-6; 
props = {"x":0,"z":0,"x span":1e-6,"z":0,"z span":0, 
         "y min": y_pos,"y max": y_pos+t,"index" : n1 , "name":"substrate" } ;
fdtd.addrect(properties=props); fdtd.addtogroup("epilayer_struct");
y_pos+=t
################################################################################
#######   DBR 1
###############################################################################
print("DBR1 bot : " + str(y_pos) )
y_pos_DBR1_bot=y_pos
for k in np.arange(N_DBR1):
    t=89.3e-9; 
    props = {"x":0,"z":0, "x span":1e-6,"y min": y_pos,  "y max": y_pos+t, 
              "index" : n2,"name":"DBR1_n2",  "alpha":0.2} ;
    fdtd.addrect(properties=props); fdtd.addtogroup("epilayer_struct");
    y_pos+=t
    ####################
    t=75.3e-9; 
    props = {"x":0,"z":0, "x span":1e-6,"y min": y_pos, "y max": y_pos+t, 
              "index" : n1,"name":"DBR1_n1"} ;
    fdtd.addrect(properties=props);fdtd.addtogroup("epilayer_struct");
    y_pos+=t
    ####################
y_pos_DBR1_top=y_pos
print("DBR1 top : " + str(y_pos) )
####### add mesh DBR1
dy=(y_pos_DBR1_top-y_pos_DBR1_bot)/N_DBR1/NUM_MESH_PER_DBR_PERIOD
print("dy mesh DBR1 : " + str(dy))
props = {"x":0,"z":0,"x span":1.5e-6   ,"y min": y_pos_DBR1_bot, "y max": y_pos_DBR1_top,  
          "name":"mesh_DBR1","set maximum mesh step":1,
          "override y mesh":1,"override x mesh":0,"override z mesh":0,"dy":dy} ;
fdtd.addmesh(properties=props); fdtd.addtogroup("mesh_group");
###############################################################################
#######   DBR 2
###############################################################################
print("DBR2 bot : " + str(y_pos) )
y_pos_DBR2_bot=y_pos
for k in np.arange(N_DBR2):
    t=87.8e-9; 
    props = {"x":0,"z":0, "x span":1e-6,"y min": y_pos,"y max": y_pos+t, 
              "index" : n3, "name":"DBR2_n3","alpha":0.5} ;
    fdtd.addrect(properties=props); fdtd.addtogroup("epilayer_struct");
    y_pos+=t
    ####################
    t=75.3e-9; 
    props = {"x":0,"z":0, "x span":1e-6,"y min": y_pos,"y max": y_pos+t, 
              "index" : n1,"name":"DBR2_n1"} ;
    fdtd.addrect(properties=props); fdtd.addtogroup("epilayer_struct");
    y_pos+=t
    ####################
y_pos_DBR2_top=y_pos
print("DBR2 top : " + str(y_pos) )  
####### add mesh DBR2  
dy=(y_pos_DBR2_top-y_pos_DBR2_bot)/N_DBR2/NUM_MESH_PER_DBR_PERIOD
print("dy mesh DBR2 : " + str(dy))
props = {"x":0,"z":0,"x span":1.5e-6   ,"y min": y_pos_DBR2_bot,"y max": y_pos_DBR2_top,  
          "name":"mesh_DBR2","set maximum mesh step":1,
          "override y mesh":1,"override x mesh":0, "override z mesh":0,"dy":dy          } ;
fdtd.addmesh(properties=props); fdtd.addtogroup("mesh_struct");
##############################################################################
#### LINE MONITOR to get y mesh 
##############################################################################
props = {"monitor type":"Linear Y","x":0,"z":0,"y min":1.5e-6   ,"y max": 4e-6} ;
fdtd.addpower(properties=props);
##########################
fdtd.run();
######### y mesh
y=fdtd.getresult("monitor","y") ;print( np.diff(y[:,0]) )