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

Update ontology #107

Merged
merged 15 commits into from
May 8, 2024
249 changes: 216 additions & 33 deletions atomrdf/data/asmo.owl

Large diffs are not rendered by default.

282 changes: 188 additions & 94 deletions atomrdf/data/cmso.owl

Large diffs are not rendered by default.

128 changes: 100 additions & 28 deletions atomrdf/data/pldo.owl

Large diffs are not rendered by default.

146 changes: 127 additions & 19 deletions atomrdf/data/podo.owl

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions atomrdf/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,7 @@ def inspect_sample(self, sample):
]
)
crystalstructure = self.value(material, CMSO.hasStructure)
spacegroup = self.value(crystalstructure, CMSO.hasSpaceGroup)
spacegroupsymbol = self.value(spacegroup, CMSO.hasSpaceGroupSymbol).toPython()
spacegroupsymbol = self.value(crystalstructure, CMSO.hasSpaceGroupSymbol).toPython()

lattice = self.value(sample, CMSO.hasNumberOfAtoms).toPython()
defect_types = list([self.value(d, RDF.type).toPython() for d in defects])
Expand Down
1 change: 1 addition & 0 deletions atomrdf/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ def __init__(self, infile, delimiter="/"):
PODO = Namespace(os.path.join(file_location, "data/podo.owl"))
ASMO = Namespace(os.path.join(file_location, "data/asmo.owl"))
PROV = RDFLibNamespace("http://www.w3.org/ns/prov#")
MDO = RDFLibNamespace("https://w3id.org/mdo/calculation/")
12 changes: 10 additions & 2 deletions atomrdf/network/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,18 @@ def read_ontology():
combo.add_path(("cmso:CrystalStructure", "cmso:hasAltName", "string"))

# interontology paths
#CMSO -> PODO VACANCY
combo.add_path(("cmso:Material", "cmso:hasDefect", "pldo:PlanarDefect"))
combo.add_path(("cmso:Material", "cmso:hasDefect", "podo:Vacancy"))
combo.add_path(("cmso:SimulationCell", "podo:hasVacancyConcentration", "float"))
combo.add_path(("cmso:SimulationCell", "podo:hasNumberOfVacancies", "int"))
combo.add_path(("cmso:AtomicScaleSample", "podo:hasVacancyConcentration", "float"))
combo.add_path(("cmso:AtomicScaleSample", "podo:hasNumberOfVacancies", "int"))

#CMSO -> PODO IMPURITY
combo.add_path(("cmso:Material", "cmso:hasDefect", "podo:SubstitutionalImpurity"))
combo.add_path(("cmso:Material", "cmso:hasDefect", "podo:InterstitialImpurity"))
combo.add_path(("cmso:AtomicScaleSample", "podo:hasNumberOfImpurityAtoms", "int"))
combo.add_path(("cmso:AtomicScaleSample", "podo:hasImpurityConcentration", "float"))

