• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

materialsproject / pymatgen / 4075885785

pending completion
4075885785

push

github

Shyue Ping Ong
Merge branch 'master' of github.com:materialsproject/pymatgen

96 of 96 new or added lines in 27 files covered. (100.0%)

81013 of 102710 relevant lines covered (78.88%)

0.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

38.0
/pymatgen/command_line/tests/test_vampire_caller.py
1
# Copyright (c) Pymatgen Development Team.
2
# Distributed under the terms of the MIT License.
3

4
from __future__ import annotations
1✔
5

6
import os
1✔
7
import unittest
1✔
8
import warnings
1✔
9
from shutil import which
1✔
10

11
import pandas as pd
1✔
12
from pytest import approx
1✔
13

14
import pymatgen.command_line.vampire_caller as vampirecaller
1✔
15
from pymatgen.core.structure import Structure
1✔
16
from pymatgen.util.testing import PymatgenTest
1✔
17

18
test_dir = os.path.join(PymatgenTest.TEST_FILES_DIR, "magnetic_orderings")
1✔
19

20

21
@unittest.skipIf(not which("vampire-serial"), "vampire executable not present")
1✔
22
class VampireCallerTest(unittest.TestCase):
1✔
23
    @classmethod
1✔
24
    def setUpClass(cls):
1✔
25
        print("Testing with: ", which("vampire-serial"))
×
26

27
        cls.Mn3Al = pd.read_json(os.path.join(test_dir, "Mn3Al.json"))
×
28

29
        cls.compounds = [cls.Mn3Al]
×
30

31
        cls.structure_inputs = []
×
32
        cls.energy_inputs = []
×
33
        for c in cls.compounds:
×
34
            ordered_structures = list(c["structure"])
×
35
            ordered_structures = [Structure.from_dict(d) for d in ordered_structures]
×
36
            epa = list(c["energy_per_atom"])
×
37
            energies = [e * len(s) for (e, s) in zip(epa, ordered_structures)]
×
38

39
            cls.structure_inputs.append(ordered_structures)
×
40
            cls.energy_inputs.append(energies)
×
41

42
    def setUp(self):
1✔
43
        pass
×
44

45
    def tearDown(self):
1✔
46
        warnings.simplefilter("default")
×
47

48
    def test_vampire(self):
1✔
49
        for structs, energies in zip(self.structure_inputs, self.energy_inputs):
×
50
            settings = {"start_t": 0, "end_t": 500, "temp_increment": 50}
×
51
            vc = vampirecaller.VampireCaller(
×
52
                structs,
53
                energies,
54
                mc_box_size=3.0,
55
                equil_timesteps=1000,  # 1000
56
                mc_timesteps=2000,  # 2000
57
                user_input_settings=settings,
58
            )
59

60
            voutput = vc.output
×
61
            critical_temp = voutput.critical_temp
×
62
            assert 400 == approx(critical_temp)
×
63

64
        if os.path.exists("Mn3Al.mat"):
×
65
            os.remove("Mn3Al.mat")
×
66
        if os.path.exists("Mn3Al.ucf"):
×
67
            os.remove("Mn3Al.ucf")
×
68
        if os.path.exists("input"):
×
69
            os.remove("input")
×
70
        if os.path.exists("log"):
×
71
            os.remove("log")
×
72
        if os.path.exists("output"):
×
73
            os.remove("output")
×
74

75

76
if __name__ == "__main__":
1✔
77
    unittest.main()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc