EME solver analysis
setemeanalysis - Script command
Sets calculation parameters in MODE' EME analysis window.
Syntax | Description |
---|---|
?setemeanalysis; | Lists all the parameters in the EME analysis window. |
setemeanalysis("property", value); | Sets the parameter named "property" to value. |
Examples
This code will display the properties that can be set, and set the group spans column in the EME analysis window's EME setup section.
# display properties that can be set using setemeanalysis command ?setemeanalysis; # set group spans property to 1 micron (for 3 cell groups) setemeanalysis("group spans",[1e-6;1e-6;1e-6]);
This code will set up, run and collect the user s-matrix result from the propagation sweep tool in Analysis mode.
# set propagation sweep settings setemeanalysis("propagation sweep",1); setemeanalysis("parameter","group span 2"); setemeanalysis("start",10e-6); setemeanalysis("stop",200e-6); setemeanalysis("number of points",10); # run propagation sweep tool emesweep; # get propagation sweep result S = getemesweep('S');
This code will set up, run and export the user s-matrix result from the wavelength sweep tool in Analysis mode to a file named "s_param".
# set wavelength sweep settings setemeanalysis("wavelength sweep", 1); setemeanalysis("start wavelength", 1.5e-6); setemeanalysis("stop wavelength", 1.6e-6); setemeanalysis("number of wavelength points", 31); setemeanalysis("calculate group delays", 1); # run wavelength sweep tool emesweep("wavelength sweep"); # export the wavelength sweep result exportemesweep("s_param");
getemeanalysis - Script command
Gets calculation parameters in MODE' EME analysis window.
Syntax | Description |
---|---|
?getemeanalysis; | Lists all the parameters in the analysis window. |
getemeanalysis("property"); | Gets the value of the calculation parameter named "property" in EME solver analysis window. |
Examples
This code will display the values of the "group spans" parameters from the EME setup section of the EME analysis window.
# display the values of the group spans ?getemeanalysis("group spans");
emesweep - Script command
When in Analysis mode using EME solver, runs either propagation sweep tool which sweeps the length of a cell group span or mode convergence sweep tool which sweeps the number of modes. .
Syntax | Description |
---|---|
emesweep; emesweep("propagation sweep"); | Run propagation sweep. |
emesweep("wavelength sweep"); | Run wavelength sweep. |
emesweep("mode convergence sweep"); | Run mode convergence sweep. |
Examples
This code will set up, run and collect the user s-matrix result from the propagation sweep tool in Analysis mode. The result from the propagation sweep is packaged in a dataset called "S".
# set propagation sweep settings setemeanalysis("propagation sweep",1); setemeanalysis("parameter","group span 2"); setemeanalysis("start",10e-6); setemeanalysis("stop",200e-6); setemeanalysis("number of points",10); emesweep; S = getemesweep('S'); # plot S21 vs group span s21 = S.s21; group_span = S.group_span_2; plot(group_span,abs(s21)^2);
This code will set up, run and collect the user s-matrix result from the mode convergence sweep tool in Analysis mode. The result from the mode convergence sweep is packaged in a dataset called "S_mode_convergence_sweep".
# set mode convergence sweep settings start_mode = 4; #set smaller number of modes for convergence test mode_interval = 1; #set mode interval for convergence test setnamed("EME","number of modes for all cell groups",25); setemeanalysis("mode convergence sweep", 1); setemeanalysis("start mode", start_mode); setemeanalysis("mode interval", mode_interval); # run mode convergence sweep tool emesweep("mode convergence sweep"); # get mode convergence sweep result S = getemesweep("S_mode_convergence_sweep"); # plot S21 vs number of modes s21 = S.s21; modes = S.modes; plot(modes, abs(s21)^2);
emepropagate - Script command
Propagates fields for EME profile monitor and calculates s-matrix and user s-matrix results, as well as any error diagnostic results when in Analysis mode using EME solver. This is equivalent to clicking the "eme propagate" button.
Syntax | Description |
---|---|
emepropagate; | Propagate fields and s-matrix results. This is equivalent to the "eme propagate" button in the graphical user interface. |
Examples
This code will set up the group spans column in the EME analysis window then propagate using the EME solver.
# set group spans to 1 micron setemeanalysis("group spans",[1e-6;1e-6;1e-6]); # propagate eme emepropagate;
getemesweep - Script command
Gets the user s-matrix result from a propagation sweep, mode convergence sweep, or perturbative wavelength sweep.
Syntax | Description |
---|---|
getemesweep("S"); | Gets the user s-matrix result from an EME propagation sweep named "S". |
getemesweep("S_mode_convergence_sweep"); | Gets the user s-matrix result from an EME mode convergence sweep named "S_mode_convergence_sweep". |
getemesweep("S_wavelength_sweep"); | Gets the user s-matrix result from an EME wavelength convergence sweep named "S_wavelength_sweep". |
Examples
This code will set up, run and collect the user s-matrix result from the propagation sweep tool in Analysis mode. The result from the propagation sweep is packaged in a dataset called "S".
# set propagation sweep settings setemeanalysis("propagation sweep",1); setemeanalysis("parameter","group span 2"); setemeanalysis("start",10e-6); setemeanalysis("stop",200e-6); setemeanalysis("number of points",10); # run propagation sweep tool emesweep; # get propagation sweep result S = getemesweep('S'); # plot S21 vs group span s21 = S.s21; group_span = S.group_span_2; plot(group_span,abs(s21)^2);
This code will set up, run and collect the user s-matrix result from the mode convergence sweep tool in Analysis mode. The result from the mode convergence sweep is packaged in a dataset called "S_mode_convergence_sweep".
# set mode convergence sweep settings start_mode = 4; #set smaller number of modes for convergence test mode_interval = 1; #set mode interval for convergence test setnamed("EME","number of modes for all cell groups",25); setemeanalysis("mode convergence sweep", 1); setemeanalysis("start mode", start_mode); setemeanalysis("mode interval", mode_interval); # run mode convergence sweep tool emesweep("mode convergence sweep"); # get mode convergence sweep result S_mode = getemesweep("S_mode_convergence_sweep"); # plot S21 vs number of modes s21 = S_mode.s21; modes = S_mode.modes; plot(modes, abs(s21)^2);
This code will set up, run and collect the user s-matrix result from the perturbative wavelength convergence sweep tool in Analysis mode. The result from the wavelength convergence sweep is packaged in a dataset called "S_wavelength_sweep".
# set wavelength convergence sweep settings start_lam = 1.5e-6; #set start wavelength [m] end_lam = = 1.6e-6; #set end wavelength [m] lam_res = 100; #set wavelength for convergence test setnamed("EME","number of modes for all cell groups",25); setemeanalysis("wavelength sweep",1); setemeanalysis("start wavelength",start_lam); setemeanalysis("stop wavelength",end_lam); setemeanalysis("number of wavelength points",lam_res); # run wavelength convergence sweep tool emesweep("wavelength sweep"); # get mode convergence sweep result S_lambda = getemesweep("S_wavelength_sweep"); # plot S21 vs number of wavelength s21 = S_lambda.s21; lambda = S_lambda.wavelength; plot(lambda, abs(s21)^2);
exportemesweep - Script command
Exports the EME analysis wavelength sweep result to a file that can load to INTERCONNECT.
Syntax | Description |
---|---|
exportemesweep("filename", "format"); | Exports the EME analysis wavelength sweep result to a file that can load to INTERCONNECT with the name "filename". The "format" can be either "lumerical" or "touchstone" formats, and if not specified the "lumerical" format will be used. The "touchstone" format will be format v1.1. |
Note that Touchstone format v1.1 doesn't handle different modes, so the number of "ports" is really the number of effective ports (port/mode combinations).
Examples
This code will export the EME wavelength sweep result to the file "s_param".
exportemesweep("s_param", "touchstone");
FDE solver analysis
setanalysis - Script command
Sets calculation parameters in MODE' FDE and FEEM analysis window.
Syntax | Description |
---|---|
?setanalysis; | Lists all the parameters in the analysis window. |
setanalysis("property", value); | Sets"property" to value. |
Example
To perform a frequency sweep on the first mode and plot the dispersion:
switchtolayout; findmodes; selectmode(1); setanalysis("track selected mode",1); setanalysis("detailed dispersion calculation",1); frequencysweep; D=getdata("frequencysweep","D"); f=getdata("frequencysweep","f_D"); plot(c/f*1e6,D*1e6,"Wavelength (um)", "Dispersion (ps/nm/km)");
getanalysis - Script command
Lists the parameters used in MODE' FDE and Finite Element IDE analysis window.
Syntax | Description |
---|---|
?getanalysis; | Lists all the parameters in the analysis window. |
getanalysis("property"); | Returns the current value for the particular property on the analysis window |
analysis - Script command
Opens the MODE analysis window corresponding to the active solver (FDE or EME).
Syntax | Description |
---|---|
analysis; | Opens the analysis window corresponding to the active solver. |
mesh - Script command
Produces a mesh of the current structure that is required to perform a subsequent calculation. In MODE, it produces a d-card called "material" which contains the material properties of the meshed object.
This is equivalent to pressing the "mesh structure" button in the graphical user interface of MODE, or "Mesh" button in Finite Element IDE.
Syntax | Description |
---|---|
mesh; | Mesh the current simulation in FDE, DGTD, or FEEM. In MODE, it can be used only with FDE solver. In Finite Element IDE, it meshes the simulation that is present (DGTD or FEEM) |
mesh("solver_name"); | Mesh the current simulation in the desired solver defined by the argument "solver_name". Argument name is supported only in Finite Element IDE, and the options are "DGTD" and "FEEM". |
findmodes - Script command
Calculates the modes supported by the structure using the current calculation settings. This function is the script equivalent to the "Calculate Modes" button. Each mode will be saved as a D-CARD named "modeX", where X is the xth mode found. The D-CARD saves data such as effective index and mode profile.
Syntax | Description |
---|---|
n=findmodes; | n will be equal to the number of modes found. |
Example
To perform a frequency sweep on the first mode and plot the dispersion:
switchtolayout; findmodes; selectmode(1); setanalysis("track selected mode",1); setanalysis("detailed dispersion calculation",1); frequencysweep; D=getdata("frequencysweep","D"); f=getdata("frequencysweep","f_D"); plot(c/f*1e6,D*1e6,"Wavelength (um)", "Dispersion (ps/nm/km)");
nummodes - Script command
Returns the number of eigenmodes found in the FDE solver mode list.
Syntax | Description |
---|---|
n=nummodes; | n will be equal to the number of modes found. |
selectmode - Script command
Selects a mode from the mode list. All modes found in a simulation are numbered based on their effective index and they are displayed in the mode list in the Eigensolver analysis window.
Syntax | Description |
---|---|
selectmode(N); | Select the Nth mode from the mode list. |
selectmode([N]); | Select the Nth mode from a scalar matrix argument. |
selectmode(name); | Selects the desired mode where name is a string containing the name of a mode. Modes are named mode1, mode2, ..modeN. This form of the command is compatible with the bestoverlap function. |
Examples
Both these commands select the third mode in the list:
selectmode(3);selectmode("mode3");
Selects the 3rd, 5th, and 6th modes.
selectmode([3,5,6]);
Selects the modes 2 through 5, and 8.
selectmode([[2:5];8]);
This command selects the mode that has the best overlap with the D-card named "reference"
selectmode(bestoverlap("reference"));
frequencysweep - Script command
Performs a frequency sweep using the current settings within the frequency analysis tab. Produces a D-CARD called "frequencysweep" that contains dispersion, effective index, and other data for as a function of frequency.
Syntax | Description |
---|---|
frequencysweep; | Perform a frequency sweep with the current settings. This function does not return any data. |
Example
To perform a frequency sweep on the first mode and plot the dispersion:
switchtolayout; findmodes; selectmode(1); setanalysis("track selected mode",1); setanalysis("detailed dispersion calculation",1); frequencysweep; D=getdata("frequencysweep","D"); f=getdata("frequencysweep","f_D"); plot(c/f*1e6,D*1e6,"Wavelength (um)", "Dispersion (ps/nm/km)");
coupling - Script command
Returns the complex coupling coefficient between two modes. The power coupling can be calculated with the overlap function, or by the following formula.
Power_Coupling = | coupling | 2
Reference: Allan W. Snyder and John D. Love, Optical Waveguide Theory. Chapman & Hall, London, England, 1983.
See the overlap function for more details about overlap and coupling calculations.
Note: coupling command is deprecated, consider using expand |
Syntax | Description |
---|---|
out = coupling(mode2, mode1); |
|
out = coupling(mode2, mode1, x, y); | Mode alignment can be adjusted before coupling is calculated.
|
Examples
This example shows how to use the overlap command to calculate the overlap and power coupling between two modes.
copydcard("mode1","test_mode1"); copydcard("mode2","test_mode2"); out = overlap("test_mode1","test_mode2"); ?out(1); # overlap ?out(2); # power coupling ?coupling("test_mode1","test_mode2"); # the complex coupling coefficient ?abs(coupling("test_mode1","test_mode2"))^2; # same as out(2), the power coupling
overlap - Script command
Returns the overlap and power coupling between two modes calculated by the FDE solver or recorded by frequency monitors from a varFDTD simulation. In FDTD, it calculates the overlap and power coupling between the field profiles (modes) recorded by two frequency monitors.
Overlap measures the fraction of electromagnetic fields that overlap between the two field profiles (modes). This is also the fraction of power from mode2 that can propagate in mode1 (for both forward and backward propagating fields). The absolute value of the entire formula is to ensure it is positive.
overlap =∣∣ ∣∣Re[(∫E1×H∗2⋅dS)(∫E2×H∗1⋅dS)∫E1×H∗1⋅dS]1Re(∫E2×H∗2⋅dS)∣∣ ∣∣
Syntax | Description |
---|---|
out = overlap(mode2, mode1); |
|
out = overlap(mode2, mode1, x, y,z); | Mode alignment can be adjusted before overlap is calculated.
The offset is applied to the second mode listed. |
Examples
This example shows how to use the overlap command to calculate the overlap and power coupling between two modes.
copydcard("mode1","test_mode1");copydcard("mode2","test_mode2"); out = overlap("test_mode1","test_mode2"); ?out(1); # overlap ?out(2); # power coupling
bestoverlap - Script command
Finds the mode with highest (best) overlap between the specified D-CARD and the currently calculated modes in the mode list. Returns the name of the mode with the best overlap. This function is used for tracking the desired mode during parameter sweeps using the FDE solver.
See the overlap function for more details about overlap and coupling calculations.
Syntax | Description |
---|---|
out = bestoverlap("test_mode"); | Calculates the best overlap.
|
Examples
This example will calculate which of the current modes have the best overlap with the D-CARD named "test_mode". The effective index of the best mode is then returned.
mode_name = bestoverlap("test_mode"); neff = getdata(mode_name,"neff");
bestoverlap2 - Script command
This function is similar to bestoverlap but it uses expand2 to get the necessary parameters, which can be useful when an evanescent mode is involved.
Syntax | Description |
---|---|
out = bestoverlap2("test_mode"); | Calculates the best overlap.
|
out = bestoverlap2("test_mode", x,y,z); | Calculates the best overlap.
Mode alignment can be adjusted before best overlap is calculated.
The offset is applied to the test_mode. |
Examples
This example will calculate which of the current modes have the best overlap with the D-CARD named "test_mode". The effective index of the best mode is then returned.
mode_name = bestoverlap2("test_mode"); neff = getdata(mode_name,"neff");
propagate - Script command
Calculates the resulting mode profile of an arbitrary mode after it has propagated through a waveguide for some distance. This is done by decomposing the mode into modes supported by the waveguide. Each supported mode is then propagated through the waveguide. The resulting modes are then added coherently to give the final mode profile. The modes used in this calculation are obtained from one or more FDE simulations.
See the overlap function for more details about overlap and coupling calculations.
Syntax | Description |
---|---|
out = propagate(mode, d, n1, n2); |
|
out = propagate(mode, d, n1, n2, x, y); | Mode alignment can be adjusted before propagate is calculated.
|
Examples
This example is adapted from the polarization_rotator.lsf from polarization rotation. You can download waveguideA.lms and waveguideB.lms from the polarization rotation page.
The following script takes the first mode on the mode list from waveguide A and propagates this mode in waveguide B a distance of L_rotation. It generates a plot of |E|^2 for the mode from waveguide A and the mode after propagation in waveguide B.
# find the indices of the top 2 modes of waveguide B n1 = getdata("mode1","neff"); n2 = getdata("mode2","neff"); lambda_0 = c/getdata("mode1","f"); # estimate the propagation length required to rotate polarization L_rotation = lambda_0/2/real(n1-n2); # propagate by L_rotation mode_L = propagate("TE_A",L_rotation,n1,n2); ?getdata(mode_L,"accounted_transmission"); result: 0.845998 ?getdata(mode_L); # to see a list of the available data f x y z num_modes Ex Ey Ez Hx Hy Hz accounted_transmission accounted_reflection
optimizeposition - Script command
The optimizeposition command calculates the x shift, y shift, and z shift resulting in maximum overlap between the specified mode and d-card when using the FDE solver.
The x shift, y shift, and z shift correspond to the offset in the d-card profile in x, y, and z.
This function also populates the overlap and power coupling as well as the x shift, y shift, and z shift positions in the Overlap analysis tab of the Eigensolver Analysis window, similarly to when you click on the "Optimize position" button in the GUI.
See the overlap function for more details about overlap and coupling calculations.
Syntax | Description |
---|---|
out = optimizeposition(mode number, d-card number); |
Note that the "shift d-card center" option must be selected in order to use this function. |
Examples
This example shows how to use the optimizeposition command to calculate the x shift, y shift, and z shift between a specified mode and d-card resulting in maximum overlap, print out the shift values and the optimal overlap and power coupling with the applied shift.
setanalysis("shift d-card center",1); shift = optimizeposition(4,1); # find x, y, z shift resulting in optimal overlap between # the 4th mode in the mode list and the 1st mode in the deck ?"x shift:"+num2str(shift(1)); ?"y shift:"+num2str(shift(2)); ?"z shift:"+num2str(shift(3)); out = overlap("mode4","global_mode1",shift(1),shift(2),shift(3)); ?"maximum overlap:"+num2str(out(1)); ?"maximum power coupling:"+num2str(out(2));
FDTD measurements
transmission - Script command
Returns the amount of power transmitted through power monitors and profile monitors, normalized to the source power. A value of 0.3 means that 30% the optical power injected by the source passed through the monitor. Negative values mean the power is flowing in the negative direction.
The frequency domain power transmission is calculated with the following formula.
T(f)=12∫monitorRe(P(f))⋅dS sourcepower(f)
where
T(f)
is the normalized transmission as a function of frequency
P(f)
is the Poynting vector
dS
is the surface normal
The normalization state (cwnorm or nonorm) does not affect the result because of the source power normalization.
Syntax | Description |
---|---|
out = transmission("mname"); | Transmission through monitor mname. It must be obvious from the shape of the monitor which axis is normal to the monitor surface. |
out = transmission("mname", option); | The additional argument, option, can have a value of 1 or 2. If it is 2, the data is unfolded where possible according to the symmetry or anti-symmetric boundaries if it comes from a monitor that intersect such a boundary at x min, y min or z min. The default value of option is 2. |
Example
This example shows how to plot the power transmission through a monitor.
m="x2"; # monitor name f=getdata(m,"f"); T=transmission(m); plot(c/f*1e6,T,"wavelength(um)","transmission");
transmission_avg - Script command
Returns the total spectral average power through a monitor surface, normalized to the total spectral average of the source. See the Units and normalization - Spectral averaging section for more information.
Tavg=12∫real(<PMonitor>total)⋅dSsourcepoweravg
where
Tavg
is the normalized total spectral average transmission
P
is the total spectral average Poynting vector
dS
is the surface normal
The normalization state (cwnorm or nonorm) does not affect the result because of the source power normalization.
Syntax | Description |
---|---|
out = transmission_avg ("monitorname"); | Returns the total spectral average transmission through monitorname. It must be obvious from the shape of the monitor which axis is normal to the monitor surface. |
out = transmission_avg ("monitorname", option); | The additional argument, option, can have a value of 1 or 2. If it is 2, the data is unfolded where possible according to the symmetry or anti-symmetric boundaries if it comes from a monitor that intersect such a boundary at x min, y min or z min. The default value of option is 2. |
Example
Please refer to transmission and Spectral averaging - Usage
transmission_pavg - Script command
Returns the partial spectral average power through a monitor surface, normalized to the partial spectral average of the source. See the Units and normalization - Spectral averaging section for more information.
Tpavg(f)=12∫real(partial).dSsourcepowerpavg(f)
where
Tpavg is the normalized partial spectral average transmission
is the partial spectral average Poynting vector
dS is the surface normal
The normalization state (cwnorm or nonorm) does not affect the result because of the source power normalization.
Syntax | Description |
---|---|
out = transmission_pavg ("monitorname"); | Returns the partial spectral average transmission through monitorname. It must be obvious from the shape of the monitor which axis is normal to the monitor surface. |
out = transmission_pavg ("monitorname", option); | The additional argument, option, can have a value of 1 or 2. If it is 2, the data is unfolded where possible according to the symmetry or anti-symmetric boundaries if it comes from a monitor that intersect such a boundary at x min, y min or z min. The default value of option is 2. |
Example
Please refer to transmission and Spectral averaging - Usage
getsourceangle - Script command
Returns the source angle theta as a function of frequency. Broadband sources inject fields that have a constant in-plane wavevector at all frequencies. This implies injection angle must change as a function of frequency. The in-plane wavevector is chosen such that the incidence angle at the center frequency of the simulation (fsim
) will match the source angle theta (θsim
) specified in the source properties. Higher frequencies will be injected at smaller angles, while lower frequencies will be injected at larger angles. This 'theta vs wavelength' plot in the beam source edit window shows the same function.
θ(f)=arcsin[sin(θsim)fsimf]
Syntax | Description |
---|---|
theta = getsourceangle( "sourcename", f); | Returns the source angle theta (degrees) as a function of frequency. f is a vector of frequencies (Hz). |
Example
This example shows how to get the source injection angle as a function of frequency. The source frequency range is 300-600THz, and the nominal source angle theta is 10 degrees.
f_max=600e12; f_min=300e12; f=linspace(f_min,f_max,5); ?theta_f=getsourceangle("source1",f); result: 15.0981 12.0273 10 8.55978 7.48324
FDTD normalization
nonorm - Script command
Does not normalize the data to the source power. The actual field intensities will be used in all calculations. This function controls the checkbox located in Settings - Normalization state. Note, this command works in both the Layout and Analysis mode.
Syntax | Description |
---|---|
nonorm; | Use no normalization. This function does not return any data. |
Example
This example shows how to switch to the nonorm state.
nonorm;
cwnorm - Script command
Uses CW normalization. All simulation data will be normalized to the injected source power. Most users prefer to do their analysis in the CW normalization state, since it removes any effect caused by the finite pulse length of the source. It also converts the units of all electromagnetic fields to be the same as in the time domain. Note, this command works in both the Layout and Analysis mode.
This function controls the checkbox located in Settings - Normalization state.
Syntax | Description |
---|---|
cwnorm; | Use CW normalization. Uses the first active source in the Object tree; This function does not return any data. |
cwnorm(norm_option) | norm_option: 1 (first source), 2 (average of all sources) |
Example
This example shows how to switch to the cwnorm state.
cwnorm; # normalized to the first active source cwnorm(1); # normalized to the first active source cwnorm(2); # normalized to the average of all the sources
sourcenorm - Script command
Returns the source normalization spectrum used to normalize data in the cwnorm state for standard fourier transform quantities. See the Units and normalization page for more information.
Syntax | Description |
---|---|
out = sourcenorm(f); | Returns the source normalization spectrum used to normalize data in the cwnorm state at the vector of frequency points f. (f is the frequency in Hz) If the normalization state is set to 'CWNorm (average)': s(ω)=sourcenorm(ω)=1N∑sources∫exp(iωt)sj(t)dt |
- sj(t): the time signal of the jth active source in the object tree
- N is the number of active sources then
If the normalization state is set to 'CWNorm (first)':
s(ω)=∫exp(iωt)s1(t)dt
out = sourcenorm(f, name); | When you enter an additional argument for the source name, it uses the specific source of your choice, rather than the first source or the average of all the sources in the object tree. |
Example
This example shows how to reproduce the source spectrum figures shown in the Frequency/Wavelength tab of the source property window.
lambda1 = 0.4e-6; # start wavelength lambda2 = 0.7e-6; # end wavelength f=linspace(c/lambda2,c/lambda1,1000); # get the source spectrum spectrum=sourcenorm(f); spectrum=abs(spectrum)^2; spectrum=spectrum/max(spectrum); # get the source time domain signal time = getdata("source","time"); time_signal = getdata("source","time_signal"); plot(c/f*1e6,spectrum, "wavelength (um)","spectrum vs wavelength"); plot(f/1e12,spectrum, "frequency (THz)","spectrum vs frequency"); plot(time*1e15,time_signal,"time (fs)","amplitude","Source time signal");
sourcenorm2_avg - Script command
Returns the source normalization spectrum used to normalize data in the cwnorm state for the total spectral averaged quantities. See the Units and normalization - Spectral averaging section for more information.
The script function sourcenorm is defined as
s(ω)=sourcenorm(ω)=1N∑sourcss∫exp(iωt)sj(t)dt
If sourcenorm2_avg is called without any arguments, it returns
sourcenorm2−avg=∫+∞−∞∣∣s(ω′)∣∣2dω′
Syntax | Description |
---|---|
out = sourcenorm2_avg; | This function returns the source normalization for total spectral averaged quantities. |
out = sourcenorm2_avg( "sourcename"); | This function makes it possible to perform the normalization using the spectrum of one source, rather than the sum of all the sources. |
Example
Please refer to sourcenorm and Spectral averaging - Usage
sourcenorm2_pavg - Script command
Returns the source normalization spectrum used to normalize data in the cwnorm state for the partial spectral averaged quantities. See the Units and normalization - Spectral averaging section for more information.
If the source time signal of the jth source in the simulation is sj(t), and N is the number of active sources then
s(ω)=sourcenorm(ω)=1N∑sourcss∫exp(iωt)sj(t)dt
Partial spectral averaging uses a Lorentzian weighting of the following form. Delta is the FWHM of |h|2.
|h2(ω,ω′)|2=δ2π1(ω−ω′)2+(δ/2)2∫|h(ω,ω′)|2dω′=1
If this function is called without any arguments, it returns
sourcenorm2pavg=∫+∞−∞∣∣h(ω,ω′)∣∣2∣∣s(ω′)∣∣2dω′
Syntax | Description |
---|---|
out = sourcenorm2_pavg( f, delta); | This function returns the source normalization for partial spectral averaged quantities. |
out = sourcenorm2_pavg( f, delta, "sourcename"); | This function makes it possible to perform the normalization using the spectrum of one source, rather than the sum of all the sources. |
Example
Please refer to sourcenorm and Spectral averaging - Usage
dipolepower - Script command
Returns the power injected into the simulation region by a dipole source. In 3D simulations, the units will be in Watts if cwnorm is used, and Watts/Hertz2 if nonorm is used.
The dipolepower script command returns the power that was injected into the simulation region, and is equivalent to measuring the power transmitted out of a small box surrounding the dipole. In contrast, sourcepower will return the power that the dipole would radiate in a homogeneous material. dipolepower and sourcepower are equivalent for dipoles in a homogeneous medium.
Advanced notes:
- If the dipole is located within a dispersive medium (with a non-zero imaginary part of the refractive index), then the results of this function are not reliable. In such situations, using a box of monitors around the dipole is recommended.
- Numerical errors in this calculation may become noticeable when very small simulation mesh sizes are used. If the mesh step is the order of, or smaller than, λ/1000, verifying the dipolepower results by measuring the radiated power with a small box of monitors surrounding the dipole is recommended.
Please visit the Support Center for more assistance if you are using a dipole in a dispersive medium.
Syntax | Description |
---|---|
out = dipolepower(f); | Returns the amount of power radiated by the dipole source, at frequency points f. (f in Hz) |
out = dipolepower(f, name); | This option allows you to obtain the power radiated by a single dipole, rather than the sum of all dipoles. This option is only needed for simulations with multiple dipoles. |
Examples
See the Dipoles - Radiated Power page and the Fluorescence enhancement application example.
sourcepower - Script command
Returns the power injected into the simulation by the source.
Dipole sources
The sourcepower script function returns the power the dipole source would radiate in a homogeneous medium. This quantity can be calculated analytically (see Dipole source). The actual radiated power is not given by the sourcepower function. The actual radiated power is highly dependant on the surrounding materials since the reflections from the structures will interfere with the fields from the dipole, changing the actual radiated power. To get the actual radiated power, see the dipolepower script function.
Other sources (Gaussian, plane wave, mode, etc)
The sourcepower is determined from the equation below. Note that P(f)Source
is the Poynting vector determined from the E, H fields injected by the source. The integral is evaluated over the injection plane of the source.
source powerno_norm(f)=12∫Re(P(f)Source)⋅dS
source powercw_norm(f)=12∫Re(P(f)Source)⋅dS|sourcenorm|2
As stated above, sourcepower gives the amount of power injected into the simulation. The only exception is if the simulation is set up such that there is radiation that travels through the injection plane of the source in the source injection direction (pink arrow). In such cases, the actual amount of power injected by the source will not be given by sourcepower . In this situation, the incident radiation interferes with the source, changing the amount of injected power (similar to what happens for the dipole source). In most cases, this means your simulation is not set up properly.
Notes: Multiple sources and CW normalization In the case of multiple sources, the sourcepower(f) command will return the sum of all sourcepowers from all sources. Since the value of the sourcenorm depend on the choice of cwnorm option, the calculated sourcepower will also be affected by it. |
Syntax | Description |
---|---|
out = sourcepower(f); | Returns the source power used to normalize transmission calculations at the vector of frequency points f (frequency in Hz). The unit of the source power is Watts if CW norm is used, and Watts/Hertz 2 if no norm is used. |
out = sourcepower(f, option); | The additional argument, option, can have a value of 1 or 2. If it is 2, the data is unfolded where possible according to the symmetry or anti-symmetric boundaries if it comes from a monitor that intersects such a boundary at x min, y min, or z min. The default value of the option is 2. |
out = sourcepower(f, option, name); | This option allows you to obtain the spectrum of one source, rather than the sum of all sources. This option is only needed for simulations with multiple sources. |
Examples
This example shows how to calculate the power injected by a source as a function of frequency.
f=linspace(200e12,300e12,100); sp=sourcepower(f); # power in Watts, assuming CW norm is on.
This example shows how to use the transmission and sourcepower functions to calculate the power injected by a plane wave source.
newproject; save("test"); # simulation region addfdtd; set("x span",1e-6); set("y span",1e-6); set("z span",1e-6); set("x min bc","periodic"); set("y min bc","periodic"); # plane wave source addplane; set("z",-0.3e-6); set("x span",2e-6); set("y span",2e-6); set("center wavelength",500e-9); set("wavelength span",0); # power monitor addpower; set("z",0.3e-6); set("x span",2e-6); set("y span",2e-6); # run simulation run; # get results m="monitor"; f=getdata(m,"f"); # get frequency vector T=transmission(m); # get power transmission (fraction of source power) sp=sourcepower(f); # get power injected by source (Watts) # output results ?"Transmitted power (fraction of source power): " +num2str(T); ?"Transmitted power (Watts): " +num2str(T*sp); ?"Source power (Watts): "+num2str(sp); > Transmitted power (fraction of source power): 0.999986 > Transmitted power (Watts): 1.26203e-015 > Source power (Watts): 1.26204e-015
sourcepower_avg - Script command
Returns the total spectral average power injected into the simulation by the source. See the Units and normalization - Spectral averaging section for more information.
This script function calculates the following quantities, depending on whether the normalization state is cwnorm or nonorm:
sourcepower−avgnonorm=∫+∞0sourcepowernonorm(ω)dω
sourcepower−avgcwnorm(f)=∫+∞0|s(ω)|2sourcepowercwnorm(ω)dω∫+∞0|s(ω)|2dω
where sourcepower is the quantity returned by the sourcepower script function, s(w) is returned by sourcenorm, and ω=2πf. Typically, this function should be used in the cwnorm state. Also see the sourcenorm2_pavg script function.
Syntax | Description |
---|---|
out = sourcepower_avg; | Returns the spectrally averaged source power as defined above. |
out = sourcepower_avg(option); | The additional argument, option, can have a value of 1 or 2. If it is 2, the data is unfolded where possible according to the symmetry or anti-symmetric boundaries if it comes from a monitor that intersect such a boundary at x min, y min or z min. The default value of option is 2. |
out = sourcepower_avg(option, "sourcename"); | This option allows you to obtain the spectrum of one source, rather than the sum of all sources. This option is only needed for simulations with multiple sources. |
Example
Please refer to sourcepower and Spectral averaging - Usage
sourcepower_pavg - Script command
Returns the partial spectral average power injected into the simulation by the source. See the Units and normalization - Spectral averaging section for more information.
Partial spectral averaging uses a Lorentzian weighting of the form
|h(ω,ω′)|2=δ2π1(ω−ω′)2+(δ/2)2∫|h(ω,ω′)|2dω′=1
This script function calculates the following quantities, depending on whether the normalization state is cwnorm or nonorm:
sourcepower−pavgnonorm(f)=∫+∞−∞∣∣h(ω,ω′)∣∣2 sourcepowernonorm(ω)dω
sourcepower−pavgcwnorm(f)=∫+∞0|h(ω,ω′)|2|s(ω)|2 sourcepowercwnorm(ω′)dω′∫+∞0|h(ω,ω′)|2|s(ω)′|2dω′
where sourcepower is the quantity returned by the sourcepower script function, s(w) is returned by sourcenorm, and ω=2πf. Typically, this function should be used in the cwnorm state. Also see the sourcenorm2_pavg script function.
Syntax | Description |
---|---|
out = sourcepower_pavg(f,df); | Returns the spectrally averaged source power as defined above. The quantity f is the frequency and the quantity df is the frequency range around which the averaging is performed, both in Hz. |
out = sourcepower_pavg(f, df,option); | The additional argument, option, can have a value of 1 or 2. If it is 2, the data is unfolded where possible according to the symmetry or anti-symmetric boundaries if it comes from a monitor that intersect such a boundary at x min, y min or z min. The default value of option is 2. |
out = sourcepower_pavg(f,df, option, "sourcename"); | This option allows you to obtain the spectrum of one source, rather than the sum of all sources. This option is only needed for simulations with multiple sources. |
Example
Please refer to sourcepower and Spectral averaging - Usage
sourceintensity - Script command
Returns the source power divided by the area of the source. In 3D simulations, the units will be in Watts/m 2 if CW norm is used, and Watts/m 2 /Hertz 2 if No norm is used. This function is often used when normalizing power measurements from simulations with a TFSF source.
In the case of multiple sources, the sourceintensity(f) command will return the sum of all sourceintensity from all sources.
Syntax | Description |
---|---|
out = sourceintensity(f); | Returns the source intensity at the vector of frequency points f (f is the frequency in Hz). |
out = sourceintensity(f, option); | The additional argument, option, can have a value of 1 or 2. If it is 2, the data is unfolded where possible according to the symmetry or anti-symmetric boundaries if it comes from a monitor that intersect such a boundary at x min, y min or z min. The default value of option is 2. |
out = sourceintensity(f, option, name); | This function makes it possible to perform the normalization using the spectrum of one source, rather than the sum of all the sources. |
Examples
This example shows how to use the transmission , sourcepower and sourceintensity functions to measure the power injected by a TFSF source. Notice that the monitor is 1/4 the area of the source.
newproject; # create new simulation save("test"); addfdtd; # add simulation region set("mesh accuracy",4); set("x span",2.5e-6); set("y span",2.5e-6); set("z span",2.5e-6); addtfsf; # add source set("x span",2e-6); set("y span",2e-6); set("z span",2e-6); set("wavelength span",0); addpower; # add monitor (1/4 area of source) set("x span",1e-6); set("y span",1e-6); run; # run simulation m="monitor"; f=getdata(m,"f"); # get frequency vector T=transmission(m); # get power transmission (fraction of source power) sp=sourcepower(f); # get power injected by source (Watts) I=sourceintensity(f); # get source intensity (Watts/m^2) area = getdata("source","area"); # get source area (it's not exactly 2um^2 due to finite sized mesh) # output results ?"Transmitted power (fraction of source power): " +num2str(T); ?"Transmitted power (Watts): " +num2str(T*sp); ?"Source power (Watts): "+num2str(sp); ?"Source intensity (Watts/um^2): " + num2str(I*1e-12); ?"Ensure Intensity*Area=Power: " + num2str(I*area/sp); > Transmitted power (fraction of source power): 0.235078 > Transmitted power (Watts): 1.24415e-015 > Source power (Watts): 5.2925e-015 > Source intensity (Watts/um^2): 1.30714e-015 > Ensure Intensity*Area=Power: 1
sourceintensity_avg - Script command
Returns the total spectral average intensity injected into the simulation by the source. The average intensity is equal to the average power divided by the source area. See the sourcepower_pavg command and the Units and normalization - Spectral averaging section for more information.
Syntax | Description |
---|---|
out = sourceintensity_avg; | Returns the spectrally averaged source intensity as defined above. |
out = sourceintensity_avg(option); | The additional argument, option, can have a value of 1 or 2. If it is 2, the data is unfolded where possible according to the symmetry or anti-symmetric boundaries if it comes from a monitor that intersect such a boundary at x min, y min or z min. The default value of option is 2. |
out = sourceintensity_avg(option, "sourcename"); | This function makes it possible to perform the normalization using the spectrum of one source, rather than the sum of all the sources. |
Example
Please refer to sourceintensity and Spectral averaging - Usage
sourceintensity_pavg - Script command
Returns the partial spectral average intensity injected into the simulation by the source. The partial average intensity is equal to the partial average power divided by the source area. See the sourcepower_pavg command and the Units and normalization - Spectral averaging section for more information.
Syntax | Description |
---|---|
out = sourceintensity_pavg (f,df); | Returns the spectrally averaged source power as defined above. The quantity f is the frequency and the quantity df is the frequency range around which the averaging is performed, both in Hz. |
out = sourceintensity_pavg(f,df, option); | The additional argument, option, can have a value of 1 or 2. If it is 2, the data is unfolded where possible according to the symmetry or anti-symmetric boundaries if it comes from a monitor that intersect such a boundary at x min, y min or z min. The default value of option is 2. |
out = sourceintensity_pavg(f,df, option, "sourcename"); | This function makes it possible to perform the normalization using the spectrum of one source, rather than the sum of all the sources. |
Example
Please refer to sourceintensity and Spectral averaging - Usage
FEEM & DGTD measurements
modeexpansion
Returns the mode expansion coefficients with respect to two FEEM solver results, or a FEEM solver result and a DGTD 2D frequency monitor result. The script command expects two structs according to the modeoverlap input.
Syntax | Description |
---|---|
out = modeexpansion(struct1, struct2); | |
out = modeexpansion(struct1, struct2, conjugated); |
Example
Using the two structs given in modeoverlap one can calculate the mode expansion coefficients as follows:
?modeexpansion(feem_struct, dgtd_struct); ?modeexpansion(feem_struct, dgtd_struct, false);
Note that bent waveguide FEEM calculations are not supported by this feature.
modeoverlap
Returns the overlap between the respective mode profiles (modes) of two FEEM calculations, if given two FEEM solver result structs. The command result is a matrix where each row corresponds to a mode in the struct with the highest polynomial order or highest number of elements, and each column corresponds to a mode in the other struct. If the polynomial order and number of elements are identical in both FEEM calculation, each row corresponds to a mode in the first struct, whereas each column corresponds to the second struct. Note that the FEEM simulation regions must have the same orientation.
Returns the overlap between all modes found in a FEEM calculation and the Fourier-transformed (frequency-domain) field of a DGTD calculation for all frequencies, if given two structs containing a FEEM solver result and a DGTD frequency monitor result, respectively. The command result is a matrix where each row corresponds to a mode in the FEEM struct and each column corresponds to a frequency in the DGTD struct, independent of the order of the input. Note that the FEEM simulation region and the DGTD frequency monitor must have the same orientation apart from the sign.
To construct the input structs, the FEEM solver results of rawFeemFields, rawFeemMesh, and modeproperties are required for a FEEM/FEEM mode overlap. To calculate a FEEM/DGTD mode overlap the frequency monitor results rawDgtdFields and rawDgtdMesh are required in addition. Furthermore, the FEEM simulation region orientation needs to be specified as a vector. The same applies to the DGTD monitor orientation, if in use.
Syntax | Description |
---|---|
out = modeoverlap(struct1, struct2); | |
out = modeoverlap(struct1, struct2, conjugated); |
|
Example
The following example shows how to construct the input structs:
feem_struct = { "E": rawFeemFields.E, "H": rawFeemFields.H, "order": rawFeemMesh.order, "connectivity": rawFeemMesh.connectivity, "vertices": rawFeemMesh.vertices, "normal vector": [0,0,1] "DoFt": rawFeemFields.DoFt, “DoFz": rawFeemFields.DoFz, “kz": modeproperties.DoFz, }; dgtd_struct = { "E": rawDgtdFields.E, "H": rawDgtdFields.H, "order": rawDgtdMesh.order, "connectivity": rawDgtdMesh.connectivity, "vertices": rawDgtdMesh.vertices, "normalvector": [0,0,1] };
Using the two structs from above, one can calculate the overlap between the FEEM mode profiles and the frequency-domain DGTD fields:
?modeoverlap(feem_struct, dgtd_struct); ?modeoverlap(feem_struct, dgtd_struct, false);
DGTD Raw Fields/Mesh Data
For a given DGTD calculation the 2D frequency monitor now records the raw Fourier-transformed i.e., frequency domain fields rawDgtdFields as well as the raw mesh data rawDgtdMesh.
rawDgtdFields | Description | Dimensions | Units |
---|---|---|---|
E | Electric field | 1. number of components 2. number of frequencies 3. number of elements 4. number of DG nodes | Internal electric field unit |
H | Magnetic field | 1. number of components 2. number of frequencies 3. number of elements 4. number of DG nodes | Internal magnetic field unit |
rawDgtdMesh | Description | Dimensions | Units |
---|---|---|---|
vertices | Mesh vertices of the 2D elements lying on the 2D frequency monitor | 1. number of vertices on the 2D mesh 2. Simulation domain dimension | Internal length unit |
connectivity | Map connecting each 2D element to its respective vertices, which are marked by their row number in the rawDgtdMesh.vertices data set | 1. number of 2D elements 2. number of vertices per 2D DG element i.e. 3 | - |
FEEM Raw Fields/Mesh Data
For a given FEEM calculation raw i.e., unprocessed mode data rawFeemFields as well as the raw mesh data rawDgtdMesh is now recorded
rawFeemFields | Description | Dimensions | Units |
---|---|---|---|
E | Electric field | 1. number of components 2. number of modes 3. number of elements 4. number of barycentric FEEM points | Internal electric field unit |
H | Magnetic field | 1. number of components 2. number of modes 3. number of elements 4. number of barycentric FEEM points | Internal magnetic field unit |
rawFeemMesh | Description | Dimensions | Units |
---|---|---|---|
vertices | Mesh vertices of the 2D elements lying on the 2D frequency monitor | 1. number of vertices on the 2D mesh 2. Simulation domain dimension i.e., 2 | Internal length unit |
connectivity | Map connecting each 2D element to its respective vertices, which are marked by their row number in the rawDgtdMesh.vertices data set | 1. number of 2D elements 2. number of vertices per 2D FEEM element i.e., 3 | - |