Re: [Wannier] Problems with SPN formatted and gw2wannier.py

2019-09-30 Thread Giovanni Pizzi
Dear Marten,
Thanks a lot.
I’ve opened an issue to keep track of this problem and its solution

https://github.com/wannier-developers/wannier90/issues/293

Just one question - which version of the code did you use? Could you report 
directly in the issue?

Thanks,
Giovanni

--
Giovanni Pizzi
Theory and Simulation of Materials and MARVEL, EPFL
http://people.epfl.ch/giovanni.pizzi
http://nccr-marvel.ch/en/people/profile/giovanni-pizzi


On 26 Sep 2019, at 12:36, Marten Richter 
mailto:marten.rich...@tu-berlin.de>> wrote:

Dear Wannier90 list,

for some reasons, I tried to use gw stuff from yambo with wannier and I
also needed spins.
I need to use the spn formatted option, since I am too stupid (or lazy)
to install the python package for FortranFile on the cluster.
So I tried to run gw2wannier90.py from the utility folder using spn
output with spn_formatted.

I ran into several issues and I am really wondering, if the spn
formatted output was tested.
Anyway I made a patch and I would be glad, if someone can look over it
(who has reference data for the unformatted option for testing)
and could integrate it.
(Special care necessary, since I can write in several programming
languages but not in python and I do not have really much data to check
the correct behaviour).
I hope, that this is the right mailing list.

Regards,

Marten Richter

--

Dr. Marten Richter
Institut für Theoretische Physik
Technische Universität Berlin
Hardenbergstr. 36 Sekr. EW 7-1
D-10623 Berlin
Germany

email: marten.rich...@tu-berlin.de
Tel: +49-30-314-24858 (office)
Fax: +49-30-314-21130
http://www.itp.TU-Berlin.DE/knorr/



___
Wannier mailing list
Wannier@lists.quantum-espresso.org
https://lists.quantum-espresso.org/mailman/listinfo/wannier

___
Wannier mailing list
Wannier@lists.quantum-espresso.org
https://lists.quantum-espresso.org/mailman/listinfo/wannier


[Wannier] Problems with SPN formatted and gw2wannier.py

2019-09-26 Thread Marten Richter

Dear Wannier90 list,

for some reasons, I tried to use gw stuff from yambo with wannier and I 
also needed spins.
I need to use the spn formatted option, since I am too stupid (or lazy) 
to install the python package for FortranFile on the cluster.
So I tried to run gw2wannier90.py from the utility folder using spn 
output with spn_formatted.


I ran into several issues and I am really wondering, if the spn 
formatted output was tested.
Anyway I made a patch and I would be glad, if someone can look over it 
(who has reference data for the unformatted option for testing)

and could integrate it.
(Special care necessary, since I can write in several programming 
languages but not in python and I do not have really much data to check 
the correct behaviour).

I hope, that this is the right mailing list.

Regards,

Marten Richter

--

Dr. Marten Richter
Institut für Theoretische Physik
Technische Universität Berlin
Hardenbergstr. 36 Sekr. EW 7-1
D-10623 Berlin
Germany

email: marten.rich...@tu-berlin.de
Tel: +49-30-314-24858 (office)
Fax: +49-30-314-21130
http://www.itp.TU-Berlin.DE/knorr/



--- wannier/wannier90-3.0.0/utility/gw2wannier90.py	2019-02-27 15:28:29.0 +0100
+++ gw2wannier90.py	2019-09-26 12:12:19.336909411 +0200
@@ -297,6 +297,7 @@ if calcSPN:
 f_spn_out.write(header)
 nbnd,NK=np.array(f_spn_in.readline().split(),dtype=np.int32)
 	f_spn_out.write("  ".join(str(x) for x in (NBND,NKPT) ) )
+	f_spn_out.write("\n")
 else:
 	f_spn_in = FortranFile(seedname+".spn", 'r')
 	f_spn_out = FortranFile(seednameGW+".spn", 'w')
@@ -313,24 +314,25 @@ if calcSPN:
 indmQP,indnQP=np.tril_indices(NBND)
 
 if SPNformatted:
-	SPN=np.loadtxt(f_spn_in).reshape(-1)
+	SPN=np.loadtxt(f_spn_in).view(complex).reshape(-1)
+	print(SPN)
 	start=0
 	length=(3*nbnd*(nbnd+1))/2
 
 for ik in xrange(NK):
+	A=np.zeros((3,nbnd,nbnd),dtype=np.complex)
 	if SPNformatted:
-	A=SPN[start:start+length]
+	A[:,indn,indm]=SPN[start:start+length].reshape(3,nbnd*(nbnd+1)/2,order='F')
 	start+=length
 	else:
-	A=np.zeros((3,nbnd,nbnd),dtype=np.complex)
-	A[:,indn,indm]=f_spn_in.read_record(dtype=np.complex).reshape(3,nbnd*(nbnd+1)/2,order='F')
+	A[:,indn,indm]=f_spn_in.read_record(dtype=np.complex).reshape(3,nbnd*(nbnd+1)/2,order='F')
 	A[:,indm,indn]=A[:,indn,indm].conj()
 	check=np.einsum('ijj->',np.abs(A.imag))
 	if check> 1e-10:
 	raise RuntimeError ( "REAL DIAG CHECK FAILED for spn: {0}".format(check) )
 	A=A[:,:,BANDSORT[ik]][:,BANDSORT[ik],:][:,indnQP,indmQP].reshape((3*NBND*(NBND+1)/2),order='F')
-	if formatted:
-	f_spn_out.write("".join("{0:26:16e} {1:26:16e}\n".format(x.real,x.imag) for x in A))
+	if SPNformatted:
+	f_spn_out.write("".join("{0:26.16e} {1:26.16e}\n".format(x.real,x.imag) for x in A))
 	else:
 	f_spn_out.write_record(A)
 
___
Wannier mailing list
Wannier@lists.quantum-espresso.org
https://lists.quantum-espresso.org/mailman/listinfo/wannier