def main_esp(args): """Generate VMD script and cube files for visualizing ESP on electron density iso-surface.""" # load molecule mol = Molecule.from_file(args.fname) # make cubic grid if args.cube.endswith('.cube'): # load cube file cube = UniformGrid.from_cube(args.cube) elif len(args.cube.split(',')) == 2: # make a cubic grid spacing, extension = [float(item) for item in args.cube.split(',')] cube = UniformGrid.from_molecule(mol, spacing=spacing, extension=extension, rotate=True) else: raise ValueError('Argument cube={0} is not recognized!'.format(args.cube)) # dump cube files & script for visualization espname = args.output + '_esp.cube' rhoname = args.output + '_rho.cube' vmdname = args.output + '.vmd' cube.generate_cube(rhoname, mol.compute_density(cube.points)) cube.generate_cube(espname, mol.compute_esp(cube.points)) print_vmd_script_isosurface(vmdname, rhoname, colorfile=espname, isosurf=args.isosurface, scalemin=args.scalemin, scalemax=args.scalemax)
def main_nci(args): """Build NCI model and dump VMD script and cube files for visualizing NCI with VMD.""" # load molecule mol = Molecule.from_file(args.fname) # make cubic grid if args.cube.endswith('.cube'): # load cube file cube = UniformGrid.from_cube(args.cube) elif len(args.cube.split(',')) == 2: # make a cubic grid spacing, extension = [float(item) for item in args.cube.split(',')] cube = UniformGrid.from_molecule(mol, spacing=spacing, extension=extension, rotate=True) else: raise ValueError('Argument cube={0} is not recognized!'.format( args.cube)) # build NCI model nci = NCI.from_molecule(mol, grid=cube) # dump files/scripts for visualizing NCI nci.generate_scripts(args.output, isosurf=args.isosurface, denscut=args.denscut) # plot reduced density gradient vs. signed density if args.plot: nci.generate_plot(args.output, color=args.color)
def main_mot(args): """Build MOTBasedTool model and dump VMD script and cube files for visualizing MO.""" # load molecule mol = Molecule.from_file(args.fname) # make cubic grid if args.cube.endswith('.cube'): # load cube file cube = UniformGrid.from_cube(args.cube) elif len(args.cube.split(',')) == 2: # make a cubic grid spacing, extension = [float(item) for item in args.cube.split(',')] cube = UniformGrid.from_molecule(mol, spacing=spacing, extension=extension, rotate=True) else: raise ValueError('Argument cube={0} is not recognized!'.format(args.cube)) if args.index is not None: index = [int(item) for item in args.index.split(',')] if len(index) == 1: index = index[0] else: index = None # build MOT model mot = MOTBasedTool.from_molecule(mol) # print logging message logging.info('') logging.info('Initialized : {0}'.format(mot)) logging.info('# of basis : {0}'.format(mot.nbasis)) logging.info('# of a & b electrons : {0}'.format(mot.nelectrons)) logging.info('') logging.info('Index of a & b LUMO : {0}'.format(mot.lumo_index)) logging.info('Energy of a & b LUMO : {0}'.format(mot.lumo_energy)) logging.info('') logging.info('Index of a & b H**O : {0}'.format(mot.homo_index)) logging.info('Energy of a & b H**O : {0}'.format(mot.homo_energy)) logging.info('') # dump file/script for visualizing MOT mot.generate_scripts(args.output, spin=args.spin, index=index, grid=cube, isosurf=args.isosurface)
def main_lol(args): """Build LOL model and dump VMD script and cube files for visualizing LOL.""" # load molecule mol = Molecule.from_file(args.fname) # make cubic grid if args.cube.endswith('.cube'): # load cube file cube = UniformGrid.from_cube(args.cube) elif len(args.cube.split(',')) == 2: # make a cubic grid spacing, extension = [float(item) for item in args.cube.split(',')] cube = UniformGrid.from_molecule(mol, spacing=spacing, extension=extension, rotate=True) else: raise ValueError('Argument cube={0} is not recognized!'.format(args.cube)) # build LOL model lol = LOL.from_molecule(mol, grid=cube, trans=args.trans, trans_k=args.trans_k, trans_a=args.trans_a, denscut=args.denscut) # dump file/script for visualizing LOL lol.generate_scripts(args.output, isosurf=args.isosurface)
def main_conceptual_local(args): """Build LocalConceptualDFT class and dump a cube file of local descriptor.""" # load the first molecule mol = Molecule.from_file(args.file_wfn[0]) # make cubic grid if args.cube.endswith('.cube'): # load cube file cube = UniformGrid.from_cube(args.cube) elif len(args.cube.split(',')) == 2: # make a cubic grid spacing, threshold = [float(item) for item in args.cube.split(',')] cube = UniformGrid.from_molecule(mol, spacing, threshold) else: raise ValueError('Argument cube={0} is not recognized!'.format( args.cube)) # build global tool model = LocalConceptualDFT.from_file(args.file_wfn, args.model, cube.points) # check whether local property exists if not hasattr(model, args.prop): raise ValueError('The {0} local conceptual DFT class does not contain ' '{1} attribute.'.format(args.model, args.prop)) if callable(getattr(model, args.prop)): raise ValueError( 'The {0} argument is a method, please provide an attribute of ' '{1} local conceptual DFT.'.format(args.prop, args.model)) # name of files cubefile = '{0}.cube'.format(args.output_name) vmdfile = '{0}.vmd'.format(args.output_name) # dump cube file of local property cube.generate_cube(cubefile, getattr(model, args.prop)) # generate VMD scripts for visualizing iso-surface with VMD print_vmd_script_isosurface(vmdfile, cubefile, isosurf=args.isosurface)
def main_mot(args): """Build MOTBasedTool model and dump VMD script and cube files for visualizing MO.""" # load molecule mol = Molecule.from_file(args.fname) hia, hib = np.array(mol.homo_index) - 1 lia, lib = np.array(mol.lumo_index) - 1 ea, eb = mol.orbital_energy print('') print('File: {0}'.format(args.fname)) # print('Charge : % 5f' % np.sum(mol.numbers) - np.sum(ne)) # print('Multiplicity: % 5d' % np.max(ne) - np.min(ne) + 1) print('') print('Atomic number and coordinates:') for index, num in enumerate(mol.numbers): coord = mol.coordinates[index, :] print('% 2i %10.6f %10.6f %10.6f' % (num, coord[0], coord[1], coord[2])) print('') print('Information on alpha & beta electrons:') print('# electrons : % 3.3f % 3.3f' % mol.nelectrons) print('H**O index : % 3d % 5d' % mol.homo_index) print('') print('LUMO+2 index : %10.6f %10.6f' % (ea[lia + 2], eb[lib + 2])) print('LUMO+1 energy: %10.6f %10.6f' % (ea[lia + 1], eb[lib + 1])) print('LUMO energy: %10.6f %10.6f' % mol.lumo_energy) print('H**O energy: %10.6f %10.6f' % mol.homo_energy) print('H**O-1 energy: %10.6f %10.6f' % (ea[hia - 1], eb[hib - 1])) print('H**O-2 energy: %10.6f %10.6f' % (ea[hia - 2], eb[hib - 2])) print('') if args.info: return # make cubic grid if args.cube.endswith('.cube'): # load cube file cube = UniformGrid.from_cube(args.cube) elif len(args.cube.split(',')) == 2: # make a cubic grid spacing, extension = [float(item) for item in args.cube.split(',')] cube = UniformGrid.from_molecule(mol, spacing=spacing, extension=extension, rotate=True) else: raise ValueError('Argument cube={0} is not recognized!'.format( args.cube)) if args.index is not None: index = [int(item) for item in args.index.split(',')] if len(index) == 1: index = index[0] else: index = None # build MOT model mot = MOTBasedTool.from_molecule(mol) # print logging message # logging.info('') # logging.info('Initialized : {0}'.format(mot)) # logging.info('# of basis : {0}'.format(mot.nbasis)) # logging.info('# of a & b electrons : {0}'.format(mot.nelectrons)) # logging.info('') # logging.info('Index of a & b LUMO : {0}'.format(mot.lumo_index)) # logging.info('Energy of a & b LUMO : {0}'.format(mot.lumo_energy)) # logging.info('') # logging.info('Index of a & b H**O : {0}'.format(mot.homo_index)) # logging.info('Energy of a & b H**O : {0}'.format(mot.homo_energy)) # logging.info('') # dump file/script for visualizing MOT if args.output is None: args.output = args.fname.rsplit('.')[0] mot.generate_scripts(args.output, spin=args.spin, index=index, grid=cube, isosurf=args.isosurface)