Exemple #1
0
 def test_parse_structure_section_noposfile(self):
     myip = InputParser(inputfile="neb_with_phonons.inp")
     minput = MASTFile("%s/structure_noposfile_lines.txt" % testdir)
     cleanlines = list()
     for line in minput.data:
         cleanlines.append(line.strip())
     myoptions = InputOptions()
     myip.parse_structure_section('structure', cleanlines, myoptions)
     #print myoptions
     self.assertEqual(myoptions.options['structure']['atom_list'],
                      ['Al', 'Mg', 'Al', 'Fe'])
     self.assertEqual(myoptions.options['structure']['coord_type'],
                      'fractional')
     self.assertTrue(
         np.array_equal(myoptions.options['structure']['lattice'],
                        np.array([[3.5, 1, 2], [3, 3.5, 4], [5, 6, 3.5]])))
     self.assertTrue(
         np.array_equal(
             myoptions.options['structure']['coordinates'],
             np.array([[0, 0, 0], [0.5, 0.5, 0], [0, 0.5, 0.5],
                       [0.5, 0, 0.5]])))
     self.assertItemsEqual(myoptions.options['structure']['element_map'],
                           dict({
                               'X1': 'Al',
                               'X2': 'Mg',
                               'X3': 'Fe'
                           }))
Exemple #2
0
 def test_parse_structure_section_noposfile(self):
     myip = InputParser(inputfile="neb_with_phonons.inp")
     minput = MASTFile("%s/structure_noposfile_lines.txt" % testdir)
     cleanlines = list()
     for line in minput.data:
         cleanlines.append(line.strip())
     myoptions = InputOptions()
     myip.parse_structure_section('structure',cleanlines,myoptions)
     #print myoptions
     self.assertEqual(myoptions.options['structure']['atom_list'],['Al','Mg','Al','Fe'])
     self.assertEqual(myoptions.options['structure']['coord_type'],'fractional')
     self.assertTrue(np.array_equal(myoptions.options['structure']['lattice'],np.array([[3.5,1,2],[3,3.5,4],[5,6,3.5]])))
     self.assertTrue(np.array_equal(myoptions.options['structure']['coordinates'],np.array([[0,0,0],[0.5,0.5,0],[0,0.5,0.5],[0.5,0,0.5]])))
     self.assertItemsEqual(myoptions.options['structure']['element_map'],dict({'X1':'Al','X2':'Mg','X3':'Fe'}))
Exemple #3
0
 def test_parse_structure_section_posfile(self):
     myip = InputParser(inputfile="neb_with_phonons.inp")
     minput = MASTFile("%s/structure_posfile_lines.txt" % testdir)
     cleanlines = list()
     for line in minput.data:
         cleanlines.append(line.strip())
     myoptions = InputOptions()
     myip.parse_structure_section('structure',cleanlines,myoptions)
     #print myoptions
     mdict=dict()
     mdict['structure'] = dict()
     mdict['structure']['posfile']="POSCAR_startpos"
     #mdict['structure']['posfile'] = os.path.join(testdir, "POSCAR_startpos")
     self.assertItemsEqual(myoptions.options.keys(), ['structure'])
     self.assertEqual(myoptions.options['structure']['posfile'],mdict['structure']['posfile']) 
     myip = InputParser(inputfile="neb_with_phonons.inp")
     minput = MASTFile("%s/structure_posfile_lines_nosuch.txt" % testdir)
     cleanlines = list()
     for line in minput.data:
         cleanlines.append(line.strip())
     myoptions = InputOptions()
     self.assertRaises(MASTError, myip.parse_structure_section,'structure',cleanlines,myoptions)
Exemple #4
0
 def test_parse_structure_section_posfile(self):
     myip = InputParser(inputfile="neb_with_phonons.inp")
     minput = MASTFile("%s/structure_posfile_lines.txt" % testdir)
     cleanlines = list()
     for line in minput.data:
         cleanlines.append(line.strip())
     myoptions = InputOptions()
     myip.parse_structure_section('structure', cleanlines, myoptions)
     #print myoptions
     mdict = dict()
     mdict['structure'] = dict()
     mdict['structure']['posfile'] = "POSCAR_startpos"
     #mdict['structure']['posfile'] = os.path.join(testdir, "POSCAR_startpos")
     self.assertItemsEqual(myoptions.options.keys(), ['structure'])
     self.assertEqual(myoptions.options['structure']['posfile'],
                      mdict['structure']['posfile'])
     myip = InputParser(inputfile="neb_with_phonons.inp")
     minput = MASTFile("%s/structure_posfile_lines_nosuch.txt" % testdir)
     cleanlines = list()
     for line in minput.data:
         cleanlines.append(line.strip())
     myoptions = InputOptions()
     self.assertRaises(MASTError, myip.parse_structure_section, 'structure',
                       cleanlines, myoptions)