issp-center-dev / mVMC

A numerical solver package for a wide range of quantum lattice models based on many-variable Variational Monte Carlo method
http://www.pasums.issp.u-tokyo.ac.jp/mvmc/en/
GNU General Public License v3.0
59 stars 19 forks source link

lda unitialized #18

Closed nikita-astronaut closed 3 years ago

nikita-astronaut commented 3 years ago

Dear mVMC developers,

as I tried to apply the GreenFuncN function I encountered several errors connected to invalid memory reads/writes. It seems like in the current mVMC release, in the src/mVMC/locgrn.c:325 function calculateNewPfMN_child the parameter lda is unitialized, which causes unexpected behavior of Pfaffian computation M_ZSKPFA(&uplo, &mthd, &n, mat, &lda, &pfaff, iwork, work, &lwork, rwork, &info);

Could you please comment on that? Should I set lda = 2 * n; somewhere before applying M_ZSKPFA?

It seems to me that this very function could not probably be used in a recent paper https://arxiv.org/pdf/2005.14142.pdf, at least since this bug (?) is present. Would mind to please commit the properly and surely working version?

Thanks a lot!

Best wishes, Nikita

xrq-phys commented 3 years ago

I cannot ensure uncommenting lda = 2*n would make it work, but leading dimension for that matrix is indeed 2.

nikita-astronaut commented 3 years ago

Dear RuQing,

thank you very much for clarifying this. Could you please tell, what are the all changes required to be done in calculateNewPfMN_child and perhaps in M_ZSKPFA to make everything work?

Could you please share the version of the src/mVMC/locgrn.c file used in obtaining the results of https://arxiv.org/pdf/2005.14142.pdf ?

Thanks a lot!

Best wishes, Nikita

tmisawa commented 3 years ago

Dear Nikita,

Because I and RuXing are not authors of the arXiv paper, we do not know the details of the codes used in the arXiv paper. If you want to use the code, please contact the authors of the arXiv paper.

By the way, on the GreenFuncN, it is used in the power Lanczos calculations. For example, in lslocgrn.c, we calculate the 3-body and 4-body Green functions using GreenFuncN. Could you refer to the usages of GreenFuncN?

Best, Takahiro Misawa

nikita-astronaut commented 3 years ago

Dear Takahiro,

thanks a lot, this is a very good comment.

However, it is unclear to me how the function GreenFuncN can work properly in its current implementation.

As RuXing and me found out above, GreenFuncN calls calculateNewPfMN_child, where currently the parameter lda is uninitialized, and most likely during equals lda = 0 during execution (though this is not guaranteed).

Then pointer to lda is passed to M_ZSKPFA as 5th argument &lda, and I get an error from PFAPACK that 5th argument is invalid (note that LDA >= max(1, N)).

So, as I understand, in the lslocgrn.c file, where you calculate 3-body and 4-body GF, the execution of GreenFuncN never goes further line 254 (reduction stage, if some of the operators have matching indices).

I still believe that calculateNewPfMN_child in its currently commited way has an unexpected behavior.

Thanks for the advice, I will contact the authors of the very paper.

Best wishes, Nikita

nikita-astronaut commented 3 years ago

Dear all,

I have correctly modified calculateNewPfMN_child and checked the result by explicitly looking at the Pfaffians ratios. Now I have the working 4-point function. I thank you a lot for your assistance.

Closing this.

Best, Nikita