########################################################################### # Scriptfile: usr_custom_source.lsf # # Description: # This is an example of how to create an arbitrary source using the # usr_createsource.lsf script file. In this example, we create a radially # polarized source. # # Copyright 2008, Lumerical Solutions, Inc. ########################################################################### # clear all current variables clear; # ################################################################# # To create your desired source modify this section: # this data could even come from a monitor in a previous simulation lambda = 650e-9; refractive_index = 1; # in order to inject this source in 3D, define y and z vectors x = linspace(-10e-6,10e-6,100); y = linspace(-10e-6,10e-6,100); z = 0; # this is z z-normal source # now we creat a 2d surface X = meshgridx(x,y); Y = meshgridy(x,y); # create radially polarized beam phi=atan2(X,Y); # x-polarized beam Ex = 1; Ey = 0; Ez = 0; # Create gaussian envelope FWHM = 8e-6; sigma = FWHM / ( 2*sqrt(2*log(2)) ); envelope = exp( - (X^2)/(2*sigma^2) - (Y^2)/(2*sigma^2) ); # apply envelope to fields Ex = Ex*envelope; Ey = Ey*envelope; Ez = Ez*envelope; # plot Er and Etheta if (1) { # 1=make plots, 0=don't make plots Er = Ex*sin(phi)+Ey*cos(phi); Etheta = -cos(phi)*Ex+Ey*sin(phi); image(x*1e6,y*1e6,envelope,"x (um)","y (um)","envelope"); image(x*1e6,y*1e6,abs(Er),"x (um)","y (um)","abs(Er) Source"); image(x*1e6,y*1e6,abs(Etheta),"x (um)","y (um)","abs(Etheta) Source"); image(x*1e6,y*1e6,abs(Ex),"x (um)","y (um)","abs(Ex) Source"); image(x*1e6,y*1e6,abs(Ey),"x (um)","y (um)","abs(Ey) Source"); } # end of user modification section ########################################################### # don't modify the following commands dx = x(2)-x(1); dy = y(2)-y(1); # fill in the variables needed for createsource.lsf include_H = 0; # 1: H fields are defined, 0: H fields defined from E fields wavelength = lambda; power = 1; index = refractive_index; axis1 = 1; # x axis axis2 = 2; # y axis min1 = x(1)-dx/2; max1 = x(length(x)) + dx/2; min2 = y(1)-dy/2; max2 = y(length(y)) + dy/2; depth = z; n1 = length(x); n2 = length(y); sourcefilename = "sourcefile"; #create the source by calling usr_create_fld.lsf usr_create_fld;