Exemple #1
0
    def test_card_tostring(self):
        c   = Card("atomic_positions")
        c.addLine(" Ni 0.00 0.00 0.00 ")
        self.assertEqual(c.toString(), fixtures.assertC_no_arg)

        c.setArg("alat")
        self.assertEqual(c.toString(indent=3), fixtures.assertC_arg)
Exemple #2
0
    def test_card_lines(self):
        c   = Card("atomic_positions")
        c.addLine(" Ni 0.00 0.00 0.00 ")
        self.assertEqual(c.line(0), "Ni 0.00 0.00 0.00")    # should strip side spaces

        c.addLine(" Ni 0.50 0.50 0.50 ")
        self.assertEqual(len(c.lines()), 2)
Exemple #3
0
    def test_card_tostring(self):
        c = Card("atomic_positions")
        c.addLine(" Ni 0.00 0.00 0.00 ")
        self.assertEqual(c.toString(), fixtures.assertC_no_arg)

        c.setArg("alat")
        self.assertEqual(c.toString(indent=3), fixtures.assertC_arg)
Exemple #4
0
    def _convertCards(self, cards):
        for cname in cards.keys():
            c   = Card(cname)
            c.setArg(cards[cname]["args"])
            for l in cards[cname]["values"]:
                c.addLine(l)

            self.cards[cname]    = c
Exemple #5
0
    def test_card_lines(self):
        c = Card("atomic_positions")
        c.addLine(" Ni 0.00 0.00 0.00 ")
        self.assertEqual(c.line(0),
                         "Ni 0.00 0.00 0.00")  # should strip side spaces

        c.addLine(" Ni 0.50 0.50 0.50 ")
        self.assertEqual(len(c.lines()), 2)
Exemple #6
0
    def test_card_remove_lines(self):
        c   = Card("atomic_positions")
        c.addLine(" Ni 0.00 0.00 0.00 ")
        c.addLine(" Ni 0.50 0.50 0.50 ")
        c.removeLine(0)
        self.assertEqual(c.line(0), "Ni 0.50 0.50 0.50")

        c.editLines(["a", "b"])
        self.assertEqual(c.lines(), ["a", "b"])
Exemple #7
0
    def test_card_remove_lines(self):
        c = Card("atomic_positions")
        c.addLine(" Ni 0.00 0.00 0.00 ")
        c.addLine(" Ni 0.50 0.50 0.50 ")
        c.removeLine(0)
        self.assertEqual(c.line(0), "Ni 0.50 0.50 0.50")

        c.editLines(["a", "b"])
        self.assertEqual(c.lines(), ["a", "b"])
Exemple #8
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)
Exemple #9
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)
Exemple #10
0
def testCreateConfig():
    print "Testing creation of config file"
    qe = QEInput()
    nl = Namelist('control')
    nl.add('title', "'Ni'")
    nl.add('restart_mode', "'from_scratch'")
    print "Adding parameters to namelist:\n%s" % nl.toString()
    nl.set('title', "'Fe'")
    qe.addNamelist(nl)
    print "Adding namelist to QEInput:\n%s" % qe.toString()

    c = Card('atomic_species')
    c.addLine('Ni  26.98  Ni.pbe-nd-rrkjus.UPF')
    print "Adding line to card:\n%s" % c.toString()
    qe.addCard(c)
    print "Adding card to QEInput:\n%s" % qe.toString()
Exemple #11
0
def testCreateConfig():
    print "Testing creation of config file"
    qe  = QEInput()
    nl  = Namelist('control')
    nl.add('title', "'Ni'")
    nl.add('restart_mode', "'from_scratch'")
    print "Adding parameters to namelist:\n%s" % nl.toString()
    nl.set('title', "'Fe'")
    qe.addNamelist(nl)
    print "Adding namelist to QEInput:\n%s" % qe.toString()

    c = Card('atomic_species')
    c.addLine('Ni  26.98  Ni.pbe-nd-rrkjus.UPF')
    print "Adding line to card:\n%s" % c.toString()
    qe.addCard(c)
    print "Adding card to QEInput:\n%s" % qe.toString()