Ejemplo n.º 1
0
 def setUp(self):
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.Li2O'),
                          check_for_POTCAR=False)
     s1 = p.structure
     p = Poscar.from_file(os.path.join(test_dir, 'CONTCAR.Li2O'),
                          check_for_POTCAR=False)
     s2 = p.structure
     self.analyzer = RelaxationAnalyzer(s1, s2)
Ejemplo n.º 2
0
 def setUp(self):
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.Li2O'),
                          check_for_POTCAR=False)
     s1 = p.structure
     p = Poscar.from_file(os.path.join(test_dir, 'CONTCAR.Li2O'),
                          check_for_POTCAR=False)
     s2 = p.structure
     self.analyzer = RelaxationAnalyzer(s1, s2)
Ejemplo n.º 3
0
 def test_write(self):
     filepath = os.path.join(test_dir, 'POSCAR')
     poscar = Poscar.from_file(filepath)
     tempfname = "POSCAR.testing"
     poscar.write_file(tempfname)
     p = Poscar.from_file(tempfname)
     self.assertArrayAlmostEqual(poscar.structure.lattice.abc,
                                 p.structure.lattice.abc, 5)
     os.remove(tempfname)
Ejemplo n.º 4
0
 def test_write(self):
     filepath = os.path.join(test_dir, 'POSCAR')
     poscar = Poscar.from_file(filepath)
     tempfname = "POSCAR.testing"
     poscar.write_file(tempfname)
     p = Poscar.from_file(tempfname)
     self.assertArrayAlmostEqual(poscar.structure.lattice.abc,
                                 p.structure.lattice.abc, 5)
     os.remove(tempfname)
    def test_apply_transformation(self):
        trans = MagOrderingTransformation({"Fe": 5})
        p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.LiFePO4'),
                             check_for_POTCAR=False)
        s = p.structure
        alls = trans.apply_transformation(s, 10)
        self.assertEqual(len(alls), 3)
        f = SymmetryFinder(alls[0]["structure"], 0.1)
        self.assertEqual(f.get_spacegroup_number(), 31)

        model = IsingModel(5, 5)
        trans = MagOrderingTransformation({"Fe": 5},
                                          energy_model=model)
        alls2 = trans.apply_transformation(s, 10)
        #Ising model with +J penalizes similar neighbor magmom.
        self.assertNotEqual(alls[0]["structure"], alls2[0]["structure"])
        self.assertEqual(alls[0]["structure"], alls2[2]["structure"])

        from pymatgen.io.smartio import read_structure
        s = read_structure(os.path.join(test_dir, 'Li2O.cif'))
        #Li2O doesn't have magnetism of course, but this is to test the
        # enumeration.
        trans = MagOrderingTransformation({"Li+": 1}, max_cell_size=3)
        alls = trans.apply_transformation(s, 100)
        self.assertEqual(len(alls), 10)
Ejemplo n.º 6
0
 def test_from_md_run(self):
     #Parsing from an MD type run with velocities
     p = Poscar.from_file(os.path.join(test_dir, "CONTCAR.MD"),
                          check_for_POTCAR=False)
     self.assertAlmostEqual(np.sum(np.array(p.velocities)), 0.0065417961324)
     self.assertEqual(p.predictor_corrector[0][0], 1)
     self.assertEqual(p.predictor_corrector[1][0], 2)
 def test_ferrimagnetic(self):
     trans = MagOrderingTransformation({"Fe": 5}, 0.75, max_cell_size=1)
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.LiFePO4'),
                          check_for_POTCAR=False)
     s = p.structure
     alls = trans.apply_transformation(s, 10)
     self.assertEqual(len(alls), 2)
 def test_ferrimagnetic(self):
     trans = MagOrderingTransformation({"Fe": 5}, 0.75, max_cell_size=1)
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.LiFePO4'),
                          check_for_POTCAR=False)
     s = p.structure
     alls = trans.apply_transformation(s, 10)
     self.assertEqual(len(alls), 2)
Ejemplo n.º 9
0
    def test_init_from_structure(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        struct = poscar.structure
        xyz = XYZ(struct)
        ans = """24
Fe4 P4 O16
Fe 2.277347 4.550379 2.260125
Fe 2.928536 1.516793 4.639870
Fe 7.483231 4.550379 0.119620
Fe 8.134420 1.516793 2.499364
P 0.985089 1.516793 1.990624
P 4.220794 4.550379 4.370369
P 6.190973 1.516793 0.389120
P 9.426677 4.550379 2.768865
O 0.451582 4.550379 3.365614
O 1.006219 1.516793 3.528306
O 1.725331 0.279529 1.358282
O 1.725331 2.754057 1.358282
O 3.480552 3.313115 3.738027
O 3.480552 5.787643 3.738027
O 4.199665 4.550379 1.148562
O 4.754301 1.516793 0.985870
O 5.657466 4.550379 3.773620
O 6.212102 1.516793 3.610928
O 6.931215 0.279529 1.021463
O 6.931215 2.754057 1.021463
O 8.686436 3.313115 3.401208
O 8.686436 5.787643 3.401208
O 9.405548 4.550379 1.231183
O 9.960184 1.516793 1.393875"""
        self.assertEqual(str(xyz), ans)
Ejemplo n.º 10
0
 def test_apply_transformation(self):
     p = Poscar.from_file(os.path.join(test_dir, "POSCAR.LiFePO4"), check_for_POTCAR=False)
     t = AutoOxiStateDecorationTransformation()
     s = t.apply_transformation(p.structure)
     expected_oxi = {"Li": 1, "P": 5, "O": -2, "Fe": 2}
     for site in s:
         self.assertEqual(site.specie.oxi_state, expected_oxi[site.specie.symbol])
Ejemplo n.º 11
0
 def test_get_energy_tersoff(self):
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.Al12O18'),
                          check_for_POTCAR=False)
     structure = p.structure
     enrgy = get_energy_tersoff(structure)
     self.assertIsInstance(enrgy, float)
     print "tersoff energy", enrgy
