125 dcomplex ff = (j) ? (dcomplex(0., 0.5 / PI / k) * (exp(dcomplex(0., -
b * k * r)) - exp(dcomplex(0., -
b * k * l))))
150 std::set<std::string> roles;
151 if (epsilon_connected && solver->lcomputed[layer] || gain_connected && solver->lgained[layer])
152 roles = geometry->getRolesAt(
vec(mesh->tran()->at(j), maty));
153 bool computed = epsilon_connected && solver->lcomputed[layer] && roles.find(
"inEpsilon") != roles.end();
155 eps = Zero<Tensor3<dcomplex>>();
157 for (
size_t k = 0, v = j * solver->verts->size(); k != mesh->vert()->size(); ++v, ++k) {
158 if (solver->stack[k] == layer) {
159 if (
isnan(epsilons[v]))
160 throw BadInput(solver->getId(),
"complex permittivity tensor got from inEpsilon is NaN at {}", mesh->at(v));
162 (k == 0 || k == mesh->vert()->size() - 1) ? 1
e-6 : solver->vbounds->at(k) - solver->vbounds->at(k - 1);
163 eps += w * epsilons[v];
169 double T = 0., W = 0., C = 0.;
170 for (
size_t k = 0, v = j * solver->verts->size(); k != mesh->vert()->size(); ++v, ++k) {
171 if (solver->stack[k] == layer) {
173 (k == 0 || k == mesh->vert()->size() - 1) ? 1
e-6 : solver->vbounds->at(k) - solver->vbounds->at(k - 1);
174 T += w * temperature[v];
183 auto material = geometry->getMaterial(
vec(mesh->tran()->at(j), maty));
184 lock = material->lock();
185 eps = material->Eps(lam, T, C);
187 throw BadInput(solver->getId(),
"complex permittivity tensor (Eps) for {} is NaN at lam={}nm, T={}K, n={}/cm3",
188 material->name(), lam, T, C);
191 if (eps.c01 != 0. || eps.c10 != 0.) {
193 throw BadInput(solver->getId(),
"symmetry not allowed for structure with non-diagonal permittivity tensor");
196 "single polarization not allowed for structure with non-diagonal permittivity tensor");
198 if (eps.c02 != 0. || eps.c21 != 0. || eps.c12 != 0. || eps.c20 != 0.) {
199 throw BadInput(solver->getId(),
"symmetry not allowed for structure with non-diagonal permittivity tensor");
201 if (!computed && gain_connected && solver->lgained[layer] && roles.find(
"QW") != roles.end() ||
202 roles.find(
"QD") != roles.end() || roles.find(
"gain") != roles.end()) {
205 for (
size_t k = 0, v = j * solver->verts->size(); k != mesh->vert()->size(); ++v, ++k) {
206 if (solver->stack[k] == layer) {
208 (k == 0 || k == mesh->vert()->size() - 1) ? 1
e-6 : solver->vbounds->at(k) - solver->vbounds->at(k - 1);
214 double n00 = sqrt(eps.c00).real(), n11 = sqrt(eps.c11).real(), n22 = sqrt(eps.c22).real();
215 eps.c00 = dcomplex(n00 * n00 - ni.
c00 * ni.
c00, 2 * n00 * ni.
c00);
216 eps.c11 = dcomplex(n11 * n11 - ni.
c00 * ni.
c00, 2 * n11 * ni.
c00);
217 eps.c22 = dcomplex(n22 * n22 - ni.
c11 * ni.
c11, 2 * n22 * ni.
c11);