Program to visualize vibrations

Search:

Program to visualize vibrations

From: Dr. Reinaldo Pis Diez <pis_diez_at_email.domain.hidden>
Date: Tue, 30 Mar 1999 16:01:20 -0300
X-Mailer: Windows Eudora Light Version 3.0.1 (32)

        Dear Adf'ers,

                I wrote a small fortran 77 program, Adf_Vibs, which is able to read an
Adf (v2.3) frequency job output, extract the normal modes and generate xyz
files to be read by XMol, xbs or your favorite viewer/animator program. It
is included as an attachment and it is self-explained.

                We in our lab use Chem3D by CambridgeSoft to view and animate our
systems. That program needs some special formatted files (cc1) to work
fine. So if you also use Chem3D and want to test Adf_Vibs send me a mail
and I'll send you the corresponding code.

                Regards,

                                                Reinaldo

c
c This is Adf_Vibs v1.0
c
c This program reads an ADF frequency job output
c and generates an xyz file with frames for each
c frequency found. Those files can then be animated
c using XMol, xbs or your favorite viewer/animator.
c
c The program was written in plane fortran 77 so it
c must be compiled on any platform without problems.
c I used in my PII under Linux the following
c
c g77 -o adf_vibs adf_vibs.f
c
c so feel free to use your favorite flags.
c
c To run it simply type
c
c adf_vibs <name_of_the_file
c
c You will get some advices to the screen concerning
c the processing of the input file.
c
c There are two important parameters you can modify
c if you wish, natommax, the maximum number of atoms
c (set to 30) and nframes, the number of frames to
c generate in the xyz files (set to 40).
c
c Of course you are free to modify/improve the code
c but in this case send a mail to adf-list with the
c comments for the benefit of all the ADF users.
c
c E-mail me if you find bugs!
c
c Enjoy!
c Reinaldo PIS DIEZ
c Cequinor, FCE, Natl. Univ. of La Plata
c C.C. 962
c 1900 La Plata, Argentine
c pis_diez_at_biol.unlp.edu.ar
c

        implicit real*8 (a-h,o-z)

        parameter(natommax=30, nframes=40)
        parameter(nfreqmax=(3*natommax-6), nfreqmax2=nfreqmax-9)
        parameter(twopi=6.2831853071795865, scale=0.7)

        character line*132, tmpSym*4, Symbol(natommax)*4
        character cfreq1(9)*1, outfreq1(9)*5
        character cfreq2(nfreqmax2)*2, outfreq2(nfreqmax2)*6
        dimension xatom(natommax), yatom(natommax), zatom(natommax)
        dimension freqs(nfreqmax)
        dimension xfreq(nfreqmax,natommax), yfreq(nfreqmax,natommax),
> zfreq(nfreqmax,natommax)

c
c ADF file identification
c

10 read(*,'(a132)',end=90)line
        if(line(1:33).eq.' * Amsterdam Density Functional') then
                print*,'ADF file found'
        else
                goto 10
        endif

c
c Frequency run identification
c

11 read(*,'(a132)',end=91)line
        if(line(41:75).eq.'* R U N T Y P E : FREQUENCIES *')then
                print*,'Frequency run in ADF'
        else
                goto 11
        endif

c
c Finding if the molecule is linear or not
c

16 read(*,'(a132)',end=94)line
        if(line(24:29).eq.'Linear')then
                print*,'Linear molecule found'
                in=5
        elseif(line(24:25).eq.'3D'.or.line(24:29).eq.'Planar')then
                print*,'3D or planar molecule found'
                in=6
        else
                goto 16
        endif
        

c
c Finding and reading atom symbols and coordinates
c

12 read(*,'(a132)',end=92)line
        if(line(35:39).eq.'X Y Z')then
                read(*,'(a132)')line
                read(*,'(a132)')line
                print*,'Now reading atom coordinates'
                goto 100
        else
                goto 12
        endif
100 continue
        natoms=0
