Added to_cube.py

This commit is contained in:
Anthony Scemama 2009-12-04 16:14:23 +01:00
parent 38ade7947e
commit fab6ef7e30
10 changed files with 104 additions and 40 deletions

Binary file not shown.

View File

@ -2,7 +2,7 @@
all: bin/eplf
EZFIO/config/eplf.config: EZFIO.tar.gz
tar -zxvf EZFIO.tar.gz
tar -zxf EZFIO.tar.gz
cd EZFIO ; ./configure
if [ -e $@ ] ; then rm $@ ; fi
ln -s $$PWD/eplf.config $@
@ -16,7 +16,6 @@ bin/ezfio.py: EZFIO/lib/libezfio.so
bin/eplf: EZFIO/lib/libezfio.so
make -C src
mv src/eplf bin
clean:
- rm -rf EZFIO

5
bin/common.py Normal file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env python
import sys, os
wd = os.path.dirname(__file__)
sys.path = [ wd+"/../EZFIO/Python" ]+sys.path

46
bin/to_cube.py Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env python
import sys
import common
# Check command line
try:
x, filename, grid_type = sys.argv
except ValueError:
print "usage: "+sys.argv[0]+" filename grid_type"
sys.exit(2)
from ezfio import ezfio
def main():
ezfio.set_file(filename)
file = open("%s_%s.cube"%(filename,grid_type),"w")
print >>file, " Cube File"
print >>file, filename, grid_type
data = [ ezfio.nuclei_nucl_num ]+ezfio.grid_origin
print >>file, "%5d%12.6f%12.6f%12.6f" % tuple(data)
data = [ ezfio.grid_num_x, ezfio.grid_step_size[0],0.,0. ]
print >>file, "%5d%12.6f%12.6f%12.6f" % tuple(data)
data = [ ezfio.grid_num_y, 0., ezfio.grid_step_size[1],0. ]
print >>file, "%5d%12.6f%12.6f%12.6f" % tuple(data)
data = [ ezfio.grid_num_z, 0.,0., ezfio.grid_step_size[2] ]
print >>file, "%5d%12.6f%12.6f%12.6f" % tuple(data)
charge = ezfio.nuclei_nucl_charge
coord = ezfio.nuclei_nucl_coord
for i in range(ezfio.nuclei_nucl_num):
data = [ charge[i], charge[i], coord[0][i], coord[1][i], coord[2][i] ]
print >>file, "%5d%12.6f%12.6f%12.6f%12.6f" % tuple(data)
data = getattr(ezfio,"grid_data_%s"%grid_type)
for i in xrange(0,ezfio.grid_num_x):
for j in xrange(0,ezfio.grid_num_y):
for k in xrange(0,ezfio.grid_num_z,6):
for l in xrange(k,min(ezfio.grid_num_z,k+6)):
file.write (" %12.5E"%data[l][j][i])
file.write ("\n")
file.close()
main()

View File

