diff --git a/atomrdf/network/network.py b/atomrdf/network/network.py
index 89c8e8e..f2aff5e 100644
--- a/atomrdf/network/network.py
+++ b/atomrdf/network/network.py
@@ -383,7 +383,7 @@ def create_query(self, source, destinations, enforce_types=True):
#iterate through the list, if they have condition parents, add them explicitely
for destination in destinations:
for parent in destination._condition_parents:
- if parent.name not in [d.name for d in destinations]:
+ if parent.variable_name not in [d.variable_name for d in destinations]:
destinations.append(parent)
#all names are now collected, in a list of lists
diff --git a/atomrdf/network/ontology.py b/atomrdf/network/ontology.py
index f96317f..30bd71c 100644
--- a/atomrdf/network/ontology.py
+++ b/atomrdf/network/ontology.py
@@ -134,5 +134,6 @@ def read_ontology():
combo.add_path(("asmo:InteratomicPotential", "cmso:hasReference", "string"))
combo.add_path(("asmo:InteratomicPotential", "rdfs:label", "string"))
+
# return
return combo
diff --git a/atomrdf/network/term.py b/atomrdf/network/term.py
index b914bbb..a852dd0 100644
--- a/atomrdf/network/term.py
+++ b/atomrdf/network/term.py
@@ -274,14 +274,15 @@ def _is_data_node(self):
def _create_condition_string(self, condition, val):
- return f'(?{self.query_name}{condition}"{val}"^^xsd:{self._clean_datatype(self.range[0])})'
+ return f'(?{self.variable_name}{condition}"{val}"^^xsd:{self._clean_datatype(self.range[0])})'
# overloading operators
def __eq__(self, val):
"""
=
"""
- # self._is_number(val)
+ #print("eq")
+ #print(f'lhs {self} rhs {val}')
self._is_data_node()
item = copy.deepcopy(self)
item._condition = item._create_condition_string("=", val)
@@ -316,6 +317,8 @@ def __ge__(self, val):
return item
def __gt__(self, val):
+ #print("gt")
+ #print(f'lhs {self} rhs {val}')
self._is_number(val)
self._is_data_node()
item = copy.deepcopy(self)
@@ -358,9 +361,11 @@ def __or__(self, term):
def or_(self, term):
self.__or__(term)
- def __rshift__(self, term):
- item = copy.deepcopy(term)
- item._parents.append(copy.deepcopy(self))
+ def __matmul__(self, term):
+ #print("matmul")
+ #print(f'lhs {self} rhs {term}')
+ item = copy.deepcopy(self)
+ item._parents.append(copy.deepcopy(term))
return item
def refresh_condition(self):
diff --git a/examples/01_getting_started.ipynb b/examples/01_getting_started.ipynb
index 2ae3289..e7d2b94 100644
--- a/examples/01_getting_started.ipynb
+++ b/examples/01_getting_started.ipynb
@@ -3589,7 +3589,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.8"
+ "version": "3.1.-1"
}
},
"nbformat": 4,
diff --git a/examples/02_grain_boundaries.ipynb b/examples/02_grain_boundaries.ipynb
index 310253e..14622db 100644
--- a/examples/02_grain_boundaries.ipynb
+++ b/examples/02_grain_boundaries.ipynb
@@ -1617,7 +1617,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.8"
+ "version": "3.1.-1"
}
},
"nbformat": 4,
diff --git a/examples/03_point_defects.ipynb b/examples/03_point_defects.ipynb
index ce86926..9fc12e5 100644
--- a/examples/03_point_defects.ipynb
+++ b/examples/03_point_defects.ipynb
@@ -5214,7 +5214,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.8"
+ "version": "3.1.-1"
}
},
"nbformat": 4,
diff --git a/examples/05_interstitials.ipynb b/examples/05_interstitials.ipynb
index 3fd8ce3..83dcf53 100644
--- a/examples/05_interstitials.ipynb
+++ b/examples/05_interstitials.ipynb
@@ -2517,7 +2517,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.8"
+ "version": "3.1.-1"
}
},
"nbformat": 4,
diff --git a/examples/07_dislocation.ipynb b/examples/07_dislocation.ipynb
index b2d4a68..2312eab 100644
--- a/examples/07_dislocation.ipynb
+++ b/examples/07_dislocation.ipynb
@@ -2733,7 +2733,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.8"
+ "version": "3.1.-1"
}
},
"nbformat": 4,
diff --git a/examples/09_structure_modification.ipynb b/examples/09_structure_modification.ipynb
index 081d94c..e712ca5 100644
--- a/examples/09_structure_modification.ipynb
+++ b/examples/09_structure_modification.ipynb
@@ -8482,7 +8482,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.8"
+ "version": "3.1.-1"
}
},
"nbformat": 4,
diff --git a/examples/10_sparql_queries.ipynb b/examples/10_sparql_queries.ipynb
new file mode 100644
index 0000000..e197016
--- /dev/null
+++ b/examples/10_sparql_queries.ipynb
@@ -0,0 +1,1180 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# SPARQL queries\n",
+ "\n",
+ "This notebook demonstrates how SPARQL queries can be composed programmatically, and without (almost) no knowledge of SPARQL. For this purpose, we will use an existing dataset."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "f91e78cb67cf4f979fbad1022ea5c6fa",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": []
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "from atomrdf import KnowledgeGraph"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "kg = KnowledgeGraph.unarchive('dataset.tar.gz')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "22"
+ ]
+ },
+ "execution_count": 5,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.n_samples"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The dataset contains 22 samples"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Of course, SPARQL queries can be directly run through atomRDF. See an example:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "query = \"\"\"\n",
+ "PREFIX cmso: \n",
+ "SELECT DISTINCT ?sample ?symbol ?number \n",
+ "WHERE {\n",
+ " ?sample cmso:hasMaterial ?material .\n",
+ " ?material cmso:hasStructure ?structure .\n",
+ " ?structure cmso:hasSpaceGroupSymbol ?symbol .\n",
+ " ?sample cmso:hasNumberOfAtoms ?number .\n",
+ "FILTER (?number=\"4\"^^xsd:integer)\n",
+ "}\"\"\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The above query finds the Space Group symbol of all structures which have four atoms."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " sample | \n",
+ " symbol | \n",
+ " number | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " sample:10ffd2cc-9e92-4f04-896d-d6c0fdb9e55f | \n",
+ " Pm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " sample:1f6b1b0f-446a-4ad8-877e-d2e6176797df | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " sample:286c3974-962b-4333-a2bb-d164ae645454 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " sample:67be61c7-f9c7-4d46-a61d-5350fd0ee246 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " sample:721b7447-8363-4e65-9515-9da2581d7124 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 5 | \n",
+ " sample:8fc8e47b-acee-40f8-bcbf-fc298cc31f05 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 6 | \n",
+ " sample:9f0f48d1-5ebf-4f7a-b241-5e7aa273f5a0 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 7 | \n",
+ " sample:a3cf6d97-c922-4c4d-8517-e784df83b71e | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 8 | \n",
+ " sample:ab2bea57-39ea-49ea-ad3f-c1c40b013154 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 9 | \n",
+ " sample:aef7472e-7577-4256-8422-6ba77a954ce1 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 10 | \n",
+ " sample:b1f52dc6-5c92-428f-8f7a-78794fd0544c | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 11 | \n",
+ " sample:d015cfca-e047-40bc-baab-423e87fa2618 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 12 | \n",
+ " sample:e54c0e91-52ec-4c47-8ba3-43979a1ebe2e | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 13 | \n",
+ " sample:fb01a7f2-8984-442b-a32e-15321c4fa99b | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " sample symbol number\n",
+ "0 sample:10ffd2cc-9e92-4f04-896d-d6c0fdb9e55f Pm-3m 4\n",
+ "1 sample:1f6b1b0f-446a-4ad8-877e-d2e6176797df Fm-3m 4\n",
+ "2 sample:286c3974-962b-4333-a2bb-d164ae645454 Fm-3m 4\n",
+ "3 sample:67be61c7-f9c7-4d46-a61d-5350fd0ee246 Fm-3m 4\n",
+ "4 sample:721b7447-8363-4e65-9515-9da2581d7124 Fm-3m 4\n",
+ "5 sample:8fc8e47b-acee-40f8-bcbf-fc298cc31f05 Fm-3m 4\n",
+ "6 sample:9f0f48d1-5ebf-4f7a-b241-5e7aa273f5a0 Fm-3m 4\n",
+ "7 sample:a3cf6d97-c922-4c4d-8517-e784df83b71e Fm-3m 4\n",
+ "8 sample:ab2bea57-39ea-49ea-ad3f-c1c40b013154 Fm-3m 4\n",
+ "9 sample:aef7472e-7577-4256-8422-6ba77a954ce1 Fm-3m 4\n",
+ "10 sample:b1f52dc6-5c92-428f-8f7a-78794fd0544c Fm-3m 4\n",
+ "11 sample:d015cfca-e047-40bc-baab-423e87fa2618 Fm-3m 4\n",
+ "12 sample:e54c0e91-52ec-4c47-8ba3-43979a1ebe2e Fm-3m 4\n",
+ "13 sample:fb01a7f2-8984-442b-a32e-15321c4fa99b Fm-3m 4"
+ ]
+ },
+ "execution_count": 7,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.query(query)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The results are given in the form of a Pandas DataFrame."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "This query can also be performed programmatically, which looks like this:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " AtomicScaleSample | \n",
+ " hasSpaceGroupSymbolvalue | \n",
+ " hasNumberOfAtomsvalue | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " sample:10ffd2cc-9e92-4f04-896d-d6c0fdb9e55f | \n",
+ " Pm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " sample:286c3974-962b-4333-a2bb-d164ae645454 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " sample:8fc8e47b-acee-40f8-bcbf-fc298cc31f05 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " sample:9f0f48d1-5ebf-4f7a-b241-5e7aa273f5a0 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " sample:e54c0e91-52ec-4c47-8ba3-43979a1ebe2e | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 5 | \n",
+ " sample:1f6b1b0f-446a-4ad8-877e-d2e6176797df | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 6 | \n",
+ " sample:67be61c7-f9c7-4d46-a61d-5350fd0ee246 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 7 | \n",
+ " sample:721b7447-8363-4e65-9515-9da2581d7124 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 8 | \n",
+ " sample:a3cf6d97-c922-4c4d-8517-e784df83b71e | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 9 | \n",
+ " sample:ab2bea57-39ea-49ea-ad3f-c1c40b013154 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 10 | \n",
+ " sample:b1f52dc6-5c92-428f-8f7a-78794fd0544c | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 11 | \n",
+ " sample:d015cfca-e047-40bc-baab-423e87fa2618 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 12 | \n",
+ " sample:fb01a7f2-8984-442b-a32e-15321c4fa99b | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 13 | \n",
+ " sample:aef7472e-7577-4256-8422-6ba77a954ce1 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " AtomicScaleSample hasSpaceGroupSymbolvalue \\\n",
+ "0 sample:10ffd2cc-9e92-4f04-896d-d6c0fdb9e55f Pm-3m \n",
+ "1 sample:286c3974-962b-4333-a2bb-d164ae645454 Fm-3m \n",
+ "2 sample:8fc8e47b-acee-40f8-bcbf-fc298cc31f05 Fm-3m \n",
+ "3 sample:9f0f48d1-5ebf-4f7a-b241-5e7aa273f5a0 Fm-3m \n",
+ "4 sample:e54c0e91-52ec-4c47-8ba3-43979a1ebe2e Fm-3m \n",
+ "5 sample:1f6b1b0f-446a-4ad8-877e-d2e6176797df Fm-3m \n",
+ "6 sample:67be61c7-f9c7-4d46-a61d-5350fd0ee246 Fm-3m \n",
+ "7 sample:721b7447-8363-4e65-9515-9da2581d7124 Fm-3m \n",
+ "8 sample:a3cf6d97-c922-4c4d-8517-e784df83b71e Fm-3m \n",
+ "9 sample:ab2bea57-39ea-49ea-ad3f-c1c40b013154 Fm-3m \n",
+ "10 sample:b1f52dc6-5c92-428f-8f7a-78794fd0544c Fm-3m \n",
+ "11 sample:d015cfca-e047-40bc-baab-423e87fa2618 Fm-3m \n",
+ "12 sample:fb01a7f2-8984-442b-a32e-15321c4fa99b Fm-3m \n",
+ "13 sample:aef7472e-7577-4256-8422-6ba77a954ce1 Fm-3m \n",
+ "\n",
+ " hasNumberOfAtomsvalue \n",
+ "0 4 \n",
+ "1 4 \n",
+ "2 4 \n",
+ "3 4 \n",
+ "4 4 \n",
+ "5 4 \n",
+ "6 4 \n",
+ "7 4 \n",
+ "8 4 \n",
+ "9 4 \n",
+ "10 4 \n",
+ "11 4 \n",
+ "12 4 \n",
+ "13 4 "
+ ]
+ },
+ "execution_count": 8,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.query_sample([kg.terms.cmso.hasSpaceGroupSymbol, kg.terms.cmso.hasNumberOfAtoms==4])"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "or more explicitely (`query_sample` is just a shortcut for `auto_query`)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " AtomicScaleSample | \n",
+ " hasSpaceGroupSymbolvalue | \n",
+ " hasNumberOfAtomsvalue | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " sample:10ffd2cc-9e92-4f04-896d-d6c0fdb9e55f | \n",
+ " Pm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " sample:286c3974-962b-4333-a2bb-d164ae645454 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " sample:8fc8e47b-acee-40f8-bcbf-fc298cc31f05 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " sample:9f0f48d1-5ebf-4f7a-b241-5e7aa273f5a0 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " sample:e54c0e91-52ec-4c47-8ba3-43979a1ebe2e | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 5 | \n",
+ " sample:1f6b1b0f-446a-4ad8-877e-d2e6176797df | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 6 | \n",
+ " sample:67be61c7-f9c7-4d46-a61d-5350fd0ee246 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 7 | \n",
+ " sample:721b7447-8363-4e65-9515-9da2581d7124 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 8 | \n",
+ " sample:a3cf6d97-c922-4c4d-8517-e784df83b71e | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 9 | \n",
+ " sample:ab2bea57-39ea-49ea-ad3f-c1c40b013154 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 10 | \n",
+ " sample:b1f52dc6-5c92-428f-8f7a-78794fd0544c | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 11 | \n",
+ " sample:d015cfca-e047-40bc-baab-423e87fa2618 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 12 | \n",
+ " sample:fb01a7f2-8984-442b-a32e-15321c4fa99b | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ " 13 | \n",
+ " sample:aef7472e-7577-4256-8422-6ba77a954ce1 | \n",
+ " Fm-3m | \n",
+ " 4 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " AtomicScaleSample hasSpaceGroupSymbolvalue \\\n",
+ "0 sample:10ffd2cc-9e92-4f04-896d-d6c0fdb9e55f Pm-3m \n",
+ "1 sample:286c3974-962b-4333-a2bb-d164ae645454 Fm-3m \n",
+ "2 sample:8fc8e47b-acee-40f8-bcbf-fc298cc31f05 Fm-3m \n",
+ "3 sample:9f0f48d1-5ebf-4f7a-b241-5e7aa273f5a0 Fm-3m \n",
+ "4 sample:e54c0e91-52ec-4c47-8ba3-43979a1ebe2e Fm-3m \n",
+ "5 sample:1f6b1b0f-446a-4ad8-877e-d2e6176797df Fm-3m \n",
+ "6 sample:67be61c7-f9c7-4d46-a61d-5350fd0ee246 Fm-3m \n",
+ "7 sample:721b7447-8363-4e65-9515-9da2581d7124 Fm-3m \n",
+ "8 sample:a3cf6d97-c922-4c4d-8517-e784df83b71e Fm-3m \n",
+ "9 sample:ab2bea57-39ea-49ea-ad3f-c1c40b013154 Fm-3m \n",
+ "10 sample:b1f52dc6-5c92-428f-8f7a-78794fd0544c Fm-3m \n",
+ "11 sample:d015cfca-e047-40bc-baab-423e87fa2618 Fm-3m \n",
+ "12 sample:fb01a7f2-8984-442b-a32e-15321c4fa99b Fm-3m \n",
+ "13 sample:aef7472e-7577-4256-8422-6ba77a954ce1 Fm-3m \n",
+ "\n",
+ " hasNumberOfAtomsvalue \n",
+ "0 4 \n",
+ "1 4 \n",
+ "2 4 \n",
+ "3 4 \n",
+ "4 4 \n",
+ "5 4 \n",
+ "6 4 \n",
+ "7 4 \n",
+ "8 4 \n",
+ "9 4 \n",
+ "10 4 \n",
+ "11 4 \n",
+ "12 4 \n",
+ "13 4 "
+ ]
+ },
+ "execution_count": 9,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.auto_query(kg.terms.cmso.AtomicScaleSample, [kg.terms.cmso.hasSpaceGroupSymbol, kg.terms.cmso.hasNumberOfAtoms==4])"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Now the building of such a query programmatically is discussed. The function needs a source and destination(s). Destination can include conditions attached to it, for example, that numbers of atoms. The first thing to do is to find the right terms. For this, we can use the tab completion feature."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "cmso, qudt, pldo, podo, asmo, ns, calculation, ldo, prov, rdf, rdfs"
+ ]
+ },
+ "execution_count": 10,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.terms"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Those are all the ontologies, with the terms we use. One can go deeper down"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "SimulationCell, UnitCell, LatticeAngle, SimulationCellAngle, Angle, AtomicScaleSample, AtomicForce, AtomicPosition, AtomicVelocity, CoordinationNumber, Occupancy, AtomAttribute, Basis, MacroscaleSample, MesoscaleSample, MicroscaleSample, NanoscaleSample, ComputationalSample, CalculatedProperty, CrystallineMaterial, CrystalDefect, Atom, Molecule, ChemicalSpecies, ChemicalElement, LatticeParameter, SimulationCellLength, Length, AmorphousMaterial, Material, CrystalStructure, SpaceGroup, Microstructure, Structure, LatticeVector, SimulationCellVector, Vector, ChemicalComposition, hasAngle, hasAttribute, hasBasis, hasCalculatedProperty, isCalculatedPropertyOf, hasDefect, isDefectOf, hasElement, hasLatticeParameter, hasLength, hasMaterial, isMaterialOf, hasSimulationCell, hasSpaceGroup, hasSpecies, hasStructure, hasUnit, hasUnitCell, hasVector, hasAltName, hasName, hasAngle_alpha, hasAngle_beta, hasAngle_gamma, hasAtomicPercent, hasBravaisLattice, hasChemicalSymbol, hasSymbol, hasComponent_x, hasComponent_y, hasComponent_z, hasElementRatio, hasIdentifier, hasLength_x, hasLength_y, hasLength_z, hasNumberOfAtoms, hasPath, hasReference, hasRepetition_x, hasRepetition_y, hasRepetition_z, hasSpaceGroupNumber, hasSpaceGroupSymbol, hasValue, hasVolume, hasWeightPercent"
+ ]
+ },
+ "execution_count": 11,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.terms.cmso"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "And further select terms from there."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "cmso:AtomicScaleSample"
+ ]
+ },
+ "execution_count": 12,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.terms.cmso.AtomicScaleSample"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Applying constraints can be done through basic comparison operators"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Basic comparison operations\n",
+ "\n",
+ "Basic operators such as <, >, <=, >=, and =="
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "These operations are useful for adding conditions to the SPARQL query. When these operations are performed on a term, it is stored in its condition string. No other changes are needed. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "cmso:hasElementRatio"
+ ]
+ },
+ "execution_count": 13,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.terms.cmso.hasElementRatio==1.0"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Logical operators\n",
+ "\n",
+ "Logical operators currently supported are & and |. These operators, when applied, aggregates the condition between two terms|"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "cmso:hasChemicalSymbol"
+ ]
+ },
+ "execution_count": 14,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "(kg.terms.cmso.hasChemicalSymbol=='Al') & (kg.terms.cmso.hasElementRatio==1.0)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 42,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "cmso:hasChemicalSymbol"
+ ]
+ },
+ "execution_count": 42,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "(kg.terms.cmso.hasChemicalSymbol=='Al') | (kg.terms.cmso.hasElementRatio==1.0)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## @ operator\n",
+ "\n",
+ "The final class of operator we have is the @ operator. This can be used for resolving terms that has multiple paths. For example, rdfs:label which multiple entities can have. "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "If we want to specify label for the InputParameter, it can be done like this:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "rdfs:label"
+ ]
+ },
+ "execution_count": 15,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.terms.rdfs.label@kg.terms.asmo.hasInputParameter"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "conditions can also be applied on top"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "rdfs:label"
+ ]
+ },
+ "execution_count": 16,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.terms.rdfs.label@kg.terms.asmo.hasInputParameter=='label_string'"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "That summarises all the possible options. Now we put together these blocks to formulate some more complex queries"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "__All samples that have been used for an energy calculation__"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " AtomicScaleSample | \n",
+ " EnergyCalculation | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " sample:e54c0e91-52ec-4c47-8ba3-43979a1ebe2e | \n",
+ " activity:f61a2139-2dae-4aab-954e-73d34d7bc042 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " sample:721b7447-8363-4e65-9515-9da2581d7124 | \n",
+ " activity:0848b931-d647-41c7-a6dc-8150989e36c7 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " sample:ab2bea57-39ea-49ea-ad3f-c1c40b013154 | \n",
+ " activity:8a680cb2-c7f1-4747-95b0-a4ce71fab87f | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " sample:b1f52dc6-5c92-428f-8f7a-78794fd0544c | \n",
+ " activity:2e461195-15a4-45ba-b369-5a2429ded084 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " sample:d015cfca-e047-40bc-baab-423e87fa2618 | \n",
+ " activity:1e081e86-73fd-45e5-8341-cab787b9ff0c | \n",
+ "
\n",
+ " \n",
+ " 5 | \n",
+ " sample:fb01a7f2-8984-442b-a32e-15321c4fa99b | \n",
+ " activity:923e1808-efdf-4a6a-a5de-9e0a64cb198c | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " AtomicScaleSample \\\n",
+ "0 sample:e54c0e91-52ec-4c47-8ba3-43979a1ebe2e \n",
+ "1 sample:721b7447-8363-4e65-9515-9da2581d7124 \n",
+ "2 sample:ab2bea57-39ea-49ea-ad3f-c1c40b013154 \n",
+ "3 sample:b1f52dc6-5c92-428f-8f7a-78794fd0544c \n",
+ "4 sample:d015cfca-e047-40bc-baab-423e87fa2618 \n",
+ "5 sample:fb01a7f2-8984-442b-a32e-15321c4fa99b \n",
+ "\n",
+ " EnergyCalculation \n",
+ "0 activity:f61a2139-2dae-4aab-954e-73d34d7bc042 \n",
+ "1 activity:0848b931-d647-41c7-a6dc-8150989e36c7 \n",
+ "2 activity:8a680cb2-c7f1-4747-95b0-a4ce71fab87f \n",
+ "3 activity:2e461195-15a4-45ba-b369-5a2429ded084 \n",
+ "4 activity:1e081e86-73fd-45e5-8341-cab787b9ff0c \n",
+ "5 activity:923e1808-efdf-4a6a-a5de-9e0a64cb198c "
+ ]
+ },
+ "execution_count": 26,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.auto_query(kg.terms.cmso.AtomicScaleSample, kg.terms.asmo.EnergyCalculation)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "__Which of those had an input parameter, called Temperature?__"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 32,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " AtomicScaleSample | \n",
+ " EnergyCalculation | \n",
+ " InputParameter_labelvalue | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " sample:e54c0e91-52ec-4c47-8ba3-43979a1ebe2e | \n",
+ " activity:f61a2139-2dae-4aab-954e-73d34d7bc042 | \n",
+ " temperature | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " AtomicScaleSample \\\n",
+ "0 sample:e54c0e91-52ec-4c47-8ba3-43979a1ebe2e \n",
+ "\n",
+ " EnergyCalculation InputParameter_labelvalue \n",
+ "0 activity:f61a2139-2dae-4aab-954e-73d34d7bc042 temperature "
+ ]
+ },
+ "execution_count": 32,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.auto_query(kg.terms.cmso.AtomicScaleSample, [kg.terms.asmo.EnergyCalculation,\n",
+ " kg.terms.rdfs.label@kg.terms.asmo.InputParameter=='temperature'])"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "And the value"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 37,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " AtomicScaleSample | \n",
+ " EnergyCalculation | \n",
+ " InputParameter_labelvalue | \n",
+ " InputParameter_hasValuevalue | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " sample:e54c0e91-52ec-4c47-8ba3-43979a1ebe2e | \n",
+ " activity:f61a2139-2dae-4aab-954e-73d34d7bc042 | \n",
+ " temperature | \n",
+ " 500.0 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " AtomicScaleSample \\\n",
+ "0 sample:e54c0e91-52ec-4c47-8ba3-43979a1ebe2e \n",
+ "\n",
+ " EnergyCalculation InputParameter_labelvalue \\\n",
+ "0 activity:f61a2139-2dae-4aab-954e-73d34d7bc042 temperature \n",
+ "\n",
+ " InputParameter_hasValuevalue \n",
+ "0 500.0 "
+ ]
+ },
+ "execution_count": 37,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.auto_query(kg.terms.cmso.AtomicScaleSample, [kg.terms.asmo.EnergyCalculation,\n",
+ " kg.terms.rdfs.label@kg.terms.asmo.InputParameter=='temperature',\n",
+ " kg.terms.asmo.hasValue@kg.terms.asmo.InputParameter])"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "**What is the composition and space group of these structures**"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 41,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " AtomicScaleSample | \n",
+ " InputParameter_labelvalue | \n",
+ " InputParameter_hasValuevalue | \n",
+ " hasSpaceGroupSymbolvalue | \n",
+ " hasChemicalSymbolvalue | \n",
+ " hasElementRatiovalue | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " sample:e54c0e91-52ec-4c47-8ba3-43979a1ebe2e | \n",
+ " temperature | \n",
+ " 500.0 | \n",
+ " Fm-3m | \n",
+ " Cu | \n",
+ " 1.0 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " AtomicScaleSample InputParameter_labelvalue \\\n",
+ "0 sample:e54c0e91-52ec-4c47-8ba3-43979a1ebe2e temperature \n",
+ "\n",
+ " InputParameter_hasValuevalue hasSpaceGroupSymbolvalue \\\n",
+ "0 500.0 Fm-3m \n",
+ "\n",
+ " hasChemicalSymbolvalue hasElementRatiovalue \n",
+ "0 Cu 1.0 "
+ ]
+ },
+ "execution_count": 41,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "kg.auto_query(kg.terms.cmso.AtomicScaleSample, [\n",
+ " kg.terms.rdfs.label@kg.terms.asmo.InputParameter=='temperature',\n",
+ " kg.terms.asmo.hasValue@kg.terms.asmo.InputParameter,\n",
+ " kg.terms.cmso.hasSpaceGroupSymbol,\n",
+ " kg.terms.cmso.hasChemicalSymbol,\n",
+ " kg.terms.cmso.hasElementRatio])"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.11.8"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}
diff --git a/examples/dataset.tar.gz b/examples/dataset.tar.gz
new file mode 100644
index 0000000..9fdfeb0
Binary files /dev/null and b/examples/dataset.tar.gz differ
diff --git a/examples/workflow_examples/03_murnaghan_pyiron.ipynb b/examples/workflow_examples/03_murnaghan_pyiron.ipynb
index de43d4c..09ff597 100644
--- a/examples/workflow_examples/03_murnaghan_pyiron.ipynb
+++ b/examples/workflow_examples/03_murnaghan_pyiron.ipynb
@@ -75,87 +75,6 @@
"kg.enable_workflow(pr, workflow_environment='pyiron')"
]
},
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "cmso:hasNumberOfAtoms"
- ]
- },
- "execution_count": 6,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "kg.terms.cmso.hasNumberOfAtoms"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 9,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "a2\n"
- ]
- },
- {
- "data": {
- "text/html": [
- "\n",
- "\n",
- "
\n",
- " \n",
- " \n",
- " | \n",
- " AtomicScaleSample | \n",
- " hasNumberOfAtomsvalue | \n",
- "
\n",
- " \n",
- " \n",
- " \n",
- " 0 | \n",
- " sample:410f2be6-9bc8-44bc-8568-25ef67ffe05a | \n",
- " 2 | \n",
- "
\n",
- " \n",
- "
\n",
- "
"
- ],
- "text/plain": [
- " AtomicScaleSample hasNumberOfAtomsvalue\n",
- "0 sample:410f2be6-9bc8-44bc-8568-25ef67ffe05a 2"
- ]
- },
- "execution_count": 9,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "kg.auto_query(kg.terms.cmso.AtomicScaleSample, kg.terms.cmso.hasNumberOfAtoms==2, enforce_types=True)"
- ]
- },
{
"cell_type": "code",
"execution_count": 6,
@@ -2783,7 +2702,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.8"
+ "version": "3.1.-1"
}
},
"nbformat": 4,
diff --git a/examples/workflow_examples/05_quasiharmonic.ipynb b/examples/workflow_examples/05_quasiharmonic.ipynb
index c02115e..6a2cc0c 100644
--- a/examples/workflow_examples/05_quasiharmonic.ipynb
+++ b/examples/workflow_examples/05_quasiharmonic.ipynb
@@ -335,7 +335,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.8"
+ "version": "3.1.-1"
}
},
"nbformat": 4,
diff --git a/notebooks/generate_sample_data/generate_data.ipynb b/notebooks/generate_sample_data/generate_data.ipynb
new file mode 100644
index 0000000..48fa781
--- /dev/null
+++ b/notebooks/generate_sample_data/generate_data.ipynb
@@ -0,0 +1,291 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Generate dataset\n",
+ "\n",
+ "The aim of this notebook is to create a varied dataset with atomRDF that can be used testing quering methods, and also to show to variety of tasks that can be done. This should be runnable top to bottom."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "%config IPCompleter.evaluation='unsafe'"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Create a project"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from pyiron_atomistics import Project\n",
+ "from atomrdf import KnowledgeGraph, System\n",
+ "import numpy as np"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "project = 'data_gen_1'\n",
+ "pr = Project(project)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "kg = KnowledgeGraph(store='db', store_file=f'{project}.db')\n",
+ "kg.enable_workflow(pr, workflow_environment='pyiron')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Regular structures"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "struct_Fe = System.create.element.Fe(graph=kg)\n",
+ "struct_Si = System.create.element.Si(graph=kg)\n",
+ "struct_l12 = System.create.lattice.l12(element=['Al', 'Ni'], \n",
+ " lattice_constant=3.57, graph=kg)\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "struct_gb_1 = System.create.defect.grain_boundary(axis=[0,0,1], \n",
+ " sigma=5, \n",
+ " gb_plane=[3, -1, 0],\n",
+ " element='Fe',\n",
+ " graph=kg)\n",
+ "struct_gb_2 = System.create.defect.grain_boundary(axis=[1,1,1], \n",
+ " sigma=19, \n",
+ " gb_plane=[-3, 2, 0],\n",
+ " element='Fe',\n",
+ " graph=kg)\n",
+ "\n",
+ "struct_gb_3 = System.create.defect.grain_boundary(axis=[1,1,1], \n",
+ " sigma=19, \n",
+ " gb_plane=[-1, -1, -1],\n",
+ " element='Fe',\n",
+ " graph=kg)\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 10,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "struct_Fe = System.create.element.Fe(graph=kg)\n",
+ "struct_with_vacancy = struct_Fe.delete(indices=[0], copy_structure=True)\n",
+ "struct_Al = System.create.element.Al(graph=kg)\n",
+ "struct_Al.substitute_atoms('Mg', indices=[0], copy_structure=True)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "slip_direction = np.array([1, 0, -1])\n",
+ "slip_plane = np.array([1, 1, 1])\n",
+ "slip_system = [slip_direction, slip_plane]\n",
+ "burgers_vector = 0.5\n",
+ "dislocation_line = np.array([1, 0, -1])\n",
+ "elastic_constant_dict = {'C11': 169, 'C12': 122, 'C44': 75.4}\n",
+ "sys = System.create.defect.dislocation(slip_system,\n",
+ " dislocation_line,\n",
+ " elastic_constant_dict,\n",
+ " burgers_vector=burgers_vector,\n",
+ " element='Cu',\n",
+ " dislocation_type='monopole',\n",
+ " graph=kg,\n",
+ " )"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The job j1 was saved and received the ID: 1106\n"
+ ]
+ }
+ ],
+ "source": [
+ "structure = pr.create.structure.annotated_structure.bulk('Cu', cubic=True)\n",
+ "job = pr.create.job.Lammps('j1', delete_existing_job=True, delete_aborted_job=True)\n",
+ "job.structure = structure\n",
+ "job.potential = '2001--Mishin-Y--Cu-1--LAMMPS--ipr1'\n",
+ "job.calc_md(pressure=0, temperature=500)\n",
+ "job.run()\n",
+ "kg.add_workflow(job, workflow_environment='pyiron')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The job murn_job was saved and received the ID: 1106\n",
+ "The job murn_job_0_9 was saved and received the ID: 1107\n",
+ "The job murn_job_0_95 was saved and received the ID: 1108\n",
+ "The job murn_job_1_0 was saved and received the ID: 1109\n",
+ "The job murn_job_1_05 was saved and received the ID: 1110\n",
+ "The job murn_job_1_1 was saved and received the ID: 1111\n"
+ ]
+ }
+ ],
+ "source": [
+ "structure = pr.create.structure.annotated_structure.bulk('Cu', cubic=True)\n",
+ "ref_job = pr.create.job.Lammps('j1', delete_existing_job=True, delete_aborted_job=True)\n",
+ "ref_job.structure = structure\n",
+ "ref_job.potential = '2001--Mishin-Y--Cu-1--LAMMPS--ipr1'\n",
+ "ref_job.calc_minimize()\n",
+ "murn_job = ref_job.create_job(pr.job_type.Murnaghan, 'murn_job')\n",
+ "murn_job.input[\"num_points\"] = 5\n",
+ "murn_job.run()\n",
+ "kg.add_workflow(murn_job, workflow_environment='pyiron', add_intermediate_jobs=True)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The job quasi was saved and received the ID: 1112\n",
+ "The job quasi_0_9 was saved and received the ID: 1113\n",
+ "The job reflmp_0 was saved and received the ID: 1114\n",
+ "The job quasi_0_92 was saved and received the ID: 1115\n",
+ "The job reflmp_0 was saved and received the ID: 1116\n",
+ "The job quasi_0_94 was saved and received the ID: 1117\n",
+ "The job reflmp_0 was saved and received the ID: 1118\n",
+ "The job quasi_0_96 was saved and received the ID: 1119\n",
+ "The job reflmp_0 was saved and received the ID: 1120\n",
+ "The job quasi_0_98 was saved and received the ID: 1121\n",
+ "The job reflmp_0 was saved and received the ID: 1122\n",
+ "The job quasi_1_0 was saved and received the ID: 1123\n",
+ "The job reflmp_0 was saved and received the ID: 1124\n",
+ "The job quasi_1_02 was saved and received the ID: 1125\n",
+ "The job reflmp_0 was saved and received the ID: 1126\n",
+ "The job quasi_1_04 was saved and received the ID: 1127\n",
+ "The job reflmp_0 was saved and received the ID: 1128\n",
+ "The job quasi_1_06 was saved and received the ID: 1129\n",
+ "The job reflmp_0 was saved and received the ID: 1130\n",
+ "The job quasi_1_08 was saved and received the ID: 1131\n",
+ "The job reflmp_0 was saved and received the ID: 1132\n",
+ "The job quasi_1_1 was saved and received the ID: 1133\n",
+ "The job reflmp_0 was saved and received the ID: 1134\n"
+ ]
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/home/srmnitc/miniconda3/envs/workflow-rdf/lib/python3.11/site-packages/atomrdf/graph.py:376: UserWarning: asmo:hasValue has a range with unspecified datatype!\n",
+ " warnings.warn(f\"{triple[1].name} has a range with unspecified datatype!\")\n"
+ ]
+ }
+ ],
+ "source": [
+ "struct = pr.create.structure.annotated_structure.bulk('Cu')\n",
+ "refjob = pr.create.job.Lammps('reflmp')\n",
+ "refjob.structure = struct\n",
+ "refjob.potential = '2009--Mendelev-M-I--Cu-Zr--LAMMPS--ipr1'\n",
+ "phono = pr.create.job.PhonopyJob('phono')\n",
+ "phono.ref_job = refjob\n",
+ "quasi = pr.create.job.QuasiHarmonicJob('quasi')\n",
+ "quasi.ref_job = phono\n",
+ "quasi.input[\"temperature_end\"] = 500\n",
+ "quasi.input[\"temperature_steps\"] = 2\n",
+ "quasi.input[\"axes\"]=[\"x\",\"y\",\"z\"]\n",
+ "quasi.input[\"strains\"] = None\n",
+ "quasi.run()\n",
+ "kg.add_workflow(quasi, workflow_environment='pyiron')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "kg.archive('dataset')"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "workflow-rdf",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.11.8"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/notebooks/semantic_operations.ipynb b/notebooks/semantic_operations.ipynb
index c13b0b2..ef58b52 100644
--- a/notebooks/semantic_operations.ipynb
+++ b/notebooks/semantic_operations.ipynb
@@ -341,6 +341,85 @@
"cell_type": "markdown",
"metadata": {},
"source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "query = \"\"\"\n",
+ "PREFIX cmso: \n",
+ "SELECT DISTINCT ?symbol\n",
+ "WHERE {\n",
+ " ?sample cmso:hasNumberOfAtoms ?number .\n",
+ " ?sample cmso:hasMaterial ?material .\n",
+ " ?material cmso:hasStructure ?structure .\n",
+ " ?structure cmso:hasSpaceGroupSymbol ?symbol .\n",
+ "FILTER (?number=\"4\"^^xsd:integer)\n",
+ "}\"\"\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "kg.query_sample([kg.terms.cmso.hasSpaceGroupSymbol, kg.terms.cmso.hasNumberOfAtoms==4])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "res = kg.query_sample( \n",
+ " [kg.ontology.terms.cmso.hasAltName=='bcc'])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "res = kg.query_sample(kg.ontology.terms.pldo.SymmetricalTiltGrainBoundary)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "res = kg.query_sample([kg.ontology.terms.pldo.SymmetricalTiltGrainBoundary, \n",
+ " kg.ontology.terms.pldo.hasSigmaValue])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "res = kg.query_sample(kg.ontology.terms.ldo.ScrewDislocation)\n"
+ ]
}
],
"metadata": {
@@ -359,7 +438,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.8"
+ "version": "3.1.-1"
}
},
"nbformat": 4,
diff --git a/tests/test_term.py b/tests/test_term.py
index a60ec2b..275ff41 100644
--- a/tests/test_term.py
+++ b/tests/test_term.py
@@ -10,7 +10,7 @@ def test_lt():
term = kg.ontology.terms.cmso.hasNumberOfAtoms
term = term < 2
- assert term._condition == '(?cmso:hasNumberOfAtomsvalue<"2"^^xsd:int)'
+ assert term._condition == '(?hasNumberOfAtomsvalue<"2"^^xsd:int)'
def test_eq():
kg = KnowledgeGraph()
@@ -18,7 +18,7 @@ def test_eq():
term = kg.ontology.terms.cmso.hasNumberOfAtoms
term = (term == 2)
- assert term._condition == '(?cmso:hasNumberOfAtomsvalue="2"^^xsd:int)'
+ assert term._condition == '(?hasNumberOfAtomsvalue="2"^^xsd:int)'
def test_gt():
kg = KnowledgeGraph()
@@ -26,7 +26,7 @@ def test_gt():
term = kg.ontology.terms.cmso.hasNumberOfAtoms
term = term > 2
- assert term._condition == '(?cmso:hasNumberOfAtomsvalue>"2"^^xsd:int)'
+ assert term._condition == '(?hasNumberOfAtomsvalue>"2"^^xsd:int)'
def test_lte():
kg = KnowledgeGraph()
@@ -34,7 +34,7 @@ def test_lte():
term = kg.ontology.terms.cmso.hasNumberOfAtoms
term = term <= 2
- assert term._condition == '(?cmso:hasNumberOfAtomsvalue<="2"^^xsd:int)'
+ assert term._condition == '(?hasNumberOfAtomsvalue<="2"^^xsd:int)'
def test_gte():
kg = KnowledgeGraph()
@@ -42,7 +42,7 @@ def test_gte():
term = kg.ontology.terms.cmso.hasNumberOfAtoms
term = term >= 2
- assert term._condition == '(?cmso:hasNumberOfAtomsvalue>="2"^^xsd:int)'
+ assert term._condition == '(?hasNumberOfAtomsvalue>="2"^^xsd:int)'
def test_ne():
kg = KnowledgeGraph()
@@ -50,18 +50,18 @@ def test_ne():
term = kg.ontology.terms.cmso.hasNumberOfAtoms
term = term != 2
- assert term._condition == '(?cmso:hasNumberOfAtomsvalue!="2"^^xsd:int)'
+ assert term._condition == '(?hasNumberOfAtomsvalue!="2"^^xsd:int)'
def test_and():
kg = KnowledgeGraph()
struct_Fe = System.create.element.Fe(graph=kg)
term = (kg.ontology.terms.cmso.hasVolume > 2) & (kg.ontology.terms.cmso.hasVolume < 4)
- assert term._condition == '((?cmso:hasVolumevalue>"2"^^xsd:float)&&(?cmso:hasVolumevalue<"4"^^xsd:float))'
+ assert term._condition == '((?hasVolumevalue>"2"^^xsd:float)&&(?hasVolumevalue<"4"^^xsd:float))'
def test_or():
kg = KnowledgeGraph()
struct_Fe = System.create.element.Fe(graph=kg)
term = (kg.ontology.terms.cmso.hasVolume > 2) | (kg.ontology.terms.cmso.hasVolume < 4)
- assert term._condition == '((?cmso:hasVolumevalue>"2"^^xsd:float)||(?cmso:hasVolumevalue<"4"^^xsd:float))'
\ No newline at end of file
+ assert term._condition == '((?hasVolumevalue>"2"^^xsd:float)||(?hasVolumevalue<"4"^^xsd:float))'
\ No newline at end of file