Ejemplo n.º 12
0
    def setUp(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        self.struct = poscar.structure

        self.mitparamset = MITVaspInputSet()
        self.mitparamset_unsorted = MITVaspInputSet(sort_structure=False)
        self.mithseparamset = MITHSEVaspInputSet()
        self.paramset = MPVaspInputSet()
        self.userparamset = MPVaspInputSet(
            user_incar_settings={'MAGMOM': {
                "Fe": 10,
                "S": -5,
                "Mn3+": 100
            }})
        self.mitggaparam = MITGGAVaspInputSet()
        self.mpstaticparamset = MPStaticVaspInputSet()
        self.mpnscfparamsetu = MPNonSCFVaspInputSet({"NBANDS": 50},
                                                    mode="Uniform")
        self.mpnscfparamsetl = MPNonSCFVaspInputSet({"NBANDS": 60},
                                                    mode="Line")
        self.mphseparamset = MPHSEVaspInputSet()
        self.mpbshseparamsetl = MPBSHSEVaspInputSet(mode="Line")
        self.mpbshseparamsetu = MPBSHSEVaspInputSet(
            mode="Uniform", added_kpoints=[[0.5, 0.5, 0.0]])
        self.mpdielparamset = MPStaticDielectricDFPTVaspInputSet()
Ejemplo n.º 13
0
    def test_init_from_structure(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        struct = poscar.structure
        xyz = XYZ(struct)
        ans = """24
Fe4 P4 O16
Fe 2.277347 4.550379 2.260125
Fe 2.928536 1.516793 4.639870
Fe 7.483231 4.550379 0.119620
Fe 8.134420 1.516793 2.499364
P 0.985089 1.516793 1.990624
P 4.220794 4.550379 4.370369
P 6.190973 1.516793 0.389120
P 9.426677 4.550379 2.768865
O 0.451582 4.550379 3.365614
O 1.006219 1.516793 3.528306
O 1.725331 0.279529 1.358282
O 1.725331 2.754057 1.358282
O 3.480552 3.313115 3.738027
O 3.480552 5.787643 3.738027
O 4.199665 4.550379 1.148562
O 4.754301 1.516793 0.985870
O 5.657466 4.550379 3.773620
O 6.212102 1.516793 3.610928
O 6.931215 0.279529 1.021463
O 6.931215 2.754057 1.021463
O 8.686436 3.313115 3.401208
O 8.686436 5.787643 3.401208
O 9.405548 4.550379 1.231183
O 9.960184 1.516793 1.393875"""
        self.assertEqual(str(xyz), ans)
Ejemplo n.º 14
0
 def test_get_structure(self):
     if not aio.ase_loaded:
         raise SkipTest("ASE not present. Skipping...")
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR'))
     atoms = aio.AseAtomsAdaptor.get_atoms(p.structure)
     self.assertEqual(aio.AseAtomsAdaptor.get_structure(atoms).formula,
                      "Fe4 P4 O16")
Ejemplo n.º 15
0
 def test_from_md_run(self):
     #Parsing from an MD type run with velocities
     p = Poscar.from_file(os.path.join(test_dir, "CONTCAR.MD"),
                          check_for_POTCAR=False)
     self.assertAlmostEqual(np.sum(np.array(p.velocities)), 0.0065417961324)
     self.assertEqual(p.predictor_corrector[0][0], 1)
     self.assertEqual(p.predictor_corrector[1][0], 2)
    def test_apply_transformation(self):
        enum_trans = EnumerateStructureTransformation(refine_structure=True)
        p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.LiFePO4'),
                             check_for_POTCAR=False)
        struct = p.structure
        expected_ans = [1, 3, 1]
        for i, frac in enumerate([0.25, 0.5, 0.75]):
            trans = SubstitutionTransformation({'Fe': {'Fe': frac}})
            s = trans.apply_transformation(struct)
            oxitrans = OxidationStateDecorationTransformation({'Li': 1,
                                                               'Fe': 2,
                                                               'P': 5,
                                                               'O': -2})
            s = oxitrans.apply_transformation(s)
            alls = enum_trans.apply_transformation(s, 100)
            self.assertEquals(len(alls), expected_ans[i])
            self.assertIsInstance(trans.apply_transformation(s), Structure)
            for s in alls:
                self.assertIn("energy", s)

        #make sure it works for non-oxidation state decorated structure
        trans = SubstitutionTransformation({'Fe': {'Fe': 0.5}})
        s = trans.apply_transformation(struct)
        alls = enum_trans.apply_transformation(s, 100)
        self.assertEquals(len(alls), 3)
        self.assertIsInstance(trans.apply_transformation(s), Structure)
        for s in alls:
            self.assertNotIn("energy", s)
Ejemplo n.º 17
0
    def run_task(self, fw_spec):
        chgcar_start = False
        # read the VaspInput from the previous run

        poscar = Poscar.from_file(zpath('POSCAR'))
        incar = Incar.from_file(zpath('INCAR'))

        # figure out what GGA+U values to use and override them
        # LDAU values to use
        mpvis = MPVaspInputSet()
        ggau_incar = mpvis.get_incar(poscar.structure).to_dict
        incar_updates = {k: ggau_incar[k] for k in ggau_incar.keys() if 'LDAU' in k}

        for k in ggau_incar:
            # update any parameters not set explicitly in previous INCAR
            if k not in incar and k in ggau_incar:
                incar_updates[k] = ggau_incar[k]

        incar.update(incar_updates)  # override the +U keys


        # start from the CHGCAR of previous run
        if os.path.exists('CHGCAR'):
            incar['ICHARG'] = 1
            chgcar_start = True

        # write back the new INCAR to the current directory
        incar.write_file('INCAR')
        return FWAction(stored_data={'chgcar_start': chgcar_start})
Ejemplo n.º 18
0
 def test_get_structure(self):
     if not aio.ase_loaded:
         raise SkipTest("ASE not present. Skipping...")
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR'))
     atoms = aio.AseAtomsAdaptor.get_atoms(p.structure)
     self.assertEqual(
         aio.AseAtomsAdaptor.get_structure(atoms).formula, "Fe4 P4 O16")
Ejemplo n.º 19
0
def parse_vasp(groupdireclist, args):

    data_to_csv = []

    default_energies = not (args.get_energies or args.ion_list or args.ion_avg_list)

    templatestructure = []

    if args.template:
        for (parent, subdirs, files) in os.walk(args.strtemp[0]):
            if 'POSCAR' in files:
                filepath = glob.glob(os.path.join(parent,"POSCAR"))
                poscarfile = Poscar.from_file(filepath[0])
                templatestructure = poscarfile.structure



    if args.get_energies or default_energies:
        for d in groupdireclist:
            groupdata= get_energies(d, args.reanalyze, args.verbose,
                         args.detailed, args.sort[0],args.formulaunit,args.debug,args.hull,args.threshold, args, templatestructure)
            data_to_csv.extend(groupdata)



    output_CSV(data_to_csv,args)
Ejemplo n.º 20
0
    def test_apply_transformations_best_first(self):

        p = Poscar.from_file(os.path.join(test_dir, "POSCAR.LiFePO4"), check_for_POTCAR=False)
        t1 = OxidationStateDecorationTransformation({"Li": 1, "Fe": 2, "P": 5, "O": -2})
        s = t1.apply_transformation(p.structure)
        t = PartialRemoveSpecieTransformation("Li+", 0.5, PartialRemoveSpecieTransformation.ALGO_BEST_FIRST)
        self.assertEqual(len(t.apply_transformation(s)), 26)
Ejemplo n.º 21
0
    def run_task(self, fw_spec):
        chgcar_start = False
        # read the VaspInput from the previous run

        poscar = Poscar.from_file(zpath('POSCAR'))
        incar = Incar.from_file(zpath('INCAR'))

        # figure out what GGA+U values to use and override them
        # LDAU values to use
        mpvis = MPVaspInputSet()
        ggau_incar = mpvis.get_incar(poscar.structure).to_dict
        incar_updates = {
            k: ggau_incar[k]
            for k in ggau_incar.keys() if 'LDAU' in k
        }

        for k in ggau_incar:
            # update any parameters not set explicitly in previous INCAR
            if k not in incar and k in ggau_incar:
                incar_updates[k] = ggau_incar[k]

        incar.update(incar_updates)  # override the +U keys

        # start from the CHGCAR of previous run
        if os.path.exists('CHGCAR'):
            incar['ICHARG'] = 1
            chgcar_start = True

        # write back the new INCAR to the current directory
        incar.write_file('INCAR')
        return FWAction(stored_data={'chgcar_start': chgcar_start})
Ejemplo n.º 22
0
    def test_static_constructors(self):
        kpoints = Kpoints.gamma_automatic([3, 3, 3], [0, 0, 0])
        self.assertEqual(kpoints.style, "Gamma")
        self.assertEqual(kpoints.kpts, [[3, 3, 3]])
        kpoints = Kpoints.monkhorst_automatic([2, 2, 2], [0, 0, 0])
        self.assertEqual(kpoints.style, "Monkhorst")
        self.assertEqual(kpoints.kpts, [[2, 2, 2]])
        kpoints = Kpoints.automatic(100)
        self.assertEqual(kpoints.style, "Automatic")
        self.assertEqual(kpoints.kpts, [[100]])
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        kpoints = Kpoints.automatic_density(poscar.structure, 500)
        self.assertEqual(kpoints.kpts, [[2, 4, 4]])
        self.assertEqual(kpoints.style, "Monkhorst")
        kpoints = Kpoints.automatic_density(poscar.structure, 500, True)
        self.assertEqual(kpoints.style, "Gamma")
        kpoints = Kpoints.automatic_density_by_vol(poscar.structure, 1000)
        self.assertEqual(kpoints.kpts, [[6, 11, 13]])
        self.assertEqual(kpoints.style, "Gamma")

        s = poscar.structure
        s.make_supercell(3)
        kpoints = Kpoints.automatic_density(s, 500)
        self.assertEqual(kpoints.kpts, [[1, 1, 1]])
        self.assertEqual(kpoints.style, "Gamma")
    def test_apply_transformation(self):
        enum_trans = EnumerateStructureTransformation(refine_structure=True)
        p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.LiFePO4'),
                             check_for_POTCAR=False)
        struct = p.structure
        expected_ans = [1, 3, 1]
        for i, frac in enumerate([0.25, 0.5, 0.75]):
            trans = SubstitutionTransformation({'Fe': {'Fe': frac}})
            s = trans.apply_transformation(struct)
            oxitrans = OxidationStateDecorationTransformation({
                'Li': 1,
                'Fe': 2,
                'P': 5,
                'O': -2
            })
            s = oxitrans.apply_transformation(s)
            alls = enum_trans.apply_transformation(s, 100)
            self.assertEquals(len(alls), expected_ans[i])
            self.assertIsInstance(trans.apply_transformation(s), Structure)
            for s in alls:
                self.assertIn("energy", s)

        #make sure it works for non-oxidation state decorated structure
        trans = SubstitutionTransformation({'Fe': {'Fe': 0.5}})
        s = trans.apply_transformation(struct)
        alls = enum_trans.apply_transformation(s, 100)
        self.assertEquals(len(alls), 3)
        self.assertIsInstance(trans.apply_transformation(s), Structure)
        for s in alls:
            self.assertNotIn("energy", s)
