def test_make_unitcell(tmpdir, mocker):
    tmpdir.chdir()
    vasprun_band_mock = mocker.Mock(spec=Vasprun, autospec=True)
    outcar_band_mock = mocker.Mock(spec=Outcar, autospec=True)
    outcar_dielectric_mock = mocker.Mock(spec=Outcar, autospec=True)
    args = Namespace(vasprun_band=vasprun_band_mock,
                     outcar_band=outcar_band_mock,
                     outcar_dielectric_clamped=outcar_dielectric_mock,
                     outcar_dielectric_ionic=outcar_dielectric_mock,
                     name="H")

    mock = mocker.patch(
        "pydefect.cli.vasp.main_vasp_functions.make_unitcell_from_vasp")
    mock.return_value = Unitcell(system="H",
                                 vbm=1.0,
                                 cbm=2.0,
                                 ele_dielectric_const=np.eye(3).tolist(),
                                 ion_dielectric_const=np.eye(3).tolist())
    make_unitcell(args)
    mock.assert_called_once_with(
        vasprun_band=vasprun_band_mock,
        outcar_band=outcar_band_mock,
        outcar_dielectric_clamped=outcar_dielectric_mock,
        outcar_dielectric_ionic=outcar_dielectric_mock,
        system_name="H")
Exemple #2
0
def unitcell():
    ele = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
    ion = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]
    return Unitcell(vbm=0.1,
                    cbm=5.1,
                    ele_dielectric_const=ele,
                    ion_dielectric_const=ion)
Exemple #3
0
def unitcell():
    ele = [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]
    ion = [[10.0, 20.0, 30.0], [40.0, 50.0, 60.0], [70.0, 80.0, 90.0]]
    return Unitcell(system="MgAl2O4",
                    vbm=-1.5053,
                    cbm=5.1,
                    ele_dielectric_const=ele,
                    ion_dielectric_const=ion)
Exemple #4
0
def make_unitcell_from_vasp(vasprun_band: Vasprun, outcar_band: Outcar,
                            outcar_dielectric_clamped,
                            outcar_dielectric_ionic) -> Unitcell:
    outcar_dielectric_clamped.read_lepsilon()
    outcar_dielectric_ionic.read_lepsilon_ionic()
    band_edge_properties = VaspBandEdgeProperties(vasprun_band, outcar_band)
    vbm, cbm = band_edge_properties.vbm_cbm

    return Unitcell(
        vbm=vbm,
        cbm=cbm,
        ele_dielectric_const=outcar_dielectric_clamped.dielectric_tensor,
        ion_dielectric_const=outcar_dielectric_ionic.dielectric_ionic_tensor)
def test_make_unitcell(mocker):
    vasprun_band_mock = mocker.Mock(spec=Vasprun, autospec=True)
    outcar_band_mock = mocker.Mock(spec=Outcar, autospec=True)
    outcar_dielectric_mock = mocker.Mock(spec=Outcar, autospec=True)
    args = Namespace(vasprun_band=vasprun_band_mock,
                     outcar_band=outcar_band_mock,
                     outcar_dielectric_clamped=outcar_dielectric_mock,
                     outcar_dielectric_ionic=outcar_dielectric_mock)

    mock = mocker.patch("pydefect.cli.vasp.main_function.make_unitcell_from_vasp")
    mock.return_value = Unitcell(vbm=1.0,
                                 cbm=2.0,
                                 ele_dielectric_const=np.eye(3),
                                 ion_dielectric_const=np.eye(3))
    make_unitcell(args)
    mock.assert_called_once_with(vasprun_band=vasprun_band_mock,
                                 outcar_band=outcar_band_mock,
                                 outcar_dielectric_clamped=outcar_dielectric_mock,
                                 outcar_dielectric_ionic=outcar_dielectric_mock)
Exemple #6
0
def make_unitcell_from_vasp(vasprun_band: Vasprun,
                            outcar_band: Outcar,
                            outcar_dielectric_clamped: Outcar,
                            outcar_dielectric_ionic: Outcar,
                            system_name: str = None) -> Unitcell:
    name = (system_name
            or vasprun_band.final_structure.composition.reduced_formula)
    outcar_dielectric_clamped.read_lepsilon()
    outcar_dielectric_ionic.read_lepsilon_ionic()
    band_edge_properties = VaspBandEdgeProperties(vasprun_band, outcar_band)
    vbm, cbm = band_edge_properties.vbm_cbm

    return Unitcell(
        system=name,
        # vbm and cbm are <class 'numpy.float64'>.
        vbm=float(vbm),
        cbm=float(cbm),
        ele_dielectric_const=outcar_dielectric_clamped.dielectric_tensor,
        ion_dielectric_const=outcar_dielectric_ionic.dielectric_ionic_tensor)