Ejemplo n.º 1
0
    def generate_cube(self, fname, vals, nx, ny, nz, comment="HEADER LINE\n"):
        import cubetools

        cube = {}
        cube["comment"] = comment
        cube["type"] = "\n"
        cube["natoms"] = self.supercell.natm
        cube["origin"] = np.zeros(3)
        cube["ints"] = np.array([nx, ny, nz])
        cube["latvec"] = self.supercell.lattice_vectors()
        cube["latvec"] = cube["latvec"] / cube["ints"][:, np.newaxis]
        cube["atomname"] = self.supercell.atom_charges()
        cube["atomxyz"] = self.supercell.atom_coords()
        cube["data"] = np.reshape(vals, (nx, ny, nz))
        with open(fname, "w") as f:
            cubetools.write_cube(cube, f)
Ejemplo n.º 2
0
import cubetools
import copy 

s1=cubetools.read_cube("qwalk_000.spin.dens.cube")
s2=cubetools.read_cube("../../../../undoped/PBE0/CHK/plots/qwalk_000.spin.dens.cube")

c1=cubetools.read_cube("qwalk_000.chg.dens.cube")
c2=cubetools.read_cube("../../../../undoped/PBE0/CHK/plots/qwalk_000.chg.dens.cube")

s1['data']-=s2['data'] #make 'up' the spin density
cubetools.write_cube(s1,"qwalk_000.spin_diff.dens.cube")
c1['data']-=c2['data'] #make 'up' the charge density
cubetools.write_cube(c1,"qwalk_000.chg_diff.dens.cube")

Ejemplo n.º 3
0
import cubetools as ct
import sys

samp = ct.read_cube(open(sys.argv[1],'r'))
ct.freq_cutoff(samp,freq_cutoff=0.6)
ct.gaussian_averager(samp,sigma=6,nbr_dist=10,repeat=1)
ct.write_cube(samp,open("smoothed/"+sys.argv[1],"w"))
Ejemplo n.º 4
0
import cubetools
nup = 67
ndown = 66
import copy

#up=cubetools.read_cube("qwalk_000.plot_u.dens.cube")
#down=cubetools.read_cube("qwalk_000.plot_d.dens.cube")
#down=cubetools.read_cube("qwalk_000.plot_d_ex.dens.cube")
up = cubetools.read_cube("qwalk_110.plot_u.dens.cube")
down = cubetools.read_cube("qwalk_110.plot_d.dens.cube")
#down=cubetools.read_cube("qwalk_100.plot_d_ex.dens.cube")
up = cubetools.normalize_abs(up)
down = cubetools.normalize_abs(down)
up['data'] *= nup
down['data'] *= ndown
up['data'] -= down['data']  #make 'up' the spin density
cubetools.write_cube(up, "qwalk_110.spin.dens.cube")
up['data'] += 2 * down['data']  #make 'up' the charge density
cubetools.write_cube(up, "qwalk_110.chg.dens.cube")
Ejemplo n.º 5
0
import cubetools
import copy 

nup=66
ndown=66
'''
up=cubetools.read_cube("qwalk_000.plot_u.dens.cube")
down=cubetools.read_cube("qwalk_000.plot_d.dens.cube")
up=cubetools.normalize_abs(up)
down=cubetools.normalize_abs(down)
up['data']*=nup
down['data']*=ndown
up['data']-=down['data'] #make 'up' the spin density
cubetools.write_cube(up,"qwalk_000.spin.dens.cube")
up['data']+=2*down['data'] #make 'up' the charge density
cubetools.write_cube(up,"qwalk_000.chg.dens.cube")
'''

up=cubetools.read_cube("qwalk_000.plot_u.dens.cube")
down=cubetools.read_cube("qwalk_000.plot_d.dens.cube")
up_ct=cubetools.read_cube("qwalk_000.plot_u_ct.dens.cube")
down_ct=cubetools.read_cube("qwalk_000.plot_d_ct.dens.cube")
up=cubetools.normalize_abs(up)
down=cubetools.normalize_abs(down)
up_ct=cubetools.normalize_abs(up_ct)
down_ct=cubetools.normalize_abs(down_ct)
up['data']*=nup
down['data']*=ndown
up_ct['data']*=nup
down_ct['data']*=ndown
Ejemplo n.º 6
0
# Output as cube file.
# Twist average over set of dmc results input.

