/usr/share/doc/psi4/html/quickaddalias.html is in psi4-data 1:0.3-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Defining a Method Alias — Psi4 [] Docs</title>
<link rel="stylesheet" href="_static/psi4.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="./" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/jquery.cookie.js"></script>
<script type="text/javascript" src="_static/toggle_sections.js"></script>
<script type="text/javascript" src="_static/toggle_sidebar.js"></script>
<script type="text/javascript" src="_static/toggle_codeprompt.js"></script>
<link rel="shortcut icon" href="_static/favicon-psi4.ico"/>
<link rel="top" title="Psi4 [] Docs" href="index.html" />
<link rel="up" title="Customization: Adding Simple Extensions" href="customizing.html" />
<link rel="next" title="Creating a Database" href="quickadddatabase.html" />
<link rel="prev" title="Customization: Adding Simple Extensions" href="customizing.html" />
</head>
<body role="document">
<div class="relbar-top">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> </li>
<li class="right" >
<a href="contents.html" title="Table Of Contents"
accesskey="C">toc</a> </li>
<li class="right" >
<a href="quickadddatabase.html" title="Creating a Database"
accesskey="N">next</a> </li>
<li class="right" >
<a href="customizing.html" title="Customization: Adding Simple Extensions"
accesskey="P">previous</a> </li>
<li><a href="index.html">Psi4 []</a> » </li>
<li class="nav-item nav-item-1"><a href="customizing.html" accesskey="U">Customization: Adding Simple Extensions</a> »</li>
</ul>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<a class="reference internal image-reference" href="_images/psi4banner.png"><img alt="Psi4 Project Logo" src="_images/psi4banner.png" style="width: 100%;" /></a>
<div class="admonition note" id="index-0">
<p class="first admonition-title">Note</p>
<p class="last">No recompile of the PSI program is necessary for changes made to
files in <code class="docutils literal"><span class="pre">$PSIDATADIR</span></code> aka <a class="reference external" href="https://github.com/psi4/psi4public/blob/master/lib">psi4/lib</a>, including those described below.</p>
</div>
<div class="section" id="defining-a-method-alias">
<span id="sec-methodalias"></span><h1>Defining a Method Alias<a class="headerlink" href="#defining-a-method-alias" title="Permalink to this headline">ΒΆ</a></h1>
<p>Since quantum chemical methods in <span class="sc">Psi4</span> are accessed through Python functions, and
most important quantities are available as PSI variables, it is straightforward
to create aliases to commonly run calculations or to define hybrid methods. The
<a class="reference external" href="https://github.com/psi4/psi4public/blob/master/lib/python/aliases.py">psi4/lib/python/aliases.py</a> file is intended for editing by the user for
this purpose.</p>
<p>As an example, the MP2.5 method is the average of MP2 and MP3. The latter is
available through the arbitrary order MPn code and returns all lower energies
along with it in PSI variables. The following is basic code that will compute
and return the MP2.5 energy.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">run_mp2_5</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="n">energy</span><span class="p">(</span><span class="s">'mp3'</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="n">e_scf</span> <span class="o">=</span> <span class="n">psi4</span><span class="o">.</span><span class="n">get_variable</span><span class="p">(</span><span class="s">'SCF TOTAL ENERGY'</span><span class="p">)</span>
<span class="n">ce_mp2</span> <span class="o">=</span> <span class="n">psi4</span><span class="o">.</span><span class="n">get_variable</span><span class="p">(</span><span class="s">'MP2 CORRELATION ENERGY'</span><span class="p">)</span>
<span class="n">ce_mp3</span> <span class="o">=</span> <span class="n">psi4</span><span class="o">.</span><span class="n">get_variable</span><span class="p">(</span><span class="s">'MP3 CORRELATION ENERGY'</span><span class="p">)</span>
<span class="n">ce_mp25</span> <span class="o">=</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="p">(</span><span class="n">ce_mp2</span> <span class="o">+</span> <span class="n">ce_mp3</span><span class="p">)</span>
<span class="n">e_mp25</span> <span class="o">=</span> <span class="n">e_scf</span> <span class="o">+</span> <span class="n">ce_mp25</span>
<span class="k">print</span> <span class="s">""" MP2.5 total energy: </span><span class="si">%16.8f</span><span class="se">\n</span><span class="s">"""</span> <span class="o">%</span> <span class="p">(</span><span class="n">e_mp25</span><span class="p">)</span>
<span class="k">print</span> <span class="s">""" MP2.5 correlation energy: </span><span class="si">%16.8f</span><span class="se">\n</span><span class="s">"""</span> <span class="o">%</span> <span class="p">(</span><span class="n">ce_mp25</span><span class="p">)</span>
<span class="k">return</span> <span class="n">e_mp25</span>
</pre></div>
</div>
<p>Compare the above to the method that resides in <a class="reference external" href="https://github.com/psi4/psi4public/blob/master/lib/python/aliases.py">psi4/lib/python/aliases.py</a>.
The rationale for the changes is indicated in the comments below.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">run_mp2_5</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="n">lowername</span> <span class="o">=</span> <span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="c"># handy variable with name keyword in lowercase</span>
<span class="n">kwargs</span> <span class="o">=</span> <span class="n">kwargs_lower</span><span class="p">(</span><span class="n">kwargs</span><span class="p">)</span> <span class="c"># removes case sensitivity in keyword names</span>
<span class="c"># Run detci calculation and collect conventional quantities</span>
<span class="n">energy</span><span class="p">(</span><span class="s">'mp3'</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="n">e_scf</span> <span class="o">=</span> <span class="n">psi4</span><span class="o">.</span><span class="n">get_variable</span><span class="p">(</span><span class="s">'SCF TOTAL ENERGY'</span><span class="p">)</span>
<span class="n">ce_mp2</span> <span class="o">=</span> <span class="n">psi4</span><span class="o">.</span><span class="n">get_variable</span><span class="p">(</span><span class="s">'MP2 CORRELATION ENERGY'</span><span class="p">)</span>
<span class="n">ce_mp3</span> <span class="o">=</span> <span class="n">psi4</span><span class="o">.</span><span class="n">get_variable</span><span class="p">(</span><span class="s">'MP3 CORRELATION ENERGY'</span><span class="p">)</span>
<span class="n">e_mp2</span> <span class="o">=</span> <span class="n">e_scf</span> <span class="o">+</span> <span class="n">ce_mp2</span> <span class="c"># reform mp2 and mp3 total energies for printing</span>
<span class="n">e_mp3</span> <span class="o">=</span> <span class="n">e_scf</span> <span class="o">+</span> <span class="n">ce_mp3</span>
<span class="c"># Compute quantities particular to MP2.5</span>
<span class="n">ce_mp25</span> <span class="o">=</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="p">(</span><span class="n">ce_mp2</span> <span class="o">+</span> <span class="n">ce_mp3</span><span class="p">)</span>
<span class="n">e_mp25</span> <span class="o">=</span> <span class="n">e_scf</span> <span class="o">+</span> <span class="n">ce_mp25</span>
<span class="n">psi4</span><span class="o">.</span><span class="n">set_variable</span><span class="p">(</span><span class="s">'MP2.5 CORRELATION ENERGY'</span><span class="p">,</span> <span class="n">ce_mp25</span><span class="p">)</span> <span class="c"># add new method's important results</span>
<span class="n">psi4</span><span class="o">.</span><span class="n">set_variable</span><span class="p">(</span><span class="s">'MP2.5 TOTAL ENERGY'</span><span class="p">,</span> <span class="n">e_mp25</span><span class="p">)</span> <span class="c"># to PSI variable repository</span>
<span class="n">psi4</span><span class="o">.</span><span class="n">set_variable</span><span class="p">(</span><span class="s">'CURRENT CORRELATION ENERGY'</span><span class="p">,</span> <span class="n">ce_mp25</span><span class="p">)</span>
<span class="n">psi4</span><span class="o">.</span><span class="n">set_variable</span><span class="p">(</span><span class="s">'CURRENT ENERGY'</span><span class="p">,</span> <span class="n">e_mp25</span><span class="p">)</span> <span class="c"># geometry optimizer tracks this variable, permits</span>
<span class="c"># MP2.5 finite difference optimizations</span>
<span class="c"># build string of title banner and print results</span>
<span class="n">banners</span> <span class="o">=</span> <span class="s">''</span>
<span class="n">banners</span> <span class="o">+=</span> <span class="s">"""psi4.print_out('</span><span class="se">\\</span><span class="s">n')</span><span class="se">\n</span><span class="s">"""</span>
<span class="n">banners</span> <span class="o">+=</span> <span class="s">"""banner(' MP2.5 ')</span><span class="se">\n</span><span class="s">"""</span>
<span class="n">banners</span> <span class="o">+=</span> <span class="s">"""psi4.print_out('</span><span class="se">\\</span><span class="s">n')</span><span class="se">\n\n</span><span class="s">"""</span>
<span class="k">exec</span> <span class="n">banners</span>
<span class="n">tables</span> <span class="o">=</span> <span class="s">''</span>
<span class="n">tables</span> <span class="o">+=</span> <span class="s">""" SCF total energy: </span><span class="si">%16.8f</span><span class="se">\n</span><span class="s">"""</span> <span class="o">%</span> <span class="p">(</span><span class="n">e_scf</span><span class="p">)</span>
<span class="n">tables</span> <span class="o">+=</span> <span class="s">""" MP2 total energy: </span><span class="si">%16.8f</span><span class="se">\n</span><span class="s">"""</span> <span class="o">%</span> <span class="p">(</span><span class="n">e_mp2</span><span class="p">)</span>
<span class="n">tables</span> <span class="o">+=</span> <span class="s">""" MP2.5 total energy: </span><span class="si">%16.8f</span><span class="se">\n</span><span class="s">"""</span> <span class="o">%</span> <span class="p">(</span><span class="n">e_mp25</span><span class="p">)</span>
<span class="n">tables</span> <span class="o">+=</span> <span class="s">""" MP3 total energy: </span><span class="si">%16.8f</span><span class="se">\n\n</span><span class="s">"""</span> <span class="o">%</span> <span class="p">(</span><span class="n">e_mp3</span><span class="p">)</span>
<span class="n">tables</span> <span class="o">+=</span> <span class="s">""" MP2 correlation energy: </span><span class="si">%16.8f</span><span class="se">\n</span><span class="s">"""</span> <span class="o">%</span> <span class="p">(</span><span class="n">ce_mp2</span><span class="p">)</span>
<span class="n">tables</span> <span class="o">+=</span> <span class="s">""" MP2.5 correlation energy: </span><span class="si">%16.8f</span><span class="se">\n</span><span class="s">"""</span> <span class="o">%</span> <span class="p">(</span><span class="n">ce_mp25</span><span class="p">)</span>
<span class="n">tables</span> <span class="o">+=</span> <span class="s">""" MP3 correlation energy: </span><span class="si">%16.8f</span><span class="se">\n</span><span class="s">"""</span> <span class="o">%</span> <span class="p">(</span><span class="n">ce_mp3</span><span class="p">)</span>
<span class="n">psi4</span><span class="o">.</span><span class="n">print_out</span><span class="p">(</span><span class="n">tables</span><span class="p">)</span> <span class="c"># prints nice header and table of all involved quantities to output file</span>
<span class="k">return</span> <span class="n">e_mp25</span>
</pre></div>
</div>
<p>One final step is necessary. At the end of the <code class="docutils literal"><span class="pre">aliases.py</span></code> file, add
the following line.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">procedures</span><span class="p">[</span><span class="s">'energy'</span><span class="p">][</span><span class="s">'mp2.5'</span><span class="p">]</span> <span class="o">=</span> <span class="n">run_mp2_5</span>
</pre></div>
</div>
<p>This permits the newly defined MP2.5 method to be called in the input file
with the following command.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">energy</span><span class="p">(</span><span class="s">'mp2.5'</span><span class="p">)</span>
</pre></div>
</div>
<style type="text/css"><!--
.green {color: red;}
.sc {font-variant: small-caps;}
--></style></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="customizing.html"
title="previous chapter">Customization: Adding Simple Extensions</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="quickadddatabase.html"
title="next chapter">Creating a Database</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/quickaddalias.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="relbar-bottom">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> </li>
<li class="right" >
<a href="contents.html" title="Table Of Contents"
>toc</a> </li>
<li class="right" >
<a href="quickadddatabase.html" title="Creating a Database"
>next</a> </li>
<li class="right" >
<a href="customizing.html" title="Customization: Adding Simple Extensions"
>previous</a> </li>
<li><a href="index.html">Psi4 []</a> » </li>
<li class="nav-item nav-item-1"><a href="customizing.html" >Customization: Adding Simple Extensions</a> »</li>
</ul>
</div>
</div>
<div class="footer" role="contentinfo">
© Copyright 2015, The Psi4 Project.
Last updated on Tuesday, 12 January 2016 03:10PM.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.3.
</div>
<!-- cloud_sptheme 1.3 -->
</body>
</html>
|