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)