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 qha model #125

Merged
merged 9 commits into from
Jun 6, 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
4 changes: 2 additions & 2 deletions atomrdf/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""


from rdflib import Graph, Literal, XSD, RDF, RDFS, BNode, URIRef
from rdflib import Graph, XSD, RDF, RDFS, BNode, URIRef

import os
import numpy as np
Expand Down Expand Up @@ -50,7 +50,7 @@
from atomrdf.sample import Sample
import atomrdf.mp as amp

from atomrdf.namespace import Namespace, CMSO, PLDO, PODO, ASMO, PROV, MATH, UNSAFECMSO, UNSAFEASMO
from atomrdf.namespace import Namespace, CMSO, PLDO, PODO, ASMO, PROV, MATH, UNSAFECMSO, UNSAFEASMO, Literal

# read element data file
file_location = os.path.dirname(__file__).split("/")
Expand Down
16 changes: 14 additions & 2 deletions atomrdf/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@
"""

import os
from rdflib import Literal, URIRef
import json
import numpy as np
from rdflib import URIRef
from rdflib import Namespace as RDFLibNamespace
from rdflib import Literal as RDFLibLiteral
from pyscal3.atoms import AttrSetter

from atomrdf.network.network import OntologyNetwork


def Literal(value, datatype=None):
if datatype is not None:
return RDFLibLiteral(value, datatype=datatype)
elif isinstance(value, list):
return RDFLibLiteral(json.dumps(value))
elif isinstance(value, np.ndarray):
return RDFLibLiteral(json.dumps(value.tolist()))
else:
return RDFLibLiteral(value)

class Namespace(AttrSetter, RDFLibNamespace):
"""A class representing a namespace in the AtomRDF library.

Expand Down
4 changes: 2 additions & 2 deletions atomrdf/network/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
- StructureOperation:
- RotationOperation and associated vectors, see structure.py
- TranslationOperation - no triples yet, see structure.py

- PROV activities
- ADD SHEAR OPERATION
- PointDefectCreation
- DeleteAtom - to create vacancy - Now Just added as label to PROV activities
- AddAtom - to create impurity
- SubstituteAtom - to create impurity
Expand Down
14 changes: 11 additions & 3 deletions atomrdf/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
In this module a new Sample class is defined.
"""
from pyscal3.atoms import AttrSetter
from atomrdf.namespace import CMSO, PLDO, PODO, ASMO, PROV
from rdflib import RDFS, Namespace, RDF, URIRef, Literal
from atomrdf.namespace import CMSO, PLDO, PODO, ASMO, PROV, Literal
from rdflib import RDFS, Namespace, RDF, URIRef
import numpy as np
import uuid
import re
import json

MATH = Namespace("http://purls.helmholtz-metadaten.de/asmo/")

Expand Down Expand Up @@ -115,12 +117,18 @@ def _output_properties(self):

class Property:
def __init__(self, value, unit=None, graph=None, parent=None):
self._value = value
self._value = self._clean_value(value)
self._unit = unit
self._graph = graph
self._parent = parent
self._label = None

def _clean_value(self, value):
if isinstance(value, str):
if (value[0] == '[') and (value[-1] == ']'):
value = np.array(json.loads(value))
return value

def __repr__(self):
if self._unit is not None:
return f"{self._value} {self._unit}"
Expand Down
3 changes: 2 additions & 1 deletion atomrdf/stores.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from rdflib.store import NO_STORE, VALID_STORE
from rdflib import plugin
from rdflib import Graph, Literal
from rdflib import Graph
from atomrdf.namespace import Literal

import os

Expand Down
4 changes: 2 additions & 2 deletions atomrdf/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import atomrdf.json_io as json_io
import atomrdf.properties as prp

from rdflib import Graph, Literal, Namespace, XSD, RDF, RDFS, BNode, URIRef
from atomrdf.namespace import CMSO, PLDO, PODO, UNSAFEASMO, UNSAFECMSO, PROV
from rdflib import Graph, Namespace, XSD, RDF, RDFS, BNode, URIRef
from atomrdf.namespace import CMSO, PLDO, PODO, UNSAFEASMO, UNSAFECMSO, PROV, Literal

from atomman.defect.Dislocation import Dislocation
import atomman as am
Expand Down
2 changes: 1 addition & 1 deletion atomrdf/visualize.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import graphviz
import os
from rdflib import BNode, URIRef, Literal, Namespace
from rdflib import BNode, URIRef, Namespace, Literal
import uuid
import json

Expand Down
Empty file added atomrdf/workflow/jobdict.yml
Empty file.
3 changes: 3 additions & 0 deletions atomrdf/workflow/pyiron/pyiron.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import atomrdf.workflow.pyiron.lammps as lammps
import atomrdf.workflow.pyiron.vasp as vasp
import atomrdf.workflow.pyiron.murnaghan as murnaghan
import atomrdf.workflow.pyiron.quasiharmonic as qha

def process_job(job):
"""
Expand All @@ -32,6 +33,8 @@ def process_job(job):
return vasp.process_job(job)
elif type(job).__name__ == 'Murnaghan':
return murnaghan.process_job(job)
elif type(job).__name__ == 'QuasiHarmonicJob':
return qha.process_job(job)
else:
raise TypeError("These type of pyiron Job is not currently supported")

