Skip to content

Commit

Permalink
Fixing the get_defined_properties method.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikibonacci committed Oct 29, 2024
1 parent 5552c6d commit dc2e522
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 171 deletions.
47 changes: 33 additions & 14 deletions docs/01-structuredata.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
{
"data": {
"text/plain": [
"<aiida_atomistic.data.structure.structure.StructureDataMutable at 0x7afbd3d62050>"
"<aiida_atomistic.data.structure.structure.StructureDataMutable at 0x703e435b3ac0>"
]
},
"execution_count": 7,
Expand Down Expand Up @@ -602,18 +602,18 @@
"source": [
"## Automatic kinds generation\n",
"\n",
"It is possible to automatically detect kinds for a given structure. This is done by default when initializing the structure from ASE or Pymatgen. Moreover, the kind can be also generated during the `to_dict` call, such that our output_dictionary will already have the detected kinds. This is valid also for the `get_value`, `to_immutable` methods. \n",
"It is possible to automatically detect kinds for a given structure. This is done by default when initializing the structure from ASE or Pymatgen. Moreover, the kind can be also generated during the `to_dict` call, such that our output_dictionary will already have the detected kinds. This is valid also for the `get_value`, `from_mutable` methods. \n",
"In summary, we can control automatic kind detection in the initialization of our StructureData/StructureDataMutable:\n",
"\n",
"1. new_structuredata = StructureData.from_ase(ase_structure, detect_kinds=False) # default is True\n",
"2. new_structuredata = StructureData.from_pymatgen(pymatgen_structure, detect_kinds=False) # default is True\n",
"3. new_structuredata = StructureData(**old_structuredata.to_dict(detect_kinds=True)) # default is False\n",
"4. new_structuredata = mutable_structure.to_immutable(detect_kinds=True) # default is False"
"4. new_structuredata = StructureData.from_mutable(mutable_structure, detect_kinds=True) # default is False"
]
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -747,30 +747,49 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2031\n",
"[<StructureData: uuid: 8851c51a-0560-404b-abba-82359ee5a595 (pk: 2029)>]\n"
"2247\n"
]
},
{
"data": {
"text/plain": [
"[[<StructureData: uuid: 8851c51a-0560-404b-abba-82359ee5a595 (pk: 2029)>],\n",
" [<StructureData: uuid: 3f5390e2-816b-450c-b67c-b87dfe11872f (pk: 2242)>],\n",
" [<StructureData: uuid: 8eeeef7a-3a40-4735-bafb-00d78b97202d (pk: 2030)>],\n",
" [<StructureData: uuid: fcc156e7-b633-4513-a2af-cf130cbc6ddd (pk: 2031)>],\n",
" [<StructureData: uuid: 3d91cbd3-e4aa-4ddf-a49f-94c4b0fe9ec7 (pk: 2243)>],\n",
" [<StructureData: uuid: abf28cab-f8a9-4084-b603-967b907eb08c (pk: 2244)>],\n",
" [<StructureData: uuid: 8310cd8a-6d95-4b32-9752-a5186bd0929e (pk: 2245)>],\n",
" [<StructureData: uuid: 8762ed75-09b1-4b8b-97a7-136233d9ceaa (pk: 2246)>],\n",
" [<StructureData: uuid: 1123f488-a8f5-46aa-8b07-65a3bc395db7 (pk: 2247)>],\n",
" [<StructureData: uuid: 1ee9c471-786f-424b-ad6a-6a9626380231 (pk: 1649)>],\n",
" [<StructureData: uuid: d3cba3d3-b21a-43fa-8397-b734cc006a37 (pk: 1650)>]]"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from aiida.orm import QueryBuilder\n",
"\n",
"stored = new_StructureData.from_mutable(mutable_structure).store()\n",
"stored = StructureData.from_mutable(mutable_structure).store()\n",
"print(stored.pk)\n",
"\n",
"qb = QueryBuilder()\n",
"qb.append(StructureData, \n",
" filters={'attributes.formula': 'Fe2'},\n",
" )\n",
"\n",
"print(qb.all()[0])"
"qb.all()"
]
},
{
Expand All @@ -784,7 +803,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 19,
"metadata": {},
"outputs": [
{
Expand All @@ -799,7 +818,7 @@
" 'weights': (0.5, 0.5)}"
]
},
"execution_count": 14,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -827,7 +846,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 20,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -856,7 +875,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 21,
"metadata": {},
"outputs": [
{
Expand All @@ -874,7 +893,7 @@
"<AttributesFrozendict {'electronic_type': 'metal'}>"
]
},
"execution_count": 16,
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
52 changes: 26 additions & 26 deletions docs/02-supercell-generation-and-more.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -55,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand All @@ -76,7 +76,7 @@
" <SiteImmutable: kind name 'H12' @ 0.0,0.0,16.176537180435968>]"
]
},
"execution_count": 25,
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -95,7 +95,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand All @@ -104,7 +104,7 @@
"[True, True, False]"
]
},
"execution_count": 26,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -122,7 +122,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand All @@ -131,7 +131,7 @@
"[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0]"
]
},
"execution_count": 28,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -159,7 +159,7 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -230,7 +230,7 @@
"PeriodicSite: Si1 (Si) (11.16, 7.893, 19.33) [0.8333, 0.8333, 0.8333]"
]
},
"execution_count": 40,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -244,7 +244,7 @@
},
{
"cell_type": "code",
"execution_count": 41,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand All @@ -255,7 +255,7 @@
" [0.0, 0.0, 11.60092395]]"
]
},
"execution_count": 41,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -274,7 +274,7 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand All @@ -283,7 +283,7 @@
"{'Si0'}"
]
},
"execution_count": 42,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -301,7 +301,7 @@
},
{
"cell_type": "code",
"execution_count": 44,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand All @@ -310,7 +310,7 @@
"{'Si0', 'Si1'}"
]
},
"execution_count": 44,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -331,7 +331,7 @@
},
{
"cell_type": "code",
"execution_count": 58,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -342,7 +342,7 @@
},
{
"cell_type": "code",
"execution_count": 61,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -351,7 +351,7 @@
},
{
"cell_type": "code",
"execution_count": 62,
"execution_count": 11,
"metadata": {},
"outputs": [
{
Expand All @@ -361,7 +361,7 @@
" -1., 1., -1.])"
]
},
"execution_count": 62,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -372,7 +372,7 @@
},
{
"cell_type": "code",
"execution_count": 63,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -381,7 +381,7 @@
},
{
"cell_type": "code",
"execution_count": 64,
"execution_count": 13,
"metadata": {},
"outputs": [
{
Expand All @@ -405,7 +405,7 @@
" -1.0]"
]
},
"execution_count": 64,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -423,7 +423,7 @@
},
{
"cell_type": "code",
"execution_count": 67,
"execution_count": 14,
"metadata": {},
"outputs": [
{
Expand All @@ -432,7 +432,7 @@
"{'Cl1', 'Na0'}"
]
},
"execution_count": 67,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -443,7 +443,7 @@
},
{
"cell_type": "code",
"execution_count": 70,
"execution_count": 15,
"metadata": {},
"outputs": [
{
Expand All @@ -452,7 +452,7 @@
"[HubbardParameters(atom_index=0, atom_manifold='3d', neighbour_index=0, neighbour_manifold='3d', translation=(0, 0, 0), value=4.0, hubbard_type='U')]"
]
},
"execution_count": 70,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
Loading

0 comments on commit dc2e522

Please sign in to comment.