Ansys Learning Forum › Forums › Discuss Simulation › Photonics › Can’t add frequency domain field profile into structure group using script › Reply To: Can’t add frequency domain field profile into structure group using script
Hi Devika,
I've added a copy of the script along with an image of the parameters I've set in the structure group below. I've also attached an image of the produced structure.
The script is just a modified version of the included script to produce a photonic crystal with a square lattice. I've added extra functionality to add input and output waveguides and change the structure of the crystal. Now I want to add a frequency domain field profile to the output waveguide. I've used the example script for the "addprofile" command but it seems to be not valid in my case.
I'm new to scripting in Lumerical Mode so please let me know if I've missed anything thank you.
deleteall;
####################################################
# Rectangular lattice PC array
# A periodic array of photonic crystals in a rectangular lattice.
#
# Input properties
# z span: height of crystals
# nx, ny: the number of columns and rows
# a: lattice constant
# index: index of refraction
# material
# alength, blength, ylength: length of input and output waveguides
#
# Tags: square rectangular lattice pc photonic crystal array
#
# Copyright 2012 Lumerical Solutions Inc
#####################################################
# simplify variable names by removing spaces
z_span = %z span%;
n_rows = ny-1;
n_cols = nx-1;
even_flag = 0;
radius1 = 0.36*a;
radius2 = 0.24*a;
for(i=-n_rows/2:n_rows/2) {
for(j=-n_cols/2:n_cols/2) {
if( (j<=i+nx/2) and (-j>=i-nx/2) and ((-round(j+2) != round(i)) or (j <= -1 and j >= -4))) {
addcircle;
set("radius",radius1);
set("x",(j)*a);
set("y",(i)*a);
set("z span",z_span);
set("material",material);
if(get("material")=="
# Input A
addrect;
set("name","input_A");
set("x",-((nx/2)*a)-alength/2);
set("x span",alength);
set("y",5*a);
set("y span",2*a);
set("z",0);
set("z span",z_span);
set("material","Si (Silicon) - Palik");
# Input B
addrect;
set("name","input_B");
set("x",-((nx/2)*a)-blength/2);
set("x span",blength);
set("y",-5*a);
set("y span",2*a);
set("z",0);
set("z span",z_span);
set("material","Si (Silicon) - Palik");
# Output Y
addrect;
set("name","output_Y");
set("x",((nx/2)*a)+ylength/2);
set("x span",ylength);
set("y",5*a);
set("y span",4*a);
set("z",0);
set("z span",z_span);
set("material","Si (Silicon) - Palik");
# Silicon
addrect;
set("name","Silicon");
set("x",0);
set("x span",(nx+1)*a);
set("y",0);
set("y span",(ny+1)*a);
set("z",0);
set("z span",z_span);
set("material","Si (Silicon) - Palik");
# Output Monitor
addprofile;
set("name","field_profile");
set("monitor type",7); # 2D z-normal
set("x",0);
set("x span",5e-6);
set("y",0);
set("y span",5e-6);
set("z",0);