########################################################################### # Scriptfile: usr_custom_source.lsf # # Description: # This file imports a slab mode profile from a file named mode_profie.txt # and multiply it with sech(x) function to create an input beam used in # soliton propagation simulation. The input beam profile is output to # a lumerical data file named sourcefile.fld # # Copyright 2013, Lumerical Solutions, Inc. ########################################################################### #clear; #closeall; Ex0=readdata("mode_profile.txt"); s=pinch(size(Ex0)); y0=Ex0(1:s(1),1); lambda = 850e-9; refractive_index = 1; # in order to inject this source in 3D, define x and y vectors x = linspace(-3e-6,3e-6,100); y = linspace(-1.5e-6,1.5e-6,100); z = 0; Ex1 = interp(Ex0(1:s(1),2), y0, y); # now we creat a 2d surface X = meshgridx(x,y); Y = meshgridy(x,y); Ex = meshgridy(x,Ex1); Ey = 0; Ez = 0; fwhm=1.0e-6; #FWHM of sech function a0=fwhm/(2*log(2+sqrt(3))); sechX=2/(exp(X/a0)+exp(-X/a0)); envelope=sechX; #image(x,y,envelope); # apply envelope to fields Ex = Ex*envelope; Ey = Ey*envelope; Ez = Ez*envelope; image(x*1e6,y*1e6,Ex,"x","y"); ####################################### # 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;