The URI of TUHH Docker Registry changed from "docker.rz.tu-harburg.de:5000" to "docker.rz.tu-harburg.de". Please update your gitlab-ci.yml files if you use images from this registry.

Commit 9744aaec authored by CharlieEchoMike's avatar CharlieEchoMike Committed by Cem Gülsan

Added new METRIC apps for single, double and tripple strip waveguides.

All apps take the widths of the respective strips and the simulation resolution as command line inputs.
Parameters as refractive indices, vaccum wavelength or output parameters must be set in the respective app file.

These apps were originally written for the maximizing delta beta project, but are easily configurable.
All apps can be operated by MATLAB wrapper functions.
parent 61b08b15
/*
* METRIC-Application:
* A three layer waveguide: mode analysis, mode object handling
*
* Modified and commented by Cem Gülsan
* 2018-12-18
*/
/* Includes and definitions -------------------------------------------------------------------- */
/* --------------------------------------------------------------------------------------------- */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include"metric.h"
#include<cstring>
#include<algorithm>
#include <iostream>
//Settings
#define n_air 1.00 //Refractive index of air
#define n_sil 3.50 //Refractive index of silicon
#define Wavel 1.55 //Vacuum wavelength (in microns)
//#define plotRes 100000 //Plot resolution
#define extraLeft 2 //Extra interval left of WG boarders (in microns)
#define extraRight 2 //Extra interval right of WG boarders (in microns)
#define maxMode 2 //Maximum mode to be plotted (with 0 being the fundamental mode)
#define solveLog false //Output log from METRIC solver
#define outputLog false //Output log from METRIC output generation
#define otherOut false //Output various other outputs
#define outStruct false //Flag for MATLAB structure output (for verification)
#define outMatlab false //Flag for MATLAB output
#define outASCII true //Flag for ASCII output
/* Auxiliary functions-------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------------------------- */
Waveguide wgdef(double sil1_width, double gap_width, double sil2_width) {
/* Defines the waveguide which is to be analyzed. Must adhere to syntax specified by METRIC.
* see https://metric.computational-photonics.eu/structure.html#WAVEG
* Waveguide objects represent a 1-D piecewise constant refractive index profile.
* Dimensions in micro meters!
*/
//Define a waveguide with x inner layers
Waveguide g(3);
//Positions of the dielectric interfaces
g.hx(0) = 0.0; //Interface between layer 0 and 1 (Start silicon 1)
g.hx(1) = sil1_width; //Interface between layer 1 and 2 (End silicon 1)
g.hx(2) = sil1_width + gap_width; //Interface between layer 2 and 3 (Start silicon 2)
g.hx(3) = sil1_width + gap_width + sil2_width; //Interface between layer 3 and 4 (End silicon 2)
//Refractive index values
g.n(0) = n_air;
g.n(1) = n_sil;
g.n(2) = n_air;
g.n(3) = n_sil;
g.n(4) = n_air;
//The vacuum wavelength
g.lambda = Wavel;
return g;
}
/* Main calculation and output------------------------------------------------------------------ */
/* --------------------------------------------------------------------------------------------- */
int main(int argc, char *argv[]) {
/* After an initial setup of a ModeArray and a Waveguide, a modeAnalysis for guided TE and TM
* modes is conducted and the results are stored as MATLAB plots and in ASCII format.
* See https://metric.computational-photonics.eu/visual.html#PROF for more information about plots
*/
//Initial input handling--------------------------------------------------------------------
//Helper option - displays usage instructions for function
if (strcmp(argv[1], "help") == 0) {
printf("\n\tUsage: (Wavelength and slab_height are in nano meters.)\n\n"
"\tsilicon1 width, gap width, silicon2 width, resolution\n\n");
return 0;
}
//Check for incomplete input
if (argc != 5) {
printf("\n\tNot the right amount of arguments.\n\n");
return 1;
}
//Assign input params to variables
double sil1_width = atof(argv[1]);
double gap_width = atof(argv[2]);
double sil2_width = atof(argv[3]);
double plotRes = atof(argv[4]);
//Print input params to console
if (otherOut) {
fprintf(stdout, "------------------------------------\n");
fprintf(stdout, "\tAir refractive index:\t\t%1.2f\n", n_air);
fprintf(stdout, "\tSilicon refractive index:\t%1.2f\n", n_sil);
fprintf(stdout, "\tSimulation rresolution:\t%1.0f\n\n", plotRes);
fprintf(stdout, "\tDimensions in nano meters\n");
fprintf(stdout, "\t--Air--|--Sil--|--Air--|--Sil--|--Air--\n");
fprintf(stdout, "\t <-- | %4.0f | %4.0f | %4.0f | -->\n\n", sil1_width, gap_width, sil2_width);
}
//Set up------------------------------------------------------------------------------------
ModeArray maTE; //ModeaArray: Object to store results of modeanalysis for TE modes
ModeArray maTM; //ModeaArray: Object to store results of modeanalysis for TM modes
Waveguide wg = wgdef(sil1_width/1000, gap_width/1000, sil2_width/1000); //Define waveguide using the waveguide definition function above.
Interval disp(wg.hx(0) - extraLeft, wg.hx(wg.nx) + extraRight); //Define display interval for output
//Calculate guided modes------------------------------------------------------------------
modeanalysis(wg, TE, maTE, !solveLog); //Find all guided TE modes and store in ModeArray
modeanalysis(wg, TM, maTM, !solveLog); //Find all guided TM modes and store in ModeArray
//Plots mode profiles (Matlab figures) for every entry in the array
if(outputLog) {
fprintf(stdout, "\tFile outputs:\n");
}
if(outStruct) {
wg.plot(disp, '0', '0'); //Plot refractive index profile
}
if(outMatlab) {
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Plots mode profiles for every entry in the array
char t = 'L'; if(i >= 1) t = 'V'; //Char t signals the plot function which info to include into the plot
maTM(i).plot(EX, ORG, disp, plotRes, dig10(i), dig1(i), t); //Real part of E_x compoment (TM mode)
}
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Plots mode profiles for every entry in the array
char t = 'L'; if(i >= 1) t = 'V'; //Char t signals the plot function which info to include into the plot
maTM(i).plot(EZ, IMP, disp, plotRes, dig10(i), dig1(i), t); //Imagingary part of E_z component (TM mode)
}
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Cycle through entries in the array
char t = 'L'; if(i >= 1) t = 'V'; //Char t signals the plot function which info to include into the plot
maTM(i).plot(HY, ORG, disp, plotRes, dig10(i), dig1(i), t); //Real part of H_y component (TM mode)
}
}
//Stores results in xyz files (ASCII)
if(outASCII) {
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Stores mode profiles in ASCII format
maTM(i).writeprofileQ(EX, ORG, disp, plotRes, dig10(i), dig1(i), !outputLog); //Real part of E_x compoment (TM mode)
//fprintf(stderr, "beta: %f\n", maTM(i).beta);
}
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Stores mode profiles in ASCII format
maTM(i).writeprofileQ(EZ, IMP, disp, plotRes, dig10(i), dig1(i), !outputLog); //Imagingary part of E_z component (TM mode)
}
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Stores mode profiles in ASCII format
maTM(i).writeprofileQ(HY, ORG, disp, plotRes, dig10(i), dig1(i), !outputLog); //Real part of H_y component (TM mode)
}
}
if(otherOut) {
fprintf(stderr, "------------------------------------\n");
}
return 0;
}
// // access properties of individual modes:
// Mode m;
// m = ma(0);
// // the propagation constant, effective index
// double beta = m.beta;
// double neff = m.neff;
// // the field profile, real version: component EY at x = 0.0
// double f_ey = m.field(EY, 0.0);
// // directional field profile, complex:
// // component HZ of the forward propagating mode at x = 1.0
// Complex f_hz = m.cfield(HZ, FORW, 1.0);
/*
* METRIC-Application:
* A one layer waveguide: mode analysis, mode object handling
*
* Modified and commented by Cem Gülsan
* 2019-01-21
*/
/* Includes and definitions -------------------------------------------------------------------- */
/* --------------------------------------------------------------------------------------------- */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include"metric.h"
#include<cstring>
#include<algorithm>
#include <iostream>
//Settings
#define n_air 1.00 //Refractive index of air
#define n_sil 3.50 //Refractive index of silicon
#define n_silica 1.43 //Refractive index of silica
#define n_subs 1.95
#define n_film 2.302
#define n_cover 1.00
//#define Wavel 1.55 //Vacuum wavelength (in microns) - standard
#define Wavel 1.3 //Vacuum wavelength (in microns) - for DEOTSCH comparison
//#define plotRes 1000000 //Plot resolution
#define extraLeft 1 //Extra interval left of WG boarders (in microns)
#define extraRight 4 //Extra interval right of WG boarders (in microns)
#define maxMode 0 //Maximum mode to be plotted (with 0 being the fundamental mode)
#define solveLog false //Output log from METRIC solver
#define outputLog false //Output log from METRIC output generation
#define otherOut false //Output various other outputs
#define outStruct false //Flag for MATLAB structure output (for verification)
#define outMatlab false //Flag for MATLAB output
#define outASCII true //Flag for ASCII output
/* Auxiliary functions-------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------------------------- */
Waveguide wgdef(double sil1_width) {
/* Defines the waveguide which is to be analyzed. Must adhere to syntax specified by METRIC.
* see https://metric.computational-photonics.eu/structure.html#WAVEG
* Waveguide objects represent a 1-D piecewise constant refractive index profile.
* Dimensions in micro meters!
*/
//Define a waveguide with x inner layers
Waveguide g(1);
//Positions of the dielectric interfaces
g.hx(0) = 0.0; //Interface between layer 0 and 1 (Start silicon 1)
g.hx(1) = sil1_width; //Interface between layer 1 and 2 (End silicon 1)
//Refractive index values
g.n(0) = n_air;
g.n(1) = n_sil;
g.n(2) = n_air;
//The vacuum wavelength
g.lambda = Wavel;
return g;
}
/* Main calculation and output------------------------------------------------------------------ */
/* --------------------------------------------------------------------------------------------- */
int main(int argc, char *argv[]) {
/* After an initial setup of a ModeArray and a Waveguide, a modeAnalysis for guided TE and TM
* modes is conducted and the results are stored as MATLAB plots and in ASCII format.
* See https://metric.computational-photonics.eu/visual.html#PROF for more information about plots
*/
//Initial input handling--------------------------------------------------------------------
//Helper option - displays usage instructions for function
if (strcmp(argv[1], "help") == 0) {
printf("\n\tUsage: (Wavelength and slab_height are in nano meters.)\n\n"
"\tsilicon1 width, resolution\n\n");
return 0;
}
//Check for incomplete input
if (argc !=3) {
printf("\n\tNot the right amount of arguments.\n\n");
return 1;
}
//Assign input params to variables
double sil1_width = atof(argv[1]);
double plotRes = atof(argv[2]);
//Print input params to console
if (otherOut) {
fprintf(stdout, "------------------------------------\n");
fprintf(stdout, "\tAir refractive index:\t\t%1.2f\n", n_air);
fprintf(stdout, "\tSilicon refractive index:\t%1.2f\n", n_sil);
fprintf(stdout, "\tSilica refractive index:\t%1.2f\n", n_silica);
fprintf(stdout, "\tSimulation rresolution:\t%1.0f\n\n", plotRes);
fprintf(stdout, "\tDimensions in nano meters\n");
fprintf(stdout, "\t--Air--|--Sil--|-Silca-\n");
fprintf(stdout, "\t <-- | %4.0f | -->\n\n", sil1_width);
}
//Set up------------------------------------------------------------------------------------
ModeArray maTE; //ModeaArray: Object to store results of modeanalysis for TE modes
ModeArray maTM; //ModeaArray: Object to store results of modeanalysis for TM modes
Waveguide wg = wgdef(sil1_width/1000); //Define waveguide using the waveguide definition function above.
Interval disp(wg.hx(0) - extraLeft, wg.hx(wg.nx) + extraRight); //Define display interval for output
//Calculate guided modes------------------------------------------------------------------
modeanalysis(wg, TE, maTE, !solveLog); //Find all guided TE modes and store in ModeArray
modeanalysis(wg, TM, maTM, !solveLog); //Find all guided TM modes and store in ModeArray
//Plots mode profiles (Matlab figures) for every entry in the array
if(outputLog) {
fprintf(stdout, "\tFile outputs:\n");
}
if(outStruct) {
wg.plot(disp, '0', '0'); //Plot refractive index profile
}
if(outMatlab) {
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Plots mode profiles for every entry in the array
char t = 'L'; if(i >= 1) t = 'V'; //Char t signals the plot function which info to include into the plot
maTM(i).plot(EX, ORG, disp, plotRes, dig10(i), dig1(i), t); //Real part of E_x compoment (TM mode)
}
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Plots mode profiles for every entry in the array
char t = 'L'; if(i >= 1) t = 'V'; //Char t signals the plot function which info to include into the plot
maTM(i).plot(EZ, IMP, disp, plotRes, dig10(i), dig1(i), t); //Imagingary part of E_z component (TM mode)
}
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Cycle through entries in the array
char t = 'L'; if(i >= 1) t = 'V'; //Char t signals the plot function which info to include into the plot
maTM(i).plot(HY, ORG, disp, plotRes, dig10(i), dig1(i), t); //Real part of H_y component (TM mode)
}
}
//Stores results in xyz files (ASCII)
if(outASCII) {
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Stores mode profiles in ASCII format
maTM(i).writeprofileQ(EX, ORG, disp, plotRes, dig10(i), dig1(i), !outputLog); //Real part of E_x compoment (TM mode)
}
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Stores mode profiles in ASCII format
maTM(i).writeprofileQ(EZ, IMP, disp, plotRes, dig10(i), dig1(i), !outputLog); //Imagingary part of E_z component (TM mode)
}
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Stores mode profiles in ASCII format
maTM(i).writeprofileQ(HY, ORG, disp, plotRes, dig10(i), dig1(i), !outputLog); //Real part of H_y component (TM mode)
}
}
if(otherOut) {
fprintf(stderr, "------------------------------------\n");
}
return 0;
}
// // access properties of individual modes:
// Mode m;
// m = ma(0);
// // the propagation constant, effective index
// double beta = m.beta;
// double neff = m.neff;
// // the field profile, real version: component EY at x = 0.0
// double f_ey = m.field(EY, 0.0);
// // directional field profile, complex:
// // component HZ of the forward propagating mode at x = 1.0
// Complex f_hz = m.cfield(HZ, FORW, 1.0);
/*
* METRIC-Application:
* A five layer (3 interior layer) waveguide: mode analysis, mode object handling
*
* Modified and commented by Cem Gülsan
* 2019-01-29
*/
/* Includes and definitions -------------------------------------------------------------------- */
/* --------------------------------------------------------------------------------------------- */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include"metric.h"
#include<cstring>
#include<algorithm>
#include <iostream>
//Settings
#define n_air 1.00 //Refractive index of air
#define n_sil 3.50 //Refractive index of silicon
#define Wavel 1.55 //Vacuum wavelength (in microns)
//#define plotRes 100000 //Plot resolution
#define extraLeft 2 //Extra interval left of WG boarders (in microns)
#define extraRight 2 //Extra interval right of WG boarders (in microns)
#define maxMode 0 //Maximum mode to be plotted (with 0 being the fundamental mode)
#define solveLog false //Output log from METRIC solver
#define outputLog false //Output log from METRIC output generation
#define otherOut false //Output various other outputs
#define outStruct false //Flag for MATLAB structure output (for verification)
#define outMatlab false //Flag for MATLAB output
#define outASCII true //Flag for ASCII output
/* Auxiliary functions-------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------------------------- */
Waveguide wgdef(double sil1_width, double gap1_width, double sil2_width, double gap2_width, double sil3_width) {
/* Defines the waveguide which is to be analyzed. Must adhere to syntax specified by METRIC.
* see https://metric.computational-photonics.eu/structure.html#WAVEG
* Waveguide objects represent a 1-D piecewise constant refractive index profile.
* Dimensions in micro meters!
*/
//Define a waveguide with x inner layers
Waveguide g(5);
//Positions of the dielectric interfaces
g.hx(0) = 0.0; //Interface between layer 0 and 1 (Start silicon 1)
g.hx(1) = g.hx(0) + sil1_width; //Interface between layer 1 and 2 (End silicon 1)
g.hx(2) = g.hx(1) + gap1_width; //Interface between layer 2 and 3 (Start silicon 2)
g.hx(3) = g.hx(2) + sil2_width; //Interface between layer 3 and 4 (End silicon 2)
g.hx(4) = g.hx(3) + gap2_width; //Interface between layer 4 and 5 (Start silicon 3)
g.hx(5) = g.hx(4) + sil3_width; //Interface between layer 5 and 6 (End silicon 3)
//Refractive index values
g.n(0) = n_air;
g.n(1) = n_sil; //Silicon 1
g.n(2) = n_air;
g.n(3) = n_sil; //Silicon 2
g.n(4) = n_air;
g.n(5) = n_sil; //Silicon 3
g.n(6) = n_air;
//The vacuum wavelength
g.lambda = Wavel;
return g;
}
/* Main calculation and output------------------------------------------------------------------ */
/* --------------------------------------------------------------------------------------------- */
int main(int argc, char *argv[]) {
/* After an initial setup of a ModeArray and a Waveguide, a modeAnalysis for guided TE and TM
* modes is conducted and the results are stored as MATLAB plots and in ASCII format.
* See https://metric.computational-photonics.eu/visual.html#PROF for more information about plots
*/
//Initial input handling--------------------------------------------------------------------
//Helper option - displays usage instructions for function
if (strcmp(argv[1], "help") == 0) {
printf("\n\tUsage: (Wavelength and slab_height are in nano meters.)\n\n"
"\tsilicon1 width, gap1 width, silicon2 width, gap2 width, silicon3 width, resolution\n\n");
return 0;
}
//Check for incomplete input
if (argc != 7) {
printf("\n\tNot the right amount of arguments.\n\n");
return 1;
}
//Assign input params to variables
double sil1_width = atof(argv[1]);
double gap1_width = atof(argv[2]);
double sil2_width = atof(argv[3]);
double gap2_width = atof(argv[4]);
double sil3_width = atof(argv[5]);
double plotRes = atof(argv[6]);
//Print input params to console
if (otherOut) {
fprintf(stdout, "------------------------------------\n");
fprintf(stdout, "\tAir refractive index:\t\t%1.2f\n", n_air);
fprintf(stdout, "\tSilicon refractive index:\t%1.2f\n", n_sil);
fprintf(stdout, "\tSimulation rresolution:\t%1.0f\n\n", plotRes);
fprintf(stdout, "\tDimensions in nano meters\n");
fprintf(stdout, "\t--Air--|--Sil--|--Air--|--Sil--|--Air--|--Sil--|--Air--\n");
fprintf(stdout, "\t <-- | %4.0f | %4.0f | %4.0f | %4.0f | %4.0f | -->\n\n", sil1_width, gap1_width, sil2_width, gap2_width, sil3_width);
}
//Set up------------------------------------------------------------------------------------
ModeArray maTE; //ModeaArray: Object to store results of modeanalysis for TE modes
ModeArray maTM; //ModeaArray: Object to store results of modeanalysis for TM modes
Waveguide wg = wgdef(sil1_width/1000, gap1_width/1000, sil2_width/1000, gap2_width/1000, sil3_width/1000); //Define waveguide using the waveguide definition function above.
Interval disp(wg.hx(0) - extraLeft, wg.hx(wg.nx) + extraRight); //Define display interval for output
//Calculate guided modes------------------------------------------------------------------
modeanalysis(wg, TE, maTE, !solveLog); //Find all guided TE modes and store in ModeArray
modeanalysis(wg, TM, maTM, !solveLog); //Find all guided TM modes and store in ModeArray
//Plots mode profiles (Matlab figures) for every entry in the array
if(outputLog) {
fprintf(stdout, "\tFile outputs:\n");
}
if(outStruct) {
wg.plot(disp, '0', '0'); //Plot refractive index profile
}
if(outMatlab) {
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Plots mode profiles for every entry in the array
char t = 'L'; if(i >= 1) t = 'V'; //Char t signals the plot function which info to include into the plot
maTM(i).plot(EX, ORG, disp, plotRes, dig10(i), dig1(i), t); //Real part of E_x compoment (TM mode)
}
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Plots mode profiles for every entry in the array
char t = 'L'; if(i >= 1) t = 'V'; //Char t signals the plot function which info to include into the plot
maTM(i).plot(EZ, IMP, disp, plotRes, dig10(i), dig1(i), t); //Imagingary part of E_z component (TM mode)
}
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Cycle through entries in the array
char t = 'L'; if(i >= 1) t = 'V'; //Char t signals the plot function which info to include into the plot
maTM(i).plot(HY, ORG, disp, plotRes, dig10(i), dig1(i), t); //Real part of H_y component (TM mode)
}
}
//Stores results in xyz files (ASCII)
if(outASCII) {
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Stores mode profiles in ASCII format
maTM(i).writeprofileQ(EX, ORG, disp, plotRes, dig10(i), dig1(i), !outputLog); //Real part of E_x compoment (TM mode)
}
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Stores mode profiles in ASCII format
maTM(i).writeprofileQ(EZ, IMP, disp, plotRes, dig10(i), dig1(i), !outputLog); //Imagingary part of E_z component (TM mode)
}
for(int i = 0; i <= std::min(maTM.num - 1, maxMode); ++i) { //Stores mode profiles in ASCII format
maTM(i).writeprofileQ(HY, ORG, disp, plotRes, dig10(i), dig1(i), !outputLog); //Real part of H_y component (TM mode)
}
}
if(otherOut) {
fprintf(stderr, "------------------------------------\n");
}
return 0;
}
// // access properties of individual modes:
// Mode m;
// m = ma(0);
// // the propagation constant, effective index
// double beta = m.beta;
// double neff = m.neff;
// // the field profile, real version: component EY at x = 0.0
// double f_ey = m.field(EY, 0.0);
// // directional field profile, complex:
// // component HZ of the forward propagating mode at x = 1.0
// Complex f_hz = m.cfield(HZ, FORW, 1.0);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment