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 c7934e33 authored by Hendrik Preuss's avatar Hendrik Preuss

added script for simple output of wavenumber

parent 4f921d25
......@@ -7,9 +7,8 @@ These are apps for the Metric mode solver from: https://metric.computational-pho
Apps are located in the *apps* folder. They are are complied with the following command:
`.\build_app <app_folder> <app_name>`. For example with:`.\build_app p_air p_4l`.
The metric source code is located in the *source* folder. The compiled apps will be placed in the *bin* folder.
The metric source code is located in the *source* folder. The compiled apps will be placed in the *bin* folder. Run the apps in the bin folder to get the output.
When cloning for the first time use the *--recursive* optione to also clone the submodules: `git clone --recursive <url>`.
## Type of apps
......@@ -21,4 +20,16 @@ When cloning for the first time use the *--recursive* optione to also clone the
- max_p_air
searches for the core thickness, which maximizes p of the cladding in a three layered slab waveguide
- p_4l
estimate the influence of a glue below the substrate for different substrate thicknesses
estimate the influence of a glue below the substrate for different substrate thicknesses, this simulation turned out to be not suitable for the task
- p_simple
a simplified version fo p_air for different purposes
- slab_mode
different general simulation of modes in a three layerd slab
- effective_wavenumber
returns the effective wavenumber of a slab mode for differnet wavelengths
## Installation
- clone this repository: `git clone --recursive git@collaborating.tuhh.de:e-12/metric.git`
- if not cloned recursively, update the Eigen submodule: `git submodule update --init -- source/Eigen`
- install C++ compiler: `sudo dnf install gcc-c++`
/*
* 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>
// Switch verbose output
#define quiet true
/**
Defines a layed stack of slabs, to defiene a slab waveguide.
The constructor of the wg calss takes the number of inner layers.
Args:
layers (int): the number of inner layers.
layer (int): The layer to which the refractive indes change is applied.
n_diff (double): Refractive index perturbation.
Notes:
Length(wg.hx) = layers + 1 <- These are the positions of the material
interfaces.
Length(wg.n) = layers + 2 <- These are the material refractive indeces,
including the ideces of the materials above and below the inner layers.
All distances are in micro meters.
*/
Waveguide wgdef(double lambda,
std::vector<double> hx,
std::vector<double> n) {
Waveguide wg(hx.size());
wg.lambda = lambda;
wg.hx(0) = 0;
quiet ? 0 : printf("hx =");
for (unsigned i = 0; i < hx.size(); i++) {
quiet ? 0 : printf(" %g", hx[i]);
wg.hx(i+1) = wg.hx(i) + hx[i];
}
quiet ? 0 : printf("\nn =");
for (unsigned i = 0; i < n.size(); i++) {
quiet ? 0 : printf(" %g", n[i]);
wg.n(i) = n[i];
}
quiet ? 0 : printf("\n");
return wg;
}
/**
Returns an array of the medium-specific refractive index sensitivites.
*/
void beta_eff (double* b_eff, double* n_eff, bool* first_mode_present,
double lambda,
Polarization pol,
std::vector<double> hx,
std::vector<double> n) {
quiet ? 0 : printf("in beta_eff\n");
Waveguide wg;
ModeArray modes;
wg = wgdef(lambda, hx, n);
modeanalysis(wg, pol, modes, 1);
if (modes.num > 0) {
*first_mode_present = true;
*b_eff = modes(0).beta;
*n_eff = modes(0).neff;
} else {
*first_mode_present = false;
*b_eff = 0;
*n_eff = 0;
}
quiet ? 0 : printf("beta_eff = %g\n", *b_eff);
quiet ? 0 : printf("n_eff = %g\n", *n_eff);
}
int main(int argc, char *argv[]) {
// speed of light [um/s]
double c = 299792458e6;
// wavelength in um
//double lambda = 1.55;
// refective indeces of the layers and claddings (bottom to top)
std::vector<double> n = {1.45, 3.48, 1};
// layer thicknesses in um (bottom to top)
std::vector<double> hx = {0.22};
// light polarization (TE or TM)
Polarization pol = TE;
// printf("# Wavelength: %g\n", lambda);
if (pol == TE) {
printf("# Polarization: TE\n");
} else if (pol == TM) {
printf("# Polarization: TM\n");
}
printf("# Layer thicknesses: ");
for(unsigned i = 0; i < hx.size(); i++) {
printf("%-9g", hx[i]);
}
printf("\n# Refractice indeces: ");
for(unsigned i = 0; i < n.size(); i++) {
printf("%-9g", n[i]);
}
// layer names as used in wgdef (length = layers + 2)
printf("\n#\n# %-9s %-11s %-11s %-11s %-11s\n",
"freq [THz]",
"lambda [um]",
"k_0 [1/um]",
"n_eff",
"b_eff [1/um]");
double lambda;
// For a sweep the following section can be put into a loop.
// The function f_p needs to be adapted to include the sweep parameter.
for(double freq = 0; freq <= 500e12; freq += 0.01e12) {
lambda = c / freq;
// output of the effective refractive index
double* n_eff = new double();
// output of the effective wavenumber
double* b_eff = new double();
// is the first mode present
bool* first_mode_present = new bool();
// calcualte the refractive index sensitivity
beta_eff(b_eff, n_eff, first_mode_present,
lambda, pol, hx, n);
// print the sensitivites
if (*first_mode_present) {
printf("%-31.25g %-41.35g %-31.25g %-31.25g %-31.25g\n", freq, lambda, 2*M_PI/lambda, *n_eff, *b_eff);
}
}
}
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