DFT-EFE
 
Loading...
Searching...
No Matches
RDM1Mixing.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2021. *
3 * The Regents of the University of Michigan and DFT-EFE developers. *
4 * *
5 * This file is part of the DFT-EFE code. *
6 * *
7 * DFT-EFE is free software: you can redistribute it and/or modify *
8 * it under the terms of the Lesser GNU General Public License as *
9 * published by the Free Software Foundation, either version 3 of *
10 * the License, or (at your option) any later version. *
11 * *
12 * DFT-EFE is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15 * See the Lesser GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License at the top level of DFT-EFE distribution. If not, see *
19 * <https://www.gnu.org/licenses/>. *
20 ******************************************************************************/
21
22/*
23 * @author Avirup Sircar
24 */
25
26#ifndef dftefe_RDM1Mixing_h
27#define dftefe_RDM1Mixing_h
28
29#include <vector>
30#include <set>
31#include <unordered_map>
32#include <memory>
33#include <functional>
34
35#include <ksdft/RDM1.h>
36#include <ksdft/MixingScheme.h>
37#include <utils/MemoryStorage.h>
40
41namespace dftefe
42{
43 namespace ksdft
44 {
61 template <typename ValueType, dftefe::utils::MemorySpace memorySpace>
62 class RDM1Mixing : public RDM1<ValueType, memorySpace>
63 {
64 public:
67
68 public:
84 const size_type mixingHistory,
85 const std::vector<RealType> & jxwDataHost,
86 const double mixingParameter,
87 const bool isAdaptiveMixingParameter,
88 std::shared_ptr<
90 linAlgOpContextHost,
91 const MPI_Comm &mpiCommDomain);
92
93 virtual ~RDM1Mixing() = default;
94
98 void
99 setRDM1(std::shared_ptr<RDM1<ValueType, memorySpace>> rdm1);
100
102 getRDM1() const;
103
110 void
111 mix();
112
113 // ---- RDM1 interface ------------------------------------------------
114
118 void
120 const std::set<DensityDescrAttr> & densityAttrs,
121 const std::set<WfcDescrAttr> & wfcAttrs,
122 std::unordered_map<DensityDescrAttr, AttrStorage> &densityAttrVals,
123 std::unordered_map<WfcDescrAttr, AttrStorage> &wfcAttrVals) override;
124
125 void
126 setDescriptors(const std::unordered_map<DensityDescrAttr, AttrStorage>
127 &densityAttrVals,
128 const std::unordered_map<WfcDescrAttr, AttrStorage>
129 &wfcAttrVals) override;
130
131 void
133 const std::set<DensityObsAttr> &densityObsAttrs,
134 std::unordered_map<DensityObsAttr, std::vector<std::vector<double>>>
135 &densityObsAttrVals) override;
136
137 void
138 setEvalDescrFlag(const bool evalFlag) override;
139 bool
140 isSpinPolarized() const override;
141 bool
142 isNonCollinear() const override;
143 bool
144 isSOC() const override;
146 getnKSOrbs() const override;
147 std::vector<double>
148 getkPointCoords() const override;
149 std::vector<double>
150 getkPointWeights() const override;
151 std::unique_ptr<RDM1<ValueType, memorySpace>>
152 clone() const override;
153
154 private:
155 std::weak_ptr<RDM1<ValueType, memorySpace>> d_rdm1Ptr;
156
160 std::shared_ptr<linearAlgebra::LinAlgOpContext<utils::MemorySpace::HOST>>
162 std::reference_wrapper<const MPI_Comm> d_mpiCommDomain;
163
166 };
167
168 } // namespace ksdft
169} // namespace dftefe
170#include "RDM1Mixing.t.cpp"
171#endif // dftefe_RDM1Mixing_h
This class performs the anderson mixing in a variable agnostic way This class takes can take differen...
Definition: MixingScheme.h:72
RDM1 implementation that performs Anderson mixing of the electron density. Derives directly from RDM1...
Definition: RDM1Mixing.h:63
bool isSOC() const override
Definition: RDM1Mixing.t.cpp:249
MixingScheme< RealType, RealType > & d_mixingScheme
Definition: RDM1Mixing.h:157
bool isNonCollinear() const override
Definition: RDM1Mixing.t.cpp:238
AttrStorage d_gradDensityInAttrVals
Definition: RDM1Mixing.h:165
void setRDM1(std::shared_ptr< RDM1< ValueType, memorySpace > > rdm1)
Store rdm1 as a weak_ptr (non-owning).
Definition: RDM1Mixing.t.cpp:62
std::shared_ptr< linearAlgebra::LinAlgOpContext< utils::MemorySpace::HOST > > d_linAlgOpContextHost
Definition: RDM1Mixing.h:161
void getDensityObs(const std::set< DensityObsAttr > &densityObsAttrs, std::unordered_map< DensityObsAttr, std::vector< std::vector< double > > > &densityObsAttrVals) override
Definition: RDM1Mixing.t.cpp:207
std::weak_ptr< RDM1< ValueType, memorySpace > > d_rdm1Ptr
Definition: RDM1Mixing.h:155
size_type d_numElectrons
Definition: RDM1Mixing.h:159
const RDM1< ValueType, memorySpace > & getRDM1() const
Definition: RDM1Mixing.t.cpp:70
std::vector< double > getkPointWeights() const override
Definition: RDM1Mixing.t.cpp:282
void getDescriptors(const std::set< DensityDescrAttr > &densityAttrs, const std::set< WfcDescrAttr > &wfcAttrs, std::unordered_map< DensityDescrAttr, AttrStorage > &densityAttrVals, std::unordered_map< WfcDescrAttr, AttrStorage > &wfcAttrVals) override
Returns d_densityInAttrVals (the last mixed in-density).
Definition: RDM1Mixing.t.cpp:175
std::vector< double > getkPointCoords() const override
Definition: RDM1Mixing.t.cpp:271
linearAlgebra::blasLapack::real_type< ValueType > RealType
Definition: RDM1Mixing.h:65
virtual ~RDM1Mixing()=default
std::unique_ptr< RDM1< ValueType, memorySpace > > clone() const override
Definition: RDM1Mixing.t.cpp:293
void mix()
Execute the Anderson mixing pipeline using the stored d_rdm1Ptr. On the first call d_densityInAttrVal...
Definition: RDM1Mixing.t.cpp:81
bool isSpinPolarized() const override
Definition: RDM1Mixing.t.cpp:227
void setEvalDescrFlag(const bool evalFlag) override
Definition: RDM1Mixing.t.cpp:221
void setDescriptors(const std::unordered_map< DensityDescrAttr, AttrStorage > &densityAttrVals, const std::unordered_map< WfcDescrAttr, AttrStorage > &wfcAttrVals) override
Definition: RDM1Mixing.t.cpp:193
size_type d_mixingHistory
Definition: RDM1Mixing.h:158
typename RDM1< ValueType, memorySpace >::AttrStorage AttrStorage
Definition: RDM1Mixing.h:66
size_type getnKSOrbs() const override
Definition: RDM1Mixing.t.cpp:260
std::reference_wrapper< const MPI_Comm > d_mpiCommDomain
Definition: RDM1Mixing.h:162
AttrStorage d_densityInAttrVals
Definition: RDM1Mixing.h:164
Abstract class for the one-particle reduced density matrix.
Definition: RDM1.h:52
std::vector< dftefe::quadrature::QuadratureValuesContainer< double, dftefe::utils::MemorySpace::HOST > > AttrStorage
Definition: RDM1.h:59
Definition: LinAlgOpContext.h:52
DensityObsAttr
Definition: KSAttributes.h:48
typeInternal::real_type< ValueType > real_type
Definition: BlasLapackTypedef.h:177
dealii includes
Definition: AtomFieldDataSpherical.cpp:31
std::uint64_t size_type
Definition: TypeConfig.h:9