Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuaki1987 committed Aug 25, 2017
2 parents 60726f6 + 6faa252 commit 6d149e9
Show file tree
Hide file tree
Showing 32 changed files with 1,536 additions and 1,465 deletions.
177 changes: 94 additions & 83 deletions doc/en/chap05_en.tex

Large diffs are not rendered by default.

148 changes: 88 additions & 60 deletions doc/jp/chap05_jp.tex

Large diffs are not rendered by default.

202 changes: 131 additions & 71 deletions src/ComplexUHF/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ along with this program. If not, see http://www.gnu.org/licenses/.
int MakeOrbitalFile(struct BindStruct *X);
void cal_cisajs(struct BindStruct *X);
void OutputAntiParallel(struct BindStruct *X,double complex **UHF_Fij,double complex *ParamOrbital,int *CountOrbital);
void OutputAntiParallel_2(struct BindStruct *X,double complex **UHF_Fij,double complex *ParamOrbital,int *CountOrbital);
void OutputParallel(struct BindStruct *X,double complex **UHF_Fij,double complex *ParamOrbital,int *CountOrbital);
void OutputGeneral(struct BindStruct *X,double complex **UHF_Fij,double complex *ParamOrbital,int *CountOrbital);

Expand Down Expand Up @@ -122,93 +123,152 @@ int MakeOrbitalFile(struct BindStruct *X){
int isite, jsite;
double complex **UHF_Fij;
double complex *ParamOrbital;

int *CountOrbital;
//int Orbitalidx;
//int int_i,int_j,int_k,int_l,xMsize;
//double complex **tmp_mat,**vec;
//double *r;
//char fileName[256];
//int ini,fin,tmp_i;
/*this part only for anti-parallel*/
int Orbitalidx;
int int_i,int_j,int_k,int_l,xMsize;
double complex **tmp_mat,**vec,**tmp_SLT_U,**tmp_SLT_D,**AP_UHF_fij;
double complex tmp;
double *r;
char fileName[256];
int ini,fin,tmp_i;

/*this part only for anti-parallel
/*this part only for anti-parallel*/
//[s] for anti-pararell, rediag
xMsize = X->Def.Nsite;
c_malloc2(tmp_mat,xMsize,xMsize);
c_malloc2(vec,xMsize,xMsize);
d_malloc1(r,xMsize);
for(int_l = 0; int_l < 2*xMsize; int_l++){
for(int_k = 0; int_k < 2*X->Def.Ne; int_k++){
X->Large.R_SLT[int_l][int_k] = 0.0;
}
}
// for up
for(int_i = 0;int_i < xMsize; int_i++){
for(int_j = 0;int_j < xMsize; int_j++){
tmp_mat[int_i][int_j] = X->Large.Ham[int_i][int_j];
}
}
ZHEEVall(xMsize,tmp_mat,r,vec);
for(int_k = 0; int_k < X->Def.Ne; int_k++){
for(int_l = 0; int_l < xMsize; int_l++){
X->Large.R_SLT[int_l][2*int_k] = (vec[int_k][int_l]);
}
}
// for down
for(int_i = 0;int_i < xMsize; int_i++){
for(int_j = 0;int_j < xMsize; int_j++){
tmp_mat[int_i][int_j] = X->Large.Ham[int_i+xMsize][int_j+xMsize];
}
}
ZHEEVall(xMsize,tmp_mat,r,vec);
for(int_k = 0; int_k < X->Def.Ne; int_k++){
for(int_l = 0; int_l < xMsize; int_l++){
X->Large.R_SLT[int_l+xMsize][2*int_k+1] = (vec[int_k][int_l]);
}
}
//[e] for anti-pararell
*/
if(X->Def.NOrbitalIdx>0){
c_malloc2(UHF_Fij, X->Def.Nsite*2, X->Def.Nsite*2);
for(ispin=0; ispin<2; ispin++){
for(jspin=0; jspin<2; jspin++){
for(i=0;i< X->Def.Nsite;i++){
for(j=0;j< X->Def.Nsite;j++){
isite = i+ispin*X->Def.Nsite;
jsite = j+jspin*X->Def.Nsite;
UHF_Fij[isite][jsite]=0;
for(n=0;n< 2*X->Def.Ne;n+=2){
UHF_Fij[isite][jsite] += conj(X->Large.R_SLT[isite][n])*conj(X->Large.R_SLT[jsite][n+1])- conj(X->Large.R_SLT[isite][n+1])*conj(X->Large.R_SLT[jsite][n]);
}
if(X->Def.NOrbitalIdx>0){/*[s]X->Def.NOrbitalIdx>0 */
if(X->Def.OrbitalOutputMode==1){/*[s]X->Def.OrbitalOutputMode==1 */
xMsize = X->Def.Nsite;
c_malloc2(tmp_mat,xMsize,xMsize);
c_malloc2(vec,xMsize,xMsize);
c_malloc2(tmp_SLT_U,xMsize,xMsize);
c_malloc2(tmp_SLT_D,xMsize,xMsize);
c_malloc2(AP_UHF_fij,xMsize,xMsize);
d_malloc1(r,xMsize);
for(int_l = 0; int_l < xMsize; int_l++){
for(int_k = 0; int_k < xMsize; int_k++){
tmp_SLT_U[int_l][int_k] = 0.0;
tmp_SLT_D[int_l][int_k] = 0.0;
}
}
// for up
for(int_i = 0;int_i < xMsize; int_i++){
for(int_j = 0;int_j < xMsize; int_j++){
tmp_mat[int_i][int_j] = X->Large.Ham[int_i][int_j];
}
}
ZHEEVall(xMsize,tmp_mat,r,vec);
for(int_k = 0; int_k < xMsize; int_k++){ // int_k = n
for(int_l = 0; int_l < xMsize; int_l++){
tmp_SLT_U[int_l][int_k] = vec[int_k][int_l];
}
}
// for down
for(int_i = 0;int_i < xMsize; int_i++){
for(int_j = 0;int_j < xMsize; int_j++){
tmp_mat[int_i][int_j] = X->Large.Ham[int_i+xMsize][int_j+xMsize];
}
}
ZHEEVall(xMsize,tmp_mat,r,vec);
for(int_k = 0; int_k < xMsize; int_k++){ // int_k: Ne
for(int_l = 0; int_l < xMsize; int_l++){
tmp_SLT_D[int_l][int_k] = (vec[int_k][int_l]);
}
}

for(int_i = 0; int_i < xMsize; int_i++){ // int_k: Ne
for(int_j = 0; int_j < xMsize; int_j++){
tmp = 0.0;
for(n=0;n< X->Def.Ne;n++){
tmp += tmp_SLT_U[int_i][n]*tmp_SLT_D[int_j][n];
}
//printf(" %d %d %lf %lf \n",int_i,int_j,creal(tmp),cimag(tmp));
AP_UHF_fij[int_i][int_j] = tmp;
}
}
}
//printf(" %d %d %d \n",X->Def.NOrbitalAP,X->Def.NOrbitalP,X->Def.NOrbitalIdx);
if(X->Def.OrbitalOutputMode>0){

c_malloc1(ParamOrbital, X->Def.NOrbitalIdx);
i_malloc1(CountOrbital, X->Def.NOrbitalIdx);
//
OutputAntiParallel(X,UHF_Fij,ParamOrbital,CountOrbital);
if(X->Def.OrbitalOutputMode==2){
OutputParallel(X,UHF_Fij,ParamOrbital,CountOrbital);
}
//
OutputAntiParallel_2(X,AP_UHF_fij,ParamOrbital,CountOrbital);
c_free1(ParamOrbital, X->Def.NOrbitalIdx);
i_free1(CountOrbital, X->Def.NOrbitalIdx);
}else if(X->Def.OrbitalOutputMode==0){
c_malloc1(ParamOrbital, X->Def.NOrbitalIdx);
i_malloc1(CountOrbital, X->Def.NOrbitalIdx);
}/*[s]X->Def.OrbitalOutputMode==1 */
//[e] for anti-pararell
else{
c_malloc2(UHF_Fij, X->Def.Nsite*2, X->Def.Nsite*2);
for(ispin=0; ispin<2; ispin++){
for(jspin=0; jspin<2; jspin++){
for(i=0;i< X->Def.Nsite;i++){
for(j=0;j< X->Def.Nsite;j++){
isite = i+ispin*X->Def.Nsite;
jsite = j+jspin*X->Def.Nsite;
UHF_Fij[isite][jsite]=0;
for(n=0;n< 2*X->Def.Ne;n+=2){
UHF_Fij[isite][jsite] += conj(X->Large.R_SLT[isite][n])*conj(X->Large.R_SLT[jsite][n+1])- conj(X->Large.R_SLT[isite][n+1])*conj(X->Large.R_SLT[jsite][n]);
}
}
}
}
}
//printf(" %d %d %d \n",X->Def.NOrbitalAP,X->Def.NOrbitalP,X->Def.NOrbitalIdx);
if(X->Def.OrbitalOutputMode==2){ // AP+P
c_malloc1(ParamOrbital, X->Def.NOrbitalIdx);
i_malloc1(CountOrbital, X->Def.NOrbitalIdx);
//
OutputGeneral(X,UHF_Fij,ParamOrbital,CountOrbital);
OutputAntiParallel(X,UHF_Fij,ParamOrbital,CountOrbital);
if(X->Def.OrbitalOutputMode==2){
OutputParallel(X,UHF_Fij,ParamOrbital,CountOrbital);
}
//
c_free1(ParamOrbital, X->Def.NOrbitalIdx);
i_free1(CountOrbital, X->Def.NOrbitalIdx);
c_free1(ParamOrbital, X->Def.NOrbitalIdx);
i_free1(CountOrbital, X->Def.NOrbitalIdx);
}else if(X->Def.OrbitalOutputMode==0){ // Only General
c_malloc1(ParamOrbital, X->Def.NOrbitalIdx);
i_malloc1(CountOrbital, X->Def.NOrbitalIdx);
//
OutputGeneral(X,UHF_Fij,ParamOrbital,CountOrbital);
//
c_free1(ParamOrbital, X->Def.NOrbitalIdx);
i_free1(CountOrbital, X->Def.NOrbitalIdx);
}
c_free2(UHF_Fij, X->Def.Nsite * 2, X->Def.Nsite * 2);
}
c_free2(UHF_Fij, X->Def.Nsite * 2, X->Def.Nsite * 2);
}
}/*[e]X->Def.NOrbitalIdx>0 */
return 0;
}

void OutputAntiParallel_2(struct BindStruct *X,double complex **UHF_Fij,double complex *ParamOrbital,int *CountOrbital){
int i,j,Orbitalidx,isite,jsite;
char fileName[256];

for (i = 0; i < X->Def.NOrbitalIdx; i++) { // all clear
ParamOrbital[i] = 0;
CountOrbital[i] = 0;
}
for(i = 0; i < X->Def.Nsite; i++) {
for(j = 0; j < X->Def.Nsite; j++) {
isite = i + 0 * X->Def.Nsite;
jsite = j + 1 * X->Def.Nsite;
Orbitalidx = X->Def.OrbitalIdx[isite][jsite];
//printf(" %d %d %d \n", isite,jsite,Orbitalidx);
if(Orbitalidx != -1) {
ParamOrbital[Orbitalidx] += UHF_Fij[i][j];
CountOrbital[Orbitalidx] += 1;
//printf(" %d %d %d %lf %lf \n", isite,jsite,Orbitalidx,creal(ParamOrbital[Orbitalidx]),cimag(ParamOrbital[Orbitalidx]));
}
}
}
for (i = 0; i < X->Def.NOrbitalAP; i++) {
ParamOrbital[i] /= (double) CountOrbital[i];
ParamOrbital[i] += genrand_real2() * pow(10.0, -X->Def.eps_int_slater);
}
sprintf(fileName, "%s_APOrbital_opt.dat", X->Def.CParaFileHead);
Child_OutputOptData(fileName, "NOrbitalAP", ParamOrbital, X->Def.NOrbitalAP);
printf("fij for mVMC are outputted to %s.\n", fileName);
}



void OutputAntiParallel(struct BindStruct *X,double complex **UHF_Fij,double complex *ParamOrbital,int *CountOrbital){
int i,j,Orbitalidx,isite,jsite;
char fileName[256];
Expand Down
63 changes: 32 additions & 31 deletions src/StdFace/ChainLattice.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**@file
@brief Standard mode for the chain lattice
*/
#include "StdFace_vals.h"
#include <stdlib.h>
#include <stdio.h>
Expand All @@ -24,24 +27,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <string.h>

/**
*
* Setup a Hamiltonian for the Hubbard model on a Chain lattice
*
* @author Mitsuaki Kawamura (The University of Tokyo)
*/
void StdFace_Chain(struct StdIntList *StdI, char *model)
@brief Setup a Hamiltonian for the Hubbard model on a Chain lattice
@author Mitsuaki Kawamura (The University of Tokyo)
*/
void StdFace_Chain(
struct StdIntList *StdI//!<[inout]
)
{
FILE *fp;
int isite, jsite;
int isite, jsite, ntransMax, nintrMax;
int iL;
double complex Cphase;

/**/
fprintf(stdout, "\n");
fprintf(stdout, "####### Parameter Summary #######\n");
fprintf(stdout, "\n");
/*
Initialize Cell
/**@brief
(1) Compute the shape of the super-cell and sites in the super-cell
*/
fp = fopen("lattice.gp", "w");
/**/
Expand All @@ -67,7 +69,9 @@ void StdFace_Chain(struct StdIntList *StdI, char *model)
StdI->W = 1;
StdFace_InitSite(StdI, fp, 2);
StdI->tau[0][0] = 0.0; StdI->tau[0][1] = 0.0; StdI->tau[0][2] = 0.0;
/**/
/**@brief
(2) check & store parameters of Hamiltonian
*/
fprintf(stdout, "\n @ Hamiltonian \n\n");
StdFace_NotUsed_J("J1", StdI->J1All, StdI->J1);
StdFace_NotUsed_J("J2", StdI->J2All, StdI->J2);
Expand Down Expand Up @@ -122,8 +126,9 @@ void StdFace_Chain(struct StdIntList *StdI, char *model)
}
}/*if (strcmp(StdI->model, "spin") != 0 )*/
fprintf(stdout, "\n @ Numerical conditions\n\n");
/*
Local Spin
/**@brief
(3) Set local spin flag (StdIntList::locspinflag) and
the number of sites (StdIntList::nsite)
*/
StdI->nsite = StdI->L;
if (strcmp(StdI->model, "kondo") == 0 ) StdI->nsite *= 2;
Expand All @@ -138,30 +143,28 @@ void StdFace_Chain(struct StdIntList *StdI, char *model)
StdI->locspinflag[isite] = StdI->S2;
StdI->locspinflag[isite + StdI->nsite / 2] = 0;
}
/*
The number of Transfer & Interaction
/**@brief
(4) Compute the upper limit of the number of Transfer & Interaction and malloc them.
*/
if (strcmp(StdI->model, "spin") == 0 ) {
StdI->ntrans = StdI->L * (StdI->S2 + 1/*h*/ + 2 * StdI->S2/*Gamma*/);
StdI->nintr = StdI->L * (StdI->NsiteUC/*D*/ + 1/*J*/ + 1/*J'*/)
ntransMax = StdI->L * (StdI->S2 + 1/*h*/ + 2 * StdI->S2/*Gamma*/);
nintrMax = StdI->L * (StdI->NsiteUC/*D*/ + 1/*J*/ + 1/*J'*/)
* (3 * StdI->S2 + 1) * (3 * StdI->S2 + 1);
}
else {
StdI->ntrans = StdI->L * 2/*spin*/ * (2 * StdI->NsiteUC/*mu+h+Gamma*/ + 2/*t*/ + 2/*t'*/);
StdI->nintr = StdI->L * (StdI->NsiteUC/*U*/ + 4 * (1/*V*/ + 1/*V'*/));
ntransMax = StdI->L * 2/*spin*/ * (2 * StdI->NsiteUC/*mu+h+Gamma*/ + 2/*t*/ + 2/*t'*/);
nintrMax = StdI->L * (StdI->NsiteUC/*U*/ + 4 * (1/*V*/ + 1/*V'*/));

if (strcmp(StdI->model, "kondo") == 0) {
StdI->ntrans += StdI->L * (StdI->S2 + 1/*h*/ + 2 * StdI->S2/*Gamma*/);
StdI->nintr += StdI->nsite / 2 * (3 * 1 + 1) * (3 * StdI->S2 + 1);
ntransMax += StdI->L * (StdI->S2 + 1/*h*/ + 2 * StdI->S2/*Gamma*/);
nintrMax += StdI->nsite / 2 * (3 * 1 + 1) * (3 * StdI->S2 + 1);
}/*if (strcmp(StdI->model, "kondo") == 0)*/
}
/**/
StdFace_MallocInteractions(StdI);
/*
Set Transfer & Interaction
StdFace_MallocInteractions(StdI, ntransMax, nintrMax);
/**@brief
(5) Set Transfer & Interaction
*/
StdI->ntrans = 0;
StdI->nintr = 0;
for (iL = 0; iL < StdI->L; iL++){

isite = iL;
Expand All @@ -171,7 +174,7 @@ void StdFace_Chain(struct StdIntList *StdI, char *model)
*/
if (strcmp(StdI->model, "spin") == 0 ) {
StdFace_MagField(StdI, StdI->S2, -StdI->h, -StdI->Gamma, isite);
StdFace_GeneralJ(StdI, StdI->D, StdI->S2, StdI->S2, isite, jsite);
StdFace_GeneralJ(StdI, StdI->D, StdI->S2, StdI->S2, isite, isite);
}/*if (strcmp(StdI->model, "spin") == 0 )*/
else {
StdFace_HubbardLocal(StdI, StdI->mu, -StdI->h, -StdI->Gamma, StdI->U, isite);
Expand Down Expand Up @@ -214,10 +217,8 @@ void StdFace_Chain(struct StdIntList *StdI, char *model)

#if defined(_HPhi)
/**
*
* Setup a Hamiltonian for the generalized Heisenberg model on a Chain lattice
*
* @author Mitsuaki Kawamura (The University of Tokyo)
@brief Setup a Hamiltonian for the generalized Heisenberg model on a Chain lattice
@author Mitsuaki Kawamura (The University of Tokyo)
*/
void StdFace_Chain_Boost(struct StdIntList *StdI)
{
Expand Down
Loading

0 comments on commit 6d149e9

Please sign in to comment.