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

Add triples for impurities #99

Merged
merged 2 commits into from
Apr 30, 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
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.

Loading