Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
fevangelista committed Nov 14, 2017
1 parent a59f5f4 commit 2b77fb8
Show file tree
Hide file tree
Showing 6 changed files with 306 additions and 0 deletions.
41 changes: 41 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# @BEGIN LICENSE
#
# psi4_plugin17 by Psi4 Developer, a plugin to:
#
# Psi4: an open-source quantum chemistry software package
#
# Copyright (c) 2007-2017 The Psi4 Developers.
#
# The copyrights for code used from other parties are included in
# the corresponding files.
#
# This file is part of Psi4.
#
# Psi4 is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, version 3.
#
# Psi4 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with Psi4; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# @END LICENSE
#

cmake_minimum_required(VERSION 3.1 FATAL_ERROR)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(psi4_plugin17 CXX)

find_package(psi4 1.1 REQUIRED)

add_psi4_plugin(psi4_plugin17 plugin.cc)
46 changes: 46 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#
# @BEGIN LICENSE
#
# psi4_plugin17 by Psi4 Developer, a plugin to:
#
# Psi4: an open-source quantum chemistry software package
#
# Copyright (c) 2007-2017 The Psi4 Developers.
#
# The copyrights for code used from other parties are included in
# the corresponding files.
#
# This file is part of Psi4.
#
# Psi4 is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, version 3.
#
# Psi4 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with Psi4; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# @END LICENSE
#

"""Plugin docstring.
"""
__version__ = '0.1'
__author__ = 'Psi4 Developer'

# Load Python modules
from .pymodule import *

# Load C++ plugin
import os
import psi4
plugdir = os.path.split(os.path.abspath(__file__))[0]
sofile = plugdir + '/' + os.path.split(plugdir)[1] + '.so'
psi4.core.plugin_load(sofile)

56 changes: 56 additions & 0 deletions doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.. comment /*
.. comment * @BEGIN LICENSE
.. comment *
.. comment * psi4_plugin17 by Psi4 Developer, a plugin to:
.. comment *
.. comment * Psi4: an open-source quantum chemistry software package
.. comment *
.. comment * Copyright (c) 2007-2017 The Psi4 Developers.
.. comment *
.. comment * The copyrights for code used from other parties are included in
.. comment * the corresponding files.
.. comment *
.. comment * This file is part of Psi4.
.. comment *
.. comment * Psi4 is free software; you can redistribute it and/or modify
.. comment * it under the terms of the GNU Lesser General Public License as published by
.. comment * the Free Software Foundation, version 3.
.. comment *
.. comment * Psi4 is distributed in the hope that it will be useful,
.. comment * but WITHOUT ANY WARRANTY; without even the implied warranty of
.. comment * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.. comment * GNU Lesser General Public License for more details.
.. comment *
.. comment * You should have received a copy of the GNU Lesser General Public License along
.. comment * with Psi4; if not, write to the Free Software Foundation, Inc.,
.. comment * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
.. comment *
.. comment * @END LICENSE
.. comment */
.. include:: /autodoc_abbr_options_c.rst
.. include:: /autodoc_abbr_options_plugins.rst

.. _`sec:modulename`:

Theory, Usage, and Notes
------------------------

.. codeauthor:: Psi4 Developer
.. sectionauthor:: Psi4 Developer

Casual documentation for this plugin goes here.
Uncomment the ``.. comment`` for some examples.

.. comment * this plugin solves :math:`H=F_A+W_A+F_B+W_B+V`
.. comment * reference to keyword |globals__docc| and |psi4_plugin17__print|
.. comment * returns :psivar:`CURRENT ENERGY <CURRENTENERGY>` in |kcalpermol|
.. comment * operation depends on :envvar:`OMP_NUM_THREADS`.
.. comment * operation requires external software described in :ref:`sec:interfacing`
.. comment
.. comment .. caution:: Some features are not yet implemented.
.. comment
.. comment - Do not run plugin more than ten feet away from developer.
.. comment
.. comment - Do not run plugin on benzene dimer.
26 changes: 26 additions & 0 deletions input.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# PYTHONPATH must include directory above plugin directory.
# Define either externally or here, then import plugin.
sys.path.insert(0, './..')
import psi4_plugin17

