Ejemplo n.º 1
0
    def test_new_with_structure(self):
        """Testing new_with_structure."""

        si2_inp = AbinitInput(structure=abidata.cif_file("si.cif"), pseudos=abidata.pseudos("14si.pspnc"),
                abi_kwargs={"ecut": 4, "toldfe": 1e-10, "nband": 6, "ngkpt": [12, 12, 12]})

        # Build new input with same parameters and compressed unit cell.
        new_vol = 0.9 * si2_inp.structure.volume
        new_lattice = si2_inp.structure.lattice.scale(new_vol)
        new_structure = abilab.Structure(new_lattice, si2_inp.structure.species, si2_inp.structure.frac_coords)

        new_inp = si2_inp.new_with_structure(new_structure, scdims=None)
        assert new_inp.structure.volume == new_vol
        assert new_inp["ecut"] == 4

        #al2_structure = abilab.Structure.from_file(abidata.cif_file("al.cif"))

        # Let's build an input file for a (2, 3, 4) supercell
        #super_structure = si2_inp.structure.make_supercell
        scdims = np.array((2, 3, 4))
        # Note: This will return a pymatgen structure, not an Abipy structure.
        super_structure = si2_inp.structure * scdims
        sc_inp = si2_inp.new_with_structure(super_structure, scdims=scdims)
        assert isinstance(sc_inp.structure, abilab.Structure)
        assert len(sc_inp.structure) == 2 * scdims.prod()
        self.assert_almost_equal(sc_inp.structure.volume, si2_inp.structure.volume * scdims.prod())
        assert sc_inp["chkprim"] == 0
        assert sc_inp["nband"] == si2_inp["nband"] * scdims.prod()
        self.assert_equal(sc_inp["ngkpt"], [6, 4, 3])
        self.abivalidate_input(sc_inp)
Ejemplo n.º 2
0
def special_positions(lattice, u):
    """Construct the crystalline `Structure` for given value of the internal parameter u."""
    frac_coords = {}

    frac_coords["Si"] = [
            [1/2 + u, 1/2 - u, 0],
            [u,       -u,      u],
   ]
    frac_coords["O"] = [ [0, 0, u] ]

    species, coords = [], []
    for symbol, positions in frac_coords.items():
        species += len(positions) * [symbol]
        coords += positions

    return abilab.Structure(lattice, species, coords, validate_proximity=True, coords_are_cartesian=False)