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 {
62 template <typename ValueType, dftefe::utils::MemorySpace memorySpace>
63 class RDM1Mixing : public RDM1<ValueType, memorySpace>
64 {
65 public:
68
69 public:
93 const size_type mixingHistory,
94 const std::vector<RealType> & jxwDataHost,
95 const double mixingParameter,
96 const bool isAdaptiveMixingParameter,
97 const double spinMixingEnhancementFactor,
98 const SpinMode spinMode,
99 const std::string & xcType,
100 std::shared_ptr<
102 linAlgOpContextHost,
103 const MPI_Comm &mpiCommDomain);
104
105 virtual ~RDM1Mixing() = default;
106
110 void
111 setRDM1(std::shared_ptr<RDM1<ValueType, memorySpace>> rdm1);
112
114 getRDM1() const;
115
124 void
125 mix();
126
127 // ---- RDM1 interface ------------------------------------------------
128
132 void
134 const std::set<DensityDescrAttr> & densityAttrs,
135 const std::set<WfcDescrAttr> & wfcAttrs,
136 std::unordered_map<DensityDescrAttr, AttrStorage> &densityAttrVals,
137 std::unordered_map<WfcDescrAttr, AttrStorage> &wfcAttrVals) override;
138
139 void
140 setDescriptors(const std::unordered_map<DensityDescrAttr, AttrStorage>
141 &densityAttrVals,
142 const std::unordered_map<WfcDescrAttr, AttrStorage>
143 &wfcAttrVals) override;
144
145 void
147 const std::set<DensityObsAttr> &densityObsAttrs,
148 std::unordered_map<DensityObsAttr, std::vector<std::vector<double>>>
149 &densityObsAttrVals) override;
150
151 void
152 setEvalDescrFlag(const bool evalFlag) override;
154 spinMode() const override;
155 bool
156 isSOC() const override;
158 getnKSOrbs() const override;
159 std::vector<double>
160 getkPointCoords() const override;
161 std::vector<double>
162 getkPointWeights() const override;
163 std::unique_ptr<RDM1<ValueType, memorySpace>>
164 clone() const override;
165
166 private:
167 std::weak_ptr<RDM1<ValueType, memorySpace>> d_rdm1Ptr;
168
172 std::shared_ptr<linearAlgebra::LinAlgOpContext<utils::MemorySpace::HOST>>
174 std::reference_wrapper<const MPI_Comm> d_mpiCommDomain;
175
178 };
179
180 } // namespace ksdft
181} // namespace dftefe
182#include "RDM1Mixing.t.cpp"
183#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:64
bool isSOC() const override
Definition: RDM1Mixing.t.cpp:306
MixingScheme< RealType, RealType > & d_mixingScheme
Definition: RDM1Mixing.h:169
AttrStorage d_gradDensityInAttrVals
Definition: RDM1Mixing.h:177
void setRDM1(std::shared_ptr< RDM1< ValueType, memorySpace > > rdm1)
Store rdm1 as a weak_ptr (non-owning).
Definition: RDM1Mixing.t.cpp:122
std::shared_ptr< linearAlgebra::LinAlgOpContext< utils::MemorySpace::HOST > > d_linAlgOpContextHost
Definition: RDM1Mixing.h:173
void getDensityObs(const std::set< DensityObsAttr > &densityObsAttrs, std::unordered_map< DensityObsAttr, std::vector< std::vector< double > > > &densityObsAttrVals) override
Definition: RDM1Mixing.t.cpp:275
SpinMode spinMode() const override
Definition: RDM1Mixing.t.cpp:295
std::weak_ptr< RDM1< ValueType, memorySpace > > d_rdm1Ptr
Definition: RDM1Mixing.h:167
size_type d_numElectrons
Definition: RDM1Mixing.h:171
const RDM1< ValueType, memorySpace > & getRDM1() const
Definition: RDM1Mixing.t.cpp:130
std::vector< double > getkPointWeights() const override
Definition: RDM1Mixing.t.cpp:339
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:243
std::vector< double > getkPointCoords() const override
Definition: RDM1Mixing.t.cpp:328
linearAlgebra::blasLapack::real_type< ValueType > RealType
Definition: RDM1Mixing.h:66
virtual ~RDM1Mixing()=default
std::unique_ptr< RDM1< ValueType, memorySpace > > clone() const override
Definition: RDM1Mixing.t.cpp:350
void mix()
Execute the Anderson mixing pipeline using the stored d_rdm1Ptr. Computes residual = densOut - d_dens...
Definition: RDM1Mixing.t.cpp:141
void setEvalDescrFlag(const bool evalFlag) override
Definition: RDM1Mixing.t.cpp:289
void setDescriptors(const std::unordered_map< DensityDescrAttr, AttrStorage > &densityAttrVals, const std::unordered_map< WfcDescrAttr, AttrStorage > &wfcAttrVals) override
Definition: RDM1Mixing.t.cpp:261
size_type d_mixingHistory
Definition: RDM1Mixing.h:170
typename RDM1< ValueType, memorySpace >::AttrStorage AttrStorage
Definition: RDM1Mixing.h:67
size_type getnKSOrbs() const override
Definition: RDM1Mixing.t.cpp:317
std::reference_wrapper< const MPI_Comm > d_mpiCommDomain
Definition: RDM1Mixing.h:174
AttrStorage d_densityInAttrVals
Definition: RDM1Mixing.h:176
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
SpinMode
Definition: KSAttributes.h:55
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