Skip to content

Commit

Permalink
Merge pull request #91 from pyscal/maintain_run
Browse files Browse the repository at this point in the history
Maintain run
  • Loading branch information
srmnitc authored Apr 18, 2024
2 parents 56fa709 + 853f272 commit e831e6f
Show file tree
Hide file tree
Showing 23 changed files with 1,003 additions and 662 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.5.4
current_version = 0.5.5
commit = True
tag = False

Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@ jobs:
pip install -e .
pip install pytest
pip install pytest-cov
pytest tests/
#pytest --cov-report=xml --cov=pyscal tests/
#pytest tests/
pytest --cov-report=xml --cov=atomrdf tests/
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: pyscal/atomRDF
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ url: 'https://atomrdf.pyscal.org'
license: "MIT"
repository-code: https://github.com/pyscal/atomRDF
type: software
version: 0.5.4
version: 0.5.5
29 changes: 29 additions & 0 deletions atomrdf/data/dft_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
method: DensityFunctionalTheory
temperature: 100
pressure: 0
dof:
- AtomicPositions
- CellVolume
id: 2314
xcfunctional: LDA
workflow_manager:
uri: xxxx
label: pyiron
software:
- uri: xxxx
label: lammps
- uri: xxxx
label: pyscal
outputs:
- label: TotalEnergy
value: 2.301
unit: EV
associate_to_sample: True
- label: TotalVolume
value: 23.01
unit: ANGSTROM3
associate_to_sample: True
inputs:
- label: AnotherInput
value: 0.1
unit: None
34 changes: 34 additions & 0 deletions atomrdf/data/md_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
method: MolecularStatics
temperature: 100
pressure: 0
dof:
- AtomicPositions
- CellVolume
ensemble: NPT
id: 2314
potential:
uri: https://doi.org/xxx
type: eam
label: string
workflow_manager:
uri: xxxx
label: pyiron
software:
- uri: xxxx
label: lammps
- uri: xxxx
label: pyscal
outputs:
- label: TotalEnergy
value: 2.301
unit: EV
associate_to_sample: True
- label: TotalVolume
value: 23.01
unit: ANGSTROM3
associate_to_sample: True
inputs:
- label: AnotherInput
value: 0.1
unit: None

