Exemplo n.º 1
0
    def test_filter_apply(self):
        input = QEInput(config=fixtures.textMain)
        # Filter that adds parameters to input
        fp = Filter("fPlus")
        fp.setParam("control", "prefix", "'ni'")
        fp.setParam("control", "pseudo_dir", "''")
        fp.setParam("control", "outdir", "''")
        fp.setCard({
            "name": "occupations",
            "lines": ("New line", )
        })  # Add new card
        fp.setNamelist({
            "name": "cell",
            "params": {
                "hello": "world"
            }
        })  # Add new namelist
        fp.setNamelist({"name": "phonon"})
        fp.apply(input, "plus")

        self.assertEqual(input.toString(), fixtures.assertPlus)

        # Filter that removes parameters from input
        fm = Filter("fMinus")
        fm.setCard({"name": "atomic_species"})
        fm.setNamelist({"name": "phonon"})  # Remove namelist
        fm.setParam("cell",
                    "hello")  # Remove parameter that makes namelist empty
        fm.setParam("control", "prefix")  # Remove parameter
        fm.apply(input, "minus")
        self.assertEqual(input.toString(), fixtures.assertMinus)
Exemplo n.º 2
0
    def test_qeinput_namelist(self):
        input   = QEInput()
        nl      = Namelist("control")
        nl.set("title", "'Ni'")
        input.addNamelist(nl)
        nl2     = input.namelist("phonon")
        self.assertEqual(input.toString(), fixtures.assertNewNamelist)

        input.removeNamelist("control")
        self.assertEqual(input.toString(), fixtures.assertNewNamelist2)
Exemplo n.º 3
0
    def test_qeinput_namelist(self):
        input = QEInput()
        nl = Namelist("control")
        nl.set("title", "'Ni'")
        input.addNamelist(nl)
        nl2 = input.namelist("phonon")
        self.assertEqual(input.toString(), fixtures.assertNewNamelist)

        input.removeNamelist("control")
        self.assertEqual(input.toString(), fixtures.assertNewNamelist2)
Exemplo n.º 4
0
    def test_qeinput_card(self):
        input   = QEInput()
        c       = Card("atomic_species")
        c.setArg("temp")
        c.addLine("Ni  26.98  Ni.pbe-nd-rrkjus.UPF")
        input.addCard(c)
        c2      = input.card("atomic_positions")
        self.assertEqual(input.toString(), fixtures.assertNewCard)

        input.removeCard("atomic_species")
        self.assertEqual(input.toString(), fixtures.assertNewCard2)
Exemplo n.º 5
0
    def test_qeinput_card(self):
        input = QEInput()
        c = Card("atomic_species")
        c.setArg("temp")
        c.addLine("Ni  26.98  Ni.pbe-nd-rrkjus.UPF")
        input.addCard(c)
        c2 = input.card("atomic_positions")
        self.assertEqual(input.toString(), fixtures.assertNewCard)

        input.removeCard("atomic_species")
        self.assertEqual(input.toString(), fixtures.assertNewCard2)
Exemplo n.º 6
0
    def test_qeinput_filter(self):
        input   = QEInput(config=fixtures.textMain)

        f  = Filter("fPlus")
        f.setParam("control", "calculation", "'md'")
        f.setCard({"name": "occupations", "lines": ("New line",)})

        input.applyFilter(f, "plus")
        self.assertEqual(input.toString(), fixtures.assertInputFilterPlus)

        f  = Filter("fMinus")
        f.setNamelist({"name":"control"})
        f.setCard({"name": "k_points"})

        input.applyFilter(f, "minus")
        self.assertEqual(input.toString(), fixtures.assertInputFilterMinus)
Exemplo n.º 7
0
    def test_qeinput_filter(self):
        input = QEInput(config=fixtures.textMain)

        f = Filter("fPlus")
        f.setParam("control", "calculation", "'md'")
        f.setCard({"name": "occupations", "lines": ("New line", )})

        input.applyFilter(f, "plus")
        self.assertEqual(input.toString(), fixtures.assertInputFilterPlus)

        f = Filter("fMinus")
        f.setNamelist({"name": "control"})
        f.setCard({"name": "k_points"})

        input.applyFilter(f, "minus")
        self.assertEqual(input.toString(), fixtures.assertInputFilterMinus)
Exemplo n.º 8
0
 def toString(self, string=None):
     if string != None:
         qeConf = QEInput(config=string)
         qeConf.parse()
     else:
         if self.qeConf != None:
             qeConf = self.qeConf
         else:
             qeConf = QEInput(config='')
     self.updatePWInput(qeConf)
     return qeConf.toString()
Exemplo n.º 9
0
 def toString(self, string = None):        
     if string != None:        
         qeConf = QEInput(config = string)
         qeConf.parse()                
     else:
         if self.qeConf != None:
             qeConf = self.qeConf
         else:
             qeConf = QEInput(config = '')
     self.updatePWInput(qeConf)    
     return qeConf.toString()
Exemplo n.º 10
0
    def test_filter_apply(self):
        input   = QEInput(config=fixtures.textMain)
        # Filter that adds parameters to input
        fp       = Filter("fPlus")
        fp.setParam("control", "prefix", "'ni'")
        fp.setParam("control", "pseudo_dir", "''")
        fp.setParam("control", "outdir", "''")
        fp.setCard({"name": "occupations", "lines": ("New line",)})     # Add new card
        fp.setNamelist({"name": "cell", "params": {"hello": "world"}})  # Add new namelist
        fp.setNamelist({"name": "phonon"})
        fp.apply(input, "plus")

        self.assertEqual(input.toString(), fixtures.assertPlus)

        # Filter that removes parameters from input
        fm      = Filter("fMinus")
        fm.setCard({"name": "atomic_species"})
        fm.setNamelist({"name": "phonon"})    # Remove namelist
        fm.setParam("cell", "hello")        # Remove parameter that makes namelist empty
        fm.setParam("control", "prefix")    # Remove parameter
        fm.apply(input, "minus")
        self.assertEqual(input.toString(), fixtures.assertMinus)
Exemplo n.º 11
0
    def test_qeinput_parse(self):
        input   = QEInput(config=fixtures.textMain, parse=False)
        self.assertEqual(input.toString(), "")

        input   = QEInput(config=fixtures.textMain, parse=True)
        self.assertEqual(input.namelistExists("control"), True)
Exemplo n.º 12
0
    def test_qeinput_attach(self):
        "This unit test is useful for matdyn simulation type"
        input   = QEInput()
        input.addAttach("176\n\
0.000000    0.000000    0.456392    0.000000")
        self.assertEqual(input.toString(), fixtures.assertAttach)
Exemplo n.º 13
0
    def test_qeinput_parse(self):
        input = QEInput(config=fixtures.textMain, parse=False)
        self.assertEqual(input.toString(), "")

        input = QEInput(config=fixtures.textMain, parse=True)
        self.assertEqual(input.namelistExists("control"), True)
Exemplo n.º 14
0
    def test_qeinput_attach(self):
        "This unit test is useful for matdyn simulation type"
        input = QEInput()
        input.addAttach("176\n\
0.000000    0.000000    0.456392    0.000000")
        self.assertEqual(input.toString(), fixtures.assertAttach)