def process_optimisation(molecule, prefs, path=''):

	good = 0
	bad = 0

	for conformer in molecule.conformers:
		if prefs['optimisation']['software'] == 'orca':
			status = orcaread.get_opt_status(conformer.opt_log)
		elif prefs['optimisation']['software'] == 'g09':
			status = g09read.get_opt_status(conformer.opt_log)
		elif prefs['optimisation']['software'] == 'g16':
			status = g16read.get_opt_status(conformer.opt_log)

		if status == 'successful':
			good +=1
			conformer.read_structure(conformer.opt_log.split('.')[0] + '.xyz', type='xyz')
			conformer.read_opt(conformer.opt_log, type=prefs['optimisation']['software'])
			#files_to_delete = glob.glob(conformer.opt_log.split('.')[0] + '*.tmp')
			#for file in files_to_delete:
			#	os.remove(file)

		else:
			bad += 1

		if conformer.opt_status != status:
			conformer.nmr_status = 'None'

		conformer.opt_status = status

		string = 'Conformer {molid:^3s} status: {status:^10s} | Energy {energy:<10.4f}'.format(molid=str(conformer.molid),
																								status=conformer.opt_status,
																								energy=conformer.energy)
		print(string)

	print(good, ' successful optimisations, ', bad, ' failed, out of ', good+bad)
Example #2
0
def test_orcaget_opt_status():

    file = 'tests/test_store/TST_pass_orca_opt.log'
    status = orcaread.get_opt_status(file)
    assert status == 'successful'

    # Dont actually have a failed one yet
    '''
def setup_resubmission(molecule, prefs, path=''):

    for conformer in molecule.conformers:
        optstatus = orcaread.get_opt_status(conformer.opt_log)

        if optstatus != 'successful':
            conformer.opt_in = orcasub.make_optin(prefs, conformer,
                                                  path + 'optimisation/')
            conformer.opt_log = conformer.optin.split('.')[0] + '.log'
            conformer.opt_status = 'pre-submission'
            opt_files.append(conformer.opt_in)

        nmrstatus = orcaread.get_nmr_status(conformer.nmr_log)
        if conformer.nmr_status != 'successful' and conformer.opt_status == 'successful':
            conformer.nmr_in = orcasub.make_nmrin(prefs, conformer,
                                                  path + 'nmr/')
            conformer.nmr_log = conformer.nmr_in.split('.') + '.log'
            conformer.nmr_status = 'pre-submission'
            nmr_files.append(conformer.nmr_in)

    for tag, in_files in zip(['OPT', 'NMR'], [opt_files, nmr_files]):

        system = prefs['comp']['system']
        if tag == 'OPT':
            memory = prefs['opt']['memory']
            processors = prefs['opt']['processors']
            walltime = prefs['opt']['walltime']
        if tag == 'NMR':
            memory = prefs['nmr']['memory']
            processors = prefs['nmr']['processors']
            walltime = prefs['nmr']['walltime']

        files = len(in_files)
        chunks = HPCsub.get_chunks(files)
        for ck in range(chunks):
            start = (ck * max) + 1
            end = ((ck + 1) * max)
            if end > files:
                end = files

            jobname = 'aE_' + molecule.molid + '_' + str(ck) + tag + '_RESUB'
            header = HPCsub.make_HPC_header(jobname=jobname,
                                            system=system,
                                            nodes=1,
                                            ppn=processors,
                                            walltime=walltime,
                                            mem=memory)

            strings = HPCsub.make_orca_batch_submission(
                prefs, in_files, start, end, ck)

            if prefs['comp']['system'] == 'PBS':
                filename = path + 'RESUB_' + tag + '_' + molecule.molid + '_' + str(
                    ck) + '.qsub'
            elif prefs['comp']['system'] == 'slurm':
                filename = path + 'RESUB_' + tag + '_' + molecule.molid + '_' + str(
                    ck) + '.slurm'
            elif prefs['comp']['system'] == 'localbox':
                filename = path + 'RESUB_' + tag + '_' + molecule.molid + '_' + str(
                    ck) + '.sh'
            with open(filename, 'w') as f:
                for string in header:
                    print(string, file=f)
                for string in strings:
                    print(string, file=f)

        print('Created ', len(chunks), ' ', tag, 'resubmission files. . .')