PLaSK library
Loading...
Searching...
No Matches
mixed.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 "mixed.hpp"
15
16namespace plask {
17
18//------------ MixedMaterial -------------------------
19
21
23 double sum = 0;
24 for (auto& p: materials) sum += std::get<1>(p);
25 for (auto& p: materials) std::get<1>(p) /= sum;
26}
27
28MixedMaterial & MixedMaterial::add(const shared_ptr<plask::Material> &material, double weight) {
29 materials.push_back(std::pair<shared_ptr<Material>,double>(material, weight));
30 return *this;
31}
32
33std::string MixedMaterial::name() const {
34 std::string result = "[";
35 for (auto i = materials.begin(); i != materials.end(); ++i) {
36 if (i != materials.begin()) result += '+';
37 result += boost::lexical_cast<std::string>(std::get<1>(*i));
38 result += '*';
39 result += std::get<0>(*i)->name();
40 }
41 result += ']';
42 return result;
43}
44
45double MixedMaterial::A(double T) const {
46 return avg([&](const Material& m) { return m.A(T); });
47}
48
49double MixedMaterial::absp(double lam, double T) const {
50 return avg([&](const Material& m) { return m.absp(lam, T); });
51}
52
53double MixedMaterial::B(double T) const {
54 return avg([&](const Material& m) { return m.B(T); });
55}
56
57double MixedMaterial::C(double T) const {
58 return avg([&](const Material& m) { return m.C(T); });
59}
60
61double MixedMaterial::CB(double T, double e, char point) const {
62 return avg([&](const Material& m) { return m.CB(T, e, point); });
63}
64
65double MixedMaterial::chi(double T, double e, char point) const {
66 return avg([&](const Material& m) { return m.chi(T, e, point); });
67}
68
70 return avg_pairs([&](const Material& m) { return m.cond(T); });
71}
72
74 if (materials.size() == 0) return CONDUCTIVITY_UNDETERMINED;
75 Material::ConductivityType result = materials[0].first->condtype();
76 for(auto mat = materials.begin()+1; mat != materials.end(); ++mat)
77 if (mat->first->condtype() != result) return CONDUCTIVITY_UNDETERMINED;
78 return result;
79}
80
81double MixedMaterial::D(double T) const {
82 return avg([&](const Material& m) { return m.D(T); });
83}
84
85double MixedMaterial::dens(double T) const {
86 return avg([&](const Material& m) { return m.dens(T); });
87}
88
89double MixedMaterial::Dso(double T, double e) const {
90 return avg([&](const Material& m) { return m.Dso(T, e); });
91}
92
93double MixedMaterial::EactA(double T) const {
94 return avg([&](const Material& m) { return m.EactA(T); });
95}
96double MixedMaterial::EactD(double T) const {
97 return avg([&](const Material& m) { return m.EactD(T); });
98}
99
100double MixedMaterial::Eg(double T, double e, char point) const {
101 return avg([&](const Material& m) { return m.Eg(T, e, point); });
102}
103
104double MixedMaterial::eps(double T) const {
105 return avg([&](const Material& m) { return m.eps(T); });
106}
107
108double MixedMaterial::lattC(double T, char x) const {
109 return avg([&](const Material& m) { return m.lattC(T, x); });
110}
111
112Tensor2<double> MixedMaterial::Me(double T, double e, char point) const {
113 return avg_pairs([&](const Material& m) { return m.Me(T, e, point); });
114}
115
116Tensor2<double> MixedMaterial::Mh(double T, double e) const {
117 return avg_pairs([&](const Material& m) { return m.Mh(T, e); });
118}
119
120Tensor2<double> MixedMaterial::Mhh(double T, double e) const {
121 return avg_pairs([&](const Material& m) { return m.Mhh(T, e); });
122}
123
124Tensor2<double> MixedMaterial::Mlh(double T, double e) const {
125 return avg_pairs([&](const Material& m) { return m.Mlh(T, e); });
126}
127
128double MixedMaterial::ac(double T) const {
129 return avg([&](const Material& m) { return m.ac(T); });
130}
131
132double MixedMaterial::av(double T) const {
133 return avg([&](const Material& m) { return m.av(T); });
134}
135
136double MixedMaterial::b(double T) const {
137 return avg([&](const Material& m) { return m.b(T); });
138}
139
140double MixedMaterial::d(double T) const {
141 return avg([&](const Material& m) { return m.d(T); });
142}
143
144double MixedMaterial::c11(double T) const {
145 return avg([&](const Material& m) { return m.c11(T); });
146}
147
148double MixedMaterial::c12(double T) const {
149 return avg([&](const Material& m) { return m.c12(T); });
150}
151
152double MixedMaterial::c44(double T) const {
153 return avg([&](const Material& m) { return m.c44(T); });
154}
155
157 return avg_pairs([&](const Material& m) { return m.mob(T); });
158}
159
160double MixedMaterial::Mso(double T, double e) const {
161 return avg([&](const Material& m) { return m.Mso(T, e); });
162}
163
164double MixedMaterial::Nf(double T) const {
165 return avg([&](const Material& m) { return m.Nf(T); });
166}
167
168double MixedMaterial::Ni(double T) const {
169 return avg([&](const Material& m) { return m.Ni(T); });
170}
171
172double MixedMaterial::nr(double lam, double T, double n) const {
173 return avg([&](const Material& m) { return m.nr(lam, T, n); });
174}
175
176dcomplex MixedMaterial::Nr(double lam, double T, double n) const {
177 return avg([&](const Material& m) { return m.Nr(lam, T, n); });
178}
179
180Tensor3<dcomplex> MixedMaterial::Eps(double lam, double T, double n) const {
182 result.c00 = avg([&](const Material& m) { return m.Eps(lam, T, n).c00; });
183 result.c11 = avg([&](const Material& m) { return m.Eps(lam, T, n).c11; });
184 result.c22 = avg([&](const Material& m) { return m.Eps(lam, T, n).c22; });
185 result.c01 = avg([&](const Material& m) { return m.Eps(lam, T, n).c01; });
186 result.c10 = avg([&](const Material& m) { return m.Eps(lam, T, n).c10; });
187 result.c02 = avg([&](const Material& m) { return m.Eps(lam, T, n).c02; });
188 result.c20 = avg([&](const Material& m) { return m.Eps(lam, T, n).c20; });
189 result.c12 = avg([&](const Material& m) { return m.Eps(lam, T, n).c12; });
190 result.c21 = avg([&](const Material& m) { return m.Eps(lam, T, n).c21; });
191 return result;
192}
193
194double MixedMaterial::cp(double T) const {
195 return avg([&](const Material& m) { return m.cp(T); });
196}
197
198Tensor2<double> MixedMaterial::thermk(double T, double h) const {
199 return avg_pairs([&](const Material& m) { return m.thermk(T, h); });
200}
201
202double MixedMaterial::VB(double T, double e, char point, char hole) const {
203 return avg([&](const Material& m) { return m.VB(T, e, point, hole); });
204}
205
206
208 return avg_pairs([&](const Material& m) { return m.mobe(T); });
209}
210
212 return avg_pairs([&](const Material& m) { return m.mobh(T); });
213}
214
215double MixedMaterial::taue(double T) const {
216 return avg([&](const Material& m) { return m.taue(T); });
217}
218
219double MixedMaterial::tauh(double T) const {
220 return avg([&](const Material& m) { return m.tauh(T); });
221}
222
223double MixedMaterial::Ce(double T) const {
224 return avg([&](const Material& m) { return m.Ce(T); });
225}
226
227double MixedMaterial::Ch(double T) const {
228 return avg([&](const Material& m) { return m.Ch(T); });
229}
230
231double MixedMaterial::e13(double T) const {
232 return avg([&](const Material& m) { return m.e13(T); });
233}
234
235double MixedMaterial::e15(double T) const {
236 return avg([&](const Material& m) { return m.e15(T); });
237}
238
239double MixedMaterial::e33(double T) const {
240 return avg([&](const Material& m) { return m.e33(T); });
241}
242
243double MixedMaterial::c13(double T) const {
244 return avg([&](const Material& m) { return m.c13(T); });
245}
246
247double MixedMaterial::c33(double T) const {
248 return avg([&](const Material& m) { return m.c33(T); });
249}
250
251double MixedMaterial::Psp(double T) const {
252 return avg([&](const Material& m) { return m.Psp(T); });
253}
254
255double MixedMaterial::Na() const {
256 return avg([&](const Material& m) { return m.Na(); });
257}
258
259double MixedMaterial::Nd() const {
260 return avg([&](const Material& m) { return m.Nd(); });
261}
262
263
264bool Material::isEqual(const Material &other) const {
265 return this->str() == other.str();
266}
267
268} // namespace plask