Skip to content

Commit

Permalink
Adding to_kinds and get_kinds functionalities.
Browse files Browse the repository at this point in the history
*Missing:
            - Give custom threshold and use kind_tags as defined in
              structure.properties.positions.kind_tags.

Questions:
        answered, but worth to leave it here for now: What is then the value of each property associated to each kind? an average? maybe yes.
        This can be then generated in another function which takes the averages. Maybe in the property specific
        to_kind methods. Maybe indeed the average point which is obtained during the space_grid generation.
  • Loading branch information
mikibonacci committed Feb 7, 2024
1 parent bef8984 commit 6a9daeb
Show file tree
Hide file tree
Showing 7 changed files with 404 additions and 53 deletions.
207 changes: 161 additions & 46 deletions aiida_atomistic/data/structure/5_feb.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,26 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"properties = {\n",
" \"cell\":{\"value\":((1.0,0,0),(0,1,0),(0,0,1))},\n",
" \"pbc\":{\"value\":[True,False,True]},\n",
" \"positions\":{\"value\":[[1,1,1],[2,3,3]]},\n",
" \"symbols\":{\"value\":[\"He\",\"Cu\"]},\n",
" \"positions\":{\n",
" \"value\":[[1,1,1],[2,3,3],[3,4,5],[1,2,3]],\n",
" \"kind_tags\":[\"He1\",\"\",\"\",\"He1\"]\n",
" },\n",
" \"symbols\":{\"value\":[\"He\",\"Cu\",\"He\",\"He\"]},\n",
" \"mass\":{\"value\":[1.551,9,1.5512,2],},\n",
" \"charge\":{\"value\":[1,0,1,0]}\n",
" }"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -66,16 +71,16 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Cell(parent=<StructureData: uuid: aa4ae241-35d6-4788-bfff-d63143c95659 (unstored)>, value=((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)), domain='global')"
"Cell(parent=<StructureData: uuid: 109f80df-7dcf-4228-9e15-1088abff849a (unstored)>, value=((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)), domain='global')"
]
},
"execution_count": 7,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -86,16 +91,16 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['pbc', 'cell', 'positions', 'symbols', 'custom']"
"['pbc', 'cell', 'positions', 'symbols', 'mass', 'charge', 'custom']"
]
},
"execution_count": 8,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -106,22 +111,40 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<StructureData: uuid: aa4ae241-35d6-4788-bfff-d63143c95659 (pk: 13813)>"
"['charge', 'symbols', 'pbc', 'cell', 'positions', 'mass']"
]
},
"execution_count": 9,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"structure.store()"
"structure.properties.get_defined_properties()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"#structure.store()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"#s = orm.load_node(structure.pk)"
]
},
{
Expand All @@ -130,27 +153,16 @@
"metadata": {},
"outputs": [],
"source": [
"s = orm.load_node(structure.pk)"
"#s.properties"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<aiida_atomistic.data.structure.properties.property_collector.PropertyCollector at 0x7f64bd218970>"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"s.properties"
"#s.properties.positions"
]
},
{
Expand All @@ -161,7 +173,7 @@
{
"data": {
"text/plain": [
"Positions(parent=<StructureData: uuid: aa4ae241-35d6-4788-bfff-d63143c95659 (pk: 13813)>, value=[(1.0, 1.0, 1.0), (2.0, 3.0, 3.0)], domain='per-site')"
"['pbc', 'cell', 'positions', 'symbols', 'mass', 'charge', 'custom']"
]
},
"execution_count": 12,
Expand All @@ -170,7 +182,7 @@
}
],
"source": [
"s.properties.positions"
"list(structure.properties.get_valid_properties())"
]
},
{
Expand All @@ -181,7 +193,7 @@
{
"data": {
"text/plain": [
"['pbc', 'cell', 'positions', 'symbols', 'custom']"
"4"
]
},
"execution_count": 13,
Expand All @@ -190,7 +202,7 @@
}
],
"source": [
"list(s.properties.get_valid_properties())"
"len(structure.properties.positions.value)"
]
},
{
Expand All @@ -201,7 +213,7 @@
{
"data": {
"text/plain": [
"2"
"Symbols(parent=<StructureData: uuid: 109f80df-7dcf-4228-9e15-1088abff849a (unstored)>, value=['He', 'Cu', 'He', 'He'], domain='per-site')"
]
},
"execution_count": 14,
Expand All @@ -210,7 +222,7 @@
}
],
"source": [
"len(s.properties.positions.value)"
"structure.properties.symbols "
]
},
{
Expand All @@ -221,7 +233,13 @@
{
"data": {
"text/plain": [
"Symbols(parent=<StructureData: uuid: aa4ae241-35d6-4788-bfff-d63143c95659 (pk: 13813)>, value=['He', 'Cu'], domain='per-site')"
"{'cell': {'value': ((1.0, 0, 0), (0, 1, 0), (0, 0, 1))},\n",
" 'pbc': {'value': [True, False, True]},\n",
" 'positions': {'value': [[1, 1, 1], [2, 3, 3], [3, 4, 5], [1, 2, 3]],\n",
" 'kind_tags': ['He1', '', '', 'He1']},\n",
" 'symbols': {'value': ['He', 'Cu', 'He', 'He']},\n",
" 'mass': {'value': [1.551, 9, 1.5512, 2]},\n",
" 'charge': {'value': [1, 0, 1, 0]}}"
]
},
"execution_count": 15,
Expand All @@ -230,7 +248,7 @@
}
],
"source": [
"s.properties.symbols "
"structure.base.attributes.get('_property_attributes')"
]
},
{
Expand All @@ -241,10 +259,13 @@
{
"data": {
"text/plain": [
"{'pbc': {'value': [True, False, True]},\n",
" 'cell': {'value': [[1.0, 0, 0], [0, 1, 0], [0, 0, 1]]},\n",
" 'symbols': {'value': ['He', 'Cu']},\n",
" 'positions': {'value': [[1, 1, 1], [2, 3, 3]]}}"
"{'cell': {'value': ((1.0, 0, 0), (0, 1, 0), (0, 0, 1))},\n",
" 'pbc': {'value': [True, False, True]},\n",
" 'positions': {'value': [[1, 1, 1], [2, 3, 3], [3, 4, 5], [1, 2, 3]],\n",
" 'kind_tags': ['He1', '', '', 'He1']},\n",
" 'symbols': {'value': ['He', 'Cu', 'He', 'He']},\n",
" 'mass': {'value': [1.551, 9, 1.5512, 2]},\n",
" 'charge': {'value': [1, 0, 1, 0]}}"
]
},
"execution_count": 16,
Expand All @@ -253,7 +274,7 @@
}
],
"source": [
"s.base.attributes.get('_property_attributes')"
"structure.to_dict()"
]
},
{
Expand All @@ -264,10 +285,7 @@
{
"data": {
"text/plain": [
"{'pbc': {'value': [True, False, True]},\n",
" 'cell': {'value': [[1.0, 0, 0], [0, 1, 0], [0, 0, 1]]},\n",
" 'symbols': {'value': ['He', 'Cu']},\n",
" 'positions': {'value': [[1, 1, 1], [2, 3, 3]]}}"
"[1.551, 9.0, 1.5512, 2.0]"
]
},
"execution_count": 17,
Expand All @@ -276,7 +294,104 @@
}
],
"source": [
"s.to_dict()"
"structure.properties.mass.value"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.001"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"structure.properties.mass.default_kind_threshold"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(array([ 0, 74, 0, 4]),\n",
" [1.601, 9.001000000000007, 1.601, 2.0010000000000003])"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"structure.properties.mass.to_kinds(thr = 0.1, kind_names=False)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['He', 'Cu', 'He', 'He']"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"structure.properties.symbols.value"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"He\n",
"Cu\n",
"He\n",
"He\n"
]
},
{
"data": {
"text/plain": [
"([2, 1, 2, 3],\n",
" ['He2', 'Cu1', 'He2', 'He3'],\n",
" {'charge': [1.1250000000000002, 0.225, 1.1250000000000002, 0.225],\n",
" 'mass': [1.5514999999999999,\n",
" 9.000499999999178,\n",
" 1.5514999999999999,\n",
" 2.0004999999999504]})"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"get_kinds(structure)"
]
},
{
Expand Down
Loading

0 comments on commit 6a9daeb

Please sign in to comment.