Ejemplo n.º 1
0
 def test_parse_1(self):
     path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"parsers/cases/openmx.output.0.testcase/output")
     p2 = os.path.join(os.path.dirname(os.path.realpath(__file__)),"parsers/cases/openmx.output.0.testcase/input")
     with open(p2, 'r') as f:
         c = parse(f, "unit-cell")
     with open(path,'r') as f:
         c1 = openmx.output(f.read()).unitCells(c)
         c2 = parse(f,"unit-cell")
     
     for i,j in zip(c1,c2):
         assert i==j
Ejemplo n.º 2
0
    def test_parse_1(self):
        path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                            "parsers/cases/openmx.output.0.testcase/output")
        p2 = os.path.join(os.path.dirname(os.path.realpath(__file__)), "parsers/cases/openmx.output.0.testcase/input")
        with open(p2, 'r') as f:
            c = parse(f, "unit-cell")
        with open(path, 'r') as f:
            c1 = openmx.output(f.read()).cells(c)
            c2 = parse(f, "unit-cell")

        for i, j in zip(c1, c2):
            assert i == j
Ejemplo n.º 3
0
    def test_parse_0(self):
        path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "parsers/cases/qe.output.0.testcase")
        with open(path, 'r') as f:
            c1 = qe.output(f.read()).cells()
            c2 = parse(f, "unit-cell")

        for i, j in zip(c1, c2):
            assert i == j
Ejemplo n.º 4
0
 def test_parse_0(self):
     path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"parsers/cases/qe.output.0.testcase")
     with open(path,'r') as f:
         c1 = qe.output(f.read()).unitCells()
         c2 = parse(f,"unit-cell")
     
     for i,j in zip(c1,c2):
         assert i==j
Ejemplo n.º 5
0
from dfttools.simple import parse
from dfttools import presentation

from matplotlib import pyplot

with open("plot.py.data",'r') as f:
    
    # Retrieve the last band structure from the file
    bands = parse(f, "band-structure")[-1]
    
    # Convert to a grid
    grid = bands.as_grid()
    
    # Plot both
    presentation.matplotlib_bands_density(bands, pyplot.gca(), 200, energy_range = (-2, 2), label = "bands")
    presentation.matplotlib_bands_density(grid,  pyplot.gca(), 200, energy_range = (-2, 2), label = "grid")
    pyplot.legend()
    pyplot.show()
Ejemplo n.º 6
0
 def test_parse_failed_1(self):
     with open(self.__file_truncated_structure__, 'r') as f:
         parse(f, 'unit-cell')
     with open(self.file_truncated_structure, 'r') as f:
         with self.assertRaises(ParseError):
             parse(f, 'unit-cell')
Ejemplo n.º 7
0
 def test_parse_failed_0(self):
     with open(self.file_no_band_structure, 'r') as f:
         with self.assertRaises(ParseError):
             parse(f, 'band-structure')
         with self.assertRaises(ParseError):
             parse(f, 'some-non-existing-data')
Ejemplo n.º 8
0
from dfttools.simple import parse
from dfttools import presentation

from matplotlib import pyplot

with open("plot.py.data", 'r') as f:

    # Retrieve the last band structure from the file
    bands = parse(f, "band-structure")

    # Convert to a grid
    grid = bands.as_grid()

    # Plot both
    presentation.matplotlib_bands_density(bands,
                                          pyplot.gca(),
                                          200,
                                          energy_range=(-2, 2),
                                          label="bands")
    presentation.matplotlib_bands_density(grid,
                                          pyplot.gca(),
                                          200,
                                          energy_range=(-2, 2),
                                          label="grid")
    pyplot.legend()
    pyplot.show()
Ejemplo n.º 9
0
from dfttools.presentation import svgwrite_unit_cell
from dfttools.simple import parse

# Parse
with open("plot.py.data", "r") as f:
    cell = parse(f, "unit-cell")
    
# Draw
svgwrite_unit_cell(cell, 'output.svg', size = (440,360), camera = (1,0,0))