molecule {
O
H 1 R
H 1 R 2 A

R = .9
A = 104.5
}

set {
basis sto-3g
}

set psi4_plugin17 {
print 1
}

energy('psi4_plugin17')

psi4_plugin17.exampleFN()
66 changes: 66 additions & 0 deletions plugin.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* @BEGIN LICENSE
*
* psi4_plugin17 by Psi4 Developer, a plugin to:
*
* Psi4: an open-source quantum chemistry software package
*
* Copyright (c) 2007-2017 The Psi4 Developers.
*
* The copyrights for code used from other parties are included in
* the corresponding files.
*
* This file is part of Psi4.
*
* Psi4 is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* Psi4 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with Psi4; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @END LICENSE
*/

#include "psi4/psi4-dec.h"
#include "psi4/libpsi4util/PsiOutStream.h"
#include "psi4/liboptions/liboptions.h"
#include "psi4/libmints/wavefunction.h"
#include "psi4/libpsio/psio.hpp"
#include "psi4/libpsio/psio.hpp"

namespace psi{ namespace psi4_plugin17 {

extern "C"
int read_options(std::string name, Options& options)
{
if (name == "PSI4_PLUGIN17"|| options.read_globals()) {
/*- The amount of information printed to the output file -*/
options.add_int("PRINT", 1);
}

return true;
}

extern "C"
SharedWavefunction psi4_plugin17(SharedWavefunction ref_wfn, Options& options)
{
int print = options.get_int("PRINT");

/* Your code goes here */
// Tuple unpacking
std::tuple<int,int> t(2,3);
auto [n,d] = t;
std::cout << "\n n * d = " << n * d << std::endl;
// Typically you would build a new wavefunction and populate it with data
return ref_wfn;
}

}} // End namespaces

71 changes: 71 additions & 0 deletions pymodule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#
# @BEGIN LICENSE
#
# psi4_plugin17 by Psi4 Developer, a plugin to:
#
# Psi4: an open-source quantum chemistry software package
#
# Copyright (c) 2007-2017 The Psi4 Developers.
#
# The copyrights for code used from other parties are included in
# the corresponding files.
#
# This file is part of Psi4.
#
# Psi4 is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, version 3.
#
# Psi4 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with Psi4; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# @END LICENSE
#

import psi4
import psi4.driver.p4util as p4util
from psi4.driver.procrouting import proc_util

def run_psi4_plugin17(name, **kwargs):
r"""Function encoding sequence of PSI module and plugin calls so that
psi4_plugin17 can be called via :py:func:`~driver.energy`. For post-scf plugins.
>>> energy('psi4_plugin17')
"""
lowername = name.lower()
kwargs = p4util.kwargs_lower(kwargs)

# Your plugin's psi4 run sequence goes here
psi4.core.set_local_option('MYPLUGIN', 'PRINT', 1)

# Compute a SCF reference, a wavefunction is return which holds the molecule used, orbitals
# Fock matrices, and more
print('Attention! This SCF may be density-fitted.')
ref_wfn = kwargs.get('ref_wfn', None)
if ref_wfn is None:
ref_wfn = psi4.driver.scf_helper(name, **kwargs)

# Ensure IWL files have been written when not using DF/CD
proc_util.check_iwl_file_from_scf_type(psi4.core.get_option('SCF', 'SCF_TYPE'), ref_wfn)

# Call the Psi4 plugin
# Please note that setting the reference wavefunction in this way is ONLY for plugins
psi4_plugin17_wfn = psi4.core.plugin('psi4_plugin17.so', ref_wfn)

return psi4_plugin17_wfn


# Integration with driver routines
psi4.driver.procedures['energy']['psi4_plugin17'] = run_psi4_plugin17


def exampleFN():
# Your Python code goes here
pass

0 comments on commit 2b77fb8

Please sign in to comment.