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)
Compute dual descriptor on a cubic grid based on the quadratic energy model using frontier molecular orbital (FMO) approach, and generate visualization scripts. """ 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
np.array([ [2.27823914e00, 4.13899085e-07, 3.12033662e-07], [1.01154892e-02, 1.09802629e-07, -6.99333116e-07], [-1.09577141e00, 1.77311416e00, 1.42544321e-07], ]), 0.1, 6, ) # 2. Build a quadratic energy models using FMO approach # path to molecule's fchk file file_path = "ch2o_q+0.fchk" # build a quadratic global conceptual DFT tool tool = LocalConceptualDFT.from_file(file_path, model="quadratic", points=xyz.reshape(-1, 3)) # 3. Evaluate quadratic Fukui function on the grid points. ff_quad = tool.fukui_function.reshape(xyz.shape[:2]) # 4. Plot 2D-contour plots of quadratic Fukui function. # sample contour lines levels = np.array([0.001 * n * n for n in range(500)]) # plot contours of quadratic Fukui function plt.contour(xyz[:, :, 0], xyz[:, :, 1], ff_quad, levels) # plot atomic centers x_atoms, y_atoms = tool.coordinates[:, 0], tool.coordinates[:, 1]
from chemtools import LocalConceptualDFT, UniformGrid, print_vmd_script_isosurface file_path = ['ch2o_q+0.fchk', 'ch2o_q+1.fchk', 'ch2o_q-1.fchk'] # 1. Make cubic grid for plotting Fukui function. # The cubic grid points are spaced by 0.2 a.u. & extending 5.0 a.u. on each side. # All 3 molecules have the same geometry (they just differ in the number of electrons # and multiplicity), so the cubic grid based on the first molecule works for all. cube = UniformGrid.from_file(file_path[0], spacing=0.2, extension=5.0) # 2. Build linear energy model for Formaldehyde using finite difference (FD) approach. 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',