Exemple #1
0
 def test_wan90_input(self):
     _g = (2, 3, 2)
     self.maxDiff = None
     grid = uniform_grid(_g).reshape(-1, 3)
     cell = Cell(Basis.orthorhombic((2.5 * angstrom, 2.5 * angstrom, 10 * angstrom)),
         (
             (1. / 3, 1. / 3, .5),
             (2. / 3, 2. / 3, .5),
         ),
         ['C'] * 2,
     )
     self.assertEqual(wannier90_input(
         cell=cell,
         kpts=grid,
         kp_grid=_g,
         parameters={"some_str": "abc", "some_int": 3, "some_float": 3.0, "some_bool": True},
         block_parameters={"some_block": "some_block"},
     ), "\n".join((
         "mp_grid = 2 3 2",
         "some_bool = .true.",
         "some_float = 3.000000e+00",
         "some_int = 3",
         "some_str = abc",
         "begin atoms_frac",
         "    C 0.3333333333 0.3333333333 0.5000000000",
         "    C 0.6666666667 0.6666666667 0.5000000000",
         "end atoms_frac",
         "begin kpoints",
         "    0.0000000000 0.0000000000 0.0000000000",
         "    0.0000000000 0.0000000000 0.5000000000",
         "    0.0000000000 0.3333333333 0.0000000000",
         "    0.0000000000 0.3333333333 0.5000000000",
         "    0.0000000000 0.6666666667 0.0000000000",
         "    0.0000000000 0.6666666667 0.5000000000",
         "    0.5000000000 0.0000000000 0.0000000000",
         "    0.5000000000 0.0000000000 0.5000000000",
         "    0.5000000000 0.3333333333 0.0000000000",
         "    0.5000000000 0.3333333333 0.5000000000",
         "    0.5000000000 0.6666666667 0.0000000000",
         "    0.5000000000 0.6666666667 0.5000000000",
         "end kpoints",
         "begin some_block",
         "    some_block",
         "end some_block",
         "begin unit_cell_cart",
         "    2.5000000000 0.0000000000 0.0000000000",
         "    0.0000000000 2.5000000000 0.0000000000",
         "    0.0000000000 0.0000000000 10.0000000000",
         "end unit_cell_cart",
     )))
Exemple #2
0
    def test_qe_input(self):
        cell = Cell(Basis.orthorhombic((2.5 * angstrom, 2.5 * angstrom, 10 * angstrom)),
            (
                (1. / 3, 1. / 3, .5),
                (2. / 3, 2. / 3, .5),
            ),
            ['C'] * 2,
        )
        self.assertEqual(qe_input(
            cell=cell,
            relax_mask=3,
            parameters={"system": {"a": 3}, "control": {"b": "c"}, "random": {"d": True}},
            inline_parameters={"random": "hello"},
            pseudopotentials={"C": "C.UPF"},
            masses={"C": 3},
        ), "\n".join((
            "&CONTROL",
            "    b = 'c'",
            "/",
            "&SYSTEM",
            "    a = 3",
            "    ibrav = 0",
            "    nat = 2",
            "    ntyp = 1",
            "/",
            "ATOMIC_SPECIES",
            "    C  3.000 C.UPF",
            "ATOMIC_POSITIONS crystal",
            "     C 0.33333333333333 0.33333333333333 0.50000000000000 3 3 3",
            "     C 0.66666666666667 0.66666666666667 0.50000000000000 3 3 3",
            "CELL_PARAMETERS angstrom",
            "    2.50000000000000e+00 0.00000000000000e+00 0.00000000000000e+00",
            "    0.00000000000000e+00 2.50000000000000e+00 0.00000000000000e+00",
            "    0.00000000000000e+00 0.00000000000000e+00 1.00000000000000e+01",
            "RANDOM hello",
            "    d = .true.",
        )))
        self.assertEqual(qe_input(
            cell=cell,
            relax_mask=(0, 1),
            pseudopotentials={"C": "C.UPF"},
        ), "\n".join((
            "&SYSTEM",
            "    ibrav = 0",
            "    nat = 2",
            "    ntyp = 1",
            "/",
            "ATOMIC_SPECIES",
            "    C  12.011 C.UPF",
            "ATOMIC_POSITIONS crystal",
            "     C 0.33333333333333 0.33333333333333 0.50000000000000 0 0 0",
            "     C 0.66666666666667 0.66666666666667 0.50000000000000 1 1 1",
            "CELL_PARAMETERS angstrom",
            "    2.50000000000000e+00 0.00000000000000e+00 0.00000000000000e+00",
            "    0.00000000000000e+00 2.50000000000000e+00 0.00000000000000e+00",
            "    0.00000000000000e+00 0.00000000000000e+00 1.00000000000000e+01",
        )))

        self.assertEqual(qe_input(
            parameters=dict(
                inputpp=dict(plot_num=3, prefix="tmd"),
                plot=dict(fileout='something.xsf', iflag=3),
            )
        ), "\n".join((
            "&INPUTPP",
            "    plot_num = 3",
            "    prefix = 'tmd'",
            "/",
            "&PLOT",
            "    fileout = 'something.xsf'",
            "    iflag = 3",
            "/",
        )))