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_conceptual_local(args): """Build LocalConceptualDFT class and dump a cube file of local descriptor.""" # load molecule & cubic grid mol, cube = load_molecule_and_grid(args.fname, args.cube) # build model model = LocalConceptualDFT.from_molecule(args.fname, 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 cubfname = "{0}.cube".format(args.output) vmdfname = "{0}.vmd".format(args.output) # dump cube file of local property cube.generate_cube(cubfname, getattr(model, args.prop)) # generate VMD scripts for visualizing iso-surface with VMD print_vmd_script_isosurface(vmdfname, cubfname, isosurf=args.isosurface, material="BlownGlass")
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)
""" from chemtools import LocalConceptualDFT, UniformGrid, print_vmd_script_isosurface # 1. Make cubic grid for plotting dual descriptor. # The cubic grid points are spaced by 0.2 a.u. & extending 5.0 a.u. on each side. file_path = 'ch2o_q+0.fchk' cube = UniformGrid.from_file(file_path, spacing=0.2, extension=5.0) # 2. Build quadratic energy model for Formaldehyde using FMO approach. tool = LocalConceptualDFT.from_file(file_path, model='quadratic', points=cube.points) # 3. Dump dual descriptor evaluated on cubic grid. cube.generate_cube('coh2_dual_fmo.cube', tool.dual_descriptor) # 4. Generate VMD scripts to plot dual-descriptor iso-surface. # To visualize the iso-surface, use command: $ vmd -e coh2_dual_fmo.vmd print_vmd_script_isosurface('coh2_dual_fmo.vmd', 'coh2_dual_fmo.cube', isosurf=0.005, scalemin=-0.005, scalemax=0.005, colorscheme=[0, 1], negative=True) # DISCARD BELOW: # the code below is for displaying the dual descriptor image on the website, you should remove it # when running the script on your machine. from tools.rug import plot_existing_image plot_existing_image('ch2o_dual_fmo.jpg')
fname = 'scl2' mol = Molecule.from_file(fname + '.fchk') cub = UniformGrid.from_molecule(mol, spacing=1.0, extension=5.0) # 2. Generate cube files: fname_esp.cube & fname_rho.cube espname = fname + '_esp.cube' rhoname = fname + '_rho.cube' cub.generate_cube(rhoname, mol.compute_density(cub.points)) cub.generate_cube(espname, mol.compute_esp(cub.points)) # 3. Generate vmd script: fname.vmd # To visualize the iso-surface, use command: $ vmd -e fname.vmd print_vmd_script_isosurface(fname + '.vmd', rhoname, colorfile=espname, isosurf=0.002, scalemin=-0.02, scalemax=0.04) # DISCARD BELOW: # the code below is for displaying the ELF image on the website, you should remove it # when running the script on your machine. from tools.rug import plot_existing_image plot_existing_image('esp_scl2.png')
tool = LocalConceptualDFT.from_file(file_path, model='linear', points=cube.points) # 3. Dump Fukui functions (f+, f- and f0) evaluated on cubic grid. cube.generate_cube('coh2_ffp_fd.cube', tool.ff_plus) cube.generate_cube('coh2_ff0_fd.cube', tool.ff_zero) cube.generate_cube('coh2_ffm_fd.cube', tool.ff_minus) # 4. Generate VMD scripts to plot dual-descriptor iso-surface. # To visualize the iso-surface, use command: $ vmd -e coh2_ffp_fd.vmd print_vmd_script_isosurface('coh2_ffp_fd.vmd', 'coh2_ffp_fd.cube', isosurf=0.005) print_vmd_script_isosurface('coh2_ff0_fd.vmd', 'coh2_ff0_fd.cube', isosurf=0.005) print_vmd_script_isosurface('coh2_ffm_fd.vmd', 'coh2_ffm_fd.cube', isosurf=0.005, negative=True, colorscheme=[0, 1]) # DISCARD BELOW: # the code below is for displaying the ff image on the website, you should remove it # when running the script on your machine. from tools.rug import plot_existing_image
fname = 'dichloropyridine26_q+0' mol = Molecule.from_file(fname + '.fchk') cub = UniformGrid.from_molecule(mol, spacing=1.0, spacing=1.0, extension=5.0) orb = DFTBasedTool.from_molecule(mol, cub.points) # 2. Generate cube files: fname_esp.cube & fname_rho.cube lip_a, lip_b = orb.average_local_ionization_energy lipname = fname + '_lip.cube' rhoname = fname + '_rho.cube' cub.generate_cube(rhoname, mol.compute_density(cub.points)) cub.generate_cube(lipname, lip_a + lip_b) # 3. Generate vmd script: fname.vmd # To visualize the iso-surface, use command: $ vmd -e fname.vmd print_vmd_script_isosurface(fname + '.vmd', rhoname, colorfile=lipname, isosurf=0.002, scalemin=-1.0, scalemax=mol.homo_energy[0]) # DISCARD BELOW: # the code below is for displaying the ELF image on the website, you should remove it # when running the script on your machine. # from tools.rug import plot_existing_image # plot_existing_image('esp_scl2.png')
file_path = 'ch2o_q+0.fchk' # 1. Make a Cubic grid for plotting Fukui functions. # The cubic grid points are spaced by 0.2 a.u. & extending 5.0 a.u. on each side. cube = UniformGrid.from_file(file_path, spacing=0.2, extension=5.0) # 2. Build linear energy model for Formaldehyde using frontier molecular orbital (FMO) theory. tool = LocalConceptualDFT.from_file(file_path, model='linear', points=cube.points) # 3. Dump Fukui functions (f+, f- and f0) evaluated on cubic grid. cube.generate_cube('coh2_ffm_fmo.cube', tool.ff_minus) cube.generate_cube('coh2_ffp_fmo.cube', tool.ff_plus) cube.generate_cube('coh2_ff0_fmo.cube', tool.ff_zero) # 4. Generate VMD scripts to plot Fukui function iso-surface. # To visualize the iso-surface, use command: $ vmd -e coh2_ffp_fmo.vmd print_vmd_script_isosurface('coh2_ffp_fmo.vmd', 'coh2_ffp_fmo.cube', isosurf=0.005) print_vmd_script_isosurface('coh2_ff0_fmo.vmd', 'coh2_ff0_fmo.cube', isosurf=0.005) print_vmd_script_isosurface('coh2_ffm_fmo.vmd', 'coh2_ffm_fmo.cube', isosurf=0.005) # DISCARD BELOW: # the code below is for displaying the ff image on the website, you should remove it # when running the script on your machine. from tools.rug import plot_existing_image plot_existing_image('ch2o-ff_fmo.jpg')