PLaSK library
Loading...
Searching...
No Matches
broyden.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_BROYDEN_H
15
#define PLASK__OPTICAL_SLAB_BROYDEN_H
16
17
#include "
rootdigger.hpp
"
18
#include "
solver.hpp
"
19
20
namespace
plask
{
namespace
optical {
namespace
modal {
21
22
class
RootBroyden
:
public
RootDigger
{
23
24
// Parameters for Broyden algorithm
25
static
constexpr
double
EPS = 1
e6
*
SMALL
;
26
27
// Return Jacobian of F(x)
28
void
fdjac(dcomplex x, dcomplex
F
, dcomplex&
Jr
, dcomplex&
Ji
);
29
30
// Search for the new point x along direction p for which f decreased sufficiently
31
bool
lnsearch(dcomplex& x, dcomplex&
F
, dcomplex g, dcomplex p,
double
stpmax
);
32
33
// Search for the root of char_val using globally convergent Broyden method
34
dcomplex Broyden(dcomplex x);
35
36
// Write log message
37
template
<
typename
...
Args
>
38
void
writelog(
LogLevel
level,
const
std::string&
msg
,
Args
&&...
args
)
const
{
39
std::string prefix =
solver
.
getId
(); prefix +=
": "
; prefix +=
log_value
.
chartName
(); prefix +=
": "
;
40
plask::writelog
(level, prefix +
msg
, std::forward<Args>(
args
)...);
41
}
42
43
public
:
44
45
// Constructor
46
RootBroyden
(
ModalBase
&
solver
,
const
function_type
&
val_fun
,
const
Params
&
pars
,
const
char
* name):
47
RootDigger
(
solver
,
val_fun
,
pars
, name) {}
48
49
dcomplex
find
(dcomplex start)
override
;
50
};
51
52
}}}
// namespace plask::optical::modal
53
#endif
// PLASK__OPTICAL_SLAB_BROYDEN_H
solvers
optical
modal
broyden.hpp
Generated by
1.9.8