PLaSK library
Loading...
Searching...
No Matches
simplegaintest.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#define BOOST_TEST_DYN_LINK
15#define BOOST_TEST_MODULE "Simple gain test"
16#include <boost/test/unit_test.hpp>
17
18#include "../fermi.hpp"
19using namespace plask;
20using namespace plask::solvers::fermi;
21
22#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
23# define V "\\"
24#else
25# define V "/"
26#endif
27
28#if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32)
29namespace boost { namespace unit_test { namespace ut_detail {
31 return ( name[0] == '&' ? std::string(name.begin()+1, name.size()-1) : std::string(name.begin(), name.size() ));
32}
33}}}
34#endif
35
36struct TheSolver: public FermiGainSolver<Geometry2DCartesian>
37{
38 TheSolver(const std::string name=""): FermiGainSolver<Geometry2DCartesian>(name) {}
39
40 void detect_active_regions() { detectActiveRegions(); }
41};
42
44
46{
47 MaterialsDB::loadAllToDefault(prefixPath() + V ".." V ".." V ".." V "lib" V "plask" V "materials");
49
51
52 auto barrier = plask::make_shared<Block<2>>(Vec<2>(10., 5.), materials.get("GaAs"));
53 auto well = plask::make_shared<Block<2>>(Vec<2>(10., 7.), materials.get("In(0.3)GaAs"));
54 well->addRole("QW");
55
57 active1->addRole("active");
58 active1->push_front(barrier);
59 active1->push_front(well);
60 active1->push_front(barrier);
61
62 auto cladding1 = plask::make_shared<Block<2>>(Vec<2>(10., 20.), materials.get("Al(0.1)GaAs"));
63 auto cladding2 = plask::make_shared<Block<2>>(Vec<2>(10., 20.), materials.get("Al(0.1)GaAs"));
64
67 shelf1->push_back(nothing);
68 shelf1->push_back(active1);
69
71 active2->addRole("active");
72 active2->push_back(well);
73
74 stack->push_front(cladding2);
75 stack->push_front(active2);
76 stack->push_front(cladding1);
77 stack->push_front(active1);
78 stack->push_front(cladding2);
79 stack->push_front(shelf1);
80 stack->push_front(cladding1);
81
82 auto geometry = plask::make_shared<Geometry2DCartesian>(stack, 1000.);
83
84 TheSolver solver("gaintest");
85
86 solver.setGeometry(geometry);
87 solver.detect_active_regions();
88
89 BOOST_CHECK_EQUAL(solver.regions.size(), 3);
90 BOOST_CHECK_EQUAL(solver.regions[0].origin, Vec<2>(2., 20.));
91 BOOST_CHECK_EQUAL(solver.regions[1].origin, Vec<2>(0., 74.));
92
93 BOOST_CHECK_EQUAL(solver.regions[0].layers->getChildrenCount(), 5);
94 BOOST_CHECK_EQUAL(solver.regions[0].size(), 5);
95
96 std::vector<bool> qw = { false, true, false, true, false };
97 for (size_t i = 0; i < 5; ++i)
98 BOOST_CHECK_EQUAL(solver.regions[0].isQW(i), qw[i]);
99
100 BOOST_CHECK_EQUAL(solver.regions[0].getLayerMaterial(1), well->singleMaterial());
101 BOOST_CHECK_EQUAL(solver.regions[0].getLayerBox(1), Box2D(2., 25., 12., 32.));
102 BOOST_CHECK_EQUAL(solver.regions[0].getBoundingBox(), Box2D(2., 20., 12., 54.));
103 BOOST_CHECK_EQUAL(solver.regions[1].getLayerBox(1), Box2D(0., 79., 10., 86.));
104
105 BOOST_CHECK_EQUAL(solver.regions[2].size(), 3);
106 BOOST_CHECK_EQUAL(solver.regions[2].getLayerMaterial(0), cladding1->singleMaterial());
107 BOOST_CHECK_EQUAL(solver.regions[2].getLayerMaterial(2), cladding2->singleMaterial());
108}
109