combo.add_path(
("cmso:ComputationalSample", "prov:wasDerivedFrom", "cmso:ComputationalSample")
)
Expand Down
36 changes: 25 additions & 11 deletions atomrdf/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ def _make_dislocation(
output_structure.atoms = atom_obj
output_structure = output_structure.modify.remap_to_box()
output_structure.label = label

return output_structure


Expand Down Expand Up @@ -735,15 +736,15 @@ def add_vacancy(self, concentration, number=None):
self.graph.add((self.material, CMSO.hasDefect, vacancy))
self.graph.add(
(
self.simulation_cell,
self.sample,
PODO.hasVacancyConcentration,
Literal(concentration, datatype=XSD.float),
)
)
if number is not None:
self.graph.add(
(
self.simulation_cell,
self.sample,
PODO.hasNumberOfVacancies,
Literal(number, datatype=XSD.integer),
)
Expand Down Expand Up @@ -805,6 +806,9 @@ def substitute_atoms(
for x in delete_ids:
self.atoms["species"][x] = substitution_element
self.atoms["types"][x] = maxtype
#impurity metrics
no_of_impurities = len(delete_ids)
conc_of_impurities = no_of_impurities/self.natoms

# operate on the graph
if self.graph is not None:
Expand Down Expand Up @@ -872,11 +876,14 @@ def substitute_atoms(
self.graph.structure_store, str(self._name).split(":")[-1]
)
json_io.write_file(outfile, datadict)
self.add_triples_for_substitutional_impurities()
self.add_triples_for_substitutional_impurities(conc_of_impurities, no_of_impurities=no_of_impurities)

def add_triples_for_substitutional_impurities(self):
def add_triples_for_substitutional_impurities(self, conc_of_impurities, no_of_impurities=None):
defect = self.graph.create_node(f"{self._name}_SubstitutionalImpurity", PODO.SubstitutionalImpurity)
self.graph.add((self.material, CMSO.hasDefect, defect))
self.graph.add((self.sample, PODO.hasImpurityConcentration, Literal(conc_of_impurities, datatype=XSD.float)))
if no_of_impurities is not None:
self.graph.add((self.sample, PODO.hasNumberOfImpurityAtoms, Literal(no_of_impurities, datatype=XSD.integer)))

def add_interstitial_impurities(
self, element, void_type="tetrahedral",
Expand Down Expand Up @@ -922,6 +929,7 @@ def add_interstitial_impurities(
randindex = np.random.randint(0, len(verts), len(element))
randpos = np.array(verts)[randindex]


elif void_type == "octahedral":
if lattice_constant is None:
if "lattice_constant" in self.lattice_properties.keys():
Expand Down Expand Up @@ -959,6 +967,9 @@ def add_interstitial_impurities(
raise ValueError("void_type can only be tetrahedral/octahedral")

# create new system with the atoms added
no_of_impurities = len(randpos)
conc_of_impurities = no_of_impurities/self.natoms

sysn = System(source=self.add_atoms({"positions": randpos, "species": element}))
# attach graphs
sysn.sample = self.sample
Expand Down Expand Up @@ -1041,12 +1052,15 @@ def add_interstitial_impurities(
)
json_io.write_file(outfile, datadict)

self.add_triples_for_interstitial_impurities()
self.add_triples_for_interstitial_impurities(conc_of_impurities, no_of_impurities=no_of_impurities)
return sysn

def add_triples_for_interstitial_impurities(self):
def add_triples_for_interstitial_impurities(self, conc_of_impurities, no_of_impurities=None):
defect = self.graph.create_node(f"{self._name}_InterstitialImpurity", PODO.InterstitialImpurity)
self.graph.add((self.material, CMSO.hasDefect, defect))
self.graph.add((self.sample, PODO.hasImpurityConcentration, Literal(conc_of_impurities, datatype=XSD.float)))
if no_of_impurities is not None:
self.graph.add((self.sample, PODO.hasNumberOfImpurityAtoms, Literal(no_of_impurities, datatype=XSD.integer)))


def __delitem__(self, val):
Expand Down Expand Up @@ -1434,18 +1448,18 @@ def _add_space_group(self, spacegroup_symbol, spacegroup_number):
Returns
-------
"""
space_group = URIRef(f"{self._name}_SpaceGroup")
self.graph.add((self.crystal_structure, CMSO.hasSpaceGroup, space_group))
#space_group = URIRef(f"{self._name}_SpaceGroup")
#self.graph.add((self.crystal_structure, CMSO.hasSpaceGroup, space_group))
self.graph.add(
(
space_group,
self.crystal_structure,
CMSO.hasSpaceGroupSymbol,
Literal(spacegroup_symbol, datatype=XSD.string),
)
)
self.graph.add(
(
space_group,
self.crystal_structure,
CMSO.hasSpaceGroupNumber,
Literal(spacegroup_number, datatype=XSD.integer),
)
Expand Down Expand Up @@ -1482,7 +1496,7 @@ def _add_bravais_lattice(self, bv):
self.graph.add(
(
self.unit_cell,
Namespace("http://purls.helmholtz-metadaten.de/cmso/").hasBravaisLattice,
CMSO.hasBravaisLattice,
bv,
)
)
Expand Down
16 changes: 8 additions & 8 deletions atomrdf/workflow/pyiron/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def identify_method(job, method_dict):
ensemble = None

if "min_style" in input_dict.keys():
dof.append("AtomicPosition")
dof.append("CellVolume")
dof.append("AtomicPositionRelaxation")
dof.append("CellVolumeRelaxation")
md_method = "MolecularStatics"

elif "nve" in input_dict["fix___ensemble"]:
Expand All @@ -66,31 +66,31 @@ def identify_method(job, method_dict):

elif int(input_dict["run"]) > 0:
method = "md_nve"
dof.append("AtomicPosition")
dof.append("AtomicPositionRelaxation")
md_method = "MolecularDynamics"
ensemble = "MicrocanonicalEnsemble"

elif "nvt" in input_dict["fix___ensemble"]:
method = "md_nvt"
raw = input_dict["fix___ensemble"].split()
temp = float(raw[3])
dof.append("AtomicPosition")
dof.append("AtomicPositionRelaxation")
md_method = "MolecularDynamics"
ensemble = "CanonicalEnsemble"

elif "npt" in input_dict["fix___ensemble"]:
dof.append("AtomicPosition")
dof.append("CellVolume")
dof.append("AtomicPositionRelaxation")
dof.append("CellVolumeRelaxation")
if "aniso" in input_dict["fix___ensemble"]:
method = "md_npt_aniso"
dof.append("CellShape")
dof.append("CellShapeRelaxation")
else:
method = "md_npt_iso"
md_method = "MolecularDynamics"
raw = input_dict["fix___ensemble"].split()
temp = float(raw[3])
press = float(raw[7])
ensemble = "IsothermalisobaricEnsemble"
ensemble = "IsothermalIsobaricEnsemble"

method_dict["method"] = md_method
method_dict["temperature"] = temp
Expand Down
24 changes: 12 additions & 12 deletions atomrdf/workflow/pyiron/vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,24 @@ def identify_method(job, method_dict):
dof = []
if 'ISIF' in mdict.keys():
if mdict['ISIF'] in ['0', '1', '2']:
dof.append('AtomicPosition')
dof.append('AtomicPositionRelaxation')
elif mdict['ISIF'] == '3':
dof.append('AtomicPosition')
dof.append('CellShape')
dof.append('CellVolume')
dof.append('AtomicPositionRelaxation')
dof.append('CellShapeRelaxation')
dof.append('CellVolumeRelaxation')
elif mdict['ISIF'] == '4':
dof.append('AtomicPosition')
dof.append('CellShape')
dof.append('AtomicPositionRelaxation')
dof.append('CellShapeRelaxation')
elif mdict['ISIF'] == '5':
dof.append('CellShape')
dof.append('CellShapeRelaxation')
elif mdict['ISIF'] == '6':
dof.append('CellShape')
dof.append('CellVolume')
dof.append('CellShapeRelaxation')
dof.append('CellVolumeRelaxation')
elif mdict['ISIF'] == '7':
dof.append('CellVolume')
dof.append('CellVolumeRelaxation')
elif mdict['ISIF'] == '8':
dof.append('AtomicPosition')
dof.append('CellVolume')
dof.append('AtomicPositionRelaxation')
dof.append('CellVolumeRelaxation')
if 'NSW' in mdict.keys():
if mdict['NSW'] == '0':
dof = []
Expand Down
Loading
Loading