Expand Down
47 changes: 47 additions & 0 deletions atomrdf/workflow/pyiron/quasiharmonic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import os
import numpy as np
import ast
from atomrdf.structure import System
import atomrdf.workflow.pyiron.lammps as lammps

def process_job(job):
#murnaghan job processing; add individual lammps jobs first
job_dicts = []

#create an additional jobdict with the murnaghan job
quasi_dict = {}
lammps.get_structures(job, quasi_dict)
quasi_dict['intermediate'] = False
lammps.get_simulation_folder(job, quasi_dict)

#add the murnaghan method
quasi_dict['method'] = "QuasiHarmonicModel"
outputs = []
outputs.append(
{
"label": "QuasiHarmonicFreeEnergy",
"value": np.round(job['output/free_energy'].T, decimals=4),
"unit": "EV",
"associate_to_sample": True,
}
)
outputs.append(
{
"label": "QuasiHarmonicVolume",
"value": np.round(job['output/volumes'].T, decimals=4),
"unit": "ANGSTROM3",
"associate_to_sample": True,
}
)
outputs.append(
{
"label": "QuasiHarmonicTemperature",
"value": np.round(job['output/temperatures'][0], decimals=2),
"unit": "K",
"associate_to_sample": True,
}
)
quasi_dict['outputs'] = outputs
lammps.add_software(quasi_dict)
job_dicts.append(quasi_dict)
return job_dicts
9 changes: 6 additions & 3 deletions atomrdf/workflow/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
See atomrdf.workflow.pyiron for more details
"""

from rdflib import Literal, Namespace, XSD, RDF, RDFS, BNode, URIRef
from rdflib import Namespace, XSD, RDF, RDFS, BNode, URIRef

import warnings
import numpy as np
Expand All @@ -28,7 +28,7 @@
from atomrdf.structure import System

# Move imports to another file
from atomrdf.namespace import PROV, CMSO, PODO, ASMO, MDO
from atomrdf.namespace import PROV, CMSO, PODO, ASMO, MDO, Literal

class Workflow:
def __init__(self, kg):
Expand Down Expand Up @@ -303,7 +303,10 @@ def _add_method(
elif job_dict["method"] == "EquationOfState":
#special type of EOS should be initialised!
self.kg.add((activity, RDF.type, Namespace("http://purls.helmholtz-metadaten.de/asmo/").EquationOfStateFit))


elif job_dict["method"] == "QuasiHarmonicModel":
self.kg.add((activity, RDF.type, Namespace("http://purls.helmholtz-metadaten.de/asmo/").QuasiHarmonicModel))

# add that structure was generated
self.kg.add((activity, ASMO.hasComputationalMethod, method))
self.kg.add((job_dict['sample']['final'], PROV.wasGeneratedBy, activity))
Expand Down
2 changes: 1 addition & 1 deletion examples/04_substitution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.1.-1"
}
},
"nbformat": 4,
Expand Down
96 changes: 93 additions & 3 deletions examples/09_structure_modification.ipynb

Large diffs are not rendered by default.

Loading
Loading