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_SLAB_ROOTDIGGER_H
15
#define PLASK__OPTICAL_SLAB_ROOTDIGGER_H
16
17
#include <functional>
18
#include <
plask/plask.hpp
>
19
20
namespace
plask
{
namespace
optical {
namespace
modal {
21
22
struct
ModalBase;
23
24
struct
RootDigger
{
25
26
typedef
std::function<dcomplex(dcomplex)>
function_type
;
27
29
enum
Method
{
30
ROOT_MULLER
,
31
ROOT_BROYDEN
,
32
ROOT_BRENT
33
};
34
35
struct
Params
{
36
Method
method
;
37
double
tolx
,
38
tolf_min
,
39
tolf_max
,
40
maxstep
;
41
int
maxiter
;
42
double
alpha
,
43
lambda_min
;
44
dcomplex
initial_dist
;
45
46
Params
():
47
method
(
ROOT_MULLER
),
48
tolx
(1
e
-6),
49
tolf_min
(1
e
-7),
50
tolf_max
(1
e
-5),
51
maxstep
(0.1),
52
maxiter
(500),
53
alpha
(1
e
-7),
54
lambda_min
(1
e
-8),
55
initial_dist
(1
e
-3) {}
56
};
57
58
protected
:
59
60
// Write log message
61
template
<
typename
...
Args
>
62
void
writelog
(
LogLevel
level,
const
std::string&
msg
,
Args
&&...
args
)
const
;
63
64
// Solver
65
ModalBase
&
solver
;
66
67
// Solver method computing the value to zero
68
function_type
val_function
;
69
70
// Value writelog
71
DataLog<dcomplex,dcomplex>
log_value
;
72
73
inline
dcomplex
valFunction
(dcomplex x)
const
{
74
try
{
75
return
val_function
(x);
76
}
catch
(...) {
77
log_value
.
throwError
(x);
78
}
79
return
NAN
;
80
}
81
82
public
:
83
84
// Rootdigger parameters
85
Params
params
;
86
87
// Constructor
88
RootDigger
(
ModalBase
&
solver
,
const
function_type
&
val_fun
,
const
Params
&
pars
,
const
char
* name);
89
90
virtual
~RootDigger
() {}
91
97
virtual
dcomplex
find
(dcomplex start) = 0;
98
};
99
100
}}}
// namespace plask::optical::modal
101
102
#endif
// PLASK__OPTICAL_SLAB_ROOTDIGGER_H
solvers
optical
modal
rootdigger.hpp
Generated by
1.9.8