Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
CalystaT committed Sep 5, 2023
1 parent 7055f27 commit 8df672b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
18 changes: 9 additions & 9 deletions macrodensity/density.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,23 +243,23 @@ def spherical_average(
resolution_x = vector_a/NGX
resolution_y = vector_b/NGY
resolution_z = vector_c/NGZ
grid_pot, electrons = density_2_grid(cube_pot, NGX, NGY, NGZ, type="CUBE")
grid_pot, electrons = density_2_grid(cube_pot, NGX, NGY, NGZ, config="CUBE")
elif 'vasp' in input_file or 'LOCPOT' in input_file or 'CHGCAR' in input_file:
vasp_pot, NGX, NGY, NGZ, lattice = read_vasp_density(input_file)
vector_a,vector_b,vector_c,av,bv,cv = matrix_2_abc(lattice)
resolution_x = vector_a/NGX
resolution_y = vector_b/NGY
resolution_z = vector_c/NGZ
grid_pot, electrons = density_2_grid(vasp_pot, NGX, NGY, NGZ, type="VASP")
grid_pot, electrons = density_2_grid(vasp_pot, NGX, NGY, NGZ, config="VASP")
elif 'gulp' in input_file or '.out' in input_file:
gulp_pot, NGX, NGY, NGZ, lattice = read_gulp_density(input_file)
vector_a,vector_b,vector_c,av,bv,cv = matrix_2_abc(lattice)
resolution_x = vector_a/NGX
resolution_y = vector_b/NGY
resolution_z = vector_c/NGZ
grid_pot, electrons = density_2_grid(gulp_pot, NGX, NGY, NGZ, type="GULP")
grid_pot, electrons = density_2_grid(gulp_pot, NGX, NGY, NGZ, config="GULP")
else:
raise ValueError("Invalid input file. File must be in VASP, GULP, or CUBE type.")
raise ValueError("Invalid input file. File must be in VASP, GULP, or CUBE configuration.")
cube = cube_size
origin = cube_origin
travelled = [0,0,0]
Expand Down Expand Up @@ -392,7 +392,7 @@ def density_2_grid(
nz: int,
charge: bool=False,
volume: float=1,
type: str = 'VASP'
config: str = 'VASP'
) -> tuple:
"""
Convert density data to a 3D grid.
Expand All @@ -412,7 +412,7 @@ def density_2_grid(
volume (float, optional): volume of the grid cell.
Used to convert charge density to electrons. Default is 1.
type (str, optional): type of the density data (e.g., 'VASP', 'GULP').
config (str, optional): config of the density data (e.g., 'VASP', 'GULP').
Default is 'VASP'.
Returns:
Expand All @@ -434,15 +434,15 @@ def density_2_grid(
l = 0
Potential_grid = np.zeros(shape=(nx, ny, nz))

if type.lower() == "gulp":
if config.lower() == "gulp":
for k in range(nx):
for j in range(ny):
for i in range(nz):
Potential_grid[k,j,i] = density[l]
l = l + 1
return Potential_grid

elif type.lower() == "vasp":
elif config.lower() == "vasp":
total_electrons = 0
for k in range(nz):
for j in range(ny):
Expand All @@ -461,7 +461,7 @@ def density_2_grid(
return Potential_grid, total_electrons

else:
raise ValueError("Invalid type. type must be 'VASP' or 'GULP'.")
raise ValueError("Invalid config. config must be 'VASP' or 'GULP'.")


def planar_average_charge(
Expand Down
22 changes: 11 additions & 11 deletions macrodensity/plotting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""macrodensity.plotting contains different types of plotting functions such as band
"""macrodensity.plotting contains different configs of plotting functions such as band
alignment diagrams and potentials at different grid points."""

from __future__ import division, print_function
Expand Down Expand Up @@ -366,7 +366,7 @@ def plot_on_site_potential(
resolution_y = vector_b / NGY
resolution_z = vector_c / NGZ
grid_pot, electrons = density_2_grid(
vasp_pot, NGX, NGY, NGZ, type="VASP"
vasp_pot, NGX, NGY, NGZ, config="VASP"
)
elif "cube" in potential_file:
grid_pot, atoms = cube.read_cube_data(potential_file)
Expand All @@ -385,7 +385,7 @@ def plot_on_site_potential(
resolution_x = vector_a / NGX
resolution_y = vector_b / NGY
resolution_z = vector_c / NGZ
grid_pot = density_2_grid(gulp_pot, NGX, NGY, NGZ, type="GULP")
grid_pot = density_2_grid(gulp_pot, NGX, NGY, NGZ, config="GULP")
else:
raise ValueError(f"File {potential_file} not recognised!")

Expand Down Expand Up @@ -445,7 +445,7 @@ def plot_planar_average(
new_resolution: int = 3000,
) -> tuple:
"""Calculate planar and macroscopic averages of potential data from different
filetypes like gulp, cube, and vasp.
fileconfigs like gulp, cube, and vasp.
Args:
lattice_vector (float): The lattice vector value.
Expand Down Expand Up @@ -529,11 +529,11 @@ def _save_df(planar, macro, output_file, interpolated_potential=None):
resolution_x = vector_a / NGX
resolution_y = vector_b / NGY
resolution_z = vector_c / NGZ
# TODO: Update type parameter in density_2_grid to be consistent with
# TODO: Update config parameter in density_2_grid to be consistent with
# code naming in other functions (e.g. if here we use GULP to refer to GULP,
# should do the same in other functions)
# Also use lower case for type variable following python conventions (eg type -> type)
grid_pot = density_2_grid(pot, NGX, NGY, NGZ, type="GULP")
# Also use lower case for config variable following python conventions (eg config -> config)
grid_pot = density_2_grid(pot, NGX, NGY, NGZ, config="GULP")

## POTENTIAL PLANAR AVERAGE
planar = planar_average(grid_pot, NGX, NGY, NGZ, axis=axis)
Expand Down Expand Up @@ -564,7 +564,7 @@ def _save_df(planar, macro, output_file, interpolated_potential=None):
resolution_x = vector_a / NGX
resolution_y = vector_b / NGY
resolution_z = vector_c / NGZ
grid_pot, electrons = density_2_grid(pot, NGX, NGY, NGZ, type="VASP")
grid_pot, electrons = density_2_grid(pot, NGX, NGY, NGZ, config="VASP")

## PLANAR AVERAGE
planar = planar_average(grid_pot, NGX, NGY, NGZ, axis=axis)
Expand Down Expand Up @@ -639,7 +639,7 @@ def plot_field_at_point(
resolution_y = vector_b / NGY
resolution_z = vector_c / NGZ
grid_pot, electrons = density_2_grid(
vasp_pot, NGX, NGY, NGZ, type="VASP"
vasp_pot, NGX, NGY, NGZ, config="VASP"
)
## Get the gradiens (Field), if required.
## Comment out if not required, due to compuational expense.
Expand Down Expand Up @@ -751,7 +751,7 @@ def plot_plane_field(
resolution_y = vector_b / NGY
resolution_z = vector_c / NGZ
grid_pot, electrons = density_2_grid(
vasp_pot, NGX, NGY, NGZ, type="VASP"
vasp_pot, NGX, NGY, NGZ, config="VASP"
)
## Get the gradiens (Field), if required.
## Comment out if not required, due to compuational expense.
Expand Down Expand Up @@ -829,7 +829,7 @@ def plot_active_plane(
resolution_y = vector_b / NGY
resolution_z = vector_c / NGZ
grid_pot, electrons = density_2_grid(
vasp_pot, NGX, NGY, NGZ, type="VASP"
vasp_pot, NGX, NGY, NGZ, config="VASP"
)

potential_variance = np.var(grid_pot)
Expand Down

0 comments on commit 8df672b

Please sign in to comment.