Пример #1
0
def test_get_molecular_grid_raises():
    # check atomic numbers shape
    with path('chemtools.data', 'ch4_uhf_ccpvdz.fchk') as fname:
        molecule = Molecule.from_file(fname)
    with path('chemtools.data', 'h2o_q+0_ub3lyp_ccpvtz.fchk') as fname:
        grid = UniformGrid.from_file(fname)
    assert_raises(ValueError, get_molecular_grid, molecule, grid)
    assert_raises(ValueError, get_molecular_grid, [molecule], grid)
    assert_raises(ValueError, get_molecular_grid, [molecule, molecule], grid)
    with path('chemtools.data', 'ch4_uhf_ccpvdz.fchk') as file1:
        with path('chemtools.data', 'h2o_q+0_ub3lyp_ccpvtz.fchk') as file2:
            molecule = [Molecule.from_file(file1), Molecule.from_file(file2)]
    assert_raises(ValueError, get_molecular_grid, molecule, grid)
    # check atomic numbers (to be added)

    # check atomic coordinate
    with path('chemtools.data', 'water_b3lyp_sto3g.fchk') as fname:
        molecule = Molecule.from_file(fname)
    with path('chemtools.data', 'h2o_q+0_ub3lyp_ccpvtz.fchk') as fname:
        grid = UniformGrid.from_file(fname)
    assert_raises(ValueError, get_molecular_grid, molecule, grid)
    assert_raises(ValueError, get_molecular_grid, molecule, grid)
    assert_raises(ValueError, get_molecular_grid, [molecule], grid)
    assert_raises(ValueError, get_molecular_grid, [molecule, molecule], grid)
    with path('chemtools.data', 'water_b3lyp_sto3g.fchk') as file1:
        with path('chemtools.data', 'h2o_q+0_ub3lyp_ccpvtz.fchk') as file2:
            molecule = [Molecule.from_file(file1), Molecule.from_file(file2)]
    assert_raises(ValueError, get_molecular_grid, molecule, grid)
    with path('chemtools.data', 'water_b3lyp_sto3g.fchk') as file1:
        with path('chemtools.data', 'h2o_q+0_ub3lyp_ccpvtz.fchk') as file2:
            with path('chemtools.data', 'h2o_q+1_ub3lyp_ccpvtz.fchk') as file3:
                molecule = [
                    Molecule.from_file(file1),
                    Molecule.from_file(file2),
                    Molecule.from_file(file3),
                ]
    assert_raises(ValueError, get_molecular_grid, molecule, grid)
==================================
EX7: Dual Descriptor (Frontier MO)
==================================

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)
Пример #3
0
r"""
======================================================
EX2: ELF from wave-function file and user-defined cube
======================================================

Compute ELF and visualize it for water dimer.

"""

from chemtools import ELF, UniformGrid

# 1. Build UniformGrid and ELF model

cub = UniformGrid.from_file('h2o_dimer.fchk', spacing=0.1, extension=2.0)
elf = ELF.from_file('h2o_dimer.fchk', grid=cub, trans='rational', trans_k=2, trans_a=1)

# 2. Generate cube file(s) and script for visualizing ELF
#    Files generated are h2o_dimer-elf.cube & h2o_dimer.vmd
#    To visualize the iso-surface, use command: $ vmd -e h2o_dimer.vmd

elf.generate_scripts('h2o_dimer', isosurf=0.8)

# 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('elf080_h2o_dimer.jpg')
Пример #4
0
r"""
======================================================
EX2: LOL from wave-function file and user-defined cube
======================================================

Compute LOL and visualize it for formamide.

"""

from chemtools import LOL, UniformGrid

# 1. Build UniformGrid and LOL model

cub = UniformGrid.from_file('formamide_q+0.fchk', spacing=0.1, extension=2.0)
lol = LOL.from_file('formamide_q+0.fchk',
                    grid=cub,
                    trans='inverse_rational',
                    trans_k=1,
                    trans_a=1)

# 2. Generate cube file(s) and script for visualizing LOL
#    Files generated are chonh2-lol.cube & chonh2.vmd
#    To visualize the iso-surface, use command: $ vmd -e chonh2.vmd

lol.generate_scripts('chonh2', isosurf=0.55)

# DISCARD BELOW:
# the code below is for displaying the LOL image on the website, you should remove it
# when running the script on your machine.
from tools.rug import plot_existing_image
Пример #5
0
Compute H**O/LUMO and visualize it for 2,6-dihydropyridine.

"""

from chemtools import MOTBasedTool, UniformGrid

# 1. Build MO Theory model

fname = 'dichloropyridine26_q+0'
mo = MOTBasedTool.from_file(fname + '.fchk')

# 2. Generate cube file(s) and script(s) for visualizing H**O/LUMO
#    Files generated are dichloropyridine26_q+0_mo{index}.cube/.vmd
#    To visualize the iso-surface, use command: $ vmd -e dichloropyridine26_q+0_mo{index}.vmd

cub = UniformGrid.from_file(fname + '.fchk', spacing=0.2, extension=5.0)
mo.generate_scripts(fname,
                    spin='a',
                    index=mo.homo_index[0],
                    isosurf=0.025,
                    grid=cub)
mo.generate_scripts(fname,
                    spin='a',
                    index=mo.lumo_index[0],
                    isosurf=0.025,
                    grid=cub)

# 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