PyChemiaMaster Database

Notes

Steps to access the database and make queries:

  • ipython <enter>

    • import pychemia <enter>

    • pcdb=pychemia.db.PyChemiaDB(‘PyChemiaMasterDB’) <enter> ## to create and object of the Master database

    • pcdb.entries.count()
      ## gives the total number of entries in the database
      Out[3]: 319465

    • pcdb.entries.find_one() ## This finds one entry from the database
      Out[4]: Here, {} may not appear at some places in the output below...
      u’_id’: ObjectId(’56732c11b1df416eda4f901e’),
      u’properties’: u’blocks’: [u’f’],
      u’bravais’: u’angles’: [90.0, 90.0, 120.00000000000001],
      u’lengths’: [4.000801927465354, 4.000801927465354, 29.138496000000004]
      ,
      u’oqmd’: u’band_gap’: 0.0,
      u’calculation_id’: 3023,
      u’energy’: -12.30815317,
      u’energy_pa’: -4.10271772333333,
      u’entry_id’: 1514,
      u’settings’: u’algo’: u’fast’,
      u’ediff’: 0.0001,
      u’encut’: 520.0,
      u’epsilon’: 1.0,
      u’ibrion’: -1,
      u’idipol’: 0,
      u’isif’: 2,
      u’ismear’: -5,
      u’ispin’: 2,
      u’istart’: 0,
      u’lcharg’: True,
      u’ldipol’: False,
      u’lorbit’: 11,
      u’lreal’: False,
      u’lvtot’: True,
      u’lwave’: False,
      u’nbands’: 28,
      u’nelm’: 60,
      u’nelmin’: 5,
      u’nsw’: 0,
      u’potentials’: [u’name’: u’Ac’,
      u’paw’: True,
      u’us’: False,
      u’xc’: u’PBE’
      ],
      u’potim’: 0.5,
      u’prec’: u’med’,
      u’pstress’: 0.0,
      u’sigma’: 0.2
      ,
      u’spacegroup_number’: 166,
      u’structure_id’: 38386
      ,
      u’spacegroup’: u’crystal_system’: u’Trigonal’, u’number’: 166,
      u’spacegroup_number’: u’symprec’: 0.001, u’value’: 166
      ,
      u’status’: u’refined’: True,
      u’structure’: u’cell’: [[2.000400963732677, 1.154932034898248, 9.712832],
      [-2.000400963732677, 1.154932034898248, 9.712832],
      [0.0, -2.309864069796496, 9.712832]],
      u’density’: 5.124818399581233,
      u’formula’: u’Ac’,
      u’natom’: 3,
      u’nspecies’: 1,
      u’periodicity’: [True, True, True],
      u’positions’: [[2.000400963732676, 1.1549320348982473, 9.712832],
      [-5.551115123125783e-17, -1.1102230246251565e-16, 6.485522000000003],
      [0.0, -8.881784197001252e-16, 22.652974000000004]],
      u’reduced’: [[0.9999999999999997,
      1.4802973661668753e-16,
      1.4802973661668753e-16],
      [0.22257572937189352, 0.22257572937189354, 0.22257572937189363],
      [0.7774242706281065, 0.7774242706281065, 0.7774242706281068]],
      u’symbols’: [u’Ac’, u’Ac’, u’Ac’]

    • pcdb.entries.find({‘structure.nspecies’: 3}) <enter> ## returns a dictionary containing list of ternary compounds

    • pcdb.entries.find({‘structure.nspecies’: 3}).count() <enter> ## returns total number of ternary compounds
      236200

    • pcdb.entries.find({‘structure.nspecies’: 3, ‘properties.spacegroup.number’: 135}).count() <enter> ## returns total number of ternary compounds with 135 space group
      18

    to print all 18 ternary compounds with 135 space group

    • for x in pcdb.entries.find({’structure.nspecies’: 3, ’properties.spacegroup.number’: 135}):
      ....: print x[’structure’][’formula’]
      ....: print x[’properties’][’spacegroup’]

      MgO4Sb2
      u’crystal_system’: u’Tetragonal’, u’number’: 135
      FeO4Sb2
      u’crystal_system’: u’Tetragonal’, u’number’: 135
      As2CuO4
      u’crystal_system’: u’Tetragonal’, u’number’: 135
      O4Sb2Zn
      u’crystal_system’: u’Tetragonal’, u’number’: 135
      MnO4Sb2
      u’crystal_system’: u’Tetragonal’, u’number’: 135
      NiO4Sb2
      u’crystal_system’: u’Tetragonal’, u’number’: 135
      B2CY
      u’crystal_system’: u’Tetragonal’, u’number’: 135
      B2CHo
      u’crystal_system’: u’Tetragonal’, u’number’: 135
      ....
      ....
      ....
      and list goes on.........

    • pcdb.entries.find({’structure.nspecies’: 3, ’properties.spacegroup.number’: {’\(in': [130, 135]\)}}).count() ## Uses the OR operation to find count of all ternary structures with having either 135 or 130 space group symmetry.
      OUTPUT: 34

    Find all compounds having more than 2 elements and with space group 130 or 135.

    • In [23]: for x in pcdb.entries.find({’structure.nspecies’: {’\(gt': 2\}, 'properties.spacegroup.number': \{'\)in’: [130, 135]}}, {’structure.formula’: 1, ’_id’: 0
      print x
      u’structure’: u’formula’: u’F7Li3Th’
      u’structure’: u’formula’: u’MgO4Sb2’
      u’structure’: u’formula’: u’IK3O5’
      u’structure’: u’formula’: u’FeO4Sb2’
      u’structure’: u’formula’: u’BeF5K3’
      u’structure’: u’formula’: u’Bi2CuO4’
      u’structure’: u’formula’: u’As2CuO4’
      u’structure’: u’formula’: u’O5SiSr3’
      u’structure’: u’formula’: u’O4Sb2Zn’
      u’structure’: u’formula’: u’MnO4Sb2’
      u’structure’: u’formula’: u’NiO4Sb2’
      u’structure’: u’formula’: u’B2CY’
      u’structure’: u’formula’: u’B2CHo’
      u’structure’: u’formula’: u’B2CTm’
      .......
      .......
      .......

    List the compounds having more than 2 elements and containing ’Bi’ OR ’O’ atoms and with space group 130 or 135... also don’t show the ObjectID in the list... (basically, we set the projection of ’_id’ to ZERO)

    • for x in pcdb.entries.find({’structure.nspecies’: {’$gt’: 2}, ’structure.symbols’: {’$in’: [’Bi’, ’O’]}, ’properties.spacegroup.number’: {’$in’: [130, 135]}}, {’structure.formula’: 1, ’_id’: 0}):
      print x

      OUTPUT:
      u’structure’: u’formula’: u’MgO4Sb2’
      u’structure’: u’formula’: u’IK3O5’
      u’structure’: u’formula’: u’FeO4Sb2’
      u’structure’: u’formula’: u’Bi2CuO4’
      u’structure’: u’formula’: u’As2CuO4’
      u’structure’: u’formula’: u’O5SiSr3’
      u’structure’: u’formula’: u’O4Sb2Zn’
      u’structure’: u’formula’: u’MnO4Sb2’
      u’structure’: u’formula’: u’NiO4Sb2’
      u’structure’: u’formula’: u’AuBi2O5’
      u’structure’: u’formula’: u’O4Sn2Ti’
      u’structure’: u’formula’: u’Bi2O4Pd’
      u’structure’: u’formula’: u’O5PV’

    List the compounds having more than 2 elements and containing ’Bi’ AND ’O’ atoms and with space group 130 or 135... also don’t show the ObjectID in the list... (basically, we set the projection of ’_id’ to ZERO)

    • for x in pcdb.entries.find({’structure.nspecies’: ’$gt’: 2, ’$and’: [{’structure.symbols’: ’Bi’}, {’structure.symbols’: ’O’}], ’properties.spacegroup.number’: {’$in’: [130, 135]}}, {’structure.formula’: 1, ’_id’: 0}):
      print x

      OUTPUT:
      u’structure’: u’formula’: u’Bi2CuO4’
      u’structure’: u’formula’: u’AuBi2O5’
      u’structure’: u’formula’: u’Bi2O4Pd’

    List the compounds having more than 2 elements and containing ’Bi’ AND ’O’ atoms and with space group 130 or 135 or 221... also don’t show the ObjectID in the list... (basically, we set the projection of ’_id’ to ZERO)

    • for x in pcdb.entries.find({’structure.nspecies’: {’$gt’: 2}, ’$and’: [{’structure.symbols’: ’Bi’}, {’structure.symbols’: ’O’}], ’properties.spacegroup.number’: {’$in’: [130, 135, 221]}}, {’structure.formula’: 1, ’_id’: 0}):
      print x

      OUTPUT:
      u’structure’: u’formula’: u’Bi2CuO4’
      u’structure’: u’formula’: u’AuBi2O5’
      u’structure’: u’formula’: u’AlBiO3’
      u’structure’: u’formula’: u’BiGaO3’
      u’structure’: u’formula’: u’BiInO3’
      u’structure’: u’formula’: u’BiO3Sc’
      u’structure’: u’formula’: u’BiLi8O3’
      u’structure’: u’formula’: u’BiNa8O3’
      u’structure’: u’formula’: u’BiK8O3’
      u’structure’: u’formula’: u’BiO3Rb8’
      u’structure’: u’formula’: u’Bi2O4Pd’
      u’structure’: u’formula’: u’BiHgO3’
      ......
      ......
      ..... and many more ....


    • Find the total number of ternary structures having ’Co’ and ’O’ elements:–
      pcdb.entries.find(śtructure.nspecies: 3, $and: [śtructure.symbols: Ćo', śtructure.symbols: Ó']).count()
      Out[10]: 489






    Select a desired structure from the database and CREATE its POSCAR:–


    1. Get the Object ID of that structure.

    2. import bson

    3. use PyChemia to create POSCAR.



    follow the below steps to create poscar

    • for x in pcdb.entries.find({’structure.nspecies’: ’$gt’: 2}, ’$and’: [{’structure.symbols’: ’Bi’}, {’structure.symbols’: ’O’}], ’properties.spacegroup.number’: {’$in’: [130, 135]}}, {’structure.formula’: 1, ’_id’: 1}):
      print x ## here I am printing the ObjectID of structures
      OUTPUT:
      u’_id’: ObjectId(’56732c7ab1df416eda4f96b6’), u’structure’: u’formula’: u’Bi2CuO4’
      u’_id’: ObjectId(’56732efbb1df416eda4fbd8e’), u’structure’: u’formula’: u’AuBi2O5’
      u’_id’: ObjectId(’567330beb1df416eda4fdb47’), u’structure’: u’formula’: u’Bi2O4Pd’

    • import bson

    • bson.ObjectId(’56732c7ab1df416eda4f96b6’)

    • st=bson.ObjectId(’56732c7ab1df416eda4f96b6’)

    • ids=bson.ObjectId(’56732c7ab1df416eda4f96b6’)

    • pcdb.get_structure(ids)

      OUTPUT:–
      Out[39]: Structure(symbols=[u’Bi’, u’Bi’, u’Bi’, u’Bi’, u’Bi’, u’Bi’, u’Bi’, u’Bi’, u’Cu’, u’Cu’, u’Cu’, u’Cu’, u’O’, u’O’, u’O’, u’O’, u’O’, u’O’, u’O’, u’O’, u’O’, u’O’, u’O’, u’O’, u’O’, u’O’, u’O’, u’O’], cell=[8.12668366, 8.12668366, 5.471898352], positions=[[1.2499309150000046, 1.2499309150000046, 1.367974588], [6.876752744999995, 6.876752744999995, 1.367974588], [5.313272745000004, 2.813410914999995, 1.367974588], [2.813410914999995, 5.313272745000004, 1.367974588], [2.813410914999995, 2.813410914999995, 4.103923764], [5.313272745000004, 5.313272745000004, 4.103923764], [6.876752744999995, 1.2499309150000046, 4.103923764], [1.2499309150000046, 6.876752744999995, 4.103923764], [0.0, 4.06334183, 0.43821000000000004], [4.06334183, 0.0, 2.297739176], [4.06334183, 0.0, 5.033688352], [0.0, 4.06334183, 3.1741591760000003], [2.3658200000000003, 0.817711830000006, 4.905409999999998], [5.760863659999999, 7.308971829999994, 4.905409999999998], [6.42916183, 3.245629999999994, 3.3024375280000022], [1.6975218299999995, 4.881053660000005, 3.3024375280000022], [7.308971829999994, 5.760863659999999, 3.3024375280000022], [0.817711830000006, 2.3658200000000003, 3.3024375280000022], [4.881053660000005, 1.6975218299999995, 4.905409999999998], [3.245629999999994, 6.42916183, 4.905409999999998], [1.6975218299999995, 3.245629999999994, 0.5664883520000021], [6.42916183, 4.881053660000005, 0.5664883520000021], [5.760863659999999, 0.817711830000006, 2.169460823999998], [2.3658200000000003, 7.308971829999994, 2.169460823999998], [4.881053660000005, 6.42916183, 2.169460823999998], [3.245629999999994, 1.6975218299999995, 2.169460823999998], [7.308971829999994, 2.3658200000000003, 0.5664883520000021], [0.817711830000006, 5.760863659999999, 0.5664883520000021]], periodicity=True)


    • st=pcdb.get_structure(ids)

    • print st

      28

      Symb ( Positions ) [ Cell-reduced coordinates ]
      Bi ( 1.2499 1.2499 1.3680 ) [ 0.1538 0.1538 0.2500 ]
      Bi ( 6.8768 6.8768 1.3680 ) [ 0.8462 0.8462 0.2500 ]
      Bi ( 5.3133 2.8134 1.3680 ) [ 0.6538 0.3462 0.2500 ]
      Bi ( 2.8134 5.3133 1.3680 ) [ 0.3462 0.6538 0.2500 ]
      Bi ( 2.8134 2.8134 4.1039 ) [ 0.3462 0.3462 0.7500 ]
      Bi ( 5.3133 5.3133 4.1039 ) [ 0.6538 0.6538 0.7500 ]
      Bi ( 6.8768 1.2499 4.1039 ) [ 0.8462 0.1538 0.7500 ]
      Bi ( 1.2499 6.8768 4.1039 ) [ 0.1538 0.8462 0.7500 ]
      Cu ( 0.0000 4.0633 0.4382 ) [ 0.0000 0.5000 0.0801 ]
      Cu ( 4.0633 0.0000 2.2977 ) [ 0.5000 0.0000 0.4199 ]
      Cu ( 4.0633 0.0000 5.0337 ) [ 0.5000 0.0000 0.9199 ]
      Cu ( 0.0000 4.0633 3.1742 ) [ 0.0000 0.5000 0.5801 ]
      O ( 2.3658 0.8177 4.9054 ) [ 0.2