def test_matrix_2_abc(self): '''Test the function for converting the lattice to abc, alpha,beta, gamma format''' lattice = np.asarray([[2.715, 2.715, 0.], [0., 2.715, 2.715], [2.715, 0., 2.715]]) a, b, c, a_vec, b_vec, c_vec = md.matrix_2_abc(lattice) self.assertAlmostEqual(a, 3.8395898218429529) self.assertAlmostEqual(b, 3.8395898218429529) self.assertAlmostEqual(c, 3.8395898218429529)
"[WARNING] Fermi energy is not extracted. Shifting is not done\n" ) print( "[WARNING] fermi energy is not extracted. Shifting is not done" ) else: log.write("--------------------\n") log.write("(Manually set) Fermi energy= [" + str(fermi_e) + " ] eV.\n") log.write("--------------------\n") #------------------------------------------------------------------ # Get the potential #------------------------------------------------------------------ vasp_pot, NGX, NGY, NGZ, Lattice = md.read_vasp_density(input_file, quiet=True) vector_a, vector_b, vector_c, av, bv, cv = md.matrix_2_abc(Lattice) resolution_x = vector_a / NGX resolution_y = vector_b / NGY resolution_z = vector_c / NGZ grid_pot, electrons = md.density_2_grid(vasp_pot, NGX, NGY, NGZ) #------------------------------------------------------------------ # POTENTIAL #------------------------------------------------------------------ planar = md.planar_average(grid_pot, NGX, NGY, NGZ) shifted_planar = planar - fermi_e plt.plot(shifted_planar) #------------start: MACROSCOPIC AVERAGE if Macro_average: macro = md.macroscopic_average(planar, lattice_vector, resolution_z)
import macrodensity as md import math import numpy as np import matplotlib.pyplot as plt import csv from itertools import izip #------------------------------------------------------------------ # Get the potential # This section should not be altered #------------------------------------------------------------------ vasp_pot, NGX, NGY, NGZ, Lattice = md.read_vasp_density('LOCPOT.slab') vector_a,vector_b,vector_c,av,bv,cv = md.matrix_2_abc(Lattice) resolution_x = vector_a/NGX resolution_y = vector_b/NGY resolution_z = vector_c/NGZ grid_pot, electrons = md.density_2_grid(vasp_pot,NGX,NGY,NGZ) cutoff_varience = 1E-4 hanksConstant = 4.89E-7 ## Get the gradiens (Field), if required. ## Comment out if not required, due to compuational expense. #grad_x,grad_y,grad_z = np.gradient(grid_pot[:,:,:],resolution_x,resolution_y,resolution_z) #------------------------------------------------------------------ ##------------------------------------------------------------------ ## Get the equation for the plane ## This is the section for plotting on a user defined plane;
import math import numpy as np import matplotlib.pyplot as plt #------------------------------------------------------------------ # READING # Get the two potentials and change them to a planar average. # This section should not be altered #------------------------------------------------------------------ # SLAB vasp_pot, NGX, NGY, NGZ, Lattice = md.read_vasp_density('CHGCAR.Slab') mag_a,mag_b,mag_c,vec_a,vec_b,vec_c = md.matrix_2_abc(Lattice) resolution_x = mag_a/NGX resolution_y = mag_b/NGY resolution_z = mag_c/NGZ Volume = md.get_volume(vec_a,vec_b,vec_c) grid_pot_slab, electrons_slab = md.density_2_grid(vasp_pot,NGX,NGY,NGZ,True,Volume) # Save the lattce vectors for use later Vector_A = [vec_a,vec_b,vec_c] #---------------------------------------------------------------------------------- # CONVERT TO PLANAR DENSITIES #---------------------------------------------------------------------------------- planar_slab = md.planar_average(grid_pot_slab,NGX,NGY,NGZ) # BULK vasp_pot, NGX, NGY, NGZ, Lattice = md.read_vasp_density('CHGCAR.Bulk') mag_a,mag_b,mag_c,vec_a,vec_b,vec_c = md.matrix_2_abc(Lattice) resolution_x = mag_a/NGX