Пример #1
0
def trilayer(doped = None):
    a = 5.43
    fcc = Lattice([[a/2,a/2,0],[a/2,0,a/2],[0,a/2,a/2]])
    trilayer = Structure(fcc,['Si']*2,[[0.00,0.00,0.00],[0.25,0.25,0.25]])
    
    # Make the cell cubic
    trilayer.make_supercell([[1,1,-1],[1,-1,1],[-1,1,1]])
    trilayer.make_supercell([[1,1,0],[1,-1,0],[0,0,4]])
    # Rotate the cell
    rt = 0.70710678118654746
    symmop = SymmOp.from_rotation_and_translation([[rt,rt,0],[rt,-rt,0],[0,0,1]])
    trilayer.apply_operation(symmop)
    
    if doped is not None:
        frac_coords = numpy.array([0.5,0.0,0.5])
        for i,atom in enumerate(trilayer):
            if numpy.linalg.norm(atom.frac_coords-frac_coords) < 0.001:
                trilayer.replace(i,doped,frac_coords)


    for z in [0.375,0.625]:
        for xy in [0.00,0.50]:
            trilayer.append('Mn',[xy,xy,z])

    return trilayer
Пример #2
0
def make_InAs001_surface(inas_layers = 4, licras_layers = 4, vacuum_layers = 8):
    total_layers = inas_layers + licras_layers + vacuum_layers
    err = 1./total_layers/10
    a = Length(6.0583, "ang")
    fcc_lattice = np.array([[.0,.5,.5],[.5,.0,.5],[.5,.5,.0]])
    lattice = Lattice(fcc_lattice * a)
    surface = Structure(lattice, ['Li', 'Cr', 'As'], [[0.50,0.50,0.50],[0.00,0.00,0.00],[0.25,0.25,0.25]])
    surface.make_supercell([[0,0,1],[1,-1,0],[1,1,-1]])
    surface.make_supercell([[1,0,0],[0,1,0],[0,0,total_layers]])
    to_remove = []
    print (1.*inas_layers / total_layers)
    print 1.*(inas_layers+licras_layers)/total_layers
    print 1. - 1. / vacuum_layers
    print err
    for idx,site in enumerate(surface):
        if (site.frac_coords[2] - 1.*inas_layers / total_layers) < -err:
            if site.specie.symbol == 'Li': to_remove.append(idx)
            if site.specie.symbol == 'Cr': surface.replace(idx,Element('In'))
        if (site.frac_coords[2] - 1. + 1./vacuum_layers/8.) > -err:
            surface.replace(idx,Element('H'))
        elif (1.*(inas_layers+licras_layers)/total_layers) - site.frac_coords[2] < err:
            to_remove.append(idx)
    surface.remove_sites(to_remove)
    selective_dynamics = len(surface) * [[True,True,True]]
    for idx,site in enumerate(surface):
        if (np.linalg.norm(site.frac_coords) < err):
            selective_dynamics[idx] = [False,False,False]
    return surface.get_sorted_structure(),np.array(selective_dynamics)
Пример #3
0
def make_trilayer(xyscale = 2, zscale = 4):
    a = Length(5.431,"ang")
    fcc_lattice = np.array([[.0,.5,.5],[.5,.0,.5],[.5,.5,.0]])
    lattice = Lattice(fcc_lattice * a)
    trilayer = Structure(lattice, ['Si','Si'], [[0.00,0.00,0.00],[0.25,0.25,0.25]])
    trilayer.make_supercell([[0,0,1],[1,-1,0],[1,1,-1]])
    trilayer.make_supercell([[xyscale,0,0],[0,xyscale,0],[0,0,zscale]])
    # Dope the Ga sites
    for idx,site in enumerate(trilayer):
        if np.linalg.norm(site.frac_coords - np.array([+.0,+.5,.0])) < 1e-10:
            trilayer.replace(idx,Element('Ga'))
        if np.linalg.norm(site.frac_coords - np.array([+.5,+.0,.0])) < 1e-10:
            trilayer.replace(idx,Element('Ga'))
    # Insert the Mn sites
    trilayer.append('Mn', [0.0,0.0,zscale*a-a/2], coords_are_cartesian=True)
    trilayer.append('Mn', [0,a,zscale*a-a/2], coords_are_cartesian=True)
    trilayer.append('Mn', [0.0,0.0,a/2], coords_are_cartesian=True)
    trilayer.append('Mn', [0,a,a/2], coords_are_cartesian=True)
    
    return trilayer.get_sorted_structure()
Пример #4
0
def make_Si001_surface(Si_layers = 4, vacuum_layers = 4):
    total_layers = Si_layers + vacuum_layers
    a = Length(5.431, "ang")
    fcc_lattice = np.array([[.0,.5,.5],[.5,.0,.5],[.5,.5,.0]])
    lattice = Lattice(fcc_lattice * a)
    surface = Structure(lattice, ['Si','Si'], [[0.00,0.00,0.00],[0.25,0.25,0.25]])
    surface.make_supercell([[0,0,1],[1,-1,0],[1,1,-1]])
    surface.make_supercell([[2,0,0],[0,2,0],[0,0,total_layers]])
    to_remove = []
    for idx,site in enumerate(surface):
        if (site.frac_coords[2] > 1.0*Si_layers/total_layers):
            to_remove.append(idx)
    surface.remove_sites(to_remove)
    print to_remove
    selective_dynamics = len(surface) * [[True,True,True]]
    for idx,site in enumerate(surface):
        if (site.frac_coords[2] < 0.001):
            selective_dynamics[idx] = [False,False,False]
            surface.replace(idx,Element('H'))
    return surface.get_sorted_structure(),np.array(selective_dynamics)
