def test_2(self): fl = tempfile.mkstemp()[1] svg = svgwrite_unit_cell(self.cell2, fl, show_cell=True, fadeout_strength=0) self.__check_svg__(svg, self.cell2) assert os.path.isfile(fl) os.remove(fl)
mos2_basis = Basis( (3.19*a, 3.19*a, 20*a, 0,0,.5), kind = 'triclinic' ) d = 1.57722483162840/20 # Unit cell with 3 atoms mos2_cell = Cell(mos2_basis, ( (1./3,1./3,.5), (2./3,2./3,0.5+d), (2./3,2./3,0.5-d), ), ('Mo','S','S')) # Rectangular supercell with 6 atoms mos2_rectangular = mos2_cell.supercell( (1,0,0), (-1,2,0), (0,0,1) ) # Rectangular sheet with a defect mos2_defect = mos2_rectangular.normalized() mos2_defect.discard((mos2_defect.values == "S") * (mos2_defect.coordinates[:,1] < .5) * (mos2_defect.coordinates[:,2] < .5)) # Prepare a sheet mos2_sheet = Cell.stack(*((mos2_rectangular,)*3 + (mos2_defect,) + (mos2_rectangular,)*3), vector = 'y') # Draw svgwrite_unit_cell(mos2_sheet.repeated(10,1,1), 'output.svg', size = (440,360), camera = (1,1,0.3), camera_top = (0,0,1))
) # Unit cell graphene_cell = UnitCell(graphene_basis, ( (1./3,1./3,.5), (2./3,2./3,.5), ), ('C','C')) # Moire matching vectors moire = [1, 26, 6, 23] # A top layer l1 = graphene_cell.supercell( (moire[0],moire[1],0), (-moire[1],moire[0]+moire[1],0), (0,0,1) ) # A bottom layer l2 = graphene_cell.supercell( (moire[2],moire[3],0), (-moire[3],moire[2]+moire[3],0), (0,0,1) ) # Make the basis fit l2.vectors[:2] = l1.vectors[:2] # Draw svgwrite_unit_cell(l1.stack(l2, vector='z'), 'output.svg', size = (440,360), camera = (0,0,-1), camera_top = (0,1,0), show_atoms = False)
from dfttools.types import Basis, Cell from dfttools.presentation import svgwrite_unit_cell from numericalunits import angstrom as a si_basis = Basis((3.9 * a / 2, 3.9 * a / 2, 3.9 * a / 2, .5, .5, .5), kind='triclinic') si_cell = Cell(si_basis, (.5, .5, .5), 'Si') svgwrite_unit_cell(si_cell, 'output.svg', size=(440, 360), show_cell=True)
def __test_0__(self, cell, **kwargs): svg = svgwrite.Drawing() svgwrite_unit_cell(cell, svg, fadeout_strength=0, **kwargs) self.__check_svg__(svg, cell, **kwargs)
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))
def test_save(self): fl = tempfile.mkstemp()[1] svgwrite_unit_cell(self.cell, fl) assert os.path.isfile(fl) os.remove(fl)
def __test_0__(self, cell, **kwargs): svg = svgwrite.Drawing(size=(1000, 1000)) svgwrite_unit_cell(self.cell, svg, insert=(100, 100), size=(800, 800), **kwargs) self.__check_dims__(svg, self.cell, (99, 99, 901, 901))
def test_2(self): fl = tempfile.mkstemp()[1] svg = svgwrite_unit_cell(self.cell2, fl, show_cell=True) self.__check_dims__(svg, self.cell2, (-0.1, -0.1, svg["width"] + 0.1, svg["height"] + 0.1)) assert os.path.isfile(fl) os.remove(fl)
) # Unit cell graphene_cell = Cell(graphene_basis, ( (1./3,1./3,.5), (2./3,2./3,.5), ), ('C','C')) # Moire matching vectors moire = [1, 26, 6, 23] # A top layer l1 = graphene_cell.supercell( (moire[0],moire[1],0), (-moire[1],moire[0]+moire[1],0), (0,0,1) ) # A bottom layer l2 = graphene_cell.supercell( (moire[2],moire[3],0), (-moire[3],moire[2]+moire[3],0), (0,0,1) ) # Make the basis fit l2.vectors[:2] = l1.vectors[:2] # Draw svgwrite_unit_cell(l1.stack(l2, vector='z'), 'output.svg', size = (440,360), camera = (0,0,-1), camera_top = (0,1,0), show_atoms = False)
mos2_basis = Basis( (3.19*a, 3.19*a, 20*a, 0,0,.5), kind = 'triclinic' ) d = 1.57722483162840/20 # Unit cell with 3 atoms mos2_cell = UnitCell(mos2_basis, ( (1./3,1./3,.5), (2./3,2./3,0.5+d), (2./3,2./3,0.5-d), ), ('Mo','S','S')) # Rectangular supercell with 6 atoms mos2_rectangular = mos2_cell.supercell( (1,0,0), (-1,2,0), (0,0,1) ) # Rectangular sheet with a defect mos2_defect = mos2_rectangular.normalized() mos2_defect.discard((mos2_defect.values == "S") * (mos2_defect.coordinates[:,1] < .5) * (mos2_defect.coordinates[:,2] < .5)) # Prepare a sheet mos2_sheet = UnitCell.stack(*((mos2_rectangular,)*3 + (mos2_defect,) + (mos2_rectangular,)*3), vector = 'y') # Draw svgwrite_unit_cell(mos2_sheet.repeated(10,1,1), 'output.svg', size = (440,360), camera = (1,1,0.3), camera_top = (0,0,1))