Ejemplo n.º 24
0
 def test_get_energy_tersoff(self):
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.Al12O18'),
                          check_for_POTCAR=False)
     structure = p.structure
     enrgy = get_energy_tersoff(structure)
     self.assertIsInstance(enrgy, float)
     print "tersoff energy", enrgy
Ejemplo n.º 25
0
 def test_get_atoms(self):
     if not aio.ase_loaded:
         raise SkipTest("ASE not present. Skipping...")
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR'))
     structure = p.structure
     atoms = aio.AseAtomsAdaptor.get_atoms(structure)
     ase_composition = Composition.from_formula(atoms.get_name())
     self.assertEqual(ase_composition, structure.composition)
Ejemplo n.º 26
0
 def test_get_atoms(self):
     if not aio.ase_loaded:
         raise SkipTest("ASE not present. Skipping...")
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR'))
     structure = p.structure
     atoms = aio.AseAtomsAdaptor.get_atoms(structure)
     ase_composition = Composition(atoms.get_name())
     self.assertEqual(ase_composition, structure.composition)
Ejemplo n.º 27
0
    def test_CifWriter(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        writer = CifWriter(poscar.structure, find_spacegroup=True)
        ans = """#generated using pymatgen
data_FePO4
_symmetry_space_group_name_H-M   Pnma
_cell_length_a   10.41176687
_cell_length_b   6.06717188
_cell_length_c   4.75948954
_cell_angle_alpha   90.00000000
_cell_angle_beta   90.00000000
_cell_angle_gamma   90.00000000
_symmetry_Int_Tables_number   62
_chemical_formula_structural   FePO4
_chemical_formula_sum   'Fe4 P4 O16'
_cell_volume   300.65685512
_cell_formula_units_Z   4
loop_
  _symmetry_equiv_pos_site_id
  _symmetry_equiv_pos_as_xyz
   1  'x, y, z'
loop_
  _atom_site_type_symbol
  _atom_site_label
  _atom_site_symmetry_multiplicity
  _atom_site_fract_x
  _atom_site_fract_y
  _atom_site_fract_z
  _atom_site_occupancy
  Fe  Fe1  1  0.218728  0.750000  0.474867  1
  Fe  Fe2  1  0.281272  0.250000  0.974867  1
  Fe  Fe3  1  0.718728  0.750000  0.025133  1
  Fe  Fe4  1  0.781272  0.250000  0.525133  1
  P  P5  1  0.094613  0.250000  0.418243  1
  P  P6  1  0.405387  0.750000  0.918243  1
  P  P7  1  0.594613  0.250000  0.081757  1
  P  P8  1  0.905387  0.750000  0.581757  1
  O  O9  1  0.043372  0.750000  0.707138  1
  O  O10  1  0.096642  0.250000  0.741320  1
  O  O11  1  0.165710  0.046072  0.285384  1
  O  O12  1  0.165710  0.453928  0.285384  1
  O  O13  1  0.334290  0.546072  0.785384  1
  O  O14  1  0.334290  0.953928  0.785384  1
  O  O15  1  0.403358  0.750000  0.241320  1
  O  O16  1  0.456628  0.250000  0.207138  1
  O  O17  1  0.543372  0.750000  0.792862  1
  O  O18  1  0.596642  0.250000  0.758680  1
  O  O19  1  0.665710  0.046072  0.214616  1
  O  O20  1  0.665710  0.453928  0.214616  1
  O  O21  1  0.834290  0.546072  0.714616  1
  O  O22  1  0.834290  0.953928  0.714616  1
  O  O23  1  0.903358  0.750000  0.258680  1
  O  O24  1  0.956628  0.250000  0.292862  1

"""
        for l1, l2 in zip(str(writer).split("\n"), ans.split("\n")):
            self.assertEqual(l1.strip(), l2.strip())
Ejemplo n.º 28
0
    def test_CifWriter(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        writer = CifWriter(poscar.structure, find_spacegroup=True)
        ans = """#generated using pymatgen
data_FePO4
_symmetry_space_group_name_H-M   Pnma
_cell_length_a   10.41176687
_cell_length_b   6.06717188
_cell_length_c   4.75948954
_cell_angle_alpha   90.00000000
_cell_angle_beta   90.00000000
_cell_angle_gamma   90.00000000
_symmetry_Int_Tables_number   62
_chemical_formula_structural   FePO4
_chemical_formula_sum   'Fe4 P4 O16'
_cell_volume   300.65685512
_cell_formula_units_Z   4
loop_
  _symmetry_equiv_pos_site_id
  _symmetry_equiv_pos_as_xyz
   1  'x, y, z'
loop_
  _atom_site_type_symbol
  _atom_site_label
  _atom_site_symmetry_multiplicity
  _atom_site_fract_x
  _atom_site_fract_y
  _atom_site_fract_z
  _atom_site_occupancy
  Fe  Fe1  1  0.218728  0.750000  0.474867  1
  Fe  Fe2  1  0.281272  0.250000  0.974867  1
  Fe  Fe3  1  0.718728  0.750000  0.025133  1
  Fe  Fe4  1  0.781272  0.250000  0.525133  1
  P  P5  1  0.094613  0.250000  0.418243  1
  P  P6  1  0.405387  0.750000  0.918243  1
  P  P7  1  0.594613  0.250000  0.081757  1
  P  P8  1  0.905387  0.750000  0.581757  1
  O  O9  1  0.043372  0.750000  0.707138  1
  O  O10  1  0.096642  0.250000  0.741320  1
  O  O11  1  0.165710  0.046072  0.285384  1
  O  O12  1  0.165710  0.453928  0.285384  1
  O  O13  1  0.334290  0.546072  0.785384  1
  O  O14  1  0.334290  0.953928  0.785384  1
  O  O15  1  0.403358  0.750000  0.241320  1
  O  O16  1  0.456628  0.250000  0.207138  1
  O  O17  1  0.543372  0.750000  0.792862  1
  O  O18  1  0.596642  0.250000  0.758680  1
  O  O19  1  0.665710  0.046072  0.214616  1
  O  O20  1  0.665710  0.453928  0.214616  1
  O  O21  1  0.834290  0.546072  0.714616  1
  O  O22  1  0.834290  0.953928  0.714616  1
  O  O23  1  0.903358  0.750000  0.258680  1
  O  O24  1  0.956628  0.250000  0.292862  1

"""
        for l1, l2 in zip(str(writer).split("\n"), ans.split("\n")):
            self.assertEqual(l1.strip(), l2.strip())
Ejemplo n.º 29
0
    def test_get_lattice_from_lattice_type(self):
        cif_structure = """#generated using pymatgen
data_FePO4
_symmetry_space_group_name_H-M   Pnma
_cell_length_a   10.41176687
_cell_length_b   6.06717188
_cell_length_c   4.75948954
_chemical_formula_structural   FePO4
_chemical_formula_sum   'Fe4 P4 O16'
_cell_volume   300.65685512
_cell_formula_units_Z   4
_symmetry_cell_setting Orthorhombic
loop_
  _symmetry_equiv_pos_site_id
  _symmetry_equiv_pos_as_xyz
   1  'x, y, z'
loop_
  _atom_site_type_symbol
  _atom_site_label
  _atom_site_symmetry_multiplicity
  _atom_site_fract_x
  _atom_site_fract_y
  _atom_site_fract_z
  _atom_site_occupancy
  Fe  Fe1  1  0.218728  0.750000  0.474867  1
  Fe  Fe2  1  0.281272  0.250000  0.974867  1
  Fe  Fe3  1  0.718728  0.750000  0.025133  1
  Fe  Fe4  1  0.781272  0.250000  0.525133  1
  P  P5  1  0.094613  0.250000  0.418243  1
  P  P6  1  0.405387  0.750000  0.918243  1
  P  P7  1  0.594613  0.250000  0.081757  1
  P  P8  1  0.905387  0.750000  0.581757  1
  O  O9  1  0.043372  0.750000  0.707138  1
  O  O10  1  0.096642  0.250000  0.741320  1
  O  O11  1  0.165710  0.046072  0.285384  1
  O  O12  1  0.165710  0.453928  0.285384  1
  O  O13  1  0.334290  0.546072  0.785384  1
  O  O14  1  0.334290  0.953928  0.785384  1
  O  O15  1  0.403358  0.750000  0.241320  1
  O  O16  1  0.456628  0.250000  0.207138  1
  O  O17  1  0.543372  0.750000  0.792862  1
  O  O18  1  0.596642  0.250000  0.758680  1
  O  O19  1  0.665710  0.046072  0.214616  1
  O  O20  1  0.665710  0.453928  0.214616  1
  O  O21  1  0.834290  0.546072  0.714616  1
  O  O22  1  0.834290  0.953928  0.714616  1
  O  O23  1  0.903358  0.750000  0.258680  1
  O  O24  1  0.956628  0.250000  0.292862  1

"""
        cp = CifParser.from_string(cif_structure)
        s_test = cp.get_structures(False)[0]
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        s_ref = poscar.structure

        sm = StructureMatcher(stol=0.05, ltol=0.01, angle_tol=0.1)
        self.assertTrue(sm.fit(s_ref, s_test))
 def test_apply_transformation(self):
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.LiFePO4'),
                          check_for_POTCAR=False)
     t = AutoOxiStateDecorationTransformation()
     s = t.apply_transformation(p.structure)
     expected_oxi = {"Li": 1, "P": 5, "O":-2, "Fe": 2}
     for site in s:
         self.assertEqual(site.specie.oxi_state,
                          expected_oxi[site.specie.symbol])
Ejemplo n.º 31
0
 def check(self):
     try:
         oszicar = Oszicar(self.output_filename)
         n = len(Poscar.from_file(self.input_filename).structure)
         max_dE = max([s['dE'] for s in oszicar.ionic_steps[1:]]) / n
         if max_dE > self.dE_threshold:
             return True
     except:
         return False
    def test_apply_transformations_complete_ranking(self):

        p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.LiFePO4'),
                             check_for_POTCAR=False)
        t1 = OxidationStateDecorationTransformation({"Li": 1, "Fe": 2, "P": 5,
                                                     "O":-2})
        s = t1.apply_transformation(p.structure)
        t = PartialRemoveSpecieTransformation("Li+", 0.5,
                                              PartialRemoveSpecieTransformation.ALGO_COMPLETE)
        self.assertEqual(len(t.apply_transformation(s, 10)), 6)
    def test_apply_transformations_best_first(self):

        p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.LiFePO4'),
                             check_for_POTCAR=False)
        t1 = OxidationStateDecorationTransformation({"Li": 1, "Fe": 2, "P": 5,
                                                     "O":-2})
        s = t1.apply_transformation(p.structure)
        t = PartialRemoveSpecieTransformation("Li+", 0.5,
                                              PartialRemoveSpecieTransformation.ALGO_BEST_FIRST)
        self.assertEqual(len(t.apply_transformation(s)), 26)
