zerothi / sisl

Electronic structure Python package for post analysis and large scale tight-binding DFT/NEGF calculations
https://zerothi.github.io/sisl
Mozilla Public License 2.0
181 stars 58 forks source link

TBtrans Error: NetCDF: Invalid dimension ID or name #654

Closed AsymmetryChou closed 9 months ago

AsymmetryChou commented 10 months ago

Describe the issue

Hi Nick !

Following your advice in #650,I construct the hamiltonian matrix and create .nc file successfully. However, when running TBtrans with those .nc files. something was wrong, could you give me some help?

Here is python code generating nc files:


    HR_all = np.zeros((geom.no,geom.no_s))
    for i in range(len(allbonds)):
        if i%100==0:print('bond_index: ',i)
        orb_first_a = geom.a2o(allbonds[i,1])
        orb_last_a = geom.a2o(allbonds[i,1]+1)
        orb_first_b = geom.a2o(allbonds[i,3])
        orb_last_b = geom.a2o(allbonds[i,3]+1)

        if allbonds[i][-3:].equal(torch.tensor([0,0,0])):
            HR_all[orb_first_a:orb_last_a,orb_first_b:orb_last_b]=hamil_block[i].detach().numpy()[:,:]*unit_constant

        else:        #[x,y,z] is supercell label                 
            off = geom.sc_index([x,y,z]) * geom.no
            HR_all[orb_first_a:orb_last_a,orb_first_b+off:orb_last_b+off] = hamil_block[i].detach().numpy()[:,:]*unit_constant

    HR_all_csr = sps.csr_matrix(HR_all)
    HR_all_sisl = sisl.Hamiltonian.fromsp(geom,HR_all_csr)
    HR_all_sisl.write(result_path+'device.nc')  
    #the same code used for  lead_L.nc and lead_R.nc

Here comes the Error from TBtrans


reinit: Reading from RUN.fdf

reinit: -----------------------------------------------------------------------
reinit: System Name: 
reinit: -----------------------------------------------------------------------
reinit: System Label: siesta
reinit: -----------------------------------------------------------------------
*** Trying to create non-existing directory: ./T/

tbt: *** No electrode names were found, default Left/Right are expected
Retrieving information about: spin in file: lead_L.nc

Error occured in NCDF:
Error occured in NCDF:
NetCDF: Invalid dimension ID or name
NetCDF: Invalid dimension ID or name
Status number: -46
Status number: -46
ncdf: Stopped due to error in NetCDF file
ncdf: Stopped due to error in NetCDF file
ncdf-Node 0
ncdf-Node 0
Abort(1) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, 1) - process 0

Here is RUN.fdf

TBT.HS device.nc
TBT.Directory ./T

TBT.k [1 1 1]
TBT.Elecs.Eta            0.000001 eV

TBT.BTD.Pivot.Device orb+none

%block TBT.Elec.Left
  HS lead_L.nc
  semi-inf-direction -A3
  electrode-position 1
%endblock TBT.Elec.Left

%block TBT.Elec.Right
  HS lead_R.nc
  semi-inf-direction +A3
  electrode-position end -1
%endblock TBT.Elec.Right

TBT.DM.GF       true 
TBT.DM.A        true 
TBT.DOS.Gf true
TBT.DOS.A true
TBT.DOS.A.All   true
TBT.DOS.A true

%block TBT.Contours
  neq
%endblock TBT.Contours

%block TBT.Contour.neq
  part line
   from   -4.0000 eV to 0.0000 eV
    delta    0.1 eV
     method mid-rule
%endblock TBT.Contour.neq

Maybe the error is due to some missing information when generating sisl.hamiltonian.

Thank you very much!

Version details Run the below code and add to issue (if an issue is relevant for the issue):

import sys
print(sys.version)
import sisl
print(sisl.__version__)

3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0]
0.14.4.dev11+g82c1e437a
zerothi commented 10 months ago

Looks like your electrode file is corrupt, your code does not show that part of the constructtion.

AsymmetryChou commented 9 months ago

OK, I would check it. However, I remember that I have constructed the Hamiltonian for device and leads with the same code. Maybe there is some mistakes in my scripts~

zerothi commented 9 months ago

I would assume so. :) I'll close, thanks.