@ -1,11 +1,9 @@
#!/usr/bin/env python
import common
import sys,os,time
wd = os.path.dirname(__file__)
sys.path = [ "/home/scemama/resultsFile" ]+sys.path
sys.path = [ wd+"/../EZFIO/Python" ]+sys.path
from resultsFile import *
# Check command line
@ -29,11 +27,11 @@ def write_ezfioFile(res,filename):
ezfio.set_file(filename)
# Electrons
ezfio.set_electrons_elec_alpha_num(res.num_alpha)
ezfio.set_electrons_elec_beta_num(res.num_beta)
ezfio.electrons_elec_alpha_num = res.num_alpha
ezfio.electrons_elec_beta_num = res.num_beta
# Nuclei
ezfio.set_nuclei_nucl_num(len(res.geometry))
ezfio.nuclei_nucl_num = len(res.geometry)
charge = []
coord = []
coord_x = []
@ -49,8 +47,8 @@ def write_ezfioFile(res,filename):
coord_x.append(a.coord[0]/a0)
coord_y.append(a.coord[1]/a0)
coord_z.append(a.coord[2]/a0)
ezfio.set_nuclei_nucl_charge(charge)
ezfio.set_nuclei_nucl_coord(coord_x+coord_y+coord_z)
ezfio.nuclei_nucl_charge = charge
ezfio.nuclei_nucl_coord = coord_x+coord_y+coord_z
# AO Basis
import string
@ -87,10 +85,10 @@ def write_ezfioFile(res,filename):
if not is_cartesian:
print 'Only cartesian basis functions work...'
sys.exit(0)
ezfio.set_ao_basis_ao_num(len(res.basis))
ezfio.set_ao_basis_ao_nucl(at)
ezfio.set_ao_basis_ao_prim_num(num_prim)
ezfio.set_ao_basis_ao_power(power_x+power_y+power_z)
ezfio.ao_basis_ao_num = len(res.basis)
ezfio.ao_basis_ao_nucl = at
ezfio.ao_basis_ao_prim_num = num_prim
ezfio.ao_basis_ao_power = power_x+power_y+power_z
prim_num_max = ezfio.get_ao_basis_ao_prim_num_max()
len_res_basis = len(res.basis)
for i in range(len(res.basis)):
@ -104,17 +102,17 @@ def write_ezfioFile(res,filename):
for j in range(i,len(coefficient),prim_num_max):
coef.append ( coefficient[j] )
expo.append ( exponent[j] )
ezfio.set_ao_basis_ao_coef(coef)
ezfio.set_ao_basis_ao_expo(expo)
ezfio.ao_basis_ao_coef = coef
ezfio.ao_basis_ao_expo = expo
# MOs
NumOrbSym = [ s[1] for s in res.symmetries ]
mo_tot_num = sum(NumOrbSym)
ezfio.set_mo_basis_mo_tot_num(mo_tot_num)
ezfio.mo_basis_mo_tot_num = mo_tot_num
MoTag = res.mo_types[-1]
if res.occ_num.keys != []:
ezfio.set_mo_basis_mo_occ(res.occ_num[MoTag])
ezfio.mo_basis_mo_occ = res.occ_num[MoTag]
mo = res.mo_sets[MoTag]
if len(mo) < mo_tot_num:
@ -124,20 +122,20 @@ def write_ezfioFile(res,filename):
while len(mo) < mo_tot_num:
mo.append(newmo)
Energies = [ m.eigenvalue for m in mo ]
ezfio.set_mo_basis_mo_energy(Energies)
ezfio.mo_basis_mo_energy = Energies
if res.occ_num is not None:
OccNum = res.occ_num[MoTag]
while len(OccNum) < mo_tot_num:
OccNum.append(0.)
ezfio.set_mo_basis_mo_occ(OccNum)
ezfio.mo_basis_mo_occ = OccNum
cls = [ "v" for i in mo ]
for i in res.closed_mos:
cls[i] = 'c'
for i in res.active_mos:
cls[i] = 'a'
ezfio.set_mo_basis_mo_classif(cls)
ezfio.mo_basis_mo_classif = cls
MoMatrix = []
for m in mo:
@ -145,7 +143,7 @@ def write_ezfioFile(res,filename):
MoMatrix.append(coef)
while len(MoMatrix) < len(mo[0].vector)**2:
MoMatrix.append(0.)
ezfio.set_mo_basis_mo_coef(MoMatrix)
ezfio.mo_basis_mo_coef = MoMatrix
# Determinants
closed_mos = res.closed_mos
@ -169,17 +167,18 @@ def write_ezfioFile(res,filename):
coef = reduce(lambda x, y: x+y,res.det_coefficients,[])
if len(dets_a[0]) > 0:
ezfio.set_determinants_det_num(len(dets_a))
ezfio.set_determinants_det_coef(coef)
ezfio.set_determinants_det_occ(dets_a+dets_b)
ezfio.determinants_det_num = len(dets_a)
ezfio.determinants_det_coef = coef
ezfio.determinants_det_occ = dets_a+dets_b
else:
ezfio.set_determinants_det_num(1)
ezfio.set_determinants_det_coef([1.])
ezfio.set_determinants_det_occ(dets_a+dets_b)
ezfio.determinants_det_num = 1
ezfio.determinants_det_coef = [1.]
ezfio.determinants_det_occ = dets_a+dets_b
ezfio.set_compute_eplf(True)
ezfio.compute_eplf = True
for i in "density density_lapl elf_grad eplf_lapl density_grad elf_grad elf_lapl eplf_grad".split():
exec "ezfio.set_compute_%s(False)" % i
exec "ezfio.compute_%s = False" % i
write_ezfioFile(file,firstArg+".ezfio")

View File

@ -37,9 +37,9 @@ grid
step_size real (3)
origin real (3)
opposite real (3)
num_x integer = grid_point_num(1)
num_y integer = grid_point_num(2)
num_z integer = grid_point_num(3)
num_x integer = at(grid_point_num,1)
num_y integer = at(grid_point_num,2)
num_z integer = at(grid_point_num,3)
grid_data
eplf real (grid_num_x,grid_num_y,grid_num_z)

View File

@ -4,7 +4,7 @@ SRC=
OBJ=
eplf: main
mv main eplf
mv main ../bin/eplf
include irpf90.make

View File

@ -1,7 +1,7 @@
BEGIN_PROVIDER [ double precision, kinetic_energy_alpha_p ]
implicit none
BEGIN_DOC
! Kinetic Energy
! Alpha Kinetic Energy
END_DOC
kinetic_energy_alpha_p = 0.d0
@ -18,7 +18,7 @@ END_PROVIDER
BEGIN_PROVIDER [ double precision, kinetic_energy_beta_p ]
implicit none
BEGIN_DOC
! Kinetic Energy
! Beta Kinetic Energy
END_DOC
kinetic_energy_beta_p = 0.d0
@ -35,6 +35,7 @@ END_PROVIDER
BEGIN_PROVIDER [ double precision, kinetic_energy_p ]
implicit none
BEGIN_DOC
! Kinetic energy
END_DOC
kinetic_energy_p = kinetic_energy_alpha_p + kinetic_energy_beta_p
END_PROVIDER

View File

@ -92,6 +92,20 @@ subroutine get_$X(res)
IRP_ENDIF
!$OMP END CRITICAL (ezfio_critical)
end
subroutine set_$X(res)
$T :: res$D
implicit none
integer :: ierr
logical :: exists
!$OMP CRITICAL (ezfio_critical)
PROVIDE ezfio_filename
if (mpi_master) then
call ezfio_set_$X(res)
endif
!$OMP END CRITICAL (ezfio_critical)
end
"""

View File

@ -60,10 +60,10 @@
grid_y_num = Npoints(2)
grid_z_num = Npoints(3)
call get_grid_point_num(Npoints)
call get_grid_origin(origin)
call get_grid_opposite(opposite)
call get_grid_step_size(step_size)
call set_grid_point_num(Npoints)
call set_grid_origin(origin)
call set_grid_opposite(opposite)
call set_grid_step_size(step_size)
END_PROVIDER