Example #1
0
 def test_composition_2(self):
     """
     Test (pychemia.core.composition)                            :
     """
     comp = pychemia.Composition('Na2Cl2')
     self.assertEqual(comp.symbols, [u'Cl', u'Cl', u'Na', u'Na'])
     self.assertEqual(pychemia.utils.periodic.valence(comp.symbols),
                      [7, 7, 1, 1])
Example #2
0
def test_composition():
    """
    Tests (pychemia.core.composition)                            :
    """
    pychemia.pcm_log.debug('Tests (pychemia.core.composition)')
    comp = pychemia.Composition('YBa2Cu3O7')
    assert sorted(comp.species) == ['Ba', 'Cu', 'O', 'Y']
    assert (sorted(comp.symbols) == [
        'Ba', 'Ba', 'Cu', 'Cu', 'Cu', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'Y'
    ])
    assert (comp.formula == 'Ba2Cu3O7Y')
    assert (abs(comp.covalent_volume() - 285.185) < 1E-5)
    assert (comp.natom == 13)

    assert (comp.sorted_formula(sortby='hill') == 'Ba2Cu3O7Y')

    comp = pychemia.Composition('Na2Cl2')
    assert (comp.symbols == ['Cl', 'Cl', 'Na', 'Na'])
    assert (pychemia.utils.periodic.valence(comp.symbols) == [7, 7, 1, 1])
Example #3
0
def test_composition():
    """
    Tests (pychemia.core.composition)                            :
    """
    pychemia.pcm_log.debug('Tests (pychemia.core.composition)')
    comp = pychemia.Composition('YBa2Cu3O7')
    assert (comp.species == sorted([u'Y', u'Cu', u'Ba', u'O']))
    assert (sorted(comp.symbols) == sorted([
        u'Y', u'Cu', u'Cu', u'Cu', u'Ba', u'Ba', u'O', u'O', u'O', u'O', u'O',
        u'O', u'O'
    ]))
    assert (comp.formula == 'Ba2Cu3O7Y')
    assert (abs(comp.covalent_volume() - 285.185) < 1E-5)
    assert (comp.natom == 13)
    assert (comp.species_hex() == 942087432)
    assert (comp.species_bin() == 72058144330612992)
    assert (comp.sorted_formula(sortby='hill') == 'Ba2Cu3O7Y')

    comp = pychemia.Composition('Na2Cl2')
    assert (comp.symbols == [u'Cl', u'Cl', u'Na', u'Na'])
    assert (pychemia.utils.periodic.valence(comp.symbols) == [7, 7, 1, 1])
Example #4
0
 def test_composition_1(self):
     """
     Test (pychemia.core.composition)                            :
     """
     comp = pychemia.Composition('YBa2Cu3O7')
     self.assertEqual(sorted(comp.species), [u'Ba', u'Cu', u'O', u'Y'])
     self.assertEqual(sorted(comp.symbols), [
         u'Ba', u'Ba', u'Cu', u'Cu', u'Cu', u'O', u'O', u'O', u'O', u'O',
         u'O', u'O', u'Y'
     ])
     self.assertEqual(comp.formula, 'Ba2Cu3O7Y')
     self.assertTrue(abs(comp.covalent_volume() - 285.185) < 1E-5)
     self.assertEqual(comp.natom, 13)
     self.assertEqual(comp.sorted_formula(sortby='hill'), 'Ba2Cu3O7Y')
Example #5
0
 def __init__(self,
              name,
              composition=None,
              tag='global',
              target_forces=1E-3,
              value_tol=1E-2,
              distance_tol=0.1,
              minimal_density=70.0,
              refine=True):
     if composition is not None:
         self.composition = pychemia.Composition(composition)
     else:
         self.composition = None
     self.tag = tag
     self.target_forces = target_forces
     self.value_tol = value_tol
     self.distance_tol = distance_tol
     self.minimal_density = minimal_density
     self.refine = refine
     Population.__init__(self, name, tag)
     print(self.minimal_density)