forked from kostrzewa/tmLQCD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eigenvalues_bi.c
156 lines (138 loc) · 4.73 KB
/
eigenvalues_bi.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/***********************************************************************
* Copyright (C) 2002,2003,2004,2005,2006,2007,2008 Carsten Urbach
*
* This file is part of tmLQCD.
*
* tmLQCD is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* tmLQCD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with tmLQCD. If not, see <http://www.gnu.org/licenses/>.
*
* Here we compute the nr_of_eigenvalues lowest eigenvalues
* of (gamma5*D)^2. Therefore we use the arnoldi routines.
*
* The computed eigenvalues are stored in g_eigenvalues
* and the computed eigenvectors in g_ev
*
* inout:
* nr_of_eigenvalues: input: Number of eigenvalues to compute
* output: Number of computed eigenvalues
* input:
* crylov_space_dimension: Dimension of crylov space dimension
* to be used in the arnoldi routines
*
* Autor: Thomas Chiarappa
*
*******************************************************************************/
#ifdef HAVE_CONFIG_H
# include<config.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#ifdef MPI
# include <mpi.h>
#endif
#include "global.h"
#include "su3.h"
#include "linalg_eo.h"
#include "start.h"
#include "tm_operators.h"
#include "solver/solver.h"
#include "solver/jdher_bi.h"
#include "eigenvalues_bi.h"
#include "Nondegenerate_Matrix.h"
double eigenvalues_bi(int * nr_of_eigenvalues,
const int max_iterations, const double precision,
const int maxmin) {
static bispinor * eigenvectors_bi_ = NULL;
static int allocated = 0;
static bispinor *eigenvectors_bi = NULL;
static double * eigenvls_bi = NULL;
/**********************
* For Jacobi-Davidson
**********************/
int verbosity = g_debug_level, converged = 0, blocksize = 1, blockwise = 0;
int solver_it_max = 200, j_max, j_min;
double decay_min = 1.7, decay_max = 1.5, prec,
threshold_min = 1.e-3, threshold_max = 5.e-2,
startvalue, threshold, decay, returnvalue;
int v0dim = 0;
/**********************
* General variables
**********************/
int returncode=0;
char * filename = NULL;
filename = calloc(200, sizeof(char));
/* strcpy(filename,optarg);*/
if(maxmin == JD_MINIMAL) {
startvalue = 0.;
threshold = threshold_min;
decay = decay_min;
solver_it_max = 200;
}
else {
startvalue = 50.;
threshold = threshold_max;
decay = decay_max;
solver_it_max = 50;
}
if(g_proc_id == g_stdio_proc) {
printf("Number of %s eigenvalues to compute = %d\n",
maxmin ? "maximal" : "minimal",(*nr_of_eigenvalues));
printf("Using Jacobi-Davidson method! \n");
}
if((*nr_of_eigenvalues) < 8){
j_max = 15;
j_min = 8;
}
else{
j_max = 2*(*nr_of_eigenvalues);
j_min = *nr_of_eigenvalues;
}
if(precision < 1.e-14){
prec = 1.e-14;
}
else{
prec = precision;
}
if(allocated == 0) {
allocated = 1;
#if (defined SSE || defined SSE2 || defined SSE3)
eigenvectors_bi_ = calloc((VOLUME)/2*(*nr_of_eigenvalues)+1, sizeof(bispinor));
eigenvectors_bi = (bispinor *)(((unsigned long int)(eigenvectors_bi_)+ALIGN_BASE)&~ALIGN_BASE);
#else
eigenvectors_bi_= calloc((VOLUME)/2*(*nr_of_eigenvalues), sizeof(bispinor));
eigenvectors_bi = eigenvectors_bi_;
#endif
eigenvls_bi = (double*)malloc((*nr_of_eigenvalues)*sizeof(double));
}
/* compute eigenvalues */
if((g_proc_id==0) && (g_debug_level > 4)) {
printf(" Values of mu = %e mubar = %e eps = %e precision = %e \n \n", g_mu, g_mubar, g_epsbar, precision);
}
/* here n and lda are equal, because Q_Qdagger_ND_BI does an internal */
/* conversion to non _bi fields which are subject to xchange_fields */
/* so _bi fields do not need boundary */
jdher_bi((VOLUME)/2*sizeof(bispinor)/sizeof(_Complex double), (VOLUME)/2*sizeof(bispinor)/sizeof(_Complex double),
startvalue, prec,
(*nr_of_eigenvalues), j_max, j_min,
max_iterations, blocksize, blockwise, v0dim, (_Complex double*) eigenvectors_bi,
BICGSTAB, solver_it_max,
threshold, decay, verbosity,
&converged, (_Complex double*) eigenvectors_bi, eigenvls_bi,
&returncode, maxmin, 1,
&Q_Qdagger_ND_BI);
*nr_of_eigenvalues = converged;
returnvalue = eigenvls_bi[0];
return(returnvalue);
}