Ejemplo n.º 34
0
    def test_init(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        comp = poscar.structure.composition
        self.assertEqual(comp, Composition("Fe4P4O16"))

        #Vasp 4 type with symbols at the end.
        poscar_string = """Test1
1.0
3.840198 0.000000 0.000000
1.920099 3.325710 0.000000
0.000000 -2.217138 3.135509
1 1
direct
0.000000 0.000000 0.000000 Si
0.750000 0.500000 0.750000 F
"""
        poscar = Poscar.from_string(poscar_string)
        self.assertEqual(poscar.structure.composition, Composition("SiF"))

        poscar_string = ""
        self.assertRaises(ValueError, Poscar.from_string, poscar_string)

        #Vasp 4 tyle file with default names, i.e. no element symbol found.
        poscar_string = """Test2
1.0
3.840198 0.000000 0.000000
1.920099 3.325710 0.000000
0.000000 -2.217138 3.135509
1 1
direct
0.000000 0.000000 0.000000
0.750000 0.500000 0.750000
"""
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            poscar = Poscar.from_string(poscar_string)
        self.assertEqual(poscar.structure.composition, Composition("HHe"))

        #Vasp 4 tyle file with default names, i.e. no element symbol found.
        poscar_string = """Test3
1.0
3.840198 0.000000 0.000000
1.920099 3.325710 0.000000
0.000000 -2.217138 3.135509
1 1
Selective dynamics
direct
0.000000 0.000000 0.000000 T T T Si
0.750000 0.500000 0.750000 F F F O
"""
        poscar = Poscar.from_string(poscar_string)
        self.assertEqual(poscar.selective_dynamics,
                         [[True, True, True], [False, False, False]])
        self.selective_poscar = poscar
Ejemplo n.º 35
0
    def test_init(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        comp = poscar.structure.composition
        self.assertEqual(comp, Composition("Fe4P4O16"))

        #Vasp 4 type with symbols at the end.
        poscar_string = """Test1
1.0
3.840198 0.000000 0.000000
1.920099 3.325710 0.000000
0.000000 -2.217138 3.135509
1 1
direct
0.000000 0.000000 0.000000 Si
0.750000 0.500000 0.750000 F
"""
        poscar = Poscar.from_string(poscar_string)
        self.assertEqual(poscar.structure.composition, Composition("SiF"))

        poscar_string = ""
        self.assertRaises(ValueError, Poscar.from_string, poscar_string)

        #Vasp 4 tyle file with default names, i.e. no element symbol found.
        poscar_string = """Test2
1.0
3.840198 0.000000 0.000000
1.920099 3.325710 0.000000
0.000000 -2.217138 3.135509
1 1
direct
0.000000 0.000000 0.000000
0.750000 0.500000 0.750000
"""
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            poscar = Poscar.from_string(poscar_string)
        self.assertEqual(poscar.structure.composition, Composition("HHe"))

        #Vasp 4 tyle file with default names, i.e. no element symbol found.
        poscar_string = """Test3
1.0
3.840198 0.000000 0.000000
1.920099 3.325710 0.000000
0.000000 -2.217138 3.135509
1 1
Selective dynamics
direct
0.000000 0.000000 0.000000 T T T Si
0.750000 0.500000 0.750000 F F F O
"""
        poscar = Poscar.from_string(poscar_string)
        self.assertEqual(poscar.selective_dynamics, [[True, True, True],
                                                     [False, False, False]])
        self.selective_poscar = poscar
Ejemplo n.º 36
0
def buildPOSCAR(iat, fposcar="POSCAR"):
    """
    Build POSCAR file according to atom for wich CL calculation is required. The
    corresponding atom is placed in first position in the POSCAR.
    """
    from pymatgen.io.vaspio.vasp_input import Poscar
    poscar = Poscar.from_file(fposcar)

    site = poscar.structure.pop(iat)
    poscar.structure.insert(0, site.specie, site.frac_coords)
    poscar.write_file("POSCAR_CL.vasp")
Ejemplo n.º 37
0
    def setUp(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        self.struct = poscar.structure

        self.mitparamset = MITVaspInputSet()
        self.mithseparamset = MITHSEVaspInputSet()
        self.paramset = MaterialsProjectVaspInputSet()
        self.userparamset = MaterialsProjectVaspInputSet(
            {'MAGMOM': {"Fe": 10, "S": -5, "Mn3+": 100}}
        )
        self.mitggaparam = MITGGAVaspInputSet()
Ejemplo n.º 38
0
 def run_task(self, fw_spec):
     user_incar_settings= {"NPAR": 2}
     if self.line:
         MPNonSCFVaspInputSet.from_previous_vasp_run(os.getcwd(), mode="Line", copy_chgcar=False,
                                                     user_incar_settings=user_incar_settings,)
         kpath = HighSymmKpath(Poscar.from_file("POSCAR").structure)
         return FWAction(stored_data={"kpath": kpath.kpath,
                                      "kpath_name": kpath.name})
     else:
         MPNonSCFVaspInputSet.from_previous_vasp_run(os.getcwd(), mode="Uniform", copy_chgcar=False,
                              user_incar_settings=user_incar_settings)
         return FWAction()
Ejemplo n.º 39
0
    def test_init(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        p = Poscar.from_file(filepath)
        original_s = p.structure

        modifier = StructureEditor(original_s)
        modifier.add_oxidation_state_by_element({"Li": 1, "Fe": 2,
                                                 "P": 5, "O":-2})
        s = modifier.modified_structure
        ham = EwaldSummation(s)
        self.assertAlmostEqual(ham.real_space_energy, -354.91294268, 4,
                               "Real space energy incorrect!")
        self.assertAlmostEqual(ham.reciprocal_space_energy, 25.475754801, 4)
        self.assertAlmostEqual(ham.point_energy, -790.463835033, 4,
                               "Point space energy incorrect!")
        self.assertAlmostEqual(ham.total_energy, -1119.90102291, 2,
                               "Total space energy incorrect!")
        self.assertAlmostEqual(ham.forces[0,0], -1.98818620e-01, 4,
                               "Forces incorrect")
        self.assertAlmostEqual(sum(sum(abs(ham.forces))), 915.925354346, 4,
                               "Forces incorrect")
        self.assertAlmostEqual(sum(sum(ham.real_space_energy_matrix)),
                               - 354.91294268, 4,
                               "Real space energy matrix incorrect!")
        self.assertAlmostEqual(sum(sum(ham.reciprocal_space_energy_matrix)),
                               25.475754801, 4,
                               "Reciprocal space energy matrix incorrect!")
        self.assertAlmostEqual(sum(ham.point_energy_matrix), -790.463835033,
                               4, "Point space energy matrix incorrect!")
        self.assertAlmostEqual(sum(sum(ham.total_energy_matrix)),
                               - 1119.90102291, 2,
                               "Total space energy matrix incorrect!")
        #note that forces are not individually tested, but should work fine.

        self.assertRaises(ValueError, EwaldSummation, original_s)
        #try sites with charge.
        charges = []
        for site in original_s:
            if site.specie.symbol == "Li":
                charges.append(1)
            elif site.specie.symbol == "Fe":
                charges.append(2)
            elif site.specie.symbol == "P":
                charges.append(5)
            else:
                charges.append(-2)

        editor = StructureEditor(original_s)
        editor.add_site_property('charge', charges)
        ham2 = EwaldSummation(editor.modified_structure)
        self.assertAlmostEqual(ham2.real_space_energy, -354.91294268, 4,
                               "Real space energy incorrect!")
Ejemplo n.º 40
0
    def setUp(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        p = Poscar.from_file(filepath)
        self.structure = p.structure
        bv = BVAnalyzer()
        valences = bv.get_valences(self.structure)
        el = [site.species_string for site in self.structure.sites]
        valence_dict = dict(zip(el, valences))
        self.rad_dict = {}
        for k, v in valence_dict.items():
            self.rad_dict[k] = Specie(k, v).ionic_radius

        assert len(self.rad_dict) == len(self.structure.composition)
Ejemplo n.º 41
0
    def setUp(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        p = Poscar.from_file(filepath)
        self.structure = p.structure
        bv = BVAnalyzer()
        valences = bv.get_valences(self.structure)
        el = [site.species_string for site in self.structure.sites]
        valence_dict = dict(zip(el, valences))
        self.rad_dict = {}
        for k, v in valence_dict.items():
            self.rad_dict[k] = Specie(k,v).ionic_radius

        assert len(self.rad_dict) == len(self.structure.composition)
Ejemplo n.º 42
0
    def setUp(self):
        filepath = os.path.join(test_dir, "POSCAR")
        poscar = Poscar.from_file(filepath)
        self.struct = poscar.structure

        self.mitparamset = MITVaspInputSet()
        self.mithseparamset = MITHSEVaspInputSet()
        self.paramset = MPVaspInputSet()
        self.userparamset = MPVaspInputSet({"MAGMOM": {"Fe": 10, "S": -5, "Mn3+": 100}})
        self.mitggaparam = MITGGAVaspInputSet()
        self.mpstaticparamset = MPStaticVaspInputSet()
        self.mpnscfparamsetu = MPNonSCFVaspInputSet({"NBANDS": 50}, mode="Uniform")
        self.mpnscfparamsetl = MPNonSCFVaspInputSet({"NBANDS": 60}, mode="Line")
Ejemplo n.º 43
0
 def test_static_constructors(self):
     kpoints = Kpoints.gamma_automatic([3, 3, 3], [0, 0, 0])
     self.assertEqual(kpoints.style, "Gamma")
     self.assertEqual(kpoints.kpts, [[3, 3, 3]])
     kpoints = Kpoints.monkhorst_automatic([2, 2, 2], [0, 0, 0])
     self.assertEqual(kpoints.style, "Monkhorst")
     self.assertEqual(kpoints.kpts, [[2, 2, 2]])
     kpoints = Kpoints.automatic(100)
     self.assertEqual(kpoints.style, "Automatic")
     self.assertEqual(kpoints.kpts, [[100]])
     filepath = os.path.join(test_dir, 'POSCAR')
     poscar = Poscar.from_file(filepath)
     kpoints = Kpoints.automatic_density(poscar.structure, 500)
     self.assertEqual(kpoints.kpts, [[2, 3, 4]])
Ejemplo n.º 44
0
 def setUp(self):
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR'))
     self.structure = p.structure
     self.sg = SpacegroupAnalyzer(self.structure, 0.001)
     self.disordered_structure = self.get_structure('Li10GeP2S12')
     self.disordered_sg = SpacegroupAnalyzer(self.disordered_structure, 0.001)
     s = p.structure.copy()
     site = s[0]
     del s[0]
     s.append(site.species_and_occu, site.frac_coords)
     self.sg3 = SpacegroupAnalyzer(s, 0.001)
     graphite = self.get_structure('Graphite')
     graphite.add_site_property("magmom", [0.1] * len(graphite))
     self.sg4 = SpacegroupAnalyzer(graphite, 0.001)
Ejemplo n.º 45
0
 def test_static_constructors(self):
     kpoints = Kpoints.gamma_automatic([3, 3, 3], [0, 0, 0])
     self.assertEqual(kpoints.style, "Gamma")
     self.assertEqual(kpoints.kpts, [[3, 3, 3]])
     kpoints = Kpoints.monkhorst_automatic([2, 2, 2], [0, 0, 0])
     self.assertEqual(kpoints.style, "Monkhorst")
     self.assertEqual(kpoints.kpts, [[2, 2, 2]])
     kpoints = Kpoints.automatic(100)
     self.assertEqual(kpoints.style, "Automatic")
     self.assertEqual(kpoints.kpts, [[100]])
     filepath = os.path.join(test_dir, "POSCAR")
     poscar = Poscar.from_file(filepath)
     kpoints = Kpoints.automatic_density(poscar.structure, 500)
     self.assertEqual(kpoints.kpts, [[2, 3, 4]])
Ejemplo n.º 46
0
 def setUp(self):
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR'))
     self.structure = p.structure
     self.sg = SpacegroupAnalyzer(self.structure, 0.001)
     self.disordered_structure = self.get_structure('Li10GeP2S12')
     self.disordered_sg = SpacegroupAnalyzer(self.disordered_structure,
                                             0.001)
     s = p.structure.copy()
     site = s[0]
     del s[0]
     s.append(site.species_and_occu, site.frac_coords)
     self.sg3 = SpacegroupAnalyzer(s, 0.001)
     graphite = self.get_structure('Graphite')
     graphite.add_site_property("magmom", [0.1] * len(graphite))
     self.sg4 = SpacegroupAnalyzer(graphite, 0.001)
Ejemplo n.º 47
0
 def setUp(self):
     filepath = os.path.join(test_dir, "INCAR")
     incar = Incar.from_file(filepath)
     filepath = os.path.join(test_dir, "POSCAR")
     poscar = Poscar.from_file(filepath)
     if "VASP_PSP_DIR" not in os.environ:
         test_potcar_dir = os.path.abspath(
             os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "test_files")
         )
         os.environ["VASP_PSP_DIR"] = test_potcar_dir
     filepath = os.path.join(test_dir, "POTCAR")
     potcar = Potcar.from_file(filepath)
     filepath = os.path.join(test_dir, "KPOINTS.auto")
     kpoints = Kpoints.from_file(filepath)
     self.vinput = VaspInput(incar, kpoints, poscar, potcar)
Ejemplo n.º 48
0
 def setUp(self):
     filepath = os.path.join(test_dir, 'INCAR')
     incar = Incar.from_file(filepath)
     filepath = os.path.join(test_dir, 'POSCAR')
     poscar = Poscar.from_file(filepath)
     if "VASP_PSP_DIR" not in os.environ:
         test_potcar_dir = os.path.abspath(
             os.path.join(os.path.dirname(__file__), "..", "..", "..", "..",
                          "test_files"))
         os.environ["VASP_PSP_DIR"] = test_potcar_dir
     filepath = os.path.join(test_dir, 'POTCAR')
     potcar = Potcar.from_file(filepath)
     filepath = os.path.join(test_dir, 'KPOINTS.auto')
     kpoints = Kpoints.from_file(filepath)
     self.vinput = VaspInput(incar, kpoints, poscar, potcar)
Ejemplo n.º 49
0
    def test_init(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        p = Poscar.from_file(filepath)
        original_s = p.structure
        s = original_s.copy()
        s.add_oxidation_state_by_element({"Li": 1, "Fe": 2, "P": 5, "O": -2})
        ham = EwaldSummation(s)
        self.assertAlmostEqual(ham.real_space_energy, -354.91294268, 4,
                               "Real space energy incorrect!")
        self.assertAlmostEqual(ham.reciprocal_space_energy, 25.475754801, 4)
        self.assertAlmostEqual(ham.point_energy, -790.463835033, 4,
                               "Point space energy incorrect!")
        self.assertAlmostEqual(ham.total_energy, -1119.90102291, 2,
                               "Total space energy incorrect!")
        self.assertAlmostEqual(ham.forces[0, 0], -1.98818620e-01, 4,
                               "Forces incorrect")
        self.assertAlmostEqual(sum(sum(abs(ham.forces))), 915.925354346, 4,
                               "Forces incorrect")
        self.assertAlmostEqual(sum(sum(ham.real_space_energy_matrix)),
                               -354.91294268, 4,
                               "Real space energy matrix incorrect!")
        self.assertAlmostEqual(sum(sum(ham.reciprocal_space_energy_matrix)),
                               25.475754801, 4,
                               "Reciprocal space energy matrix incorrect!")
        self.assertAlmostEqual(sum(ham.point_energy_matrix), -790.463835033, 4,
                               "Point space energy matrix incorrect!")
        self.assertAlmostEqual(sum(sum(ham.total_energy_matrix)),
                               -1119.90102291, 2,
                               "Total space energy matrix incorrect!")
        #note that forces are not individually tested, but should work fine.

        self.assertRaises(ValueError, EwaldSummation, original_s)
        #try sites with charge.
        charges = []
        for site in original_s:
            if site.specie.symbol == "Li":
                charges.append(1)
            elif site.specie.symbol == "Fe":
                charges.append(2)
            elif site.specie.symbol == "P":
                charges.append(5)
            else:
                charges.append(-2)

        original_s.add_site_property('charge', charges)
        ham2 = EwaldSummation(original_s)
        self.assertAlmostEqual(ham2.real_space_energy, -354.91294268, 4,
                               "Real space energy incorrect!")
Ejemplo n.º 50
0
 def setUp(self):
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR'))
     self.structure = p.structure
     self.sg = SymmetryFinder(self.structure, 0.001)
     parser = CifParser(os.path.join(test_dir, 'Li10GeP2S12.cif'))
     self.disordered_structure = parser.get_structures()[0]
     self.disordered_sg = SymmetryFinder(self.disordered_structure, 0.001)
     s = p.structure.copy()
     site = s[0]
     del s[0]
     s.append(site.species_and_occu, site.frac_coords)
     self.sg3 = SymmetryFinder(s, 0.001)
     parser = CifParser(os.path.join(test_dir, 'Graphite.cif'))
     graphite = parser.get_structures()[0]
     graphite.add_site_property("magmom", [0.1] * len(graphite))
     self.sg4 = SymmetryFinder(graphite, 0.001)
Ejemplo n.º 51
0
 def setUp(self):
     filepath = os.path.join(test_dir, 'POSCAR')
     p = Poscar.from_file(filepath)
     self.structure = p.structure
     bv = BVAnalyzer()
     self.structure = bv.get_oxi_state_decorated_structure(self.structure)
     valences = bv.get_valences(self.structure)
     radii = []
     for i in range(len(valences)):
         el = self.structure.sites[i].specie.symbol
         radius = Specie(el, valences[i]).ionic_radius
         radii.append(radius)
     el = [site.species_string for site in self.structure.sites]
     self.rad_dict = dict(zip(el, radii))
     for el in self.rad_dict.keys():
         print((el, self.rad_dict[el].real))
Ejemplo n.º 52
0
 def setUp(self):
     filepath = os.path.join(test_dir, 'POSCAR')
     p = Poscar.from_file(filepath)
     self.structure = p.structure
     bv = BVAnalyzer()
     self.structure = bv.get_oxi_state_decorated_structure(self.structure)
     valences = bv.get_valences(self.structure)
     radii = []
     for i in range(len(valences)):
         el = self.structure.sites[i].specie.symbol
         radius = Specie(el, valences[i]).ionic_radius
         radii.append(radius)
     el = [site.species_string for site in self.structure.sites]
     self.rad_dict = dict(zip(el, radii))
     for el in self.rad_dict.keys():
         print((el, self.rad_dict[el].real))
Ejemplo n.º 53
0
    def test_symmetrized(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        writer = CifWriter(poscar.structure, find_spacegroup=True,
                           symprec=0.1)
        ans = """#generated using pymatgen
data_FePO4
_symmetry_space_group_name_H-M   Pnma
_cell_length_a   10.41176687
_cell_length_b   6.06717188
_cell_length_c   4.75948954
_cell_angle_alpha   90.00000000
_cell_angle_beta   90.00000000
_cell_angle_gamma   90.00000000
_symmetry_Int_Tables_number   62
_chemical_formula_structural   FePO4
_chemical_formula_sum   'Fe4 P4 O16'
_cell_volume   300.65685512
_cell_formula_units_Z   4
loop_
 _symmetry_equiv_pos_site_id
 _symmetry_equiv_pos_as_xyz
  1  'x, y, z'
  2  '-x, -y, -z'
  3  '-x+1/2, -y, z+1/2'
  4  'x+1/2, y, -z+1/2'
  5  'x+1/2, -y+1/2, -z+1/2'
  6  '-x+1/2, y+1/2, z+1/2'
  7  '-x, y+1/2, -z'
  8  'x, -y+1/2, z'
loop_
 _atom_site_type_symbol
 _atom_site_label
 _atom_site_symmetry_multiplicity
 _atom_site_fract_x
 _atom_site_fract_y
 _atom_site_fract_z
 _atom_site_occupancy
  Fe  Fe1  4  0.218728  0.750000  0.474867  1
  P  P2  4  0.094613  0.250000  0.418243  1
  O  O3  4  0.043372  0.750000  0.707138  1
  O  O4  4  0.096642  0.250000  0.741320  1
  O  O5  8  0.165710  0.046072  0.285384  1"""
        for l1, l2 in zip(str(writer).split("\n"), ans.split("\n")):
            self.assertEqual(l1.strip(), l2.strip())
Ejemplo n.º 54
0
    def setUp(self):
        filepath = os.path.join(test_dir, 'POSCAR')
        poscar = Poscar.from_file(filepath)
        self.struct = poscar.structure

        self.mitparamset = MITVaspInputSet()
        self.mithseparamset = MITHSEVaspInputSet()
        self.paramset = MPVaspInputSet()
        self.userparamset = MPVaspInputSet(
            {'MAGMOM': {
                "Fe": 10,
                "S": -5,
                "Mn3+": 100
            }})
        self.mitggaparam = MITGGAVaspInputSet()
        self.mpstaticparamset = MPStaticVaspInputSet()
        self.mpnscfparamsetu = MPNonSCFVaspInputSet({"NBANDS": 50},
                                                    mode="Uniform")
        self.mpnscfparamsetl = MPNonSCFVaspInputSet({"NBANDS": 60},
                                                    mode="Line")
Ejemplo n.º 55
0
 def run_task(self, fw_spec):
     user_incar_settings = {"NPAR": 2}
     if self.line:
         MPNonSCFVaspInputSet.from_previous_vasp_run(
             os.getcwd(),
             mode="Line",
             copy_chgcar=False,
             user_incar_settings=user_incar_settings,
         )
         kpath = HighSymmKpath(Poscar.from_file("POSCAR").structure)
         return FWAction(stored_data={
             "kpath": kpath.kpath,
             "kpath_name": kpath.name
         })
     else:
         MPNonSCFVaspInputSet.from_previous_vasp_run(
             os.getcwd(),
             mode="Uniform",
             copy_chgcar=False,
             user_incar_settings=user_incar_settings)
         return FWAction()
Ejemplo n.º 56
0
def buildPOSCAR(iat, fposcar="POSCAR"):
    """
    Build POSCAR file according to atom for wich CL calculation is required. The
    corresponding atom is placed in first position in the POSCAR.
    """
    poscar = Poscar.from_file(fposcar, read_velocities=False)

    # move up the selected atom and ad "_" to differentiate it
    site = poscar.structure.pop(iat)
    poscar.structure.insert(0, mg.DummySpecie("_" + site.specie.symbol),
                            site.frac_coords)

    poscar.write_file("POSCAR_CL.vasp")

    # remove the _ symbol on 6th line
    with open("POSCAR_CL.vasp", "r") as f:
        lines = f.readlines()
        lines[5] = "".join(["%4s" % el.strip("_")
                            for el in lines[5].split()]) + "\n"
        lines = "".join(lines)
    with open("POSCAR_CL.vasp", "w") as f:
        f.write(lines)
    def test_apply_transformation(self):
        trans = MagOrderingTransformation({"Fe": 5})
        p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.LiFePO4'),
                             check_for_POTCAR=False)
        s = p.structure
        alls = trans.apply_transformation(s, 10)
        self.assertEqual(len(alls), 3)
        f = SpacegroupAnalyzer(alls[0]["structure"], 0.1)
        self.assertEqual(f.get_spacegroup_number(), 31)

        model = IsingModel(5, 5)
        trans = MagOrderingTransformation({"Fe": 5}, energy_model=model)
        alls2 = trans.apply_transformation(s, 10)
        #Ising model with +J penalizes similar neighbor magmom.
        self.assertNotEqual(alls[0]["structure"], alls2[0]["structure"])
        self.assertEqual(alls[0]["structure"], alls2[2]["structure"])

        s = self.get_structure('Li2O')
        #Li2O doesn't have magnetism of course, but this is to test the
        # enumeration.
        trans = MagOrderingTransformation({"Li+": 1}, max_cell_size=3)
        alls = trans.apply_transformation(s, 100)
        self.assertEqual(len(alls), 10)
Ejemplo n.º 58
0
 def test_setattr(self):
     filepath = os.path.join(test_dir, 'POSCAR')
     poscar = Poscar.from_file(filepath)
     self.assertRaises(ValueError, setattr, poscar, 'velocities',
                       [[0, 0, 0]])
     poscar.selective_dynamics = np.array([[True, False, False]] * 24)
Ejemplo n.º 59
0
 def setUp(self):
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR'))
     self.structure = p.structure
     self.sg1 = SymmetryFinder(self.structure, 0.001).get_spacegroup()