13 read(*,'(1x,i4,2x,a4,t20,3f10.4,2f10.2,f14.4)')nat, tmpSym,
> tmpx, tmpy, tmpz, a, b, c
        if(nat.ne.0) then
                if(tmpSym.ne.'XX ')then
                        natoms=natoms + 1
                        if(natoms.gt.30)stop 'atoms number greater than 30'
                        Symbol(natoms)=tmpSym
                        xatom(natoms)=tmpx
                        yatom(natoms)=tmpy
                        zatom(natoms)=tmpz
                endif
                goto 13
        else
                print*,'End of coordinates reached'
        endif

c
c Reading frequencies and normal modes
c
                
14 read(*,'(a132)',end=93)line
        if(line(2:28).eq.'Vibrations and Normal Modes')then
                print*,'Frequencies and normal modes found'
        else
                goto 14
        endif
c
c Read six more blank lines before frequencies
c

        do i= 1, 6
                read(*,'(a132)')line
        enddo

        nfreq=0
        ik=0
15 read(*,'(t22,f9.3,t52,f9.3,t82,f9.3)')frq1, frq2, frq3
        if(frq1.ne.0.0)then
                nfreq = nfreq + 1
                freqs(nfreq)=frq1
        else
                print*,'End of frequencies found'
                goto 101
        endif
        if(frq2.ne.0.0)then
                nfreq = nfreq + 1
                freqs(nfreq)=frq2
        endif
        if(frq3.ne.0.0)then
                nfreq = nfreq + 1
                freqs(nfreq)=frq3
        endif
        
        read(*,'(a132)')line
        
        indx=3*ik
        do i=1,natoms
                read(*,'(t15,3f8.3,t45,3f8.3,t75,3f8.3)')xfreq(indx+1,i),
> yfreq(indx+1,i), zfreq(indx+1,i), xfreq(indx+2,i),
> yfreq(indx+2,i), zfreq(indx+2,i), xfreq(indx+3,i),
> yfreq(indx+3,i), zfreq(indx+3,i)
        enddo
        ik=ik+1
        read(*,'(a132)')line
        read(*,'(a132)')line
        goto 15

101 if((3*natoms-in).eq.nfreq)then
                print*,nfreq,' frequencies found'
        else
                print*,'Error, number of frequencies found incorrect'
                stop
        endif

c
c Output files are open now
c
        
        do i=1,nfreq
                write(99,*)i
        enddo
        rewind 99
        if(nfreq.le.9)then
                do i=1,nfreq
                        read(99,*)cfreq1(i)
                        outfreq1(i)=cfreq1(i)//'.xyz'
                        open(i,file=outfreq1(i))
                enddo
        else
                do i=1,9
                        read(99,*)cfreq1(i)
                        outfreq1(i)=cfreq1(i)//'.xyz'
                        open(i,file=outfreq1(i))
                enddo
                do i=10,nfreq
                        read(99,*)cfreq2(i)
                        outfreq2(i)=cfreq2(i)//'.xyz'
                        open(i,file=outfreq2(i))
                enddo
        endif
        close(99)

c
c Now the trajectories are generated
c

        do i=1,nfreq
                do k=1,nframes
                        write(i,'(i3)')natoms
                        write(i,*)'Frequency #',i,' value: ', freqs(i),
> ' frame= ',k
                        factor=scale*dsin(twopi*k/nframes)
                         do j=1,natoms
                                x=xatom(j) + factor*xfreq(i,j)
                                y=yatom(j) + factor*yfreq(i,j)
                                z=zatom(j) + factor*zfreq(i,j)
                                write(i,'(a3,3(1x,f11.6))')Symbol(j),x ,y ,z
                        enddo
                enddo
        enddo

        stop 'normal stop'

90 print*,'Error, no ADF file found'
        stop
91 print*,'Error, this file is not a frequency run'
        stop
92 print*,'Error, no cartesian coordinates found'
        stop
93 print*,'Error, no frequencies found'
        stop
94 print*,'Error, no molecule type found'
        stop
        end
Received on 1999-03-30 19:15:16

This archive was generated by hypermail 2.2.0 : 2006-11-02 07:00:02 CET