PLaSK library
Loading...
Searching...
No Matches
reflection.hpp
Go to the documentation of this file.
1/*
2 * This file is part of PLaSK (https://plask.app) by Photonics Group at TUL
3 * Copyright (c) 2022 Lodz University of Technology
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14#ifndef PLASK__SOLVER_OPTICAL_MODAL_REFLECTION_H
15#define PLASK__SOLVER_OPTICAL_MODAL_REFLECTION_H
16
17#include "matrices.hpp"
18#include "transfer.hpp"
19#include "solver.hpp"
20
21
22namespace plask { namespace optical { namespace modal {
23
28
30 struct LayerFields {
32 };
33
35 enum Matching {
37 MATCH_IMPEDANCE
38 };
40
41 protected:
42
44 enum {
47 STORE_ALL
48 } storeP;
49
50 std::vector<LayerFields> fields;
51
52 private:
53
54 cdiagonal phas;
55 int* ipiv;
56 std::vector<cmatrix> memP;
57
58 void saveP(size_t n) {
59 if (memP[n].rows() == P.rows() && memP[n].cols() == P.cols())
60 memcpy(memP[n].data(), P.data(), P.rows() * P.cols() * sizeof(dcomplex));
61 else
62 memP[n] = P.copy();
63 }
64
65 void adjust_z(size_t n, double& z, PropagationDirection& part) {
66 if (std::ptrdiff_t(n) >= solver->interface) {
67 z = - z;
68 if (n != 0 && n != solver->vbounds->size())
69 z += solver->vbounds->at(n) - solver->vbounds->at(n-1);
70 if (part == PROPAGATION_DOWNWARDS) part = PROPAGATION_UPWARDS;
71 else if (part == PROPAGATION_UPWARDS) part = PROPAGATION_DOWNWARDS;
72 }
73 }
74
75 void adjust_z(size_t n, double& z1, double& z2) {
76 if (std::ptrdiff_t(n) >= solver->interface) {
77 const double zl = z1;
78 z1 = - z2; z2 = - zl;
79 if (n != 0 && n != solver->vbounds->size()) {
80 double d = solver->vbounds->at(n) - solver->vbounds->at(n-1);
81 z1 += d; z2 += d;
82 }
83 }
84 }
85
86 public:
87
88 ReflectionTransfer(ModalBase* solver, Expansion& expansion, Matching matching);
89
90 ~ReflectionTransfer();
91
92 cvector getReflectionVector(const cvector& incident, IncidentDirection direction) override;
93
94 cvector getTransmissionVector(const cvector& incident, IncidentDirection side) override;
95
96 protected:
97
98 void getFinalMatrix() override;
99
100 void determineFields() override;
101
102 void determineReflectedFields(const cvector& incident, IncidentDirection side) override;
103
104 cvector getFieldVectorE(double z, std::size_t n, PropagationDirection part = PROPAGATION_TOTAL) override;
105
106 cvector getFieldVectorH(double z, std::size_t n, PropagationDirection part = PROPAGATION_TOTAL) override;
107
115 void getAM(size_t start, size_t end, bool add, double mfac=1.);
116
124 void findReflection(std::size_t start, std::size_t end, bool emitting, int store=0);
125
126 double integrateField(WhichField field, size_t n, double z1, double z2) override;
127
128 private:
129 // dcomplex _integrate(double z1, double z2, dcomplex g, dcomplex E);
130};
131
132
133}}} // namespace plask::optical::modal
134
135#endif // PLASK__SOLVER_OPTICAL_MODAL_REFLECTION_H