PLaSK library
Loading...
Searching...
No Matches
rootdigger.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__OPTICAL_EFFECTIVE_ROOTDIGGER_H
15#define PLASK__OPTICAL_EFFECTIVE_ROOTDIGGER_H
16
17#include <functional>
18#include <plask/plask.hpp>
19
20namespace plask { namespace optical { namespace effective {
21
22struct RootDigger {
23
24 typedef std::function<dcomplex(dcomplex)> function_type;
25
32
33 struct Params {
35 double tolx,
39 int maxiter;
40 double alpha,
42 dcomplex initial_dist;
43 int stairs;
44
47 tolx(1e-6),
48 tolf_min(1e-7),
49 tolf_max(1e-5),
50 maxstep(0.1),
51 maxiter(500),
52 alpha(1e-7),
53 lambda_min(1e-8),
54 initial_dist(1e-3),
55 stairs(3)
56 {}
57 };
58
59 protected:
60
61 // Solver
63
64 // Solver method computing the value to zero
66
67 // Value writelog
69
70 inline dcomplex valFunction(dcomplex x) const {
71 try {
72 return val_function(x);
73 } catch (...) {
75 }
76 return NAN;
77 }
78
79 public:
80
81 // Rootdigger parameters
83
84 // Constructor
92
93 virtual ~RootDigger() {}
94
100 virtual dcomplex find(dcomplex start) const = 0;
101
109 static std::unique_ptr<RootDigger> get(Solver* solver, const function_type& func, DataLog<dcomplex,dcomplex>& detlog, const Params& params);
110
112 static void readRootDiggerConfig(XMLReader& reader, Params& params);
113};
114
115}}} // namespace plask::optical::effective
116
117#endif // PLASK__OPTICAL_EFFECTIVE_ROOTDIGGER_H