Пример #5
0
 def test_unique_structure_substitutions(self):
     # integration test
     # Create a pymatgen structure with 16 sites in a 4x4 square grid
     coords = np.array([[0.0, 0.0, 0.0], [0.25, 0.0, 0.0], [0.5, 0., 0.0],
                        [0.75, 0.0, 0.0], [0.0, 0.25, 0.0],
                        [0.25, 0.25, 0.0], [0.5, 0.25, 0.0],
                        [0.75, 0.25, 0.0], [0.0, 0.5,
                                            0.0], [0.25, 0.5, 0.0],
                        [0.5, 0.5, 0.0], [0.75, 0.5, 0.0], [0.0, 0.75, 0.0],
                        [0.25, 0.75, 0.0], [0.5, 0.75, 0.0],
                        [0.75, 0.75, 0.0]])
     atom_list = ['Li'] * len(coords)
     lattice = Lattice.from_parameters(a=3.0,
                                       b=3.0,
                                       c=3.0,
                                       alpha=90,
                                       beta=90,
                                       gamma=90)
     parent_structure = Structure(lattice, atom_list, coords)
     parent_structure.replace(0, 'O')  # substitute one site with 'O'
     ns = unique_structure_substitutions(parent_structure, 'Li', {
         'Na': 1,
         'Li': 14
     })
     self.assertEqual(len(ns), 5)
     distances = np.array(
         sorted([
             s.get_distance(
                 s.indices_from_symbol('O')[0],
                 s.indices_from_symbol('Na')[0]) for s in ns
         ]))
     np.testing.assert_array_almost_equal(
         distances, np.array([0.75, 1.06066, 1.5, 1.677051, 2.12132]))
     np.testing.assert_array_equal(
         np.array(
             sorted([s.number_of_equivalent_configurations for s in ns])),
         np.array([1, 2, 4, 4, 4]))
     np.testing.assert_array_equal(
         np.array(sorted([s.full_configuration_degeneracy for s in ns])),
         np.array([1, 2, 4, 4, 4]))
Пример #6
0
    def run_task(self, fw_spec):
        atom_style = self.get('atom_style')
        start_temp = self.get('start_temp')
        end_temp = self.get('end_temp')
        nsteps = self.get('nsteps')
        spawn = self.get('spawn') or False
        production = self.get('production') or False

        time_step = self.get('time_step') or 1
        vasp_cmd = self.get('vasp_cmd') or ">>vasp_gam<<"
        copy_vasp_outputs = self.get('copy_vasp_outputs') or False
        user_incar_settings = self.get('user_incar_settings') or {}
        user_kpoints_settings = self.get('user_kpoints_settings') or None
        db_file = self.get('db_file') or None
        transmute = self.get('transmute') or None

        pressure_threshold = self.get('pressure_threshold') or 5
        max_rescales = self.get('max_rescales') or 6
        wall_time = self.get('wall_time') or 19200
        copy_calcs = self.get('copy_calcs') or False
        calc_home = self.get('calc_home') or '~'

        logger.info("PARSING \"lammps.final\" to VASP.")
        data = LammpsData.from_file(os.path.join(os.getcwd(),
                                                 self.get('final_data')),
                                    atom_style=atom_style,
                                    sort_id=True)
        struc = data.structure
        structure = Structure(lattice=struc.lattice,
                              species=[s.specie for s in struc.sites],
                              coords=[s.coords for s in struc.sites],
                              coords_are_cartesian=True)

        if transmute:
            sites = structure.sites
            indices = []
            for i, s in enumerate(sites):
                if s.specie.symbol == transmute[0]:
                    indices.append(i)
            index = random.choice(indices)
            structure.replace(
                index,
                species=transmute[1],
                properties={'charge': Specie(transmute[1]).oxi_state})

        vasp_input_set = MITMDSet(structure,
                                  start_temp,
                                  end_temp,
                                  nsteps,
                                  time_step,
                                  force_gamma=True,
                                  user_incar_settings=user_incar_settings)

        if user_kpoints_settings:
            v = vasp_input_set.as_dict()
            v.update({"user_kpoints_settings": user_kpoints_settings})
            vasp_input_set = vasp_input_set.from_dict(v)

        fw = MDFW(structure,
                  start_temp,
                  end_temp,
                  nsteps,
                  vasp_input_set=vasp_input_set,
                  vasp_cmd=vasp_cmd,
                  copy_vasp_outputs=copy_vasp_outputs,
                  db_file=db_file,
                  name='MDFW',
                  wall_time=wall_time)

        if spawn:
            t = fw.tasks
            t.append(
                SpawnMDFWTask(pressure_threshold=pressure_threshold,
                              max_rescales=max_rescales,
                              wall_time=wall_time,
                              vasp_cmd=vasp_cmd,
                              db_file=db_file,
                              copy_calcs=copy_calcs,
                              calc_home=calc_home,
                              spawn_count=1,
                              production=production))
            fw = Firework(tasks=t, name='SpawnMDFW')

        return FWAction(detours=fw, stored_data={'LammpsStructure': structure})