19 typedef std::pair<vector_complex_function_3d,vector_complex_function_3d>
pairvecT;
59 vm.insert(vm.end(), bwfs_old.begin(), bwfs_old.end());
71 for (
int s=0; s<
m; s++)
75 for (
unsigned int i=0; i<vm.size(); i++)
77 ms[s] += vm[i].inner_local(rs[i]);
78 sm[s] += vs[i].inner_local(rm[i]);
81 world.gop.sum(ms.ptr(),
m);
82 world.gop.sum(sm.ptr(),
m);
85 if (
m > 1) newQ(Slice(0,-2),Slice(0,-2)) =
_Q;
90 if (world.rank() == 0)
print(
_Q);
94 if (world.rank() == 0) {
98 if (
abs(
c[
m-1]) < 3.0) {
101 else if (rcond < 0.01) {
102 if (world.rank() == 0)
103 print(
"Increasing subspace singular value threshold ",
c[
m-1], rcond);
107 if (world.rank() == 0)
108 print(
"Forcing full step due to subspace malfunction");
116 world.gop.broadcast_serializable(
c, 0);
117 if (world.rank() == 0) {
118 print(
"Subspace solution",
c);
124 std::complex<double> one = std::complex<double>(1.0,0.0);
133 gaxpy(world, one, phisa_new,
c(
m), vma,
false);
134 gaxpy(world, one, phisa_new,-
c(
m), rma,
false);
135 gaxpy(world, one, phisb_new,
c(
m), vmb,
false);
136 gaxpy(world, one, phisb_new,-
c(
m), rmb,
false);
147 _Q =
_Q(Slice(1,-1),Slice(1,-1));
149 awfs_new = phisa_new;
150 bwfs_new = phisb_new;
172 for (
int s=0; s<
m; s++)
176 for (
unsigned int i=0; i<vm.size(); i++)
178 ms[s] += vm[i].inner_local(rs[i]);
179 sm[s] += vs[i].inner_local(rm[i]);
182 world.gop.sum(ms.ptr(),
m);
183 world.gop.sum(sm.ptr(),
m);
186 if (
m > 1) newQ(Slice(0,-2),Slice(0,-2)) =
_Q;
191 if (world.rank() == 0)
print(
_Q);
195 if (world.rank() == 0) {
196 double rcond = 1
e-12;
199 if (
abs(
c[
m-1]) < 3.0) {
202 else if (rcond < 0.01) {
203 if (world.rank() == 0)
204 print(
"Increasing subspace singular value threshold ",
c[
m-1], rcond);
208 if (world.rank() == 0)
209 print(
"Forcing full step due to subspace malfunction");
217 world.gop.broadcast_serializable(
c, 0);
218 if (world.rank() == 0) {
219 print(
"Subspace solution",
c);
224 std::complex<double> one = std::complex<double>(1.0,0.0);
231 gaxpy(world, one, phisa_new,
c(
m), vma,
false);
232 gaxpy(world, one, phisa_new,-
c(
m), rma,
false);
243 _Q =
_Q(Slice(1,-1),Slice(1,-1));
245 awfs_new = phisa_new;
The Subspace class is a container class holding previous orbitals and residuals.
Definition: subspace.h:17
bool _spinpol
Definition: subspace.h:31
void reproject()
Definition: subspace.h:250
int _maxsub
Definition: subspace.h:35
void update_subspace(World &world, vector_complex_function_3d &awfs_new, const vector_complex_function_3d &awfs_old, const vector_complex_function_3d &rm)
Definition: subspace.h:155
subspaceT _subspace
Definition: subspace.h:27
std::pair< vector_complex_function_3d, vector_complex_function_3d > pairvecT
Definition: subspace.h:19
std::vector< pairvecT > subspaceT
Definition: subspace.h:20
tensor_complex _Q
Definition: subspace.h:23
Subspace(bool spinpol=false, int maxsub=4)
Definition: subspace.h:41
void update_subspace(World &world, vector_complex_function_3d &awfs_new, vector_complex_function_3d &bwfs_new, const vector_complex_function_3d &awfs_old, const vector_complex_function_3d &bwfs_old, const vector_complex_function_3d &rm)
Definition: subspace.h:48
const double m
Definition: gfit.cc:199
Tensor< T > KAIN(const Tensor< T > &Q)
Solves the KAIN equations for coefficients to compute the next vector.
Definition: kain.cc:60
void print(const tensorT &t)
Definition: mcpfit.cc:140
std::vector< complex_function_3d > vector_complex_function_3d
Definition: functypedefs.h:86
double abs(double x)
Definition: complexfun.h:48
void compress(World &world, const std::vector< Function< T, NDIM > > &v, bool fence=true)
Compress a vector of functions.
Definition: vmra.h:133
static const Slice _(0,-1, 1)
Tensor< double_complex > tensor_complex
Definition: functypedefs.h:44
void gaxpy(const double a, ScalarResult< T > &left, const double b, const T &right, const bool fence=true)
the result type of a macrotask must implement gaxpy
Definition: macrotaskq.h:140
static const double c
Definition: relops.cc:10
void e()
Definition: test_sig.cc:75