PLaSK library
Loading...
Searching...
No Matches
beta.cpp
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#include "beta.hpp"
15
16namespace plask { namespace electrical { namespace shockley {
17
18template <typename GeometryT>
19BetaSolver<GeometryT>::BetaSolver(const std::string& name)
20 : BaseClass(name), outDifferentialConductivity(this, &BetaSolver<GeometryT>::getDifferentialConductivity) {
21 js.assign(1, 1.);
22 beta.assign(1, NAN);
23}
24
25template <typename GeometryT> void BetaSolver<GeometryT>::loadConfiguration(XMLReader& source, Manager& manager) {
26 while (source.requireTagOrEnd()) {
27 if (source.getNodeName() == "junction") {
28 js[0] = source.getAttribute<double>("js", js[0]);
29 beta[0] = source.getAttribute<double>("beta", beta[0]);
30 auto condjunc = source.getAttribute<double>("pnjcond");
31 if (condjunc) {
32 this->writelog(LOG_WARNING, "'pnjcond' attribute is obselete; use <loop start-cond=>");
33 this->setCondJunc(*condjunc);
34 }
35 // if (source.hasAttribute("wavelength") || source.hasAttribute("heat"))
36 // throw XMLException(reader, "heat computation by wavelegth is no onger supporte");
37 for (auto attr : source.getAttributes()) {
38 if (attr.first == "beta" || attr.first == "js" || attr.first == "pnjcond" || attr.first == "wavelength" ||
39 attr.first == "heat")
40 continue;
41 if (attr.first.substr(0, 4) == "beta") {
42 size_t no;
43 try {
44 no = boost::lexical_cast<size_t>(attr.first.substr(4));
45 } catch (boost::bad_lexical_cast&) {
46 throw XMLUnexpectedAttrException(source, attr.first);
47 }
48 setBeta(no, source.requireAttribute<double>(attr.first));
49 } else if (attr.first.substr(0, 2) == "js") {
50 size_t no;
51 try {
52 no = boost::lexical_cast<size_t>(attr.first.substr(2));
53 } catch (boost::bad_lexical_cast&) {
54 throw XMLUnexpectedAttrException(source, attr.first);
55 }
56 setJs(no, source.requireAttribute<double>(attr.first));
57 } else
58 throw XMLUnexpectedAttrException(source, attr.first);
59 }
60 source.requireTagEnd();
61 } else {
62 this->parseConfiguration(source, manager);
63 }
64 }
65}
66
67template <typename GeometryT> BetaSolver<GeometryT>::~BetaSolver() {}
68
69template <typename GeometryT>
71 InterpolationMethod method) {
72 LazyData<Tensor2<double>> cond = this->outConductivity(dest_mesh, method);
73 LazyData<Vec<GeometryT::DIM>> curr = this->outCurrentDensity(dest_mesh, method);
74 return LazyData<Tensor2<double>>(dest_mesh->size(), [this, dest_mesh, cond, curr](std::size_t i) -> Tensor2<double> {
75 if (size_t actn = this->isActive(dest_mesh->at(i))) {
76 return Tensor2<double>(0., 10. * this->active[actn - 1].height * this->getBeta(actn - 1) * abs(curr[i].vert()));
77 } else {
78 return cond[i];
79 }
80 });
81}
82
83template <> std::string BetaSolver<Geometry2DCartesian>::getClassName() const { return "electrical.Shockley2D"; }
84template <> std::string BetaSolver<Geometry2DCylindrical>::getClassName() const { return "electrical.ShockleyCyl"; }
85template <> std::string BetaSolver<Geometry3D>::getClassName() const { return "electrical.Shockley3D"; }
86
90
91}}} // namespace plask::electrical::shockley