Skip to content

Commit

Permalink
Merge pull request #99 from pyscal/add_triples_for_impurities
Browse files Browse the repository at this point in the history
Add triples for impurities
  • Loading branch information
srmnitc authored Apr 30, 2024
2 parents b67fd3f + 7e3dd2d commit 37f1636
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 107 deletions.
95 changes: 57 additions & 38 deletions atomrdf/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,43 @@ def delete(self, ids=None, indices=None, condition=None, selection=False):
)
json_io.write_file(outfile, datadict)

def add_vacancy(self, concentration, number=None):
"""
Add Vacancy details which will be annotated by PODO
Parameters
----------
concentration: float
vacancy concentration, value should be between 0-1
number: int
Number of atoms that were deleted, optional
Returns
-------
None
"""
if self.graph is None:
return

vacancy = self.graph.create_node(f"{self._name}_Vacancy", PODO.Vacancy)
self.graph.add((self.material, CMSO.hasDefect, vacancy))
self.graph.add(
(
self.simulation_cell,
PODO.hasVacancyConcentration,
Literal(concentration, datatype=XSD.float),
)
)
if number is not None:
self.graph.add(
(
self.simulation_cell,
PODO.hasNumberOfVacancies,
Literal(number, datatype=XSD.integer),
)
)

def substitute_atoms(
self,
substitution_element,
Expand Down Expand Up @@ -812,9 +849,16 @@ def substitute_atoms(
self.graph.structure_store, str(self._name).split(":")[-1]
)
json_io.write_file(outfile, datadict)
self.add_triples_for_substitutional_impurities()

def add_triples_for_substitutional_impurities(self):
defect = self.graph.create_node(f"{self._name}_SubstitutionalImpurity", PODO.SubstitutionalImpurity)
self.graph.add((self.material, CMSO.hasDefect, defect))

def add_interstitial_impurities(
self, element, void_type="tetrahedral", lattice_constant=None, threshold=0.01
self, element, void_type="tetrahedral",
lattice_constant=None,
threshold=0.01
):
"""
Add interstitial impurities to the System
Expand All @@ -829,6 +873,12 @@ def add_interstitial_impurities(
void_type: string
type of void to be added. {`tetrahedral`, `octahedral`}
lattice_constant: float, optional
lattice constant of the system. Required only for octahedral voids
threshold: float, optional
threshold for the distance from the lattice constant for octahedral voids to account for fluctuations in atomic positions
Returns
-------
System:
Expand Down Expand Up @@ -968,8 +1018,14 @@ def add_interstitial_impurities(
)
json_io.write_file(outfile, datadict)

self.add_triples_for_interstitial_impurities()
return sysn

def add_triples_for_interstitial_impurities(self):
defect = self.graph.create_node(f"{self._name}_InterstitialImpurity", PODO.InterstitialImpurity)
self.graph.add((self.material, CMSO.hasDefect, defect))


def __delitem__(self, val):
"""
Delete item(s) from the structure.
Expand Down Expand Up @@ -1591,43 +1647,6 @@ def _add_atoms(self):
# force_identifier = uuid.uuid4()
# self.add((force, CMSO.hasIdentifier, Literal(force_identifier, datatype=XSD.string)))

def add_vacancy(self, concentration, number=None):
"""
Add Vacancy details which will be annotated by PODO
Parameters
----------
concentration: float
vacancy concentration, value should be between 0-1
number: int
Number of atoms that were deleted, optional
Returns
-------
None
"""
if self.graph is None:
return

vacancy = self.graph.create_node(f"{self._name}_Vacancy", PODO.Vacancy)
self.graph.add((self.material, CMSO.hasDefect, vacancy))
self.graph.add(
(
self.simulation_cell,
PODO.hasVacancyConcentration,
Literal(concentration, datatype=XSD.float),
)
)
if number is not None:
self.graph.add(
(
self.simulation_cell,
PODO.hasNumberOfVacancies,
Literal(number, datatype=XSD.integer),
)
)

def add_gb(self, gb_dict):
"""
Add GB details which will be annotated using PLDO
Expand Down
25 changes: 12 additions & 13 deletions examples/04_substitution.ipynb

Large diffs are not rendered by default.

74 changes: 18 additions & 56 deletions examples/05_interstitials.ipynb

Large diffs are not rendered by default.

0 comments on commit 37f1636

Please sign in to comment.