Dear Jing,
If you are able to compile a simple Fortran code, I believe the piece of
code in the attachment can be helpful. This is a small piece of code used
by myself to do some simple calculation with the .cube file. After
compiling and running the code, you should have the wavefunction or
potential stored in wfcv, you can add your own code afterwards to do the
analysis you wish to. Hope this helps.

===================
Dr. Xiaochuan Ge (Giovanni)
Center for Functional Nanomaterials
Brookhaven national laboratory
===================

On 20 December 2014 at 11:43, Jing Wang <ffyuyuz...@gmail.com> wrote:

> Thanks. Okay, let me make sure I understand that, so all the data shown in
> the file are potentials at nth position and I have to calculate the
> corresponding real space coordinate myself. Right?
> And I've actually got another relevant question for my situation: is it
> possible to convert fildv files made during ph.x calculation into human
> readable files like pw2casino does to the wavefunction in pw.x pw2casino
> <input> output precess?
>
> Thanks.
>
>
>
>
> On Dec 20, 2014, at 6:36, xiaochuan Ge <ustc.scg...@gmail.com> wrote:
>
> Nop, the first three columns are not coordinates. The coordinates are
> implicitly given. you have the size of the cell, and the number of grids at
> the first few lines, then you should be able to have a formula to calculate
> the coordinate of the n-th data.
>
>
> On Saturday, December 20, 2014, Jing Wang <ffyuyuz...@gmail.com> wrote:
>
>> Thanks for the very detailed explanation of the output file. I read the
>> format explanation in the link you gave again and again and I still can't
>> figure out what the five columns are. For example in the main part of the
>> data file (shown as below), if the first three columns are the coordinates
>> in the real r space with the unit in alat, then what are the left two
>> columns recording? Which column is the potential? How does the datafile
>> represent the Vscf(r) function in real space?
>> .....
>> .....
>> 3.248268856E+00  3.159870688E+00  2.515974539E+00  6.186557012E-01
>> -2.154636042E+00
>>  -3.866568628E+00 -3.274420891E+00 -2.365272143E+00 -2.086628582E+00
>> -1.945051309E+00
>>  -1.918992011E+00 -1.927145835E+00 -1.943940931E+00 -1.943940931E+00
>> -1.927145835E+00
>> .....
>> .....
>>
>> Thank you.
>>
>> Jing Wang
>> Dept. of Physics,
>> Georgia Tech, GA
>>
>> 2014-12-19 11:42 GMT-05:00 Paolo Giannozzi <paolo.gianno...@uniud.it>:
>>>
>>> On Wed, 2014-12-17 at 10:59 -0500, Jing Wang wrote:
>>>
>>> > I'm really confused about how can I read the local potential out
>>> > from the scf calculation. I used pp.x, plot_num=1 to extract the scf
>>> > potential of the the system, however I can't really understand the
>>> > output?
>>>
>>> the "output" is not meant to be read by humans but by other codes.
>>>
>>> > Should it show the potential in cofficients of G-vectors?
>>>
>>> no, it is in real space, in the format explained here:
>>>
>>> http://www.quantum-espresso.org/wp-content/uploads/Doc//developer_man/developer_man.html#SECTION00080000000000000000
>>>
>>> > Head of the output is like this:
>>>
>>> >       25      25     100      25      25     100       2       1
>>>
>>> FFT maximum dimensions and grids (nr1x nr2x nr3x nr1 nr2 nr3),
>>> number of atoms, number of species
>>>
>>> >      4        4.64900000      0.00000000      4.00000000
>>> >  0.00000000      0.00000000      0.00000000
>>>
>>> ibrav, celldm(1-3) as given in scf input
>>>
>>> >       153.2912575334        4.0000000000       70.0000000000     1
>>>
>>> Gmax in (2pi/a)^2 units, dual (ecutrho=dual*ecutwfc), cutoff (Ry)
>>>
>>> >    1   C     4.00
>>> >    1       0.000000000    0.000000000    0.000000000    1
>>> >    2       0.500000000   -0.288675135    0.000000000    1
>>>
>>> atomic species and atomic positions. The plotted quantity in real space
>>> (array length nr1x*nr2x*nr3) follows
>>>
>>> Paolo
>>>
>>> >   3.248268856E+00  3.159870688E+00  2.515974539E+00  6.186557012E-01
>>> > -2.154636042E+00
>>> >  -3.866568628E+00 -3.274420891E+00 -2.365272143E+00 -2.086628582E+00
>>> > -1.945051309E+00
>>> >  -1.918992011E+00 -1.927145835E+00 -1.943940931E+00 -1.943940931E+00
>>> > -1.927145835E+00
>>> >  -1.918992010E+00 -1.945051309E+00 -2.086628581E+00 -2.365272143E+00
>>> > -3.274420890E+00
>>> >  -3.866568627E+00 -2.154636041E+00  6.186557014E-01  2.515974539E+00
>>> > 3.159870688E+00
>>> >   3.159870688E+00  3.159870688E+00  2.802339131E+00  1.452305376E+00
>>> > -1.033031298E+00
>>> >  -3.409639826E+00 -3.654745566E+00 -2.575759384E+00 -2.021392120E+00
>>> > -1.762140769E+00
>>> >  -1.637123367E+00 -1.599819700E+00 -1.588050229E+00 -1.591678304E+00
>>> > -1.588050228E+00
>>> >  -1.599819700E+00 -1.637123366E+00 -1.762140768E+00 -2.021392119E+00
>>> > -2.575759383E+00
>>> >  -3.654745566E+00 -3.409639826E+00 -1.033031298E+00  1.452305376E+00
>>> > 2.802339131E+00
>>> >   2.515974539E+00  2.794920980E+00  2.515974539E+00  1.452305376E+00
>>> > -6.088327143E-01
>>> >  -2.976954364E+00 -3.787496708E+00 -2.827784418E+00 -2.048224903E+00
>>> > -1.714196738E+00
>>> >  -1.488710208E+00 -1.380390580E+00 -1.313398615E+00 -1.296957599E+00
>>> > -1.296957599E+00
>>> >  -1.313398615E+00 -1.380390580E+00 -1.488710208E+00 -1.714196738E+00
>>> > -2.048224903E+00
>>> >  -2.827784418E+00 -3.787496708E+00 -2.976954363E+00 -6.088327142E-01
>>> > 1.452305376E+00
>>> >   6.186557014E-01  1.426203806E+00  1.426203806E+00  6.186557014E-01
>>> > -1.033031298E+00
>>> >  -2.976954363E+00 -3.792558359E+00 -2.995197487E+00 -2.094921250E+00
>>> > -1.698073457
>>> >
>>> >
>>> >
>>> > Thanks.
>>> >
>>> >
>>> > Jing Wang
>>> >
>>> > Dept. of Physics
>>> >
>>> > Georgia Tech, GA, U.S.A
>>> >
>>> > _______________________________________________
>>> > Pw_forum mailing list
>>> > Pw_forum@pwscf.org
>>> > http://pwscf.org/mailman/listinfo/pw_forum
>>>
>>> --
>>>  Paolo Giannozzi, Dept. Chemistry&Physics&Environment,
>>>  Univ. Udine, via delle Scienze 208, 33100 Udine, Italy
>>>  Phone +39-0432-558216, fax +39-0432-558222
>>>
>>> _______________________________________________
>>> Pw_forum mailing list
>>> Pw_forum@pwscf.org
>>> http://pwscf.org/mailman/listinfo/pw_forum
>>>
>>
>
> --
> ===================
> Dr. Xiaochuan Ge (Giovanni)
> Center for Functional Nanomaterials
> Brookhaven national laboratory
> ===================
>
> _______________________________________________
> Pw_forum mailing list
> Pw_forum@pwscf.org
> http://pwscf.org/mailman/listinfo/pw_forum
>
>
> _______________________________________________
> Pw_forum mailing list
> Pw_forum@pwscf.org
> http://pwscf.org/mailman/listinfo/pw_forum
>
PROGRAM MAIN
  IMPLICIT NONE
  REAL*8,ALLOCATABLE :: wfcv(:,:,:)

  INTEGER :: nr(3),ios,ix,iy,iz,i
  REAL*8 :: cell(3),volumn,big_volumn,N_grids
  LOGICAL :: if_cal_dipole
  CHARACTER(256) filename
  !nr(:) are numbers of grids in xyz direction, &
  !and cell(3) are the grid steps
  write(6,*) "Please type in the filename of your cube file."
  read(6,*) filename

  !read wave functions from cube, store in real space
  !First read the grid information
  call READ_GRID(nr,cell,filename)
  volumn=cell(1)*cell(2)*cell(3) ! volumn of single grid
  N_grids=nr(1)*nr(2)*nr(3)
  big_volumn=N_grids*volumn ! whole volumn of the cell
  ALLOCATE(wfcv(nr(1),nr(2),nr(3)))

  call READ_FROM_CUBE(wfcv,filename,nr)

  !! Now do whatever you want with wfcv
  !! wfcv(ix,iy,iz) is the value at coordinate:
  !! ( (ix-1)*cell(1),  (iy-1)*cell(2), (iz-1)*cell(3))
  !! "insert your own code here"
  !! 

  DEALLOCATE(wfcv)
  contains
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
!
SUBROUTINE READ_GRID(nr,cell,filename)
  ! Read infomations of grids
  !
  INTEGER :: nr(3)
  REAL*8 :: cell(3),word(4)
  CHARACTER(256) :: filename
  OPEN(unit=18,file=trim(filename),action='READ')
  !
  !Jump to the forth line, where the grid information starts
  do i = 1, 3, 1
    READ(18,*) 
  enddo
  !
  !Read grids info
  do i =1, 3, 1
    READ(18,*) word
    nr(i)=word(1)
    cell(i)=word(i+1)
  enddo
  close(18)
  RETURN
