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

modified p_4l such taht it gives me p for Si-CaF2-Si

parent e2a28e2c
......@@ -12,207 +12,116 @@
#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, Glue};
enum Section {Lower_air = 0, Si_waver = 1, CaF2 = 2, Si_waveguide = 3, Upper_air = 4};
/* ------------------------------------------------------------------------ */
/* a slab waveguide */
Waveguide wgdef(double n_glue, double n_substrate,
double n_core, double n_superstrate,
double height_substrate, double height_core,
double wavelength) {
Waveguide wg(2);
wg.hx(0) = -height_substrate;
wg.hx(1) = 0.0;
wg.hx(2) = height_core;
wg.n(0) = n_glue;
wg.n(1) = n_substrate;
wg.n(2) = n_core;
wg.n(3) = n_superstrate;
wg.lambda = wavelength;
Waveguide wgdef(double height_CaF2, Section sec, double n_diff) {
Waveguide wg(3);
wg.hx(0) = -32;
wg.hx(1) = 0;
wg.hx(2) = height_CaF2;
wg.hx(3) = height_CaF2 + 0.6;
wg.n(0) = 1; // Air
wg.n(1) = 3.43; // Si
wg.n(2) = 1.4; // CaF2
wg.n(3) = 3.43; // Si
wg.n(4) = 1; // Air
wg.n(sec) = wg.n(sec) + n_diff;
quiet ? 0 : printf("n of section %i: %g\n", sec, wg.n(sec));
wg.lambda = 4.3;
return wg;
}
double f_p (double wavelength,
Polarization pol,
double n_glue,
double n_substrate,
double n_core,
double n_superstrate,
double n_diff,
double height_substrate,
double height_core,
Section sec) {
double f_p (double height_CaF2, Section sec, double n_diff) {
double neff[2];
int found_modes = 0;
for (int i = 0; i < 2; i++) {
Waveguide wg;
if (sec == Glue) {
wg = wgdef(n_glue + i * n_diff,
n_substrate,
n_core,
n_superstrate,
height_substrate,
height_core,
wavelength);
}
else if (sec == Substrate) {
wg = wgdef(n_glue,
n_substrate + i * n_diff,
n_core,
n_superstrate,
height_substrate,
height_core,
wavelength);
}
else if (sec == Core) {
wg = wgdef(n_glue,
n_substrate,
n_core + i * n_diff,
n_superstrate,
height_substrate,
height_core,
wavelength);
}
else if (sec == Superstrate) {
wg = wgdef(n_glue,
n_substrate,
n_core,
n_superstrate + i * n_diff,
height_substrate,
height_core,
wavelength);
}
wg = wgdef(height_CaF2, sec, i * n_diff);
// 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 ++;
ModeArray modes;
modeanalysis(wg, TM, modes, 1);
quiet ? 0 : printf("number of found modes: %i\n", modes.num);
int slab_mode = 0;
for (int m = 0; m < modes.num; m++) {
if (abs(modes(m).field(HY, height_CaF2 + 0.3)) >
abs(modes(slab_mode).field(HY, height_CaF2 + 0.3))) {
slab_mode = m;
}
// printf("mode: %i, field: %g\n", m, abs(modes(m).field(HY, height_CaF2 + 0.3)));
}
quiet ? 0 : printf("neff of slab mode %i: %10.10g\n", slab_mode, modes(slab_mode).neff);
neff[i] = modes(slab_mode).neff;
}
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;
}
// wg = wgdef(height_CaF2, sec, n_diff);
// // find the guided modes
// modeanalysis(wg, TM, modes, 1);
// slab_mode = 0;
// for (int m = 0; m < modes.num; m++) {
// if (abs(modes(m).neff - neff[0]) < abs(modes(slab_mode).neff - neff[0])) {
// slab_mode = m;
// }
// // printf("mode: %i, field: %g\n", m, abs(modes(m).field(HY, height_CaF2 + 0.3)));
// }
// quiet ? 0 : printf("number of found modes: %i\n", modes.num);
// quiet ? 0 : printf("neff of slab mode %i: %10.10g\n", slab_mode, modes(slab_mode).neff);
// neff[1] = modes(slab_mode).neff;
double p = (neff[1] - neff[0]) / n_diff;
quiet ? 0 : fprintf(stderr, "p = %g\n", p);
return p;
}
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 polarization wavelength n_glue n_substrate n_core n_superstrate heigth_core\n\n");
return 0;
}
else if (argc != 8) {
printf("\nNot the right amount of arguments.\n\n");
return 1;
}
// if (strcmp(argv[1], "-h") == 0) {
// printf("Finds the medium-specific absorption factor for Si-on-CaF2-on-Si for differnet CaF2 thicknesses.\n"
// "Usage:\n\n"
// "p_4l\n\n");
// return 0;
// }
// else if (argc != 1) {
// printf("\nNot the right amount of arguments.\n\n");
// return 1;
// }
Polarization pol;
if (strcmp(argv[1], "TE") == 0) {
pol = TE;
}
else if (strcmp(argv[1], "TM") == 0) {
pol = TM;
}
else {
return 1;
}
double wavelength = atof(argv[2]);
double n_glue = atof(argv[3]);
double n_substrate = atof(argv[4]);
double n_core = atof(argv[5]);
double n_superstrate = atof(argv[6]);
double height_core = atof(argv[7]);
double n_diff = 0.0001;
double height_sub_min = height_core;
double height_sub_max = 10 * height_core;
double steps = 1000;
if (!quiet) {
fprintf(stderr, "\nWaveguide:\n");
fprintf(stderr, "----------\n");
fprintf(stderr, "lambda = %g um\n", wavelength);
fprintf(stderr, "n_glue = %g\n", n_glue);
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, "core height =%g um\n", height_core);
if (pol == TM) {
fprintf(stderr, "polarization = TM\n\n");
}
else if (pol == TE) {
fprintf(stderr, "polarization = TE\n\n");
}
}
double n_diff = 0.001;
double height_CaF2_min = 0.5;
double height_CaF2_max = 5;
double steps = 901;
printf("# substrate_height p_glue p_substrate p_core p_cladding\n");
printf("# height_CaF2 p_lower_Air p_Si_waver p_CaF2 p_Si_waveguide, p_upper_Air\n");
for (int i = 0; i < steps; i++) {
double height_substrate = height_sub_min + i * (height_sub_max - height_sub_min) / (steps - 1);
quiet ? 0 : fprintf(stderr, "height_substrate = %g\n", height_substrate);
double p_glue = f_p(wavelength, pol,
n_glue,
n_substrate,
n_core,
n_superstrate,
n_diff,
height_substrate,
height_core,
Glue);
double p_substrate = f_p(wavelength, pol,
n_glue,
n_substrate,
n_core,
n_superstrate,
n_diff,
height_substrate,
height_core,
Substrate);
double p_core = f_p(wavelength, pol,
n_glue,
n_substrate,
n_core,
n_superstrate,
n_diff,
height_substrate,
height_core,
Core);
double p_cladding = f_p(wavelength, pol,
n_glue,
n_substrate,
n_core,
n_superstrate,
n_diff,
height_substrate,
height_core,
Superstrate);
printf("%g ", height_substrate);
printf("%g ", p_glue);
printf("%g ", p_substrate);
printf("%g ", p_core);
printf("%g\n", p_cladding);
double height_CaF2 = height_CaF2_min + i * (height_CaF2_max - height_CaF2_min) / (steps - 1);
quiet ? 0 : fprintf(stderr, "height_CaF2 = %g\n", height_CaF2);
quiet ? 0 : printf("run p_Lower_air\n");
double p_Lower_air = f_p(height_CaF2, Lower_air, n_diff);
quiet ? 0 : printf("run p_Si_waver\n");
double p_Si_waver = f_p(height_CaF2, Si_waver, n_diff);
quiet ? 0 : printf("run p_CaF2\n");
double p_CaF2 = f_p(height_CaF2, CaF2, n_diff);
quiet ? 0 : printf("run p_Si_waveguide\n");
double p_Si_waveguide = f_p(height_CaF2, Si_waveguide, n_diff);
quiet ? 0 : printf("run p_Upper_air\n");
double p_Upper_air = f_p(height_CaF2, Upper_air, n_diff);
printf("%-10.8g ", height_CaF2);
printf("%- 11.5g ", p_Lower_air);
printf("%- 11.5g ", p_Si_waver);
printf("%- 11.5g ", p_CaF2);
printf("%- 11.5g ", p_Si_waveguide);
printf("%- 11.5g ", p_Upper_air);
printf("\n");
}
}
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