Hi I am trying to extract the s parameter data from Lumerical Mode and FDTD and import them into the Interconnect Module. Could someone please explain how to do so? I am not too sure whether it can be done through writing a script or there is a simpler way to do so. If it needs to be done through writing a script, can someone help how to do so?
Hi @hani_nejadriahi,
Please have a look at this post where a related application example link is provided. Indeed in general some short scripts are used to generate the sparameter files. Let me know if you have any further problems
Hi again,
Thanks for your response, but I always have problems grasping that example as it opens a script file in Mode and not FDTD when I run it never works either. Can you help me regarding how to use the code for FDTD?
Also I asked earlier that I am trying to extract information from the Device module. Is that possible? If not, am I supposed to send everything to the Mode Module in order to be able to extract information?
Please help
Thanks, Hani
Hi @hani_nejadriahi,
The method to extract sparameter from FDTD Solutions is more or less the same as from MODE Solutions. There is a sample script in the example I linked in the previous reply, which extracts sparameters to a text file from a FDTD simulation. In the example file grating_coupler_2D.fsp (500.7 KB), the result âSâ matrix is defined in the âmodelâ analysis tab, using the following script commands:
T = getresult("waveguide","expansion for T");
?T;
Tfund = T.getattribute("T_backward");
lambda = T.lambda;
?T_avg = integrate(Tfund,1,lambda)/integrate(matrix(length(lambda))+1,1,lambda);
if(!%fiber analysis%) {
break;
}
if(havedata("fiber::top")) { # fiber turned on
fiber = getresult("fiber::fiber modes","expansion for top");
}
S = matrixdataset;
S.addparameter("lambda",T.lambda,"f",T.f);
if(output) {
S22 = T.b/T.a;
S12 = fiber.a*sqrt(fiber.N)/(T.a*sqrt(T.N));
S.addattribute("S22",S22);
S.addattribute("S12",S12);
} else {
S11 = fiber.a/fiber.b;
S21 = (T.b*sqrt(T.N))/(fiber.b*sqrt(fiber.N));
S.addattribute("S11",S11);
S.addattribute("S21",S21);
}
Then after run the simulation, the result âSâ can be read out by using the following commands:
S = getresult("::model","S");
S22 = S.S22;
S12 = S.S12;
You can also extract the admittance and impedance sparameter/matrix from DEVICE, but this has to be done by using script. After the simulation runs, you can get the current and voltage from the simulation result and then calculate for the admittance and impedance. For a small signal analysis, you then can get the transfer function of the admittance and impedance. The following script can be used to convert the admittance transfer function to smatrix:
S11 = ((1Z0*Y11)*(1+Z0*Y22) + Z0^2*Y12*Y21) / D;
S12 = 2*Z0*Y12 / D;
S21 = 2*Z0*Y21 / D;
S22 = ((1+Z0*Y11)*(1+Z0*Y22)  Z0^2*Y12*Y21) / D;
where Y is the transfer function and S is the smatrix.
I hope this could help, let me know if you have any difficulties reading these
an you please explain the code in general to me?
2) Why do you have two sections: 1) fiber analysis 2) output (I assume this is solely for the purpose of extracting the s parameters?
3) I cannot seem to be able interpret the s parameter graphs that I get? Their values seem to be way larger than 1 which it doesnât make sense to me.
 Note that I get two different s parameter graphs depending on what I set as the value for the fiber and output variables:
When output and fiber analysis are both 1 I get the following graph:
âSparameters_GRATINGCOUPLER.jpgâ
And when fiber analysis = 1 and output = 0 I get:
âSparameterSecondGraph.jpgâ

Could you please explain the above graphs to me?

You also use some variables that are nowhere defined in your design, i.e. T_backward or T.f? Could you explain these for me please?
T = getresult(âwaveguideâ,âexpansion for Tâ);
?T;
Tfund = T.getattribute(âT_backwardâ);
lambda = T.lambda;
?T_avg = integrate(Tfund,1,lambda)/integrate(matrix(length(lambda))+1,1,lambda);
if(!%fiber analysis%) {
break;
}
if(havedata(âfiber::topâ)) { # fiber turned on
fiber = getresult(âfiber::fiber modesâ,âexpansion for topâ);
}
S = matrixdataset;
S.addparameter(âlambdaâ,T.lambda,âfâ,T.f);
if(output) {
S22 = T.b/T.a;
S12 = fiber.asqrt(fiber.N)/(T.asqrt(T.N));
S.addattribute(âS22â,S22);
S.addattribute(âS12â,S12);
} else {
S11 = fiber.a/fiber.b;
S21 = (T.bsqrt(T.N))/(fiber.bsqrt(fiber.N));
S.addattribute(âS11â,S11);
S.addattribute(âS21â,S21);
}
 Where am I supposed to be using the following? After I ran the code above I did put this in the script section and no results:
S = getresult("::model",âSâ);
S22 = S.S22;
S12 = S.S12;
Hi @hani_nejadriahi,
The code I attached is not universally usable, it is only for the corresponding attached example file. You have to tweak the script a bit to suit your own design. For the âT.fâ part, âTâ is a dataset and âfâ is a parameter inside the dataset, you can access the parameters and attributes inside the dataset by using the dot â.â option.
I hope this could help. Please attach your file so that I can help you to draft the script.
Attached please find for example one design that Iâm trying to find its s parameters. Can you help me get started?
Also you didnât answer me about the graphs I attached in my above inquiry. Why are the values not less than 1 and somewhere around 500 or so?
Let me know please
Thanks, Haninew snake ring_before Run.fsp (428.2 KB)
Hi @hani_nejadriahi,
I modified your file new snake ring_modified.fsp (332.3 KB) a bit, please check it out.
I added a new result âSâ in the âanalysisâ tab and after run the analysis, a text file named âspara.txtâ will be generated to the current working directory. Please note that, only for the purpose of running faster, I changed the âmesh accuracyâ to 1, which gives very rough results. Please change this setting according to your own design requirement.
The following figure plots S11 & S21, for 30 frequency points. The transmission on the through port (S21) seems to be really small (nearly all 0), and that matches the result measured by the Mode Expansion monitor and Field and Power monitor.
I donât know how you calculate for the Sparameters to get the transmission as 500, please attach the script and I will have a look at it.
I hope this could help Let me know if you have any difficulties reading this.