74 changes: 38 additions & 36 deletions atomrdf/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def __init__(self, graph_file=None,
self._atom_ids = None
self.store = store
self._n_triples = 0
self._initialize_graph()


def add_structure(self, structure):
Expand Down Expand Up @@ -180,19 +181,19 @@ def _check_domain_if_uriref(self, triple):
break
return found, dm

def _check_domain_if_ontoterm(self, triple):
found = True
domain = triple[0].domain
if len(domain) > 0:
if 'owl:Thing' not in domain:
if triple[1].namespace != triple[0].namespace:
#cross ontology term
self.log(f'ignoring possible cross ontology connection between {triple[1].namespace} and {triple[0].namespace}')
return True, None
found = False
if triple[1].name in domain:
found = True
return found, triple[0].name
# def _check_domain_if_ontoterm(self, triple):
# found = True
# domain = triple[0].domain
# if len(domain) > 0:
# if 'owl:Thing' not in domain:
# if triple[1].namespace != triple[0].namespace:
# #cross ontology term
# self.log(f'ignoring possible cross ontology connection between {triple[1].namespace} and {triple[0].namespace}')
# return True, None
# found = False
# if triple[1].name in domain:
# found = True
# return found, triple[0].name


def _check_domain(self, triple):
Expand All @@ -204,8 +205,8 @@ def _check_domain(self, triple):
if type(triple[0]).__name__ == 'URIRef':
found, dm = self._check_domain_if_uriref(triple)

elif self._is_ontoterm(triple[0]):
found, dm = self._check_domain_if_ontoterm(triple)
#elif self._is_ontoterm(triple[0]):
# found, dm = self._check_domain_if_ontoterm(triple)

if not found:
raise ValueError(f'{dm} not in domain of {triple[1].name}')
Expand Down Expand Up @@ -234,20 +235,20 @@ def _check_range_if_uriref(self, triple):
break
return found, rn

def _check_range_if_ontoterm(self, triple):
found = True
rang = triple[1].range
if len(rang) > 0:
if 'owl:Thing' not in rang:
if triple[1].namespace != triple[2].namespace:
#cross ontology term
self.log(f'ignoring possible cross ontology connection between {triple[1].namespace} and {triple[2].namespace}')
return True, None

found = False
if triple[2].name in rang:
found = True
return found, triple[2].name
# def _check_range_if_ontoterm(self, triple):
# found = True
# rang = triple[1].range
# if len(rang) > 0:
# if 'owl:Thing' not in rang:
# if triple[1].namespace != triple[2].namespace:
# #cross ontology term
# self.log(f'ignoring possible cross ontology connection between {triple[1].namespace} and {triple[2].namespace}')
# return True, None
#
# found = False
# if triple[2].name in rang:
# found = True
# return found, triple[2].name


def _check_range_if_literal(self, triple):
Expand Down Expand Up @@ -280,8 +281,8 @@ def _check_range(self, triple):
if type(triple[2]).__name__ == 'URIRef':
found, dm = self._check_range_if_uriref(triple)

elif self._is_ontoterm(triple[2]):
found, dm = self._check_range_if_ontoterm(triple)
#elif self._is_ontoterm(triple[2]):
# found, dm = self._check_range_if_ontoterm(triple)

elif type(triple[2]).__name__ == 'Literal':
found, dm = self._check_range_if_literal(triple)
Expand Down Expand Up @@ -363,7 +364,7 @@ def _initialize_graph(self):

self.add((CMSO.LatticeVector, RDFS.subClassOf, CMSO.Vector))
self.add((CMSO.SimulationCellVector, RDFS.subClassOf, CMSO.Vector))
self.add((CMSO.PositionVector, RDFS.subClassOf, CMSO.Vector))
#self.add((CMSO.PositionVector, RDFS.subClassOf, CMSO.Vector))
self.add((CMSO.Vector, CMSO.hasUnit, URIRef("http://qudt.org/vocab/unit/ANGSTROM")))


Expand All @@ -376,13 +377,14 @@ def add_calculated_quantity(self, sample, propertyname, value, unit=None):
self.add((prop, CMSO.hasUnit, URIRef(f'http://qudt.org/vocab/unit/{unit}')))


def inspect_sample(self):
def inspect_sample(self, sample):
natoms = self.value(sample, CMSO.hasNumberOfAtoms).toPython()
material = list([k[2] for k in self.triples((sample, CMSO.hasMaterial, None))])[0]
defects = list([k[2] for k in self.triples((material, CMSO.hasDefect, None))])
composition = list([k[2].toPython() for k in self.triples((material, CMSO.hasElementRatio, None))])
crystalstructure = self.value(material, CMSO.hasStructure)
spacegroupsymbol = self.value(crystalstructure, CMSO.hasSpaceGroupSymbol).toPython()
spacegroup = self.value(crystalstructure, CMSO.hasSpaceGroup)
spacegroupsymbol = self.value(spacegroup, 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 Expand Up @@ -557,7 +559,7 @@ def archive(self, package_name, format='turtle', compress=True):

#assign corrected path
new_relpath = "/".join(['rdf_structure_store', filepath.split('/')[-1]])
self.graph.add((URIRef(f'{sample}_{val}'), CMSO.hasPath, Literal(new_relpath, datatype=XSD.string)))
self.add((URIRef(f'{sample}_{val}'), CMSO.hasPath, Literal(new_relpath, datatype=XSD.string)))

triple_file = os.path.join(package_name, 'triples')
self.write(triple_file, format=format)
Expand Down Expand Up @@ -731,7 +733,7 @@ def get_system_from_sample(self, sample):
sys.atoms = at
return sys

def to_file(self, sample, filename=None, format="lammps-dump"):
def to_file(self, sample, filename=None, format="poscar"):
"""
Save a given sample to a file
Expand Down
24 changes: 12 additions & 12 deletions atomrdf/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ def get_basis_positions(system):
return system._structure_dict["positions"]
return None

def get_basis_occupancy(system):
if system._structure_dict is None:
return None

if "species" in system._structure_dict.keys():
occ_numbers = system._structure_dict['species']
tdict = system.atoms._type_dict
vals = [val for key, val in tdict.items()]
#def get_basis_occupancy(system):
# if system._structure_dict is None:
# return None

# if "species" in system._structure_dict.keys():
# occ_numbers = system._structure_dict['species']
# tdict = system.atoms._type_dict
# vals = [val for key, val in tdict.items()]

if vals[0] is not None:
occ_numbers = [tdict[x] for x in occ_numbers]
return occ_numbers
return None
# if vals[0] is not None:
# occ_numbers = [tdict[x] for x in occ_numbers]
# return occ_numbers
# return None

def get_lattice_vector(system):
if system._structure_dict is None:
Expand Down
2 changes: 1 addition & 1 deletion atomrdf/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def add_interstitial_impurities(self, element, void_type='tetrahedral', lattice_
self.graph.remove((chemical_species, None, None))
self.graph.remove((self.sample, CMSO.hasSpecies, None))

composition = self.schema.material.element_ratio()
composition = sysn.schema.material.element_ratio()
valid = False
for e, r in composition.items():
if e in element_indetifiers.keys():
Expand Down
6 changes: 1 addition & 5 deletions atomrdf/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ def get_string_from_URI(x):
#just a normal url split now
rawsplit = raw.split("/")
if len(rawsplit) > 1:
return ".".join(rawsplit[-2:]), "URIRef"

rawsplit = raw.split(':')
if len(rawsplit) == 2:
return "_".join(rawsplit), "BNode"
return ".".join(rawsplit[-2:]), "URIRef"

#none of the conditions, worked, which means its a hex string
return raw, "BNode"
Expand Down
56 changes: 26 additions & 30 deletions atomrdf/workflow/pyiron.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,12 @@ def _identify_method(job):
ensemble = 'IsothermalisobaricEnsemble'

mdict = {}
mdict['md'] = {}
mdict['md']['method'] = md_method
mdict['md']['temperature'] = temp
mdict['md']['pressure'] = press
mdict['md']['dof'] = dof
mdict['md']['ensemble'] = ensemble
mdict['md']['id'] = job.id
mdict['method'] = md_method
mdict['temperature'] = temp
mdict['pressure'] = press
mdict['dof'] = dof
mdict['ensemble'] = ensemble
mdict['id'] = job.id

#now process potential
inpdict = job.input.to_dict()
Expand All @@ -101,47 +100,44 @@ def _identify_method(job):
if 'url' in potdict[list(potdict.keys())[0]].keys():
url = potdict[list(potdict.keys())[0]]['url']

mdict['md']['potential'] = {}
mdict['md']['potential']['type'] = ps
mdict['md']['potential']['label'] = name
mdict['potential'] = {}
mdict['potential']['type'] = ps
mdict['potential']['label'] = name
if url is not None:
mdict['md']['potential']['uri'] = url
mdict['potential']['uri'] = url
else:
mdict['md']['potential']['uri'] = name
mdict['potential']['uri'] = name


mdict['md']['workflow_manager'] = {}
mdict['md']['workflow_manager']['uri'] = "http://demo.fiz-karlsruhe.de/matwerk/E457491"
mdict['md']['workflow_manager']['label'] = "pyiron"
mdict['workflow_manager'] = {}
mdict['workflow_manager']['uri'] = "http://demo.fiz-karlsruhe.de/matwerk/E457491"
mdict['workflow_manager']['label'] = "pyiron"
#and finally code details


software = {'uri':"http://demo.fiz-karlsruhe.de/matwerk/E447986",
'label':'LAMMPS'}
mdict['md']['software'] = [software]
mdict['software'] = [software]

#finally add calculated quantities
quantdict = extract_calculated_quantities(job)
mdict['md']['outputs'] = quantdict
mdict['outputs'] = quantdict
return mdict


def extract_calculated_quantities(job):
aen = np.mean(job.output.energy_tot)
avol = np.mean(job.output.volume)
outdict = {}
outdict['TotalEnergy'] = {}
outdict['TotalEnergy']['value'] = np.round(aen, decimals=4)
outdict['TotalEnergy']['unit'] = 'EV'
outdict['TotalEnergy']['associate_to_sample'] = True


outdict['TotalVolume'] = {}
outdict['TotalVolume']['value'] = np.round(avol, decimals=4)
outdict['TotalVolume']['unit'] = 'ANGSTROM3'
outdict['TotalVolume']['associate_to_sample'] = True

return outdict
outputs = []
outputs.append({'label': 'TotalEnergy',
'value': np.round(aen, decimals=4),
'unit': 'EV',
'associate_to_sample': True})
outputs.append({'label': 'TotalVolume',
'value': np.round(avol, decimals=4),
'unit': 'ANGSTROM3',
'associate_to_sample': True})
return outputs



Expand Down
Loading

0 comments on commit e831e6f

Please sign in to comment.