END SUBROUTINE READ_GRID


SUBROUTINE READ_FROM_CUBE(wfc,filename,nr)
!wavefunctions are read from filename, then written in wfc
!Be aware that in CUBE rho*sign(wfc) is stored instead of wfc
!
  INTEGER :: nr(3),na,ix,iy,iz
  REAL*8 :: word(6)
  REAL*8 :: wfc(nr(1),nr(2),nr(3))
  CHARACTER(256) :: filename
  real*8 :: total,total2,totalabs
!
  OPEN(unit=18,file=trim(filename),action='READ')
!
! jump to the third line where we get the na
  do i = 1, 2, 1
    READ(18,*)
  enddo
  read(18,*) na
!
! jump to 6+na+1-th line, where the wfc starts
  do i = 4, na+6, 1
    READ(18,*)
  enddo
!
! start reading wavefunction
  ix=1
  iy=1
  iz=1
  total=0
  total2=0
  DO
    READ(18,'(6E13.5)',END=522) word
    Do i = 1, 6, 1
      wfc(ix,iy,iz)=word(i)
      !print *, ix,iy,iz
      !wfc(ix,iy,iz)=SIGN(SQRT(ABS(word(i))),word(i))
      iz=iz+1;
      IF(iz==nr(3)+1) THEN 
        iz=1
        iy=iy+1
      ENDIF
      IF(iy==nr(2)+1) THEN 
       ! print *, "finish iy"
        iy=1
        ix=ix+1
      ENDIF
      if(iz==1 .and. i /=6) then
       exit !when the last iz in the loop has been reached
      endif
    ENDDO  
  ENDDO
522 IF(ix/=nr(1)+1.OR.iy/=1.OR.iz/=1) THEN
      print *, "Something is wrong with reading",filename
      print *, "nr:",nr(1), nr(2), nr(3)
      print *, "ix:",ix
      print *, "iy:",iy
      print *, "iz:",iz
      STOP
    ENDIF
  close(18)
  RETURN
END SUBROUTINE READ_FROM_CUBE

END PROGRAM MAIN
_______________________________________________
Pw_forum mailing list
Pw_forum@pwscf.org
http://pwscf.org/mailman/listinfo/pw_forum

Reply via email to