-
Notifications
You must be signed in to change notification settings - Fork 0
/
BEC_Groundstate.cpp
executable file
·75 lines (60 loc) · 1.71 KB
/
BEC_Groundstate.cpp
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
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <climits>
#include <iterator>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/io.hpp>
using namespace std;
using namespace boost::numeric::ublas;
extern "C" void dsyev_(char* jobz, char* uplo,int* n,double* a,int* lda,double* w ,double*
work, int* lwork, int* info);
typedef complex<double> cmpl;
typedef boost::numeric::ublas::vector<double> Vector;
typedef std::vector<double> StlVec;
int main (){
const double pi = 4*atan(1.0);
double L = 10.;
int N = 1024;
const double q = pi*40./L;
double deltax = L/double(N);
double g=0;
std::vector<double> eigen(N);
Vector data(N);
for(size_t i = 0; i<N; ++i){
double xpos =L*0.5-double(i)*L/double(N);
data[i]=1./sqrt(2*pi)*exp(-xpos*xpos/2.);
}
matrix<double> H(N,N);
for(size_t i=0; i<H.size1();++i){
double q = pi*40/L;
double xpos =L*0.5-double(i)*L/double(N);
double sinx =sin(q*xpos);
for(size_t j=0; j<H.size2();++j){
H(i,j)=(i==j?1/(deltax*deltax)+g*data[i]*data[i]+xpos*xpos*0.5+q*q*0.5*sinx*sinx
:((i==j-1) || (i==j+1)? -0.5/(deltax*deltax):0) );
}
}
//std::cout<<H;
char jobz = 'V';
char uplo = 'U';
int n = H.size1();
//double* A = new double[];
//A=m;
int lda = n;
int lwork = 3*n-1;
double* work = new double[lwork];
int info=2313;
dsyev_(&jobz, &uplo, &n, &H(0,0), &lda, &eigen[0], work, &lwork, &info);
//copy(eigen.begin(), eigen.end(), ostream_iterator<double>(cout,"\n"));
//cout<<"&"<<endl;
for(int j=0; j<3;++j){
for(int i=0; i<H.size1();++i)
cout<<H(j,i)<<endl;
cout<<"&"<<endl;
}
return 0;
}