def test_make_optin(): prefs = get_dummy_prefs() mol = get_random_mol() molname = 'dummy_mol' infile = orcasub.make_optin(prefs, molname, mol.xyz, mol.types) # Check file was created assert os.path.isfile(infile) os.remove(infile) infile = g09sub.make_optcom(prefs, molname, mol.xyz, mol.types) # Check file was created #assert os.path.isfile(infile) #os.remove(infile) infile = g16sub.make_optcom(prefs, molname, mol.xyz, mol.types)
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. . .')
def setup_optimisation(molecule, prefs, path='', max=50): opt_files = [] for conformer in molecule.conformers: if conformer.redundant: continue if prefs['optimisation']['software'] == 'orca': conformer.opt_in = orcasub.make_optin(prefs, conformer.molid, conformer.xyz, conformer.types, path + 'optimisation/') elif prefs['optimisation']['software'] == 'g09': conformer.opt_in = g09sub.make_optcom(prefs, conformer.molid, conformer.xyz, conformer.types, path + 'optimisation/') elif prefs['optimisation']['software'] == 'g16': conformer.opt_in = g16sub.make_optcom(prefs, conformer.molid, conformer.xyz, conformer.types, path + 'optimisation/') conformer.opt_log = conformer.opt_in.split('.')[0] + '.log' conformer.opt_status = 'pre-submission' opt_files.append('optimisation/' + conformer.opt_in.split('/')[-1]) if len(opt_files) == 0: print('No files to submit. . .') sys.exit(0) IN_ARRAY = 'optimisation/OPT_IN_ARRAY.txt' with open(path + IN_ARRAY, 'w') as f: for file in opt_files: print(file, file=f) system = prefs['comp']['system'] memory = prefs['optimisation']['memory'] processors = prefs['optimisation']['processors'] walltime = prefs['optimisation']['walltime'] software = prefs['optimisation']['software'] files = len(opt_files) chunks = HPCsub.get_chunks(files) qsub_names = [] for ck in range(chunks): start = (ck * max) + 1 end = ((ck + 1) * max) if end > files: end = files #header = HPCsub.make_HPC_header(jobname=jobname, system=system, nodes=1, ppn=processors, walltime=walltime, mem=memory) jobname = 'aE_' + molecule.molid + '_' + str(ck) + '_optimisation' strings = HPCsub.make_HPC_batch_submission(prefs, molecule.molid, IN_ARRAY, start, end, software=software, jobname=jobname, nodes=1, ppn=processors, walltime=walltime, mem=memory) if prefs['comp']['system'] == 'PBS': filename = path + 'OPT_' + molecule.molid + '_' + str(ck) + '.qsub' elif prefs['comp']['system'] == 'slurm': filename = path + 'OPT_' + molecule.molid + '_' + str(ck) + '.slurm' elif prefs['comp']['system'] == 'local': filename = path + 'OPT_' + molecule.molid + '_' + str(ck) + '.sh' with open(filename, 'w') as f: for string in strings: print(string, file=f) qsub_names.append(filename) print('Created ', chunks, ' submission files. . .') if prefs['comp']['system'] == 'PBS': print('Submit the calculations using:') for file in qsub_names: print('qsub ', file) elif prefs['comp']['system'] == 'PBS': print('Submit the calculations using:') for file in qsub_names: print('bash ', file) elif prefs['comp']['system'] == 'slurm': print('Havent finished this yet, good luck pal. . . .')