from numpy import array
import multiprocessing as mp
import cubetools as ct
import sys
from operator import add
from imp import reload
reload(ct)

if len(sys.argv) < 3:
  print("Arguements : [list of files to average] outputfile")
  raise AssertionError("Not enough arguments.")

flist = sys.argv[1:-1]
w_k = [1./len(flist) for i in flist] # Assumes equal k-point weight
print("weights:", w_k)

def reader(fi): return ct.read_cube(open(fi,'r'),qwalk_patch=True)
with mp.Pool(8) as pool:
  dens_k = pool.map(reader,flist)

print("Output to "+sys.argv[-1])
dens = dens_k[0]
dens['comment'] = "Twist-average density\n"
dens['data'] = w_k[0]*dens_k[0]['data']
for i in range(1,len(w_k)):
  dens['data'] += w_k[i]*dens_k[i]['data']
ct.write_cube(dens,open(sys.argv[-1],'w'))
Ejemplo n.º 7
0
import cubetools

f1 = cubetools.read_cube('test_mom.plot.orb7.cube')
f2 = cubetools.read_cube('test_mom.plot.orb10.cube')
f1 = cubetools.normalize_abs(f1)
f2 = cubetools.normalize_abs(f2)

f1['data'] -= f2['data']
cubetools.write_cube(f1, 'test_mom.plot.orbDiff.cube')

f1['data'] += 2 * f2['data']
cubetools.write_cube(f1, 'test_mom.plot.orbSum.cube')
Ejemplo n.º 8
0
import multiprocessing as mp
import cubetools as ct
import sys
from operator import add
from imp import reload
reload(ct)

if len(sys.argv) < 3:
    print("Arguements : [list of files to average] outputfile")
    raise AssertionError("Not enough arguments.")

flist = sys.argv[1:-1]
w_k = [1. / len(flist) for i in flist]  # Assumes equal k-point weight
print("weights:", w_k)


def reader(fi):
    return ct.read_cube(open(fi, 'r'), qwalk_patch=True)


with mp.Pool(8) as pool:
    dens_k = pool.map(reader, flist)

print("Output to " + sys.argv[-1])
dens = dens_k[0]
dens['comment'] = "Twist-average density\n"
dens['data'] = w_k[0] * dens_k[0]['data']
for i in range(1, len(w_k)):
    dens['data'] += w_k[i] * dens_k[i]['data']
ct.write_cube(dens, open(sys.argv[-1], 'w'))
Ejemplo n.º 9
0
import cubetools

nup = 14
ndown = 11
import copy

up = cubetools.read_cube("Cuvtz_r1.963925_c0_s3_B3LYP.plot_u.dens.cube")
down = cubetools.read_cube("Cuvtz_r1.963925_c0_s3_B3LYP.plot_d.dens.cube")
up = cubetools.normalize_abs(up)
down = cubetools.normalize_abs(down)
up['data'] *= nup
down['data'] *= ndown
up['data'] -= down['data']  #make 'up' the spin density
cubetools.write_cube(up, "spin3.dens.cube")
up['data'] += 2 * down['data']  #make 'up' the charge density
cubetools.write_cube(up, "chg3.dens.cube")
Ejemplo n.º 10
0
import cubetools
nup = 68
ndown = 64

up = cubetools.read_cube("qwalk_000.plot_u.dens.cube")
down = cubetools.read_cube("qwalk_000.plot_d.dens.cube")
up = cubetools.normalize_abs(up)
down = cubetools.normalize_abs(down)
up['data'] *= nup
#down['data']*=ndown
#up['data']-=down['data'] #make 'up' the spin density
#cubetools.write_cube(up,"qwalk_000.spin.dens.cube")
#up['data']+=2*down['data'] #make 'up' the charge density
#cubetools.write_cube(up,"qwalk_000.chg.dens.cube")

#CT state
down_ct = cubetools.read_cube("qwalk_000.plot_d_ct1.dens.cube")
down_ct = cubetools.normalize_abs(down_ct)
down_ct['data'] *= ndown
up['data'] -= down_ct['data']  #make 'up' the spin density
cubetools.write_cube(up, "qwalk_000.ct1_spin.dens.cube")
up['data'] += 2 * down_ct['data']  #make 'up' the charge density
cubetools.write_cube(up, "qwalk_000.ct1_chg.dens.cube")
up['data'] -= down_ct['data']