Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main #1455

Merged
merged 13 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci_support/environment-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
- mp-api =0.41.2
- numpy =1.26.4
- pandas =2.2.2
- phonopy =2.23.1
- phonopy =2.24.2
- pint =0.23
- pyiron_base =0.9.1
- pyiron_snippets =0.1.1
Expand Down
2 changes: 1 addition & 1 deletion .ci_support/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- mp-api =0.41.2
- numpy =1.26.4
- pandas =2.2.2
- phonopy =2.23.1
- phonopy =2.24.2
- pint =0.23
- pyiron_base =0.9.1
- pyiron_snippets =0.1.1
Expand Down
2 changes: 1 addition & 1 deletion binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
- mp-api =0.41.2
- numpy =1.26.4
- pandas =2.2.2
- phonopy =2.23.1
- phonopy =2.24.2
- pint =0.23
- pyiron_base =0.9.1
- pylammpsmpi =0.2.19
Expand Down
33 changes: 28 additions & 5 deletions pyiron_atomistics/dft/bader.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import os
import subprocess

from pyiron_atomistics.vasp.volumetric_data import VaspVolumetricData


__author__ = "Sudarsan Surendralal"
__copyright__ = (
"Copyright 2021, Max-Planck-Institut für Eisenforschung GmbH - "
Expand All @@ -26,22 +29,23 @@ class Bader:
.. _Bader code: http://theory.cm.utexas.edu/henkelman/code/bader
"""

def __init__(self, job):
def __init__(self, structure, working_directory):
"""
Initialize the Bader module

Args:
job (pyiron_atomistics.dft.job.generic.GenericDFTJob): A DFT job instance (finished/converged job)
"""
self.job = job
self._working_directory = job.working_directory
self._structure = job.structure
self._working_directory = working_directory
self._structure = structure

def _create_cube_files(self):
"""
Create CUBE format files of the total and valce charges to be used by the Bader program
"""
cd_val, cd_total = self.job.get_valence_and_total_charge_density()
cd_val, cd_total = get_valence_and_total_charge_density(
working_directory=self._working_directory
)
cd_val.write_cube_file(
filename=os.path.join(self._working_directory, "valence_charge.CUBE")
)
Expand Down Expand Up @@ -124,3 +128,22 @@ def parse_charge_vol_file(structure, filename="ACF.dat"):
charges = np.genfromtxt(lines[2:], max_rows=len(structure))[:, 4]
volumes = np.genfromtxt(lines[2:], max_rows=len(structure))[:, 6]
return charges, volumes


def get_valence_and_total_charge_density(working_directory):
"""
Gives the valence and total charge densities

Returns:
tuple: The required charge densities
"""
cd_core = VaspVolumetricData()
cd_total = VaspVolumetricData()
cd_val = VaspVolumetricData()
if os.path.isfile(working_directory + "/AECCAR0"):
cd_core.from_file(working_directory + "/AECCAR0")
cd_val.from_file(working_directory + "/AECCAR2")
cd_val.atoms = cd_val.atoms
cd_total.total_data = cd_core.total_data + cd_val.total_data
cd_total.atoms = cd_val.atoms
return cd_val, cd_total
Loading
Loading