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 a4fa7dba authored by Hendrik Preuß's avatar Hendrik Preuß

added apps p_air and max_p_air

parent ac61cb06
/*
* METRIC-Application:
* Guided wave propagation along a slab waveguide
*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include"metric.h"
#include<vector>
#include<cstring>
#include<cstdlib>
#include<algorithm>
// #define Pol TM // light polarization
// #define Wsub 1.70 // substrate refractive index
// #define Wcore 3.43 // core refractive index
// #define Wsuper 1.0 // superstrate refractive index
// #define Wdiff 0.01 // substrate refractive index
// #define WPwstart 0.1 // core height /mum
// #define WPwstop 1.0 // core height /mum
// #define WPwstep 0.1 // core height /mum
// #define Wavel 3.3 // vacuum wavelength /mum
#define quiet true
enum Section {Substrate, Core, Superstrate};
/* ------------------------------------------------------------------------ */
/* a slab waveguide */
Waveguide wgdef(double sub, double core, double super, double height, double wavel) {
Waveguide wg(1);
wg.hx(0) = -height/2.0;
wg.hx(1) = height/2.0;
wg.n(0) = sub;
wg.n(1) = core;
wg.n(2) = super;
wg.lambda = wavel;
return wg;
}
double f_p (double wavelength,
Polarization pol,
double n_substrate,
double n_core,
double n_superstrate,
double n_diff,
double height,
Section sec) {
double neff[2];
int found_modes = 0;
for (int i = 0; i < 2; i++) {
Waveguide wg;
if (sec == Substrate) {
wg = wgdef(n_substrate + i * n_diff,
n_core,
n_superstrate,
height,
wavelength);
}
else if (sec == Core) {
wg = wgdef(n_substrate,
n_core + i * n_diff,
n_superstrate,
height,
wavelength);
}
else if (sec == Superstrate) {
wg = wgdef(n_substrate,
n_core,
n_superstrate + i * n_diff,
height,
wavelength);
}
// find the guided modes
ModeArray ma;
modeanalysis(wg, pol, ma, 1);
if (ma.num >= 1) {
quiet ? 0 : fprintf(stderr, "neff = %g\n", ma(0).neff);
neff[i] = ma(0).neff;
found_modes ++;
}
}
if (found_modes == 2) {
double p = (neff[1] - neff[0]) / n_diff;
quiet ? 0 : fprintf(stderr, "p = %g\n", p);
return p;
}
else {
return -1;
}
}
/* ------------------------------------------------------------------------ */
/* guided wave simulation */
double find_p(double wavelength,
Polarization pol,
double n_substrate,
double n_core,
double n_superstrate,
double n_diff,
double height_start,
double height_stop,
double height_step,
Section sec) {
std::vector<double> heights;
std::vector<double> p_sec;
for (double height = height_start; height < height_stop; height += height_step) {
quiet ? 0 : fprintf(stderr, "height = %g\n", height);
double p = f_p(wavelength, pol, n_substrate, n_core, n_superstrate, n_diff, height, sec);
if (p >= 0) {
heights.push_back(height);
p_sec.push_back(p);
}
quiet ? 0 : fprintf(stderr, "\n");
}
auto max_p = max_element(std::begin(p_sec), std::end(p_sec));
auto h = heights.at(distance(p_sec.begin(), max_p));
printf("%g at %g nm \n", *max_p, h * 1000);
return h;
}
int main(int argc, char *argv[]) {
if (strcmp(argv[1], "-h") == 0) {
printf("\nUsage: (Wavelength in microns)\n\n"
"max_p_air wavelength n_substrate n_core n_superstrate\n\n");
return 0;
}
else if (argc != 5) {
printf("\nNot the right amount of arguments.\n\n");
return 1;
}
// Polarization pol;
// if (strcmp(argv[2], "TE") == 0) {
// pol = TE;
// }
// else if (strcmp(argv[2], "TM") == 0) {
// pol = TM;
// }
// else {
// return 1;
// }
double wavelength = atof(argv[1]);
double n_substrate = atof(argv[2]);
double n_core = atof(argv[3]);
double n_superstrate = atof(argv[4]);
//double n_diff = atof(argv[5]);
// double height_start = atof(argv[7]);
// double height_stop = atof(argv[8]);
// double height_step = atof(argv[9]);
double n_diff = 0.01;
double height_start = 0.01;
double height_stop = 1;
double height_step = 0.001;
if (!quiet) {
fprintf(stderr, "\nWaveguide:\n");
fprintf(stderr, "----------\n");
fprintf(stderr, "lambda = %g mum\n", wavelength);
fprintf(stderr, "n_substrate = %g\n", n_substrate);
fprintf(stderr, "n_core = %g\n", n_core);
fprintf(stderr, "n_superstrate = %g\n", n_superstrate);
fprintf(stderr, "slab height = %g to %g (%g) mum\n",
height_start, height_stop, height_step);
// if (pol == TM) {
// fprintf(stderr, "polarization = TM\n\n");
// }
// else if (pol == TE) {
// fprintf(stderr, "polarization = TE\n\n");
// }
}
double h_max;
double p;
printf("\nTE:\n");
printf("air: p = ");
h_max = find_p(wavelength, TE, n_substrate, n_core, n_superstrate, n_diff, height_start, height_stop, height_step, Superstrate);
p = f_p(wavelength, TE, n_substrate, n_core, n_superstrate, n_diff, h_max, Substrate);
printf("substrate: p = %g\n", p);
p = f_p(wavelength, TE, n_substrate, n_core, n_superstrate, n_diff, h_max, Core);
printf("core: p = %g\n", p);
printf("\nTM:\n");
printf("air: p = ");
h_max = find_p(wavelength, TM, n_substrate, n_core, n_superstrate, n_diff, height_start, height_stop, height_step, Superstrate);
p = f_p(wavelength, TM, n_substrate, n_core, n_superstrate, n_diff, h_max, Substrate);
printf("substrate: p = %g\n", p);
p = f_p(wavelength, TM, n_substrate, n_core, n_superstrate, n_diff, h_max, Core);
printf("core: p = %g\n\n", p);
}
/*
* METRIC-Application:
* Guided wave propagation along a slab waveguide
*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include"metric.h"
#include<vector>
#include<cstring>
#include<cstdlib>
#include<algorithm>
// #define Pol TM // light polarization
// #define Wsub 1.70 // substrate refractive index
// #define Wcore 3.43 // core refractive index
// #define Wsuper 1.0 // superstrate refractive index
// #define Wdiff 0.01 // substrate refractive index
// #define WPwstart 0.1 // core height /mum
// #define WPwstop 1.0 // core height /mum
// #define WPwstep 0.1 // core height /mum
// #define Wavel 3.3 // vacuum wavelength /mum
#define quiet true
enum Section {Substrate, Core, Superstrate};
/* ------------------------------------------------------------------------ */
/* a slab waveguide */
Waveguide wgdef(double sub, double core, double super, double height, double wavel) {
Waveguide wg(1);
wg.hx(0) = -height/2.0;
wg.hx(1) = height/2.0;
wg.n(0) = sub;
wg.n(1) = core;
wg.n(2) = super;
wg.lambda = wavel;
return wg;
}
double f_p (double wavelength,
Polarization pol,
double n_substrate,
double n_core,
double n_superstrate,
double n_diff,
double height,
Section sec) {
double neff[2];
int found_modes = 0;
for (int i = 0; i < 2; i++) {
Waveguide wg;
if (sec == Substrate) {
wg = wgdef(n_substrate + i * n_diff,
n_core,
n_superstrate,
height,
wavelength);
}
else if (sec == Core) {
wg = wgdef(n_substrate,
n_core + i * n_diff,
n_superstrate,
height,
wavelength);
}
else if (sec == Superstrate) {
wg = wgdef(n_substrate,
n_core,
n_superstrate + i * n_diff,
height,
wavelength);
}
// find the guided modes
ModeArray ma;
modeanalysis(wg, pol, ma, 1);
if (ma.num >= 1) {
quiet ? 0 : fprintf(stderr, "neff = %g\n", ma(0).neff);
neff[i] = ma(0).neff;
found_modes ++;
}
}
if (found_modes == 2) {
double p = (neff[1] - neff[0]) / n_diff;
quiet ? 0 : fprintf(stderr, "p = %g\n", p);
return p;
}
else {
return -1;
}
}
int main(int argc, char *argv[]) {
if (strcmp(argv[1], "-h") == 0) {
printf("\nUsage: (Wavelength and slab_height are in microns.)\n\n"
"p_air wavelength n_substrate n_core n_superstrate slab_heigth\n\n");
return 0;
}
else if (argc != 6) {
printf("\nNot the right amount of arguments.\n\n");
return 1;
}
// Polarization pol;
// if (strcmp(argv[2], "TE") == 0) {
// pol = TE;
// }
// else if (strcmp(argv[2], "TM") == 0) {
// pol = TM;
// }
// else {
// return 1;
// }
double wavelength = atof(argv[1]);
double n_substrate = atof(argv[2]);
double n_core = atof(argv[3]);
double n_superstrate = atof(argv[4]);
double height = atof(argv[5]);
//double n_diff = atof(argv[5]);
// double height_start = atof(argv[7]);
// double height_stop = atof(argv[8]);
// double height_step = atof(argv[9]);
double n_diff = 0.01;
if (!quiet) {
fprintf(stderr, "\nWaveguide:\n");
fprintf(stderr, "----------\n");
fprintf(stderr, "lambda = %g mum\n", wavelength);
fprintf(stderr, "n_substrate = %g\n", n_substrate);
fprintf(stderr, "n_core = %g\n", n_core);
fprintf(stderr, "n_superstrate = %g\n", n_superstrate);
fprintf(stderr, "slab height =%g mum\n", height);
// if (pol == TM) {
// fprintf(stderr, "polarization = TM\n\n");
// }
// else if (pol == TE) {
// fprintf(stderr, "polarization = TE\n\n");
// }
}
double p;
printf("\nTE:\n");
p = f_p(wavelength, TE, n_substrate, n_core, n_superstrate, n_diff, height, Superstrate);
printf("air: p = %g\n", p);
p = f_p(wavelength, TE, n_substrate, n_core, n_superstrate, n_diff, height, Substrate);
printf("substrate: p = %g\n", p);
p = f_p(wavelength, TE, n_substrate, n_core, n_superstrate, n_diff, height, Core);
printf("core: p = %g\n", p);
printf("\nTM:\n");
p = f_p(wavelength, TM, n_substrate, n_core, n_superstrate, n_diff, height, Superstrate);
printf("air: p = %g\n", p);
p = f_p(wavelength, TM, n_substrate, n_core, n_superstrate, n_diff, height, Substrate);
printf("substrate: p = %g\n", p);
p = f_p(wavelength, TM, n_substrate, n_core, n_superstrate, n_diff, height, Core);
printf("core: p = %g\n\n", p);
}
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