Quantum 3xplorer (Q3)
Loading...
Searching...
No Matches
factory.hpp
Go to the documentation of this file.
1
#pragma once
2
3
/**
4
* MixerFactory — creates charge-density mixer instances by name.
5
*
6
* Supported mixers:
7
* - "broyden" G-space quasi-Newton (default). Best for insulators and semiconductors.
8
* - "linear" Simple linear (plain) mixing in G-space. Unconditionally stable;
9
* recommended for metallic US systems where Broyden may diverge.
10
* - "anderson" Real-space Pulay/DIIS mixing.
11
*
12
* All mixers accept mixing_parameter and history_depth (unused for linear).
13
*/
14
15
#include <memory>
16
#include <stdexcept>
17
#include <string>
18
19
#include "
layer_4_computation/iterator/internal/mixing/real_space/anderson.hpp
"
20
#include "
layer_4_computation/iterator/internal/mixing/reciprocal_space/broyden.hpp
"
21
#include "
layer_4_computation/iterator/internal/mixing/reciprocal_space/linear.hpp
"
22
23
namespace
q3
{
24
namespace
MixerFactory {
25
26
/// Create a charge density mixer by name ("broyden", "linear", or "anderson").
27
inline
std::unique_ptr<Mixer>
28
create
(
const
std::string& mode,
Real
mixing_parameter = 0.7,
int
history_depth = 8) {
29
if
(mode ==
"broyden"
) {
30
return
std::make_unique<BroydenMixer>(mixing_parameter, history_depth);
31
}
32
if
(mode ==
"linear"
) {
33
return
std::make_unique<LinearMixer>(mixing_parameter);
34
}
35
if
(mode ==
"anderson"
) {
36
return
std::make_unique<AndersonMixer>(mixing_parameter, history_depth);
37
}
38
throw
std::runtime_error(
"Unknown mixer mode: '"
+ mode +
39
"'. Supported values: 'broyden', 'linear', 'anderson'."
);
40
}
41
42
}
// namespace MixerFactory
43
}
// namespace q3
anderson.hpp
broyden.hpp
linear.hpp
q3::MixerFactory::create
std::unique_ptr< Mixer > create(const std::string &mode, Real mixing_parameter=0.7, int history_depth=8)
Create a charge density mixer by name ("broyden", "linear", or "anderson").
Definition
factory.hpp:28
q3
Definition
q3_core_api.hpp:33
q3::Real
double Real
Definition
type_aliases.hpp:20
src
layer_4_computation
iterator
internal
mixing
factory.hpp
Generated by
1.9.8