Пример #1
0
def check_poscar(filename):
    # return 0 if ok, return 1 if failed
    try:
        cl = CalculationVasp()
        cl.read_poscar(filename)
        print(cl.init.natom)
        status = 0 # good
    except:
        status = 1
    return status
Пример #2
0
        params = {}

    vasprun_command = params.get('vasp_run') or 'vasp'
    nmcstep = params.get('mcsteps') or 2  # minimum two steps are done
    thickness = params.get('thickness') or 6  # minimum layer
    temperature = params.get('temp') or 1

    printlog('\n\n\nStarting Monte-Carlo script!')
    printlog('Command to run vasp', vasprun_command)
    printlog('Total number of steps is', nmcstep)
    printlog('Thickness is ', thickness)
    printlog('Temperature is ', temperature, 'K')
    """1. Run initial calculation"""
    if debug:
        cl = CalculationVasp()
        cl.read_poscar('1.POSCAR')
        cl.end = cl.init
        last_number = 0
    else:

        files_yes = glob.glob('*yes.pickle')  #get list of calculated yes files
        files_all = glob.glob('*.pickle')  #get list of all calculated files
        """Find last yes pickle file"""
        if files_yes:
            yes_numbers = [int(file.split('-')[0]) for file in files_yes]
            all_numbers = [int(file.split('-')[0]) for file in files_all]
            last_yes_n = max(yes_numbers)
            last_number = max(all_numbers)
            last_yes_file = str(last_yes_n) + '-yes.pickle'
            printlog('Last calculation file is ', last_yes_file, imp='y')
Пример #3
0
def initial_run(xcart_voids, ):
    """1. Run initial calculation"""
    if debug:
        cl = CalculationVasp()
        cl.read_poscar('1.POSCAR')
        cl.end = cl.init
        if xcart_voids: # read void coordinates
            cl.end = cl.end.add_atoms(xcart_voids, 'void')
        last_number = 0
    else:
        
        files_yes = glob.glob('*yes.pickle') #get list of calculated yes files
        files_all = glob.glob('*.pickle') #get list of all calculated files
        

        """Find last yes pickle file"""
        if files_yes:
            yes_numbers = [int(file.split('-')[0]) for file in files_yes]
            all_numbers = [int(file.split('-')[0]) for file in files_all]
            last_yes_n = max(yes_numbers)
            last_number = max(all_numbers)
            last_yes_file = str(last_yes_n)+'-yes.pickle'
            printlog('Last calculation file is ', last_yes_file, imp = 'y')
        
        else:
            last_number = 0
            last_yes_file = None

        """Read last pickle file or run vasp """
        
        if last_yes_file:
            cl = CalculationVasp().deserialize(last_yes_file)
            printlog('Successfully deserialized')
            xcart_voids = cl.end.get_specific_elements([300], fmt = 'x') # extract voids form the last calculation
        
        else:
            cl = vasp_run(3, 'first run', vasprun_command = vasprun_command)
            
            if xcart_voids: # read void coordinates
                cl.end = cl.end.add_atoms(xcart_voids, 'void')
                printlog('I found', len(xcart_voids), 'voids in config file. Added to structure.')

            if check(cl) == 0:
                cl.serialize('0-yes')
                copyfile('OUTCAR', 'OUTCAR-0')
                copyfile('OSZICAR', 'OSZICAR-0')
                copyfile('CONTCAR', 'CONTCAR-0')
                copyfile('OUTCAR', 'OUTCAR_last')
                copyfile('CONTCAR', 'CONTCAR_last')
                with open('ENERGIES', 'w') as f:
                    f.write('{:5d}  {:.5f}\n'.format(0, cl.e0))
            else:
                printlog('Calculation is broken, no data was saved, exiting ...', imp = 'y')
                sys.exit()



    if debug2:
        sys.exit()

    return cl, last_number