-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
433 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# FermiLib plugin to interface with Psi4 | ||
# Copyright (C) 2017 FermiLib Developers | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""This is a simple script for generating data.""" | ||
import os | ||
|
||
from fermilib.utils import (make_atomic_ring, | ||
make_atom, | ||
MolecularData, | ||
periodic_table) | ||
|
||
from fermilibpluginpsi4 import run_psi4 | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
# Set chemical parameters. | ||
basis = 'sto-3g' | ||
max_electrons = 10 | ||
spacing = 0.7414 | ||
compute_elements = 0 | ||
|
||
# Select calculations. | ||
force_recompute = 1 | ||
run_scf = 1 | ||
run_mp2 = 1 | ||
run_cisd = 1 | ||
run_ccsd = 1 | ||
run_fci = 1 | ||
verbose = 1 | ||
tolerate_error = 1 | ||
|
||
# Generate data. | ||
for n_electrons in range(2, max_electrons + 1): | ||
|
||
# Initialize. | ||
if compute_elements: | ||
atomic_symbol = periodic_table[n_electrons] | ||
molecule = make_atom(atomic_symbol, basis) | ||
else: | ||
molecule = make_atomic_ring(n_electrons, spacing, basis) | ||
if os.path.exists(molecule.filename + '.hdf5'): | ||
molecule.load() | ||
|
||
# To run or not to run. | ||
if run_scf and not molecule.hf_energy: | ||
run_job = 1 | ||
elif run_mp2 and not molecule.mp2_energy: | ||
run_job = 1 | ||
elif run_cisd and not molecule.cisd_energy: | ||
run_job = 1 | ||
elif run_ccsd and not molecule.ccsd_energy: | ||
run_job = 1 | ||
elif run_fci and not molecule.fci_energy: | ||
run_job = 1 | ||
else: | ||
run_job = force_recompute | ||
|
||
# Run. | ||
if run_job: | ||
molecule = run_psi4(molecule, | ||
run_scf=run_scf, | ||
run_mp2=run_mp2, | ||
run_cisd=run_cisd, | ||
run_ccsd=run_ccsd, | ||
run_fci=run_fci, | ||
verbose=verbose, | ||
tolerate_error=tolerate_error) | ||
molecule.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# FermiLib plugin to interface with Psi4 | ||
# Copyright (C) 2017 FermiLib Developers | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""This is a simple script for generating data.""" | ||
import os | ||
|
||
from fermilib.utils import MolecularData | ||
|
||
from fermilibpluginpsi4 import run_psi4 | ||
|
||
if __name__ == '__main__': | ||
|
||
# Set chemical parameters. | ||
element_names = ['H', 'H'] | ||
basis = 'sto-3g' | ||
charge = 0 | ||
multiplicity = 1 | ||
|
||
# Single point at equilibrium for testing | ||
spacings = [0.7414] | ||
|
||
# Add points for a full dissociation curve from 0.1 to 3.0 angstroms | ||
spacings += [0.1 * r for r in range(1, 31)] | ||
|
||
# Set run options | ||
run_scf = 1 | ||
run_mp2 = 1 | ||
run_cisd = 1 | ||
run_ccsd = 1 | ||
run_fci = 1 | ||
verbose = 1 | ||
tolerate_error = 1 | ||
|
||
# Run Diatomic Curve | ||
for spacing in spacings: | ||
description = "{}".format(spacing) | ||
geometry = [[element_names[0], [0, 0, 0]], | ||
[element_names[1], [0, 0, spacing]]] | ||
molecule = MolecularData(geometry, | ||
basis, | ||
multiplicity, | ||
charge, | ||
description) | ||
|
||
molecule = run_psi4(molecule, | ||
run_scf=run_scf, | ||
run_mp2=run_mp2, | ||
run_cisd=run_cisd, | ||
run_ccsd=run_ccsd, | ||
run_fci=run_fci, | ||
verbose=verbose, | ||
tolerate_error=tolerate_error) | ||
molecule.save() | ||
|
||
# Run Li H single point | ||
description = "1.45" | ||
geometry = [['Li', [0, 0, 0]], | ||
['H', [0, 0, 1.45]]] | ||
molecule = MolecularData(geometry, | ||
basis, | ||
multiplicity, | ||
charge, | ||
description) | ||
|
||
molecule = run_psi4(molecule, | ||
run_scf=run_scf, | ||
run_mp2=run_mp2, | ||
run_cisd=run_cisd, | ||
run_ccsd=run_ccsd, | ||
run_fci=run_fci, | ||
verbose=verbose, | ||
tolerate_error=tolerate_error) | ||
molecule.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# FermiLib plugin to interface with Psi4 | ||
# Copyright (C) 2017 FermiLib Developers | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""These functions compare properties of different molecules.""" | ||
import numpy | ||
import warnings | ||
|
||
from fermilib.utils import (make_atom, make_atomic_ring, | ||
MolecularData, periodic_table) | ||
|
||
with warnings.catch_warnings(): | ||
warnings.simplefilter('ignore') | ||
import pylab | ||
|
||
|
||
def latex_name(molecule): | ||
"""Write the name of the molecule in LaTeX. | ||
Returns: | ||
name: A string giving the name in LaTeX. | ||
""" | ||
# Get sorted atom vector. | ||
atoms = [item[0] for item in molecule.geometry] | ||
atom_charge_info = [(atom, atoms.count(atom)) for atom in set(atoms)] | ||
sorted_info = sorted(atom_charge_info, | ||
key=lambda atom: molecular_data. | ||
_PERIODIC_HASH_TABLE[atom[0]]) | ||
|
||
# Name molecule and return. | ||
name = '{}$_{}$'.format(sorted_info[0][0], sorted_info[0][1]) | ||
for info in sorted_info[1::]: | ||
name += '{}$_{}$'.format(info[0], info[1]) | ||
return name | ||
|
||
|
||
# Run. | ||
if __name__ == '__main__': | ||
|
||
# Set plot parameters. | ||
pylab.rcParams['text.usetex'] = True | ||
pylab.rcParams['text.latex.unicode'] = True | ||
pylab.rc('text', usetex=True) | ||
pylab.rc('font', family='sans=serif') | ||
marker_size = 6 | ||
line_width = 2 | ||
axis_size = 12 | ||
font_size = 16 | ||
x_log = 0 | ||
y_log = 0 | ||
|
||
# Set chemical series parameters. | ||
plot_elements = 0 | ||
max_electrons = 10 | ||
spacing = 0.7414 | ||
basis = 'sto-3g' | ||
|
||
# Get chemical series. | ||
molecular_series = [] | ||
for n_electrons in range(2, max_electrons + 1): | ||
if plot_elements: | ||
atomic_symbol = periodic_table[n_electrons] | ||
molecule = make_atom(atomic_symbol, basis) | ||
else: | ||
molecule = make_atomic_ring(n_electrons, spacing, basis) | ||
molecule.load() | ||
molecular_series += [molecule] | ||
|
||
# Get plot data. | ||
x_values = [] | ||
y_values = [] | ||
for molecule in molecular_series: | ||
|
||
# x-axis. | ||
x_label = 'Number of Electrons' | ||
x_values += [molecule.n_electrons] | ||
|
||
# y-axis. | ||
y_label = 'MP2 Energy' | ||
y_values += [molecule.mp2_energy] | ||
|
||
# Print. | ||
print('\n{} for {} = {}.'.format(x_label, molecule.name, x_values[-1])) | ||
print('{} for {} = {}.'.format(y_label, molecule.name, y_values[-1])) | ||
|
||
# Plot. | ||
pylab.figure(0) | ||
pylab.plot(x_values, y_values, lw=0, marker='o') | ||
|
||
# Set log scales. | ||
if y_log: | ||
pylab.yscale('log') | ||
if x_log: | ||
pylab.xscale('log') | ||
|
||
# Finish making the plot. | ||
pylab.xticks(size=axis_size) | ||
pylab.yticks(size=axis_size) | ||
pylab.xlabel(r'%s' % x_label, fontsize=font_size) | ||
pylab.ylabel(r'%s' % y_label, fontsize=font_size) | ||
pylab.show() |
Oops, something went wrong.