<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://chemwiki.ch.ic.ac.uk/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rf614</id>
	<title>ChemWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://chemwiki.ch.ic.ac.uk/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rf614"/>
	<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/wiki/Special:Contributions/Rf614"/>
	<updated>2026-04-11T17:24:10Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=696082</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=696082"/>
		<updated>2018-04-03T12:49:27Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Running The Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Links to files==&lt;br /&gt;
Zip Archive: [[Media:OTRSH_hpc_ver_V2_Mar2018.zip]]&lt;br /&gt;
&lt;br /&gt;
==What&#039;s an OTRSH Functional?==&lt;br /&gt;
It is an optimally tuned range separated hybrid functional (OTRSH). This is a class of functionals that are useful for ccalculating electronic properties such as UV-Vis spectra (especially if charge-transfer excitations are important) or photoelectron spectra. Before talking about OTRSH functionals, it is useful to first talk about how standard range separated hybrid functionals work, and why they were created.&lt;br /&gt;
&lt;br /&gt;
===The Problem===&lt;br /&gt;
Standard DFT has problems describing long range interactions, due to the form of the exchange energy in standard functionals. Actual (exact) Exchange energy scales with distance as &amp;lt;math&amp;gt;\frac{1}{r_{12}}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; is the distance between two electrons. However, standard pure DFT exchange functionals depend directly on the electron density, which decays exponentially with distance from an atomic center (i.e. DFT exchange decays faster than actual exchange). This means that standard DFT functionals are poor at describing long-range interactions (charge transfer excitations in DFT is an example). Range seperated hybrid functionals try to fix this by using Hartree-Fock exchange energy (which is exact) at large distances (long-range) while keeping DFT exchange energy at short range.&lt;br /&gt;
&lt;br /&gt;
===One Solution - Normal Range Separated Hybrids===&lt;br /&gt;
A range separated hydrbrid functional divides the exchange energy into two terms - short range exchange (&amp;lt;math&amp;gt; E_{X}^{SR}&amp;lt;/math&amp;gt;) and long range exchange (&amp;lt;math&amp;gt; E_{X}^{LR} &amp;lt;/math&amp;gt;). The exchange energy at any one distance is a weighted combination of short-range and long range exchange, and can essentially be described with three variables; &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (See picture below). &lt;br /&gt;
&lt;br /&gt;
[[File:Frac_HF_Exchange_mu.png|200px|center|Description of the Exchange energy at varying distances in a range-separated hybrid functtional]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The equations for total, short range (DFT) and long-range (HF) exchange are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{Total} = E_{X}^{SR} + E_{X}^{LR}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{SR} = [1-(\alpha + \beta{}.\text{erf}(\mu r_{12})] E_{X}^{DFT}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{LR} = [\alpha + \beta{}.\text{erf}(\mu{}r_{12})] E_{X}^{HF}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where erf is the error function. &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; represents the amount of HF exchange at short range. For example, &amp;lt;math&amp;gt;\alpha=0.2&amp;lt;/math&amp;gt; would mean 20% HF exchange was used at &amp;lt;math&amp;gt;r_{12}=0&amp;lt;/math&amp;gt;. &amp;lt;math&amp;gt;\alpha + \beta &amp;lt;/math&amp;gt; represents the amount of HF exchange at long range (i.e as &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; approaches infinity). A value of &amp;lt;math&amp;gt;\alpha + \beta =1&amp;lt;/math&amp;gt; means that 100% HF exchange is employed at long range, which should give the correct long-range behavior for the exchange energy. &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the range seperation parameter, its value determines how quickly we change from short-range to long-range exchange expresssions. The higher &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is, the faster (shorter distances) we start using the long-range exchange energy expression.&lt;br /&gt;
&lt;br /&gt;
A problem with range separated hybrids is in picking the correct value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (i.e when should we stop using DFT exchange?). This is often determined empirically by varying &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; for a test data set, and seeing which &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value leads to a functional that best reproduces an experimental property (e.g. atomic ionisation energies). This has the same problem as any kind of empirical fitting - its not clear how well the functional will work outside the test set of molecules/properties. Also this empirical tuning of parameters can lead to unphysical values. For example, CAM-B3LYP uses &amp;lt;math&amp;gt;\alpha + \beta =0.65&amp;lt;/math&amp;gt;, meaning it definitely has the wrong long-range behavior.&lt;br /&gt;
&lt;br /&gt;
===OTRSH Functionals===&lt;br /&gt;
&lt;br /&gt;
OTRSH functionals provide a non-empirical method for choosing &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is &amp;quot;tuned&amp;quot; on a per-calculation basis. The &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value is chosen so that the calculated ionisation energy matches the negative of the HOMO energy, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = -E_{HOMO}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = E_{N-1} - E_{N}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;E_{N-1}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_{N}&amp;lt;/math&amp;gt; represent the energy of the N-1 and N electron system (both in the N electron system geometry). Note that all values in the equations above can be obtained from two single-point energy calculations. Also note that &amp;lt;math&amp;gt;IP_{Calc} = -E_{HOMO}&amp;lt;/math&amp;gt; is true for the exact (unknown) KS-DFT functional, hence it is a sensible thing to try to reproduce in a functional.&lt;br /&gt;
&lt;br /&gt;
To summarise an OTRSH functional is one whereby &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is chosen to minimise &amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} + E_{HOMO}&amp;lt;/math&amp;gt;, hence the &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value will be different for every calculation you carry out. Sometimes the IP and HOMO energy of the N-1 electron system are also used to tune &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, but unfortunately thats not possible the code on this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide (Using the test file)===&lt;br /&gt;
Once you download the .zip archive, copy the files to somewhere on your hpc path [Note: make sure you dont miss the .rng_OTRSH_V2 file]. Personally i use &amp;quot;/home/rf614/bin&amp;quot; as the location. To use the gf_OTRSH_V2 function straight away you&#039;ll need to put them in $HOME/bin. &amp;quot;echo $HOME&amp;quot; while on the hpc to find where your home directory is if your not sure.&lt;br /&gt;
&lt;br /&gt;
Move the test file (&#039;H2O_SPE_6311plgdp_GP.com&#039;) to whereever you like in your work directory, and navigate to this folder. Then type either of the following commands (assuming you put the scripts in ~/bin):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
qsub -v in=H2O_SPE_6311plgdp_GP -N test ~/bin/.rng_OTRSH_V2&lt;br /&gt;
gf_OTRSH_V2 H2O_SPE_6311plgdp_GP.com&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you saved the files somewhere else then simply modify &amp;quot;~/bin/.rng_OTRSH&amp;quot; to whatevers appropriate for the top command. For details on how the gf command works see this wiki [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/pimpQSUB link].&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide - The output files===&lt;br /&gt;
Assuming you ran the job above you will now have a loada output files in your current directory, i.e.:&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_gsstate_mu_opt.*&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_ionstate_mu_opt.*&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_OTRSH.out&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_OTRSH.out&#039;&#039;&#039; file is essentially a progress file for how the tuning process is going. Once the calculation is over its main purpose is really to keep track of the options you used to create the OTRSH functional. Its a comma delimited file, and the headings should be pretty self-explanatory (at least they will be if you read the above section on &amp;quot;What is an OTRSH&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_gsstate_mu_opt&#039;&#039;&#039;* files are for single energy calculations using the OTRSH functional tuned for this particular system. If your goal was to calculate ground state properties with an OTRSH then these files might be all you need. If you want to do something other than a single-point energy calculation, then just add the relevant keywords (e.g TD) to the  H2O_SPE_6311plgdp_GP_gsstate_mu_opt.com file - this file contains all the keywords needed to define the OTRSH functional.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_ionstate_mu_opt&#039;&#039;&#039;* files are the single point energy calculations (using the OTRSH) for the ionised system. You probably have no need for these.&lt;br /&gt;
&lt;br /&gt;
You will also have a new folder named &#039;&#039;&#039;temp_files_H2O_SPE_6311plgdp_GP&#039;&#039;&#039;. At every tested value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, the .log files for the ground and ionised state are written to this folder. The purpose of this folder is to check nothings going wrong during the calculation. If something stops the code extracting scf energies for each &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value, then it might just loop infinitely (or at least for a loooooong time). The code &#039;&#039;&#039;SHOULD&#039;&#039;&#039; catch these sorts of errors and kill the job, but if it runs a long time without any change in the *.out file then make sure the *.log files in this folder are ok. The secondary purpose of this folder is therefore to tell you WHY your job got killed, if it got killed (an error message should be given in the .out file as well but....)&lt;br /&gt;
&lt;br /&gt;
===Quick Note on Creating Input Files===&lt;br /&gt;
&lt;br /&gt;
If you want to run the code, with default options, on your own systems then theres not much to say. Simply prepare a normal &#039;&#039;&#039;SINGLE POINT ENERGY&#039;&#039;&#039; *.com file for your system, but remove the functional from the input line. Also dont use the &amp;quot;#p&amp;quot; command for excess printing - this will break the OTRSH code (sorry, the code essentially uses the # for a search + replace to insert a functional at each step of the tuning process). For example, this input line is fine(and used in the example file):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# 6-311+g(d,p) geom=connectivity int=ultrafine scf=conver=9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you use a &#039;&#039;&#039;single point energy calculation input file&#039;&#039;&#039;, using a keyword like &amp;quot;freq&amp;quot; wont throw any errors, but you&#039;ll be waiting a really long time for your job to finish.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Understanding (And Modifying) The Default Options===&lt;br /&gt;
&lt;br /&gt;
The easily changeable variables in this code are stored in the .rng_OTRSH_V2 file. They are (in order of &amp;quot;likelyhood of needing altering&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
es_mult=2&lt;br /&gt;
alpha_val=0&lt;br /&gt;
beta_val=0&lt;br /&gt;
mu_lower=0.1&lt;br /&gt;
mu_upper=0.2&lt;br /&gt;
max_step=0.03&lt;br /&gt;
min_step=0.001&lt;br /&gt;
xc_funct=&amp;quot;LC-wPBE&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Its likely you&#039;ll only ever need/want to change the &#039;&#039;&#039;es_mult&#039;&#039;&#039; here. This is the multiplicity of the ionised state, and is obviously equal to 2 if you have a closed shell system. If you use this code on an open shell system you need to set es_mult to the appropriate value for the ionised state. Personally i create seperate .rng files for each value of multiplicity i use, to save me editing the .rng_OTRSH file too often.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;alpha_val&#039;&#039;&#039; corresponds to the fraction HF exchange at short range. &#039;&#039;&#039;Setting this to zero means use the default value for the functional&#039;&#039;&#039;.Its plausible that raising this to say alpha_val=0.2 might improve your results in some cases, so it might be worth trying the functional with two different alpha values if your trying to match an experimental spectrum or have something else you can validate with.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;beta_val&#039;&#039;&#039; - as stated above &amp;quot;alpha_val + beta_val&amp;quot; corresponds to the fraction HF exchange at long range. &#039;&#039;&#039;Setting this to zero means use the default value for the functional&#039;&#039;&#039;. If alpha_val and beta_val are both zero, then only the &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value should differ between the base functional and the OTRSH&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;mu_lower&#039;&#039;&#039; and &#039;&#039;&#039;mu_upper&#039;&#039;&#039; control the initial range of &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; values to try out. If you have a good idea what your final &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; will be, then settings mu_lower and mu_upper to nearby values should speed up the optimisation process. However, there is &#039;&#039;&#039;NO NEED&#039;&#039;&#039; for the final mu_val to be between these initial search values, it will just take longer if its far away from this range.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;max_step&#039;&#039;&#039; and &#039;&#039;&#039;min_step&#039;&#039;&#039; correspond to the maximum and minimum change in &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;  between optimisation steps. Note that i think the minimum possible min_step=0.0001, so dont set it lower than that or it could cause serious problems (it&#039;ll lead to a gradient of zero between two mu values, i have no idea how the optimiser will react to that but it wont be good). Theres probably &#039;&#039;&#039;NEVER&#039;&#039;&#039; a need to mess with these values. If the optimiser isnt efficient enough, changing these values wont help much. Writing a better optimiser (the current ones pretty terrible by the way,but it works so.....) would probably be easier than working out the best values for these numbers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;LC-wPBE&#039;&#039;&#039; corresponds to the underlying functional to use. The functional this code generates is essentially LC-wPBE with a modified &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value. The underlying DFT exchange/ DFT correlation functionals are the same as those used in LC-wPBE. The underlying functional needs to be a range separated one (i think). If you change it, make sure you can reproduce the base functional with the code (e.g. run the code, change mu to that of the base functional and see if the results are the same).&lt;br /&gt;
&lt;br /&gt;
Finally, the convergence criteria for the OTRSH (the IP_HOMO - E_HOMO value) is set to 0.01 eV by default, and controlled by the IP_conver_thres variable in optimiser.py. I guess its possible you may want to relax that criteria in certain circumstances (obviously it would speed up the optimisation and lower the accuracy).&lt;br /&gt;
&lt;br /&gt;
==Further Reading/Links to relevant Papers==&lt;br /&gt;
CAM-B3LYP paper - doi:&#039;&#039;&#039;10.1016/j.cplett.2004.06.011&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Early (first?) OTRSH paper - doi:&#039;&#039;&#039;10.1021/ja8087482&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Review on using OTRSH functional to calculate bandgaps (2012) - doi:&#039;&#039;&#039;10.1021/ct2009363&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use of OTRSH functionals for Ground state properties (2013) - doi:&#039;&#039;&#039;10.1063/1.4807325&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=696081</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=696081"/>
		<updated>2018-04-03T12:41:14Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Links to files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Links to files==&lt;br /&gt;
Zip Archive: [[Media:OTRSH_hpc_ver_V2_Mar2018.zip]]&lt;br /&gt;
&lt;br /&gt;
==What&#039;s an OTRSH Functional?==&lt;br /&gt;
It is an optimally tuned range separated hybrid functional (OTRSH). This is a class of functionals that are useful for ccalculating electronic properties such as UV-Vis spectra (especially if charge-transfer excitations are important) or photoelectron spectra. Before talking about OTRSH functionals, it is useful to first talk about how standard range separated hybrid functionals work, and why they were created.&lt;br /&gt;
&lt;br /&gt;
===The Problem===&lt;br /&gt;
Standard DFT has problems describing long range interactions, due to the form of the exchange energy in standard functionals. Actual (exact) Exchange energy scales with distance as &amp;lt;math&amp;gt;\frac{1}{r_{12}}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; is the distance between two electrons. However, standard pure DFT exchange functionals depend directly on the electron density, which decays exponentially with distance from an atomic center (i.e. DFT exchange decays faster than actual exchange). This means that standard DFT functionals are poor at describing long-range interactions (charge transfer excitations in DFT is an example). Range seperated hybrid functionals try to fix this by using Hartree-Fock exchange energy (which is exact) at large distances (long-range) while keeping DFT exchange energy at short range.&lt;br /&gt;
&lt;br /&gt;
===One Solution - Normal Range Separated Hybrids===&lt;br /&gt;
A range separated hydrbrid functional divides the exchange energy into two terms - short range exchange (&amp;lt;math&amp;gt; E_{X}^{SR}&amp;lt;/math&amp;gt;) and long range exchange (&amp;lt;math&amp;gt; E_{X}^{LR} &amp;lt;/math&amp;gt;). The exchange energy at any one distance is a weighted combination of short-range and long range exchange, and can essentially be described with three variables; &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (See picture below). &lt;br /&gt;
&lt;br /&gt;
[[File:Frac_HF_Exchange_mu.png|200px|center|Description of the Exchange energy at varying distances in a range-separated hybrid functtional]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The equations for total, short range (DFT) and long-range (HF) exchange are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{Total} = E_{X}^{SR} + E_{X}^{LR}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{SR} = [1-(\alpha + \beta{}.\text{erf}(\mu r_{12})] E_{X}^{DFT}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{LR} = [\alpha + \beta{}.\text{erf}(\mu{}r_{12})] E_{X}^{HF}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where erf is the error function. &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; represents the amount of HF exchange at short range. For example, &amp;lt;math&amp;gt;\alpha=0.2&amp;lt;/math&amp;gt; would mean 20% HF exchange was used at &amp;lt;math&amp;gt;r_{12}=0&amp;lt;/math&amp;gt;. &amp;lt;math&amp;gt;\alpha + \beta &amp;lt;/math&amp;gt; represents the amount of HF exchange at long range (i.e as &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; approaches infinity). A value of &amp;lt;math&amp;gt;\alpha + \beta =1&amp;lt;/math&amp;gt; means that 100% HF exchange is employed at long range, which should give the correct long-range behavior for the exchange energy. &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the range seperation parameter, its value determines how quickly we change from short-range to long-range exchange expresssions. The higher &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is, the faster (shorter distances) we start using the long-range exchange energy expression.&lt;br /&gt;
&lt;br /&gt;
A problem with range separated hybrids is in picking the correct value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (i.e when should we stop using DFT exchange?). This is often determined empirically by varying &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; for a test data set, and seeing which &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value leads to a functional that best reproduces an experimental property (e.g. atomic ionisation energies). This has the same problem as any kind of empirical fitting - its not clear how well the functional will work outside the test set of molecules/properties. Also this empirical tuning of parameters can lead to unphysical values. For example, CAM-B3LYP uses &amp;lt;math&amp;gt;\alpha + \beta =0.65&amp;lt;/math&amp;gt;, meaning it definitely has the wrong long-range behavior.&lt;br /&gt;
&lt;br /&gt;
===OTRSH Functionals===&lt;br /&gt;
&lt;br /&gt;
OTRSH functionals provide a non-empirical method for choosing &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is &amp;quot;tuned&amp;quot; on a per-calculation basis. The &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value is chosen so that the calculated ionisation energy matches the negative of the HOMO energy, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = -E_{HOMO}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = E_{N-1} - E_{N}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;E_{N-1}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_{N}&amp;lt;/math&amp;gt; represent the energy of the N-1 and N electron system (both in the N electron system geometry). Note that all values in the equations above can be obtained from two single-point energy calculations. Also note that &amp;lt;math&amp;gt;IP_{Calc} = -E_{HOMO}&amp;lt;/math&amp;gt; is true for the exact (unknown) KS-DFT functional, hence it is a sensible thing to try to reproduce in a functional.&lt;br /&gt;
&lt;br /&gt;
To summarise an OTRSH functional is one whereby &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is chosen to minimise &amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} + E_{HOMO}&amp;lt;/math&amp;gt;, hence the &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value will be different for every calculation you carry out. Sometimes the IP and HOMO energy of the N-1 electron system are also used to tune &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, but unfortunately thats not possible the code on this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide (Using the test file)===&lt;br /&gt;
Once you download the .zip archive, copy the files to somewhere on your hpc path [Note: make sure you dont miss the .rng_OTRSH file]. Personally i use &amp;quot;/home/rf614/bin&amp;quot; as the location. To use the gf_OTRSH function straight away you&#039;ll need to put them in $HOME/bin. &amp;quot;echo $HOME&amp;quot; while on the hpc to find where your home directory is if your not sure.&lt;br /&gt;
&lt;br /&gt;
Move the test file (&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin.com&#039;) to whereever you like in your work directory, and navigate to this folder. Then type either of the following commands (assuming you put the scripts in ~/bin):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
qsub -v in=H2O_SPE_6311plgdp_GP_B3LYP_builtin -N test ~/bin/.rng_OTRSH&lt;br /&gt;
gf_OTRSH H2O_SPE_6311plgdp_GP_B3LYP_builtin.com&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you saved the files somewhere else then simply modify &amp;quot;~/bin/.rng_OTRSH&amp;quot; to whatevers appropriate for the top command. For details on how the gf command works see this wiki [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/pimpQSUB link].&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide - The output files===&lt;br /&gt;
Assuming you ran the job above you will now have a loada output files in your current directory, i.e.:&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt.*&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_ionstate_mu_opt.*&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_OTRSH.out&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_OTRSH.out&#039;&#039;&#039; file is essentially a progress file for how the tuning process is going. Once the calculation is over its main purpose is really to keep track of the options you used to create the OTRSH functional. Its a comma delimited file, and the headings should be pretty self-explanatory (at least they will be if you read the above section on &amp;quot;What is an OTRSH&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt&#039;&#039;&#039;* files are for single energy calculations using the OTRSH functional tuned for this particular system. If your goal was to calculate ground state properties with an OTRSH then these files might be all you need. If you want to do something other than a single-point energy calculation, then just add the relevant keywords (e.g TD) to the  H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt.com file - this file contains all the keywords needed to define the OTRSH functional.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_ionstate_mu_opt&#039;&#039;&#039;* files are the single point energy calculations (using the OTRSH) for the ionised system. You probably have no need for these.&lt;br /&gt;
&lt;br /&gt;
You will also have a new folder named &#039;&#039;&#039;temp_files_H2O_SPE_6311plgdp_GP_B3LYP_builtin&#039;&#039;&#039;. At every tested value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, the .log files for the ground and ionised state are written to this folder. The purpose of this folder is to check nothings going wrong during the calculation. If something stops the code extracting scf energies for each &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value, then it might just loop infinitely (or at least for a loooooong time). The code &#039;&#039;&#039;SHOULD&#039;&#039;&#039; catch these sorts of errors and kill the job, but if it runs a long time without any change in the *.out file then make sure the *.log files in this folder are ok. The secondary purpose of this folder is therefore to tell you WHY your job got killed, if it got killed (an error message should be given in the .out file as well but....)&lt;br /&gt;
&lt;br /&gt;
===Quick Note on Creating Input Files===&lt;br /&gt;
&lt;br /&gt;
If you want to run the code, with default options, on your own systems then theres not much to say. Simply prepare a normal &#039;&#039;&#039;SINGLE POINT ENERGY&#039;&#039;&#039; *.com file for your system, but remove the functional from the input line. Also dont use the &amp;quot;#p&amp;quot; command for excess printing - this will break the OTRSH code (sorry, the code essentially uses the # for a search + replace to insert a functional at each step of the tuning process). For example, this input line is fine(and used in the example file):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# 6-311+g(d,p) geom=connectivity int=ultrafine scf=conver=9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you use a &#039;&#039;&#039;single point energy calculation input file&#039;&#039;&#039;, using a keyword like &amp;quot;freq&amp;quot; wont throw any errors, but you&#039;ll be waiting a really long time for your job to finish.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Understanding (And Modifying) The Default Options===&lt;br /&gt;
&lt;br /&gt;
The easily changeable variables in this code are stored in the .rng_OTRSH file. They are (in order of &amp;quot;likelyhood of needing altering&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
es_mult=2&lt;br /&gt;
alpha_val=0&lt;br /&gt;
beta_val=1&lt;br /&gt;
mu_lower=0.1&lt;br /&gt;
mu_upper=0.2&lt;br /&gt;
max_step=0.03&lt;br /&gt;
min_step=0.001&lt;br /&gt;
P5_val=0.81&lt;br /&gt;
xc_funct=&amp;quot;CAM-B3LYP&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Its likely you&#039;ll only ever need/want to change the &#039;&#039;&#039;es_mult&#039;&#039;&#039; here. This is the multiplicity of the ionised state, and is obviously equal to 2 if you have a closed shell system. If you use this code on an open shell system you need to set es_mult to the appropriate value for the ionised state. Personally i create seperate .rng files for each value of multiplicity i use, to save me editing the .rng_OTRSH file too often.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;alpha_val&#039;&#039;&#039; corresponds to the fraction HF exchange at short range. Its plausible that raising this to say alpha_val=0.2 might improve your results in some cases, so it might be worth trying the functional with two different alpha values if your trying to match an experimental spectrum or have something else you can validate with. I personally set it to zero since i think its the least arbitrary value it can be.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;beta_val&#039;&#039;&#039; - as stated above &amp;quot;alpha_val + beta_val&amp;quot; corresponds to the fraction HF exchange at long range. So if you &#039;&#039;&#039;change alpha_val, you need to change beta_val too&#039;&#039;&#039;, otherwise you may end up with &amp;gt;100% HF exchange at long range. I&#039;d advise you keep alpha_val + beta_val =1.0, since that should give you the correct long-range potential.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;mu_lower&#039;&#039;&#039; and &#039;&#039;&#039;mu_upper&#039;&#039;&#039; control the initial range of &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; values to try out. If you have a good idea what your final &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; will be, then settings mu_lower and mu_upper to nearby values should speed up the optimisation process. However, there is &#039;&#039;&#039;NO NEED&#039;&#039;&#039; for the final mu_val to be between these initial search values, it will just take longer if its far away from this range.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;max_step&#039;&#039;&#039; and &#039;&#039;&#039;min_step&#039;&#039;&#039; correspond to the maximum and minimum change in &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;  between optimisation steps. Note that i think the minimum possible min_step=0.0001, so dont set it lower than that or it could cause serious problems (it&#039;ll lead to a gradient of zero between two mu values, i have no idea how the optimiser will react to that but it wont be good). Theres probably &#039;&#039;&#039;NEVER&#039;&#039;&#039; a need to mess with these values. If the optimiser isnt efficient enough, changing these values wont help much. Writing a better optimiser (the current ones pretty terrible by the way,but it works so.....) would probably be easier than working out the best values for these numbers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;P5_val&#039;&#039;&#039; corresponds to a parameter in the DFT functional controlling the amount of non-local correlation to use. Its the same P5 parameter that appears on the gaussian 09/16 guide to &amp;quot;user-defined DFT functionals&amp;quot;. Just leave it alone unless you REALLY know what your doing.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;CAM-B3LYP&#039;&#039;&#039; corresponds to the underlying functional to use. The functional this code generates is essentially CAM-B3LYP with modified &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;,&amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; parameters. The underlying DFT exchange/ DFT correlation functionals are the same as those used in CAM-B3LYP. I&#039;ve never tried modifying this, it would be a massive pain. If you want to try then i suggest you use a range-separated functional as your base and start by passing the relevant arguments to the &amp;quot;init_OTRSH.py&amp;quot; functional, and seeing if you can replicate the original functional (e.g if you want to use wB97XD as your base functional, try and reproduce reslts of that functional by passing relevant options to init_OTRSH.py.&lt;br /&gt;
&lt;br /&gt;
Finally, the convergence criteria for the OTRSH (the IP_HOMO - E_HOMO value) is set to 0.01 eV by default, and controlled by the IP_conver_thres variable in optimiser.py. I guess its possible you may want to relax that criteria in certain circumstances (obviously it would speed up the optimisation and lower the accuracy).&lt;br /&gt;
&lt;br /&gt;
==Further Reading/Links to relevant Papers==&lt;br /&gt;
CAM-B3LYP paper - doi:&#039;&#039;&#039;10.1016/j.cplett.2004.06.011&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Early (first?) OTRSH paper - doi:&#039;&#039;&#039;10.1021/ja8087482&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Review on using OTRSH functional to calculate bandgaps (2012) - doi:&#039;&#039;&#039;10.1021/ct2009363&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use of OTRSH functionals for Ground state properties (2013) - doi:&#039;&#039;&#039;10.1063/1.4807325&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:OTRSH_hpc_ver_V2_Mar2018.zip&amp;diff=696080</id>
		<title>File:OTRSH hpc ver V2 Mar2018.zip</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:OTRSH_hpc_ver_V2_Mar2018.zip&amp;diff=696080"/>
		<updated>2018-04-03T12:39:18Z</updated>

		<summary type="html">&lt;p&gt;Rf614: Script to generate OTRSH functionals&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Script to generate OTRSH functionals&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630606</id>
		<title>Mod:Hunt Research Group/Some G09 Parsers</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630606"/>
		<updated>2017-07-29T16:08:21Z</updated>

		<summary type="html">&lt;p&gt;Rf614: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This page has some parsers i&#039;ve made for some different types of gaussian calculation. Meaning they are scripts which essentially pull important information from output files and store them in convenient objects. They can be useful for using as part of other scripts, for example the TDDFT matlab class is a really good starting point for writing code to generate UV-Vis spectra from gaussian 09 TD-DFT calculations. If you have no interest in coding then these parsers are totally useless to you.&lt;br /&gt;
&lt;br /&gt;
Also since this is a page about parsers, i should probably mention cclib - this provides python parsers for log files from a range of computational chemistry software (including gaussian 09)[link: https://github.com/cclib/cclib]&lt;br /&gt;
&lt;br /&gt;
== Links To Files ==&lt;br /&gt;
&lt;br /&gt;
python molecule class parser [[Media:Mol Class Parser Jul2017 V0pt5.zip]]&lt;br /&gt;
&lt;br /&gt;
matlab NBO file parser [[Media:G09 NBO Parser Matlab.zip]]&lt;br /&gt;
&lt;br /&gt;
matlab AIM .sumviz file parser [[Media:AIM sumviz parser matlab.zip]]&lt;br /&gt;
&lt;br /&gt;
matlab TDDFT file parser [[Media:TDDFT Classes.zip]]&lt;br /&gt;
&lt;br /&gt;
== Rough description of Matlab Parsers ==&lt;br /&gt;
&lt;br /&gt;
All the matlab parsers are called in the same way, by calling the relevant function with a full filepath as the argument. Assuming you set the variable &amp;quot;fname&amp;quot; to the full path of the desired file:&lt;br /&gt;
&lt;br /&gt;
NBO parser: &amp;quot;NBO_test = NBO_E2_Class_V2(fname) &amp;quot;&lt;br /&gt;
&lt;br /&gt;
AIM parser: &amp;quot;AIM_test = Sumviz_File_Obj_V2(fname)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
TDDFT parser: &amp;quot;TDDFT_test = TDDFT_Output_Class_V1_2014a(fname)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Both NBO and AIM parsers also have static methods which allow you to create an object/instance for each relevant file in a given folder (these objects get stored in an array). All the parsers have various (possibly) useful methods which are documented within the code. For example, the AIM parser has a method which returns the sum of bond critical point densities for all BCPS between two user defined fragments. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rough description of molecule_class (Python parser) ==&lt;br /&gt;
&lt;br /&gt;
This code is written in python3.5 (3.4 should work, not sure about anything earlier) and uses numpy. It pulls some basic information from *.com/*.log/*.fchk files, and is meant to be used on frequency files with a single structure (not sure if there are any issues with using it on an optimisation, ive never tried). The information it extracts depends on the type of file it reads, but in all cases a geometry is extracted. Documentation is mainly within the code, though some of its capabilities can be seen by testing the simple scripts i bundled with it (see below).&lt;br /&gt;
&lt;br /&gt;
As well as Molecule_Class_V0pt5 the zip folder contains a couple of simple scripts utilising the parser, and some example files. To test the simple scripts make sure they have executable permissions (&amp;quot;chmod u+x filename&amp;quot;), are in the same folder as Molecule_Class_V0pt5 and are in your system path (&amp;quot;PATH=$PATH:&amp;lt;dir&amp;gt;&amp;quot;, replace the word &amp;lt;dir&amp;gt; with the path for the folder containing the scripts.&lt;br /&gt;
&lt;br /&gt;
Then navigate to the example_files directory. In terminal type:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get_rel_energies.py .&amp;quot;&lt;br /&gt;
&lt;br /&gt;
A file called &amp;quot;Rel_Energies.txt&amp;quot; will have been written in the current folder. This is a comma-delimited file with conformer names + there relative energies (in kJ mol).&lt;br /&gt;
&lt;br /&gt;
To run the second script type:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Min_Distances_Two_Frags.py . 1-3 4-18&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The first argument is the folder to look for .log files. The second two arguments define sub-fragments for your geometry. &amp;quot;1-3&amp;quot; corresponds to atoms 1,2,3. The script (with these arguments) finds the shortest distance between the two fragments &amp;quot;atoms 1-3&amp;quot; and &amp;quot;atoms 4-18&amp;quot;, and outputs the distance in angstroms and also the identity of atoms involved.&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630605</id>
		<title>Mod:Hunt Research Group/Some G09 Parsers</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630605"/>
		<updated>2017-07-29T16:00:04Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Links To Files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This page has some parsers i&#039;ve made for some different types of gaussian calculation. Meaning they are scripts which essentially pull important information from output files and store them in convenient objects. They can be useful for using as part of other scripts, for example the TDDFT matlab class is a really good starting point for writing code to generate UV-Vis spectra from gaussian 09 TD-DFT calculations. If you have no interest in coding then these parsers are totally useless to you.&lt;br /&gt;
&lt;br /&gt;
Also since this is a page about parsers, i should probably mention cclib - this provides python parsers for log files from a range of computational chemistry software (including gaussian 09)[link: https://github.com/cclib/cclib]&lt;br /&gt;
&lt;br /&gt;
== Links To Files ==&lt;br /&gt;
&lt;br /&gt;
python molecule class parser [[Media:Mol Class Parser Jul2017 V0pt5.zip]]&lt;br /&gt;
&lt;br /&gt;
matlab NBO file parser [[Media:G09 NBO Parser Matlab.zip]]&lt;br /&gt;
&lt;br /&gt;
matlab AIM .sumviz file parser [[Media:AIM sumviz parser matlab.zip]]&lt;br /&gt;
&lt;br /&gt;
matlab TDDFT file parser [[Media:TDDFT Classes.zip]]&lt;br /&gt;
&lt;br /&gt;
== Rough description of Matlab Parsers ==&lt;br /&gt;
&lt;br /&gt;
== Rough description of molecule_class (Python parser) ==&lt;br /&gt;
&lt;br /&gt;
This code is written in python3.5 (3.4 should work, not sure about anything earlier) and uses numpy. It pulls some basic information from *.com/*.log/*.fchk files, and is meant to be used on frequency files with a single structure (not sure if there are any issues with using it on an optimisation, ive never tried). The information it extracts depends on the type of file it reads, but in all cases a geometry is extracted. Documentation is mainly within the code, though some of its capabilities can be seen by testing the simple scripts i bundled with it (see below).&lt;br /&gt;
&lt;br /&gt;
As well as Molecule_Class_V0pt5 the zip folder contains a couple of simple scripts utilising the parser, and some example files. To test the simple scripts make sure they have executable permissions (&amp;quot;chmod u+x filename&amp;quot;), are in the same folder as Molecule_Class_V0pt5 and are in your system path (&amp;quot;PATH=$PATH:&amp;lt;dir&amp;gt;&amp;quot;, replace the word &amp;lt;dir&amp;gt; with the path for the folder containing the scripts.&lt;br /&gt;
&lt;br /&gt;
Then navigate to the example_files directory. In terminal type:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get_rel_energies.py .&amp;quot;&lt;br /&gt;
&lt;br /&gt;
A file called &amp;quot;Rel_Energies.txt&amp;quot; will have been written in the current folder. This is a comma-delimited file with conformer names + there relative energies (in kJ mol).&lt;br /&gt;
&lt;br /&gt;
To run the second script type:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Min_Distances_Two_Frags.py . 1-3 4-18&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The first argument is the folder to look for .log files. The second two arguments define sub-fragments for your geometry. &amp;quot;1-3&amp;quot; corresponds to atoms 1,2,3. The script (with these arguments) finds the shortest distance between the two fragments &amp;quot;atoms 1-3&amp;quot; and &amp;quot;atoms 4-18&amp;quot;, and outputs the distance in angstroms and also the identity of atoms involved.&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630604</id>
		<title>Mod:Hunt Research Group/Some G09 Parsers</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630604"/>
		<updated>2017-07-29T15:59:43Z</updated>

		<summary type="html">&lt;p&gt;Rf614: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This page has some parsers i&#039;ve made for some different types of gaussian calculation. Meaning they are scripts which essentially pull important information from output files and store them in convenient objects. They can be useful for using as part of other scripts, for example the TDDFT matlab class is a really good starting point for writing code to generate UV-Vis spectra from gaussian 09 TD-DFT calculations. If you have no interest in coding then these parsers are totally useless to you.&lt;br /&gt;
&lt;br /&gt;
Also since this is a page about parsers, i should probably mention cclib - this provides python parsers for log files from a range of computational chemistry software (including gaussian 09)[link: https://github.com/cclib/cclib]&lt;br /&gt;
&lt;br /&gt;
== Links To Files ==&lt;br /&gt;
&lt;br /&gt;
python molecule class parser [[Media:Mol Class Parser Jul2017 V0pt5.zip]]&lt;br /&gt;
&lt;br /&gt;
matlab NBO file parser [[Media:G09 NBO Parser Matlab.zip]]&lt;br /&gt;
&lt;br /&gt;
matlab AIM .sumviz file parser [[Media:AIM sumviz parser matlab.zip]]&lt;br /&gt;
&lt;br /&gt;
matlab TDDFT file parser [[Media:TDDFT Classes]]&lt;br /&gt;
&lt;br /&gt;
== Rough description of Matlab Parsers ==&lt;br /&gt;
&lt;br /&gt;
== Rough description of molecule_class (Python parser) ==&lt;br /&gt;
&lt;br /&gt;
This code is written in python3.5 (3.4 should work, not sure about anything earlier) and uses numpy. It pulls some basic information from *.com/*.log/*.fchk files, and is meant to be used on frequency files with a single structure (not sure if there are any issues with using it on an optimisation, ive never tried). The information it extracts depends on the type of file it reads, but in all cases a geometry is extracted. Documentation is mainly within the code, though some of its capabilities can be seen by testing the simple scripts i bundled with it (see below).&lt;br /&gt;
&lt;br /&gt;
As well as Molecule_Class_V0pt5 the zip folder contains a couple of simple scripts utilising the parser, and some example files. To test the simple scripts make sure they have executable permissions (&amp;quot;chmod u+x filename&amp;quot;), are in the same folder as Molecule_Class_V0pt5 and are in your system path (&amp;quot;PATH=$PATH:&amp;lt;dir&amp;gt;&amp;quot;, replace the word &amp;lt;dir&amp;gt; with the path for the folder containing the scripts.&lt;br /&gt;
&lt;br /&gt;
Then navigate to the example_files directory. In terminal type:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get_rel_energies.py .&amp;quot;&lt;br /&gt;
&lt;br /&gt;
A file called &amp;quot;Rel_Energies.txt&amp;quot; will have been written in the current folder. This is a comma-delimited file with conformer names + there relative energies (in kJ mol).&lt;br /&gt;
&lt;br /&gt;
To run the second script type:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Min_Distances_Two_Frags.py . 1-3 4-18&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The first argument is the folder to look for .log files. The second two arguments define sub-fragments for your geometry. &amp;quot;1-3&amp;quot; corresponds to atoms 1,2,3. The script (with these arguments) finds the shortest distance between the two fragments &amp;quot;atoms 1-3&amp;quot; and &amp;quot;atoms 4-18&amp;quot;, and outputs the distance in angstroms and also the identity of atoms involved.&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:TDDFT_Classes.zip&amp;diff=630603</id>
		<title>File:TDDFT Classes.zip</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:TDDFT_Classes.zip&amp;diff=630603"/>
		<updated>2017-07-29T15:59:29Z</updated>

		<summary type="html">&lt;p&gt;Rf614: matlab parser for TD-DFT files from gaussian 09&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;matlab parser for TD-DFT files from gaussian 09&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:AIM_sumviz_parser_matlab.zip&amp;diff=630602</id>
		<title>File:AIM sumviz parser matlab.zip</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:AIM_sumviz_parser_matlab.zip&amp;diff=630602"/>
		<updated>2017-07-29T15:58:00Z</updated>

		<summary type="html">&lt;p&gt;Rf614: Matlab code to parse .sumviz files (from AIMAll)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Matlab code to parse .sumviz files (from AIMAll)&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:G09_NBO_Parser_Matlab.zip&amp;diff=630601</id>
		<title>File:G09 NBO Parser Matlab.zip</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:G09_NBO_Parser_Matlab.zip&amp;diff=630601"/>
		<updated>2017-07-29T15:54:59Z</updated>

		<summary type="html">&lt;p&gt;Rf614: Parser for g09 NBO files, written in matlab 2014a.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Parser for g09 NBO files, written in matlab 2014a.&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630600</id>
		<title>Mod:Hunt Research Group/Some G09 Parsers</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630600"/>
		<updated>2017-07-27T20:28:22Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Rough description of molecule_class (Python parser) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This page has some parsers i&#039;ve made for some different types of gaussian calculation. Meaning they are scripts which essentially pull important information from output files and store them in convenient objects. They can be useful for using as part of other scripts, for example the TDDFT matlab class is a really good starting point for writing code to generate UV-Vis spectra from gaussian 09 TD-DFT calculations. If you have no interest in coding then these parsers are totally useless to you.&lt;br /&gt;
&lt;br /&gt;
Also since this is a page about parsers, i should probably mention cclib - this provides python parsers for log files from a range of computational chemistry software (including gaussian 09)[link: https://github.com/cclib/cclib]&lt;br /&gt;
&lt;br /&gt;
== Links To Files ==&lt;br /&gt;
&lt;br /&gt;
python molecule class parser [[Media:Mol Class Parser Jul2017 V0pt5.zip]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rough description of Matlab Parsers ==&lt;br /&gt;
&lt;br /&gt;
== Rough description of molecule_class (Python parser) ==&lt;br /&gt;
&lt;br /&gt;
This code is written in python3.5 (3.4 should work, not sure about anything earlier) and uses numpy. It pulls some basic information from *.com/*.log/*.fchk files, and is meant to be used on frequency files with a single structure (not sure if there are any issues with using it on an optimisation, ive never tried). The information it extracts depends on the type of file it reads, but in all cases a geometry is extracted. Documentation is mainly within the code, though some of its capabilities can be seen by testing the simple scripts i bundled with it (see below).&lt;br /&gt;
&lt;br /&gt;
As well as Molecule_Class_V0pt5 the zip folder contains a couple of simple scripts utilising the parser, and some example files. To test the simple scripts make sure they have executable permissions (&amp;quot;chmod u+x filename&amp;quot;), are in the same folder as Molecule_Class_V0pt5 and are in your system path (&amp;quot;PATH=$PATH:&amp;lt;dir&amp;gt;&amp;quot;, replace the word &amp;lt;dir&amp;gt; with the path for the folder containing the scripts.&lt;br /&gt;
&lt;br /&gt;
Then navigate to the example_files directory. In terminal type:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;get_rel_energies.py .&amp;quot;&lt;br /&gt;
&lt;br /&gt;
A file called &amp;quot;Rel_Energies.txt&amp;quot; will have been written in the current folder. This is a comma-delimited file with conformer names + there relative energies (in kJ mol).&lt;br /&gt;
&lt;br /&gt;
To run the second script type:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Min_Distances_Two_Frags.py . 1-3 4-18&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The first argument is the folder to look for .log files. The second two arguments define sub-fragments for your geometry. &amp;quot;1-3&amp;quot; corresponds to atoms 1,2,3. The script (with these arguments) finds the shortest distance between the two fragments &amp;quot;atoms 1-3&amp;quot; and &amp;quot;atoms 4-18&amp;quot;, and outputs the distance in angstroms and also the identity of atoms involved.&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630599</id>
		<title>Mod:Hunt Research Group/Some G09 Parsers</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630599"/>
		<updated>2017-07-27T20:14:49Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This page has some parsers i&#039;ve made for some different types of gaussian calculation. Meaning they are scripts which essentially pull important information from output files and store them in convenient objects. They can be useful for using as part of other scripts, for example the TDDFT matlab class is a really good starting point for writing code to generate UV-Vis spectra from gaussian 09 TD-DFT calculations. If you have no interest in coding then these parsers are totally useless to you.&lt;br /&gt;
&lt;br /&gt;
Also since this is a page about parsers, i should probably mention cclib - this provides python parsers for log files from a range of computational chemistry software (including gaussian 09)[link: https://github.com/cclib/cclib]&lt;br /&gt;
&lt;br /&gt;
== Links To Files ==&lt;br /&gt;
&lt;br /&gt;
python molecule class parser [[Media:Mol Class Parser Jul2017 V0pt5.zip]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rough description of Matlab Parsers ==&lt;br /&gt;
&lt;br /&gt;
== Rough description of molecule_class (Python parser) ==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group&amp;diff=630598</id>
		<title>Mod:Hunt Research Group</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group&amp;diff=630598"/>
		<updated>2017-07-27T20:14:25Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Codes to Help Analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Hunt Group Wiki==&lt;br /&gt;
&lt;br /&gt;
Back to the main [http://www.ch.ic.ac.uk/hunt web-page]&lt;br /&gt;
===HPC Resources===&lt;br /&gt;
#Computing resources available in the chemistry department [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/computing_resources link]&lt;br /&gt;
#HPC servers and run scripts [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/hpc link]&lt;br /&gt;
#Setting up a connection to HPC if you have a PC [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/hpc_connections link] &lt;br /&gt;
#How to fix Windows files under UNIX [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/Windowsfiles link] &lt;br /&gt;
#How to make ssh more comfortable [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/pimpSSH link] &lt;br /&gt;
#How to make qsub more comfortable (gfunc) [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/pimpQSUB link] &lt;br /&gt;
#How to set up a SSH keypair [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/SSHkeyfile link] &lt;br /&gt;
#How to use gaussview directly on the HPC [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/gview link] &lt;br /&gt;
#How to comfortably search through old BASH commands [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/searchbash link]&lt;br /&gt;
#How to connect to HPC directory on desktop for file transfers - MacFusion [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/hpc_Directory_on_desktop link]&lt;br /&gt;
#How to set up cx2 [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/cx2 link]&lt;br /&gt;
&lt;br /&gt;
===Visualisation===&lt;br /&gt;
*&#039;&#039;&#039;density based visualisation&#039;&#039;&#039;&lt;br /&gt;
#download [http://aim.tkgristmill.com AIMALL]&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;ESPs&#039;&#039;&#039;&lt;br /&gt;
#Instructions for visualizing electrostatic potentials (Gaussview)[https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/electrostatic_potentials link]&lt;br /&gt;
#Electrostatic Potentials II (Molden) [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/electrostatic_potentials_2 link] &lt;br /&gt;
*&#039;&#039;&#039;VMD: a molecular dynamics visualisation package&#039;&#039;&#039;&lt;br /&gt;
#Download VMD [//wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/download_vmd link]&lt;br /&gt;
#Quick reminder [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/VMDReminder link]&lt;br /&gt;
#Tricks and tips [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/VMDTips link]&lt;br /&gt;
#Changing the graphical representation of your structures [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/vmd link]&lt;br /&gt;
#Basic visualisation of a trajectory [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/VisualisingyourSimulation link] &lt;br /&gt;
#How to turn a Gaussian optimization into a VMD movie [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/VMDmovie link] &lt;br /&gt;
#Using scripts in VMD [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/VmdScripts link]&lt;br /&gt;
#Dealing with periodic boundaries and bonding (under construction) [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/VmdScriptsPeriodic link]&lt;br /&gt;
#Dealing with bonding (under construction) [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/VmdBonding link]&lt;br /&gt;
#Overlapping two structures [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/VmdVisual link]&lt;br /&gt;
*&#039;&#039;&#039;JMol&#039;&#039;&#039;&lt;br /&gt;
#Visualising MOs using Jmol [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:basic_jmol_instructions link]&lt;br /&gt;
#Surfaces (Solvent-Accessible and Connolly) in Jmol [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/jmolsurfaces link]&lt;br /&gt;
*&#039;&#039;&#039;EMO Code&#039;&#039;&#039;&lt;br /&gt;
#How to use Ling&#039;s emo plot code[https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/emoplot link] &lt;br /&gt;
#How to plot EMOs [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/emo link]&lt;br /&gt;
*&#039;&#039;&#039;PyGauss&#039;&#039;&#039;&lt;br /&gt;
#Python API for analysis of Gaussian compuations [https://pygauss.readthedocs.org - Documentation]&lt;br /&gt;
*&#039;&#039;&#039;MD Post processing&#039;&#039;&#039;&lt;br /&gt;
#Code to Recentre DL_PLOY HISTORY file [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/recentre_xyz.py link]&lt;br /&gt;
#Link to the code to convert the DL_POLY HISTORY file to the multi-frame XYZ file[https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/his2xyz.py link]&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;SDFs&#039;&#039;&#039;&lt;br /&gt;
#How to generate SDFs [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/sdfs_generate link]&lt;br /&gt;
&lt;br /&gt;
===Gaussian General===&lt;br /&gt;
#We are starting a database of common errors encountered when running Gaussian jobs [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/gaussian_errors link]&lt;br /&gt;
# Here is an already existing database of common errors [https://www.ace-net.ca/wiki/Gaussian_Error_Messages link]&lt;br /&gt;
# [http://www.ch.ic.ac.uk/hunt/g03_man/index.htm G03 Manual]&lt;br /&gt;
#How to run NBO5.9 on the HPC [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/NBO5.9 link] &lt;br /&gt;
#How to include dispersion [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/dispersion link] &lt;br /&gt;
#Basic ONIOM (Mechanical Embedding) [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/basiconiom link]&lt;br /&gt;
#M0n and DFT-D [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/DFTD link]&lt;br /&gt;
#IL ONIOM clusters [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/oniomclusers link]&lt;br /&gt;
#Molecular volume calculations [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/molecular_volume link]&lt;br /&gt;
#problems with scf convergence [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/scf_convergence link]&lt;br /&gt;
#Using a z-matrix [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/z-matrix link]&lt;br /&gt;
#generating natural transition orbitals [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/nto link]&lt;br /&gt;
#Using solvent models [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/solvent link]&lt;br /&gt;
#Using SMD on ILs [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:_Using_SMD_on_ILs link]&lt;br /&gt;
#computing excited state polarisabilities [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:_ES_alpha link]&lt;br /&gt;
#computing deuterated and/or anharmonic spectra [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:_Danharm link]&lt;br /&gt;
#manipulating checkpoint files [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:usingchkfiles link]&lt;br /&gt;
#AimAll with pseudo potentials [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:aim_pseudopotentials link]&lt;br /&gt;
#Script to pull thermodynamic data and low frequencies from log files [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:freq_script link]&lt;br /&gt;
#General procedure for locating transition state structures [[link]]&lt;br /&gt;
&lt;br /&gt;
===ADF General===&lt;br /&gt;
#Submission script [http://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/ADF_sricpt link]&lt;br /&gt;
&lt;br /&gt;
===Codes to Help Analysis===&lt;br /&gt;
# Extract E2 Values (From NBO Calculations) [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/NBO_Matlab_Code link]&lt;br /&gt;
# Calculate pDoS/XP spectra code (under construction) [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code link]&lt;br /&gt;
# Codes to extract frequency data from gaussian .log files and generate vibrational spectra [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:frequency_spectrum_script link]&lt;br /&gt;
# Optimally Tuned Range Seperated Hybrid Functionals [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct link]&lt;br /&gt;
# Some G09 Parsers [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers link]&lt;br /&gt;
&lt;br /&gt;
===Setup and Running Ab-Initio MD Simulations===&lt;br /&gt;
#CPMD: Car-Parrinello Molecular Dynamics [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/cpmd link]&lt;br /&gt;
#How to run CPMD to study aqueous solutions [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/cpmd_water link]&lt;br /&gt;
#How to run CP2K [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/cp2k_how link] &lt;br /&gt;
#[bmim]Cl using CPMD [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/bmimCl_cpmd  link] &lt;br /&gt;
#[bmim]Cl using CP2K [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/bmimCl_cp2k  link] &lt;br /&gt;
#mman using CPMD and Gaussian [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/mman link] &lt;br /&gt;
#[emim]SCN using CP2K[https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/emimscn link] &lt;br /&gt;
#CP2K Donts [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/cp2k link] &lt;br /&gt;
&lt;br /&gt;
===Setup and Running Classical MD Simulations===&lt;br /&gt;
#DLPOLY a MD simulation package, Installation on an IMac (old needs to be updated) [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/dlpoly_install  link]&lt;br /&gt;
#DL_POLY FAQs [http://www.stfc.ac.uk/cse/DL_POLY/ccp1gui/38621.aspx] from DL_POLY webpage.&lt;br /&gt;
#Installing Packmol&lt;br /&gt;
#Getting started: generating a solvated structure and &amp;quot;relaxing&amp;quot; it [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/Starting_MD link] &lt;br /&gt;
#Equilibration and production simulations [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/EquilibrationandProduction link] &lt;br /&gt;
#How to equilibrate an MD run[https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/equilibration link] &lt;br /&gt;
#Getting the Force Field [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/Wheretostart link] &lt;br /&gt;
#Choosing an Ensemble [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/Ensembles link] &lt;br /&gt;
#Molten Salt Simulations [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/MoltenSaltSimulation link]&lt;br /&gt;
#Common Errors [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/CommonErrors link]&lt;br /&gt;
#Voids in ILs[https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/voids link] &lt;br /&gt;
#Equilibration of [bmim][BF4] and [bmim][NO3][https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/BmimBF4_equilibration link] &lt;br /&gt;
#Summary of discussions with Ruth[https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/Aug09QtoRuth link]&lt;br /&gt;
&lt;br /&gt;
===Running QM/MM Simulations in ChemShell===&lt;br /&gt;
#ChemShell official website which contains the manual and a tutorial [http://www.stfc.ac.uk/CSE/randd/ccg/36254.aspx link]&lt;br /&gt;
#Introduction to ChemShell - Copper in water [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ChemShell_Introduction link]&lt;br /&gt;
#Defining the system: Cu&amp;lt;sup&amp;gt;2+&amp;lt;/sup&amp;gt; and its first 2 solvation shells [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ChemShell_System_Aqeuous_Cu(II) link] &lt;br /&gt;
#Defining the force field parameters [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ChemShell_Force_Field_Parameters_Aqueous_Cu(II) link] &lt;br /&gt;
#Single point QM/MM energy calculation [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/QMMM_SP_Aqeuous_Cu(II) link] &lt;br /&gt;
#QM/MM Optimisation [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/QMMM_OPT_Aqeuous_Cu(II) link] &lt;br /&gt;
#QM/MM Molecular Dynamics [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/QMMM_MD_Aqeuous_Cu(II) link]&lt;br /&gt;
#Using MolCluster [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/MolCluster link]&lt;br /&gt;
#Running ChemShell [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ChemShell link]&lt;br /&gt;
#Explaining ChemShell files [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ChemShell_files link]&lt;br /&gt;
#Step By Step [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/Chemshell_Step_By_Step link]&lt;br /&gt;
&lt;br /&gt;
===Research Notes===&lt;br /&gt;
#Cl- in water [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/wannier_centre link] &lt;br /&gt;
#The use of Legendre time correlation functions to study reorientational dynamics in liquids[https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/legendre  link] &lt;br /&gt;
#Functional for ILs using CPMD [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/IL_cpmd_functional link] &lt;br /&gt;
#Solving the angular part of the Schrödinger equation for a hydrogen atom [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/angular_schrodinger link] (notes by Vincent)&lt;br /&gt;
#Systematic conformational scan for ion-pair dimers [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ion_pair_scan link]&lt;br /&gt;
#Obtaining NBO, ESP, and RESP charges [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/Charges link]&lt;br /&gt;
&lt;br /&gt;
===Installing and using other packages===&lt;br /&gt;
#How to install POLYRATE [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/polyrate link] &lt;br /&gt;
#How to install Geomview [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/geomview link] &lt;br /&gt;
#XMGRACE, gfortran, c compilers for Lion [http://hpc.sourceforge.net/]&lt;br /&gt;
&lt;br /&gt;
===Admin Stuff===&lt;br /&gt;
#Not used to writing a wiki, make your test runs [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/testing  on this page]&lt;br /&gt;
#How to set-up new macs [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/mac_setup link]&lt;br /&gt;
#How to set-up remote desktop [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/mac_remote link]&lt;br /&gt;
#[https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/calendar Calendar]&lt;br /&gt;
#How to switch the printer HP CP3525dn duplex on and off [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/printing link]&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630597</id>
		<title>Mod:Hunt Research Group/Some G09 Parsers</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630597"/>
		<updated>2017-07-27T20:13:57Z</updated>

		<summary type="html">&lt;p&gt;Rf614: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This page has some parsers i&#039;ve made for some different types of gaussian calculation. Meaning they are scripts which essentially pull important information from output files and store them in convenient objects. They can be useful for using as part of other scripts, for example the TDDFT matlab class is a really good starting point for writing code to generate UV-Vis spectra from gaussian 09 TD-DFT calculations. If you have no interest in coding then these parsers page are totally useless to you.&lt;br /&gt;
&lt;br /&gt;
Also since this is a page about parsers, i should probably mention cclib - this provides python parsers for log files from a range of computational chemistry software (including gaussian 09)[link: https://github.com/cclib/cclib]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links To Files ==&lt;br /&gt;
&lt;br /&gt;
python molecule class parser [[Media:Mol Class Parser Jul2017 V0pt5.zip]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rough description of Matlab Parsers ==&lt;br /&gt;
&lt;br /&gt;
== Rough description of molecule_class (Python parser) ==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Mol_Class_Parser_Jul2017_V0pt5.zip&amp;diff=630596</id>
		<title>File:Mol Class Parser Jul2017 V0pt5.zip</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Mol_Class_Parser_Jul2017_V0pt5.zip&amp;diff=630596"/>
		<updated>2017-07-27T20:11:20Z</updated>

		<summary type="html">&lt;p&gt;Rf614: basic parser for gaussian 09 .fchk/.log/.com files&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;basic parser for gaussian 09 .fchk/.log/.com files&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630595</id>
		<title>Mod:Hunt Research Group/Some G09 Parsers</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630595"/>
		<updated>2017-07-27T20:09:50Z</updated>

		<summary type="html">&lt;p&gt;Rf614: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This page has some parsers i&#039;ve made for some different types of gaussian calculation. Meaning they are scripts which essentially pull important information from output files and store them in convenient objects. They can be useful for using as part of other scripts, for example the TDDFT matlab class is a really good starting point for writing code to generate UV-Vis spectra from gaussian 09 TD-DFT calculations. If you have no interest in coding then these parsers page are totally useless to you.&lt;br /&gt;
&lt;br /&gt;
Also since this is a page about parsers, i should probably mention cclib - this provides python parsers for log files from a range of computational chemistry software (including gaussian 09)[link: https://github.com/cclib/cclib]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links To Files ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rough description of Matlab Parsers ==&lt;br /&gt;
&lt;br /&gt;
== Rough description of molecule_class (Python parser) ==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630594</id>
		<title>Mod:Hunt Research Group/Some G09 Parsers</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/Some_G09_Parsers&amp;diff=630594"/>
		<updated>2017-07-27T20:02:09Z</updated>

		<summary type="html">&lt;p&gt;Rf614: Created page with &amp;quot;  == Introduction ==   == Links To Files ==  == Rough description of Matlab Parsers ==  == Rough description of molecule_class (Python parser) ==&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Links To Files ==&lt;br /&gt;
&lt;br /&gt;
== Rough description of Matlab Parsers ==&lt;br /&gt;
&lt;br /&gt;
== Rough description of molecule_class (Python parser) ==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630593</id>
		<title>Talk:Mod:Hunt Research Group/Calc XPS Code</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630593"/>
		<updated>2017-07-27T16:33:32Z</updated>

		<summary type="html">&lt;p&gt;Rf614: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Links to Files==&lt;br /&gt;
Open Shell Version: [[Media:Gelius_open_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
Closed Shell Version: [[Media:Gelius_closed_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
Plot Atomic Contribs Script: [[Media:Plot Atomic Contribs V3.m]]&lt;br /&gt;
&lt;br /&gt;
*MLinpt.txt File parser(Matlab): [[Media:ML inpt att2.m]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
The purpose of this code is to calculate partial density of states (pDoS) plots and Valence band x-ray photoelectron (XP) spectra from .fchk files. There is both an open shell and a closed shell version of the code, they work in exactly the same way.&lt;br /&gt;
&lt;br /&gt;
All code was written using python 2.7 (with numpy), Multiwfn version 3.3.8, Matlab version 2014a and a cygwin(bash) shell on windows 8. It should work on windows or linux if the correct options are set.  It might not work on a mac currently due to Multiwfn not working properly (I haven&#039;t personally tested it though). &lt;br /&gt;
&lt;br /&gt;
I&#039;ve now also uploaded a parser for *MLinpt.txt files. Documentation is in the file itself, this is a totally non-essential code but can make writing scripts that rely on *MLinpt.txt files easier.(e.g scripts to extract HOMO energies). &lt;br /&gt;
&lt;br /&gt;
==Some Theory==&lt;br /&gt;
&lt;br /&gt;
===Mulliken Population Analysis===&lt;br /&gt;
&lt;br /&gt;
A pretty key part to this code is the breakdown of molecular orbitals (MOs) in atomic orbitals (AOs, which are essentially basis functions). This is carried out in multiwfn using Mulliken population analysis, which i&#039;ll briefly summarise due to its importance.&lt;br /&gt;
&lt;br /&gt;
The basic question is &amp;quot;For MO X, how many electrons come from atomic orbital Y?&amp;quot;. Note im going to be using &amp;quot;basis functions&amp;quot; instead of &amp;quot;atomic orbitals&amp;quot; from this point, in terms of DFT calculations we interpret a basis function centered on atom X as an atomic orbital of atom X.We&#039;ll define &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the wavefunction for a &#039;&#039;&#039;single MO containing a single electron&#039;&#039;&#039;. Next we write &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the linear combination of individual basis functions (&amp;lt;math&amp;gt;\phi_{i}&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi = {{\sum\limits_{i} c_{i} \phi_{i} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since we want a number of electrons, we&#039;re interested in the formula for the electron density (&amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;) of this MO:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\rho = \langle{} \Psi | \Psi \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i} \phi_{i} }})({{\sum\limits_{i} c_{i} \phi_{i} }})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }}) + 2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If these formulae are tricky to follow, try doing it for a system with just two basis functions.&lt;br /&gt;
Note that in the third line the indice &#039;&#039;j&#039;&#039; runs over the same coefficients and basis functions as the indice &#039;&#039;i&#039;&#039;, its just used to show that the &amp;lt;math&amp;gt;{{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term only contains products between 2 different basis functions/co-efficients.&lt;br /&gt;
Hence, we now have a formula for the MO density which is purely in terms of (known) basis functions and (known) coefficients. Now its just a case of working out how we should interpret these values.&lt;br /&gt;
&lt;br /&gt;
Firstly note that &amp;lt;math&amp;gt;\phi_{i}^{2}=1&amp;lt;/math&amp;gt; (since we use normalised basis functions) hence:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
{{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }} = {{\sum\limits_{i} c_{i}^{2}}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The values of c_{i} in this expression are easy to interpret, they represent the fractional contribution of AO &#039;&#039;i&#039;&#039; to the wavefunction. The &amp;lt;math&amp;gt;2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term is more difficult to interpret, each expression in the series can be thought of as the number of electrons shared between two basis functions. i.e. the following term would represent the number of electrons shared between basis function 1 and 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{shared} = 2 c_{1}c_{2} \langle{}\phi_{1} | \phi_{2} \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we need to split this &amp;quot;shared&amp;quot; electron density between the two contributing basis functions. In Mulliken Population analysis &amp;quot;shared&amp;quot; electron density is divided equally between the two contributing basis functions. So the total electron density assigned to one basis function can be written as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{i} = c_{i}^{2} + {{\sum\limits_{j \neq i} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; represents the &#039;&#039;&#039;fractional&#039;&#039;&#039; contribution of &#039;&#039;i&#039;&#039; to the wavefunction. Hence if you had a 2-electron MO, you&#039;d simply multiply &amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; by 2.&lt;br /&gt;
&lt;br /&gt;
===What the code actually does (roughly/briefly)===&lt;br /&gt;
&lt;br /&gt;
Step 1 - The first step is to run a Mulliken population analysis on the *.fchk file. This leads to a file containing the energy/AO composition of each MO in the system (the *MLinpt.txt file). Subsequent steps vary depending on if you want partial density of states (pDoS) plots or calculated valence spectra.&lt;br /&gt;
&lt;br /&gt;
If &#039;&#039;&#039;calculating pDoS&#039;&#039;&#039; (not XPS spectra):&lt;br /&gt;
&lt;br /&gt;
For each type of atomic orbital present do the following:&lt;br /&gt;
&lt;br /&gt;
- For each MO, center a gaussian-lorentzian function at that MO energy. Multiply the intensity by the contribution of the current AO to the current MO.&lt;br /&gt;
&lt;br /&gt;
- Sum all the resultant peaks, this generates the pDOS the current atomic orbital&lt;br /&gt;
&lt;br /&gt;
Once all pDoS are generated, the total DoS could be created by summing them all. In practice the code probably just calculates the total DoS first, by just placing a gaussian-lorenztian with area=1 around each MO energy.&lt;br /&gt;
&lt;br /&gt;
If &#039;&#039;&#039;calculating XPS spectra&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
For each type of atomic orbital present do the following:&lt;br /&gt;
&lt;br /&gt;
- Multiply the fractional contributions of this AO to each MO by the AO cross-section. This value will be reffered to as the &amp;quot;intensity&amp;quot; This cross-section depends on both the AO type and the photon energy. Default values in this code are stored in tables in X_Section_Library, and custom/different values can easily be added.&lt;br /&gt;
&lt;br /&gt;
- For each MO, center a gaussian-lorentzian function at that MO energy. This area of this function is equal to the intensity calculated in the step above. &lt;br /&gt;
&lt;br /&gt;
Sum all the resultants peaks, this generates the contribution of the current AO to the valence XPS spectrum&lt;br /&gt;
Once this is repeated for each AO type, sum all those individual contributions to generate the total XPS valence spectrum.&lt;br /&gt;
&lt;br /&gt;
==&amp;quot;Installation&amp;quot; Instructions==&lt;br /&gt;
&lt;br /&gt;
All instructions will be given for the open shell version of the code. However, the process is the same except whenever these instructions say to edit the &amp;quot;gen_gelius_input_opensh.sh&amp;quot;, just do the corresponding edit on the gen_gelius_input.sh file. The Matlab scripts are EXACTLY the same for both open shell/closed shell codes.&lt;br /&gt;
&lt;br /&gt;
0) Make sure you have multiwfn (http://sobereva.com/multiwfn/) saved somewhere, python 2.x and numpy installed.&lt;br /&gt;
:a)On ubuntu Multiwfn needs an extra library, type the following line:&lt;br /&gt;
sudo apt-get install libmotif-dev&lt;br /&gt;
&lt;br /&gt;
1)Put the following files (all the .py/.sh files) somewhere in system path (e.g i use /usr/local/bin):&lt;br /&gt;
:a)Format_Multiwfn_Output_alpha.py (Format_Multiwfn_Output.py for closed shell)&lt;br /&gt;
:b)Format_Multilwfn_Output_beta.py&lt;br /&gt;
:c)Gen_Multiwfn_Input_Comms.py&lt;br /&gt;
:d)Gen_Multiwfn_Input_Comms_beta.py&lt;br /&gt;
:e)Merge_Fragment_Files.py&lt;br /&gt;
:f)gen_gelius_input_opensh.sh&lt;br /&gt;
&lt;br /&gt;
Make sure all files (including Multiwfn) have executable persmission (navigate to the folder and do &amp;quot;chmod u+x filename&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
2)In the gen_gelius_input_opensh.sh change the current lines accordingly:&lt;br /&gt;
:a) multiwfn_folder = &#039;C:/Users/Richard/Documents/Multiwfn_Installed&#039; to the directory where you store multiwfn and associated files.&lt;br /&gt;
:b) &amp;quot;cygwin=1” to “cygwin=0” if your not using a Cygwin shell.&lt;br /&gt;
:c) “old_sed=1” to “old_sed=0” if your version of sed allows the –i option (edit in place) to be used. I don’t think the standard version on mac does(meaning set old_sed=1),standard version of Cygwin does though.&lt;br /&gt;
:d) If on linux &amp;quot;cp $multiwfn_folder/Multiwfn.exe $curr_folder&amp;quot; to &amp;quot;cp $multiwfn_folder/Multiwfn $curr_folder&amp;quot; . Do the same for the line where multiwfn is deleted from current folder(&amp;quot;rm Multiwfn.exe&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
3)Put the following files somewhere in matlabs path (e.g your matlab folder in documents)&lt;br /&gt;
:a) Get_X_Section.m&lt;br /&gt;
:b) Gen_Gelius_Spectrum.m&lt;br /&gt;
&lt;br /&gt;
The Get_X_Section REALLY does need to be in matlabs path (unless you want to edit some code in Gen_Gelius_Spectrum.m). If you know what your doing in matlab  feel free to put Gen_Gelius_Spectrum.m wherever you want.&lt;br /&gt;
&lt;br /&gt;
4)Put the X_Section_Library folder wherever you want.&lt;br /&gt;
&lt;br /&gt;
5) In Get_X_Section.m modify the following line:&lt;br /&gt;
:&amp;quot;Lib_Path =&#039;C:\Users\Richard\Documents\X_Section_Library&#039; &amp;quot; to the path where you put the X_Section_Library folder in.&lt;br /&gt;
&lt;br /&gt;
6) OPTIONAL: Add the code in vim_template_script to your vimrc (c+p it somewhere in the file). &amp;quot;vim ~/.vimrc&amp;quot; to access your vimrc. You can then bring up a template input file in vim by using &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
Since i forgot to put the relevant text file in to the code folders, just c+p the below into your vimrc to get this to work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function! Gelius_Input()&lt;br /&gt;
        exe &#039;normal aCoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr.fchk\rNumb_Fragments=10\r1a=\r1t=a\r1l=TDOS\r2a=\r2t=\r2l=\r3a=\r3t=\r3l=\r4a=\r4t=\r4l=\r5a=\r5t=\r5l=\r6a=\r6t=\r6l=\r7a=\r7t=\r7l=\r8a=\r8t=\r8l=\r9a=\r9t=\r9l=\r10a=\r10t=\r10l=\rM_factor=1.0\rLink_File=&#039;&lt;br /&gt;
        exe &#039;%s/\\r/\r/g&#039;&lt;br /&gt;
endfunction&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
====Using the Example files====&lt;br /&gt;
1) Navigate (in your shell) to the folder &amp;quot;Example_files&amp;quot;. e.g for me i ran:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;cd /cygdrive/c/Users/Richard/Documents/Random_Coding/Gelius_Spectrum_Automated_Jan_2016/open_shell_code/Example_files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
2) Run this command in console(for closed shell use  gen_gelius_input.sh):&lt;br /&gt;
&lt;br /&gt;
&amp;quot;gen_gelius_input_opensh.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Command 2) will have created a folder for each .fchk file in Example_files/. Therefore you should now have folders:&lt;br /&gt;
:CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&lt;br /&gt;
:other_file&lt;br /&gt;
Within these folders are tons of output files. The most important ones are those ending in &amp;quot;MLinpt.txt&amp;quot; - these will be the input files for step 3.&lt;br /&gt;
&lt;br /&gt;
The script will run on all .fchk files in the current folder, when you do this for real you need to make sure that all the fchks are for the same system (e.g a water molecule) and that the atomic numbering is the same in all files (view--&amp;gt;labels in gaussview gives you what im calling atomic numbering).&lt;br /&gt;
&lt;br /&gt;
If anything went wrong try revisiting the installation instructions.&lt;br /&gt;
&lt;br /&gt;
3) Everything from now on is done using matlab. Theres a file called &amp;quot;pathname_file&amp;quot; in the Example_files folder which was created by the gen_gelius_input_opensh.sh script. Copy its full contents to clipboard and in MATLAB terminal type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist=&amp;lt;CTRL-V&amp;gt;&lt;br /&gt;
(&amp;lt;CTRL-V&amp;gt; means paste, rather than type out CTRL-V) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In matlab terms, plist now contains a cell array where each entry is the full path to a folder. The folder paths are those for the folders created in step 2). Hence to do this manually for just one of the two folders you&#039;d type something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist={&#039;C:\Users\Richard\Documents\Random_Coding\Gelius_Spectrum_Automated_Jan_2016\open_shell_code\Example_files\other_file&#039;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4) To create either an XPS spectrum or pDoS plots we use the Gen_Gelius_Spectrum script. This takes the following three arguments IN THE FOLLOWING ORDER:&lt;br /&gt;
:a) the plist variable we just made&lt;br /&gt;
:b) the photon energy we want to use (any negative number requests a pDoS rather than an XPS spectrum)&lt;br /&gt;
:c) the FWHM of the peaks to place around each MO energy (units = eV)&lt;br /&gt;
&lt;br /&gt;
So to create a pDoS plot you could type the following into the matlab terminal(Try this one first):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,-1,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To create an XPS spectrum taken at photon energy of 1486eV (standard lab-based value) type the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,1486,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you get an error like &amp;quot;Undefined function &#039;Gen_Gelius_Spectrum&#039; for input arguments of type &#039;cell&#039;.&amp;quot;, then your Gen_Gelius_Spectrum script probably isnt in your matlab path. (see installation instructions, or google a bit)&lt;br /&gt;
&lt;br /&gt;
If your error free then well done. Sub-folders should have been created in &amp;quot;other_file&amp;quot; and &amp;quot;CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&amp;quot;, which in turn will contain a loada output files. See the output files section of the wiki for an explanation of what these are.&lt;br /&gt;
&lt;br /&gt;
====Creating your own input files====&lt;br /&gt;
It can be named anything (except a substring of the fchk file name). The extension must be .test.&lt;br /&gt;
&lt;br /&gt;
If you followed the optional part above and made a vimscript, then a template for the input file can be brought up in vim by typing &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example input file is shown below. Each &amp;quot;fragment&amp;quot; (e.g cation,anion, alkyl group etc.) should have its own input file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
other_file.fchk&lt;br /&gt;
Numb_Fragments=4&lt;br /&gt;
1a=10-13&lt;br /&gt;
1t=a&lt;br /&gt;
1l=TDOS&lt;br /&gt;
2a=10-13&lt;br /&gt;
2t=s&lt;br /&gt;
2l=S3s&lt;br /&gt;
3a=10-13&lt;br /&gt;
3t=p&lt;br /&gt;
3l=S3p&lt;br /&gt;
4a=10-13&lt;br /&gt;
4t=d+&lt;br /&gt;
4l=S3d&lt;br /&gt;
M_factor=1.0&lt;br /&gt;
Link_File=all_frags.test&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The input file can be divided into parts as follows:&lt;br /&gt;
&lt;br /&gt;
1) The top line of the input file tells the code the name of the checkpoint file to use in the calculation. In practice you can write ANYTHING on this top line if using the gen_gelius_input*.sh script, as the script itself replaces the first line (whatevers there) with the names of all .fchks in the current folder. But SOMETHING must be written there.&lt;br /&gt;
&lt;br /&gt;
2)&#039;&#039;&#039;Numb_Fragments&#039;&#039;&#039; is the number of sub-fragments (max 10) that you want to break your pDoS down into (e.g fragment 2 corresponds to all Sulfur 3s atomic orbitals in the example above). Code will break if you get this wrong.&lt;br /&gt;
&lt;br /&gt;
3) &#039;&#039;&#039;1a/1t/1l&#039;&#039;&#039; instruct the code what to use as the total density of states. Hence 1a must be set to ALL the atoms your interested in for this fragment, 1t must be set to &amp;quot;a&amp;quot; and 1l should be set to TDOS (not sure it matters what this is set to, but to be on the safe side just use TDOS). The purpose of this fragment is essentially error checking.&lt;br /&gt;
&lt;br /&gt;
4) &#039;&#039;&#039;2a/3a/*a&#039;&#039;&#039; : a stands for atoms here, so the value of a corresponds to the labels of the atoms you want to be included in the sub-fragment. These labels are the same integers you get in gaussview when you go to view--&amp;gt;labels. Examples of valid options may be &amp;quot;1,4,5-7&amp;quot; or &amp;quot;1,3,5&amp;quot; (basically comma seperated list of integers)&lt;br /&gt;
&lt;br /&gt;
5) &#039;&#039;&#039;2t/3t/*t&#039;&#039;&#039;: t stands for &amp;quot;type of AO&amp;quot;.This is a comma seperated list with possible arguments (any combination) &amp;quot;a,s,p,d,f,g&amp;quot;. &amp;quot;a&amp;quot; corresponds to all types of AO centered of the atoms specified with the 2a/3a/*a line. s means s-type atomc orbitals (0 angular momentum), p means p-type atomic orbitals (1 angular momentum) etc. To get all AOs of a certain angular momentum and higher (up to g-type AOs) add a plus to the end of the relevant letter. e.g &amp;quot;p+&amp;quot; says &amp;quot;include all AOs with angular momemtnum greater than or equal to 1 in this sub-fragment&amp;quot;)&lt;br /&gt;
&#039;&#039;&#039;DON&#039;T&#039;&#039;&#039; use &amp;quot;a&amp;quot; with any other letter, and dont do anything else that will lead to a type of AO being requested twice (e.g p+,d)&lt;br /&gt;
&lt;br /&gt;
6) &#039;&#039;&#039;2l/3l/*l&#039;&#039;&#039;: l stands for label. If you dont care about calculating an XPS spectrum you can essentially set it to whatever you want. This tells the matlab script what cross section to use for calculating the XPS spectrum, hence it must match (case insensitive) a filename in the X_Section_Library folder. e.g S3s tells matlab to get the S3S.txt file when looking for what cross-section to use.&lt;br /&gt;
&lt;br /&gt;
7) &#039;&#039;&#039;M_factor=1.0&#039;&#039;&#039;, you really never need to modify this but make sure its present. It&#039;s purpose is to tell matlab to multiple the pDoS of this fragment (that this input file corresponds to) by the  value M_factor. The purpose is for systems where the real stoichiometry differs from that in your calculation. For example if i have a mixture of 99 water:1 anion but only a calculation on 1 water molecule mixed with 1 anion i could set M_factor for the water fragment input file to M_factor=99.0 to estimate (badly) what the actual DoS of the mixture would look like.&lt;br /&gt;
&lt;br /&gt;
8) &#039;&#039;&#039;Link_File=*&#039;&#039;&#039;. This options for if you have a fragment (e.g an anion) but want it broken into more than 10 sub-fragments (e.g this will be true for any molecule with &amp;gt;3 elements). In this case make 2 files for that fragment, and in the second  file set Link_File to the name of the first file. In the example above, this input file will essentially be merged with &amp;quot;all_frags.test&amp;quot;, and only an output file for all_frags.test will be generated.&lt;br /&gt;
&lt;br /&gt;
====More complex input file options====&lt;br /&gt;
====Gen_Gelius_Spectrum.m====&lt;br /&gt;
This code has the following options that can be changed (all are explained by comments in the .m file):&lt;br /&gt;
&amp;lt;pre&amp;gt;1)min_e/max_e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Matlab ignores any orbitals with energy below min_e or above max_e when generating the XPS spectrum. Note if you want to change this to include core orbitals or very high energy virtual orbitals then you&#039;ll also have to edit Gen_Multiwfn_Input_Comms.py to set the range in multiwfn to the one you want.(Theres currently no variable in that .py code to do that, it just uses the defaults in multiwfn. But the function you&#039;ll need to edit in Gen_Multiwfn_Input_Comms.py is Output_Header.&lt;br /&gt;
&amp;lt;pre&amp;gt;2)min_e_plotted/max_e_plotted&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These refer to the minimum/maximum binding energies to calculate spectral intensity for. The range should probably be slightly wider than the min_e/max_e range really, though thats not the default setting. &lt;br /&gt;
&amp;lt;pre&amp;gt;3)step_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The value (in eV) between calculated data points in the output spectra. For example, if set to 0.001eV then a data point will be calculated for 0eV,0.001eV,0.002eV etc. Lower values=larger files/slower runtimes.&lt;br /&gt;
&amp;lt;pre&amp;gt;4)lorentz_fraction &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Value between 0 and 1 that determines the % Lorentzian character of the lineshape used in the broadening function(the remaining % is set to gaussian). By broadening function i essentially mean the peak thats placed around every MO energy in generating these spectra. lorentz_fraction=0 will give you a pure gaussian peak, while lorentz_fraction=1 gives a pure Lorentzian peak.&lt;br /&gt;
&amp;lt;pre&amp;gt;5)savetext/figsave/savejpeg/all_contribs_output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These all control whether a certain type of output file is saved, with variable names that should be self-explanatory.Values of 1 mean save the file, other values mean dont save. set savetext=0 to not save any .txt output files, figsave=0 to not save any .fig output, savejpeg=0 to not save any .jpeg outputs and all_contribs_output=0 to not save the .txt file with a full breakdown of the spectrum. Leaving them all as 1 (except maybe the savejpeg) is strongly recommended.&lt;br /&gt;
&lt;br /&gt;
====Plot_Atomic_Contribs_V3====&lt;br /&gt;
&lt;br /&gt;
This is an optional script that plots certain breakdowns of your calculated DoS/XPS spectrum (i.e you run it AFTER Gen_Gelius_Spectrum) . Its not too hard to do the same thing in excel using the *ALL_Contribs* output file (see output file sections) but this is a lot faster. There are three types of breakdown this function can do (see pictures below):&lt;br /&gt;
&lt;br /&gt;
1) Atomic breakdown with fragments kept seperate (merge_spd=1,merge_fragments=0)&lt;br /&gt;
&lt;br /&gt;
2) Atomic orbital breakdown (merge_spd=0,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
3) Atomic breakdown (merge_spd=1,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
The function in its uploaded form takes a single argument , though there are two variables in the actual code that you need to mess with (merge_spd and merge_fragments).&lt;br /&gt;
&lt;br /&gt;
So for example, to run this on the output file from the &amp;quot;Using the Example files&amp;quot; i typed into the matlab terminal:&lt;br /&gt;
&lt;br /&gt;
Plot_Atomic_Contribs_V3(&#039;C:\Users\Richard\Desktop\Open_Shell_Code_Some_Stuff\Example_files\other_file\DoS_1ev_0pt3l&#039;)&lt;br /&gt;
&lt;br /&gt;
The argument needs to be a folder containing the output files from the Gen_Gelius_Spectrum script. You&#039;ll then get a saved graph with the breakdown you asked for and also a .txt file containing the breakdown in a comma delimited format. The output file names record the options you used to make the script (e.g &amp;quot;Plotted_Atomic_Contribs_spd0_frag1.txt&amp;quot; means merge_spd was set to 0 and merge_fragments was set to 1).&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag1.jpg|thumbnail|center| merge_spd=1,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted_Atomic_Contribs_spd0_frag1.jpg|thumbnail|center| merge_spd=0,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag0.jpg|thumbnail|center| merge_spd=1,merge_fragments=0 ]]&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
&lt;br /&gt;
The first &amp;quot;output file&amp;quot; is the *MCRF*.txt file, which just contains the commands to build the required fragment in multiwfn.&lt;br /&gt;
&lt;br /&gt;
===Files From Multiwfn===&lt;br /&gt;
Most people should be able to completely ignore these files. But in case your curious:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1) *DOS_curve*.txt&#039;&#039;&#039; Essentially a DoS plot. 1st column is energies in au, second column is TDOS of the fragment. Not really sure what the 3rd column is. No particular use for this file, but it gets auto-generated by multiwfn and i dont go out my way to delete it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2) *DOS_line*.txt&#039;&#039;&#039; Data to create a stick plot (where each MO is a stick). Plot column 1 vs column 2 as a line graph and you get an axis with sticks representing the MOs. 4th column onwards represent contribution of the various sub-fragments to each &amp;quot;stick&amp;quot;. This is the file that gets used to generate the *ML_inpt.txt file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3) *DOS_frag*.txt &#039;&#039;&#039; This file contains the sub-fragment info in a way multiwfn understands. If its renamed to DOS_frag.txt then multiwfn can import it to get the fragments (therefore can be useful for debugging, no further purpose).&lt;br /&gt;
&lt;br /&gt;
===MLinpt.txt File===&lt;br /&gt;
&lt;br /&gt;
Creation of the *ML_inpt.txt files is essentially the point of the gen_gelius_input* script. These are primarily input files for matlab, but they do have useful information in an easy to read format. If you import the file into excel and COMMA DELIMIT ONLY (i.e untick the space delimit option) you can get something like below(there are more decimal places in the actual file):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#M_FACTOR=1.0,													&lt;br /&gt;
#Energy(eV)	TDOS	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	S3S	S3P	S3D&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
-24.5		0.9	0.0	0.0	0.0	0.5	0.1	0.0	0.2	0.1	0.0	0.1	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-19.8		0.3	0.0	0.0	0.0	0.1	-0.1	0.0	0.2	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
-19.7		0.3	0.0	0.0	0.0	0.0	0.0	0.0	0.1	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The shown file is &amp;quot;all_frags_alpha_MLinpt.txt&amp;quot;, which is generated from the example files in the open shell code. As this actually comes from merging two MLinpt.txt files (gen_gelius_input.sh does this part silently) the TDOS in this case doesnt mean anything.&lt;br /&gt;
&lt;br /&gt;
The first column lists the energy of each MO in eV (1 ev ~27.212 au). For any row, columns 3(CO4S)--&amp;gt;end (S3D) list the fractional contributions of each type of atmoic orbital to the MO in that row. For example the MO with energy -19.7 eV is mainly from S3s type atomic orbitals. These fractions were determiend by multiwfn by using Mulliken population analysis.&lt;br /&gt;
&lt;br /&gt;
All the fractional contributions in the file get multiplied by the M_FACTOR value (as explained above in the Creating your own input files section). Therefore the value of M_FACTOR can easily be set after the MLinpt.txt file is created, as opposed to within the initial input file.&lt;br /&gt;
&lt;br /&gt;
===Formatted_UMOs===&lt;br /&gt;
&lt;br /&gt;
The default for the gen_gelius_input* script (i.e the settings for the version i uploaded) is to put only OCCUPIED MO energies/breakdowns into the *MLinpt.txt file. If you want all MOs (I really DONT recommend this) in the MLinpt.txt file then change all_orbs=&#039;cheese&#039; to all_orbs=&#039;ALLORBS&#039; at the top of the gen_gelius_input* script.&lt;br /&gt;
&lt;br /&gt;
Otherwise you will get a *Formatted_UMOs* file for every MLinpt.txt file you get. The format of the file is identical to the MLinpt.txt format except the MO at the top of the file corresponds to the LUMO.&lt;br /&gt;
&lt;br /&gt;
WARNING: If you use the link_files feature, then the output formatted_UMOs files DO NOT get merged. This shouldnt matter as you should never really use the formatted UMOs for anything.&lt;br /&gt;
&lt;br /&gt;
===Output From Matlab Code ===&lt;br /&gt;
&lt;br /&gt;
The matlab code firstly will create a new folder with a name reflecting the input arguments. The format is hv_FWHM_%lorenztian where hv is the photon energy, FWHM is full width half maximum of the broadeing function and %lorenztian is the amount of lorenztian mixed in the broadening function. For example the earlier command (from using example files section) &amp;quot;Gen_Gelius_Spectrum(plist,-1,1)&amp;quot; generates the folder &amp;quot;DoS_1ev_0pt3l&amp;quot;. DoS = Density of states, and means we did not use photoionisation cross sections. The 0pt3l part means our broadening function was 30% lorenztian and 70% Gaussian.&lt;br /&gt;
&lt;br /&gt;
Two .fig files will have been produced from this code, these contain matlab graphs of the output. These .fig files follow the naming (&amp;quot;filename&amp;quot; is the name of the original fchk file):&lt;br /&gt;
&lt;br /&gt;
1) filename_DoS.fig contains the total DoS plot.&lt;br /&gt;
&lt;br /&gt;
2) filename_DoS_frag_contribs.fig contains the DoS AND the pDoS of each of the fragments. For closed shell code you get 1 fragment per input file (assuming you dont use link_files), but for the open shell code each input file leads to two fragments - one for alpha electrons and one for beta electrons.&lt;br /&gt;
&lt;br /&gt;
[[File:Other_file_DoS.jpeg|thumb|center| 1) Total Density of States for a Co(SCN)4 fragment with filename other_file_DoS.fig]]&lt;br /&gt;
&lt;br /&gt;
[[File:Other file DoS frag contribs.jpeg|thumb|center| 2) Contribtuions of alpha and beta electrons to the Total Density of States for Co(SCN)4, filename other_file_DoS_frag_contribs.fig]]&lt;br /&gt;
&lt;br /&gt;
The filename_DoS.fig plot data is output in a .txt file of the same name, while each fragment in filename_DoS_frag_contribs.fig has its own .txt file. For the example above the two fragments have names &amp;quot;all_frags_alpha_other_file_DoS&amp;quot; and &amp;quot;all_frags_beta_other_file_DoS&amp;quot;. The start of the names are taken from the name of the original input file &amp;quot;all_frags.test&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The final file output is the &amp;quot;ALL_Contribs_other_file_DoS.txt&amp;quot; file. This(as the name implies) contains all contributions to the DoS spectra in a comma delimited file. The Plot_Atomic_Contribs*.m code can be run on this file to generate plots with a few different breakdowns (e.g atomic breakdowns) - see the relevant section of this wiki (not done yet....). The file will look something like below (commas replaced with tabs):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#all_frags_alpha	all_frags_beta								&lt;br /&gt;
#Sub fragments in each=	12	12							&lt;br /&gt;
#Energy(eV)	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED,numbers rounded]&lt;br /&gt;
7.5		0.00	0.01	0.31	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.51		0.00	0.01	0.33	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.52		0.00	0.01	0.34	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.53		0.00	0.01	0.35	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.54		0.00	0.01	0.36	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.55		0.00	0.02	0.37	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.56		0.00	0.02	0.39	0.05	0.14	0.00	0.00	0.13	0.00	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hopefully the format is mostly intuitive, the top two rows contain information on what the data is, and the rest contain the data. The top row contains (originally comma delimited) a list of all &amp;quot;fragments&amp;quot; names, which is the number of input files for the closed shell code and 2x the number of input files for the open shell code. The second row contains the number of sub-fragments (which should be atomic orbitals) in each fragment. In the example above each fragment had 12 types of atomic orbital.&lt;br /&gt;
&lt;br /&gt;
So for the example above column 2-14 shows contributions from &amp;quot;all_frags_alpha&amp;quot; while column 15-27 shows contributions from &amp;quot;all_frags_beta&amp;quot; (column 1 lists energies).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Bugs/Things to Watch For==&lt;br /&gt;
===Fragment Names===&lt;br /&gt;
Make sure your fragment names arent a substring of your .fchk file names. For example an input file called &amp;quot;Cl.test&amp;quot; wont work for a file called &amp;quot;BMIM_Cl.fchk&amp;quot;. However, &amp;quot;Cl_frag.test&amp;quot; will work. Therefore personally i add _frag to the end of every input file name. The other way to sort this is to set linked_files=0 in gen_gelius_input_opensh.sh, sincce the link files part of the code is where this bug comes from.&lt;br /&gt;
&lt;br /&gt;
===Fragment Error Checking===&lt;br /&gt;
Unless you manually turn it off (The &amp;quot;error=&amp;quot; option in gen_gelius_input_opensh.sh script) the code tries to check your input file for errors. Specifically it tests whether the TDOS in an input_file really is the sum of the other sub-fragments in the input(.test) file. E.g it will trigger if you request only Sulfur p-type and d-type AOs (but no s-type AOs) in the input file, or if you request all sulfur p-type AOs twice. If the error check triggers then it BREAKS the input file for matlab by putting an error msg in the first line of the &#039;&#039;&#039;*MLinpt.txt file&#039;&#039;&#039;. An example of what the error looks like is:&lt;br /&gt;
&amp;lt;pre&amp;gt;	&lt;br /&gt;
“Fragment Sum incorrect on row 19 for fchk file xxxx.fchk”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you *MLinpt.txt files arent working in matlab then this is probably the reason.&lt;br /&gt;
&lt;br /&gt;
===Pathlengths===&lt;br /&gt;
This code makes a lot of sub-folders based on the name of .fchk files. If you have really long .fchk file names its likely that you&#039;ll end up with some files which exceed the 256 character limit for a pathlength on a windows computer. In matlab 2014 this will cause the code to exit with an error, saying it cant save the .fig files. In newer matlab versions it may just save the output files , but you wont be able to open them on windows if the path length is greater than 256 characters. Ways to avoid this are to shorten .fchk file names where possible, or (less practical) run the code on a folder as close as possible to root (i.e a folder with a short a pathlength as possible).&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630592</id>
		<title>Talk:Mod:Hunt Research Group/Calc XPS Code</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630592"/>
		<updated>2017-07-27T16:29:32Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Links to Files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Links to Files==&lt;br /&gt;
Open Shell Version: [[Media:Gelius_open_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
Closed Shell Version: [[Media:Gelius_closed_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
Plot Atomic Contribs Script: [[Media:Plot Atomic Contribs V3.m]]&lt;br /&gt;
&lt;br /&gt;
*MLinpt.txt File parser(Matlab): [[Media:ML inpt att2.m]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
The purpose of this code is to calculate partial density of states (pDoS) plots and Valence band x-ray photoelectron (XP) spectra from .fchk files. There is both an open shell and a closed shell version of the code, they work in exactly the same way.&lt;br /&gt;
&lt;br /&gt;
All code was written using python 2.7 (with numpy), Multiwfn version 3.3.8, Matlab version 2014a and a cygwin(bash) shell on windows 8. It should work on windows or linux if the correct options are set.  It might not work on a mac currently due to Multiwfn not working properly (I haven&#039;t personally tested it though). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Some Theory==&lt;br /&gt;
&lt;br /&gt;
===Mulliken Population Analysis===&lt;br /&gt;
&lt;br /&gt;
A pretty key part to this code is the breakdown of molecular orbitals (MOs) in atomic orbitals (AOs, which are essentially basis functions). This is carried out in multiwfn using Mulliken population analysis, which i&#039;ll briefly summarise due to its importance.&lt;br /&gt;
&lt;br /&gt;
The basic question is &amp;quot;For MO X, how many electrons come from atomic orbital Y?&amp;quot;. Note im going to be using &amp;quot;basis functions&amp;quot; instead of &amp;quot;atomic orbitals&amp;quot; from this point, in terms of DFT calculations we interpret a basis function centered on atom X as an atomic orbital of atom X.We&#039;ll define &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the wavefunction for a &#039;&#039;&#039;single MO containing a single electron&#039;&#039;&#039;. Next we write &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the linear combination of individual basis functions (&amp;lt;math&amp;gt;\phi_{i}&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi = {{\sum\limits_{i} c_{i} \phi_{i} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since we want a number of electrons, we&#039;re interested in the formula for the electron density (&amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;) of this MO:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\rho = \langle{} \Psi | \Psi \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i} \phi_{i} }})({{\sum\limits_{i} c_{i} \phi_{i} }})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }}) + 2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If these formulae are tricky to follow, try doing it for a system with just two basis functions.&lt;br /&gt;
Note that in the third line the indice &#039;&#039;j&#039;&#039; runs over the same coefficients and basis functions as the indice &#039;&#039;i&#039;&#039;, its just used to show that the &amp;lt;math&amp;gt;{{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term only contains products between 2 different basis functions/co-efficients.&lt;br /&gt;
Hence, we now have a formula for the MO density which is purely in terms of (known) basis functions and (known) coefficients. Now its just a case of working out how we should interpret these values.&lt;br /&gt;
&lt;br /&gt;
Firstly note that &amp;lt;math&amp;gt;\phi_{i}^{2}=1&amp;lt;/math&amp;gt; (since we use normalised basis functions) hence:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
{{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }} = {{\sum\limits_{i} c_{i}^{2}}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The values of c_{i} in this expression are easy to interpret, they represent the fractional contribution of AO &#039;&#039;i&#039;&#039; to the wavefunction. The &amp;lt;math&amp;gt;2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term is more difficult to interpret, each expression in the series can be thought of as the number of electrons shared between two basis functions. i.e. the following term would represent the number of electrons shared between basis function 1 and 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{shared} = 2 c_{1}c_{2} \langle{}\phi_{1} | \phi_{2} \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we need to split this &amp;quot;shared&amp;quot; electron density between the two contributing basis functions. In Mulliken Population analysis &amp;quot;shared&amp;quot; electron density is divided equally between the two contributing basis functions. So the total electron density assigned to one basis function can be written as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{i} = c_{i}^{2} + {{\sum\limits_{j \neq i} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; represents the &#039;&#039;&#039;fractional&#039;&#039;&#039; contribution of &#039;&#039;i&#039;&#039; to the wavefunction. Hence if you had a 2-electron MO, you&#039;d simply multiply &amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; by 2.&lt;br /&gt;
&lt;br /&gt;
===What the code actually does (roughly/briefly)===&lt;br /&gt;
&lt;br /&gt;
Step 1 - The first step is to run a Mulliken population analysis on the *.fchk file. This leads to a file containing the energy/AO composition of each MO in the system (the *MLinpt.txt file). Subsequent steps vary depending on if you want partial density of states (pDoS) plots or calculated valence spectra.&lt;br /&gt;
&lt;br /&gt;
If &#039;&#039;&#039;calculating pDoS&#039;&#039;&#039; (not XPS spectra):&lt;br /&gt;
&lt;br /&gt;
For each type of atomic orbital present do the following:&lt;br /&gt;
&lt;br /&gt;
- For each MO, center a gaussian-lorentzian function at that MO energy. Multiply the intensity by the contribution of the current AO to the current MO.&lt;br /&gt;
&lt;br /&gt;
- Sum all the resultant peaks, this generates the pDOS the current atomic orbital&lt;br /&gt;
&lt;br /&gt;
Once all pDoS are generated, the total DoS could be created by summing them all. In practice the code probably just calculates the total DoS first, by just placing a gaussian-lorenztian with area=1 around each MO energy.&lt;br /&gt;
&lt;br /&gt;
If &#039;&#039;&#039;calculating XPS spectra&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
For each type of atomic orbital present do the following:&lt;br /&gt;
&lt;br /&gt;
- Multiply the fractional contributions of this AO to each MO by the AO cross-section. This value will be reffered to as the &amp;quot;intensity&amp;quot; This cross-section depends on both the AO type and the photon energy. Default values in this code are stored in tables in X_Section_Library, and custom/different values can easily be added.&lt;br /&gt;
&lt;br /&gt;
- For each MO, center a gaussian-lorentzian function at that MO energy. This area of this function is equal to the intensity calculated in the step above. &lt;br /&gt;
&lt;br /&gt;
Sum all the resultants peaks, this generates the contribution of the current AO to the valence XPS spectrum&lt;br /&gt;
Once this is repeated for each AO type, sum all those individual contributions to generate the total XPS valence spectrum.&lt;br /&gt;
&lt;br /&gt;
==&amp;quot;Installation&amp;quot; Instructions==&lt;br /&gt;
&lt;br /&gt;
All instructions will be given for the open shell version of the code. However, the process is the same except whenever these instructions say to edit the &amp;quot;gen_gelius_input_opensh.sh&amp;quot;, just do the corresponding edit on the gen_gelius_input.sh file. The Matlab scripts are EXACTLY the same for both open shell/closed shell codes.&lt;br /&gt;
&lt;br /&gt;
0) Make sure you have multiwfn (http://sobereva.com/multiwfn/) saved somewhere, python 2.x and numpy installed.&lt;br /&gt;
:a)On ubuntu Multiwfn needs an extra library, type the following line:&lt;br /&gt;
sudo apt-get install libmotif-dev&lt;br /&gt;
&lt;br /&gt;
1)Put the following files (all the .py/.sh files) somewhere in system path (e.g i use /usr/local/bin):&lt;br /&gt;
:a)Format_Multiwfn_Output_alpha.py (Format_Multiwfn_Output.py for closed shell)&lt;br /&gt;
:b)Format_Multilwfn_Output_beta.py&lt;br /&gt;
:c)Gen_Multiwfn_Input_Comms.py&lt;br /&gt;
:d)Gen_Multiwfn_Input_Comms_beta.py&lt;br /&gt;
:e)Merge_Fragment_Files.py&lt;br /&gt;
:f)gen_gelius_input_opensh.sh&lt;br /&gt;
&lt;br /&gt;
Make sure all files (including Multiwfn) have executable persmission (navigate to the folder and do &amp;quot;chmod u+x filename&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
2)In the gen_gelius_input_opensh.sh change the current lines accordingly:&lt;br /&gt;
:a) multiwfn_folder = &#039;C:/Users/Richard/Documents/Multiwfn_Installed&#039; to the directory where you store multiwfn and associated files.&lt;br /&gt;
:b) &amp;quot;cygwin=1” to “cygwin=0” if your not using a Cygwin shell.&lt;br /&gt;
:c) “old_sed=1” to “old_sed=0” if your version of sed allows the –i option (edit in place) to be used. I don’t think the standard version on mac does(meaning set old_sed=1),standard version of Cygwin does though.&lt;br /&gt;
:d) If on linux &amp;quot;cp $multiwfn_folder/Multiwfn.exe $curr_folder&amp;quot; to &amp;quot;cp $multiwfn_folder/Multiwfn $curr_folder&amp;quot; . Do the same for the line where multiwfn is deleted from current folder(&amp;quot;rm Multiwfn.exe&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
3)Put the following files somewhere in matlabs path (e.g your matlab folder in documents)&lt;br /&gt;
:a) Get_X_Section.m&lt;br /&gt;
:b) Gen_Gelius_Spectrum.m&lt;br /&gt;
&lt;br /&gt;
The Get_X_Section REALLY does need to be in matlabs path (unless you want to edit some code in Gen_Gelius_Spectrum.m). If you know what your doing in matlab  feel free to put Gen_Gelius_Spectrum.m wherever you want.&lt;br /&gt;
&lt;br /&gt;
4)Put the X_Section_Library folder wherever you want.&lt;br /&gt;
&lt;br /&gt;
5) In Get_X_Section.m modify the following line:&lt;br /&gt;
:&amp;quot;Lib_Path =&#039;C:\Users\Richard\Documents\X_Section_Library&#039; &amp;quot; to the path where you put the X_Section_Library folder in.&lt;br /&gt;
&lt;br /&gt;
6) OPTIONAL: Add the code in vim_template_script to your vimrc (c+p it somewhere in the file). &amp;quot;vim ~/.vimrc&amp;quot; to access your vimrc. You can then bring up a template input file in vim by using &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
Since i forgot to put the relevant text file in to the code folders, just c+p the below into your vimrc to get this to work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function! Gelius_Input()&lt;br /&gt;
        exe &#039;normal aCoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr.fchk\rNumb_Fragments=10\r1a=\r1t=a\r1l=TDOS\r2a=\r2t=\r2l=\r3a=\r3t=\r3l=\r4a=\r4t=\r4l=\r5a=\r5t=\r5l=\r6a=\r6t=\r6l=\r7a=\r7t=\r7l=\r8a=\r8t=\r8l=\r9a=\r9t=\r9l=\r10a=\r10t=\r10l=\rM_factor=1.0\rLink_File=&#039;&lt;br /&gt;
        exe &#039;%s/\\r/\r/g&#039;&lt;br /&gt;
endfunction&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
====Using the Example files====&lt;br /&gt;
1) Navigate (in your shell) to the folder &amp;quot;Example_files&amp;quot;. e.g for me i ran:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;cd /cygdrive/c/Users/Richard/Documents/Random_Coding/Gelius_Spectrum_Automated_Jan_2016/open_shell_code/Example_files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
2) Run this command in console(for closed shell use  gen_gelius_input.sh):&lt;br /&gt;
&lt;br /&gt;
&amp;quot;gen_gelius_input_opensh.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Command 2) will have created a folder for each .fchk file in Example_files/. Therefore you should now have folders:&lt;br /&gt;
:CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&lt;br /&gt;
:other_file&lt;br /&gt;
Within these folders are tons of output files. The most important ones are those ending in &amp;quot;MLinpt.txt&amp;quot; - these will be the input files for step 3.&lt;br /&gt;
&lt;br /&gt;
The script will run on all .fchk files in the current folder, when you do this for real you need to make sure that all the fchks are for the same system (e.g a water molecule) and that the atomic numbering is the same in all files (view--&amp;gt;labels in gaussview gives you what im calling atomic numbering).&lt;br /&gt;
&lt;br /&gt;
If anything went wrong try revisiting the installation instructions.&lt;br /&gt;
&lt;br /&gt;
3) Everything from now on is done using matlab. Theres a file called &amp;quot;pathname_file&amp;quot; in the Example_files folder which was created by the gen_gelius_input_opensh.sh script. Copy its full contents to clipboard and in MATLAB terminal type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist=&amp;lt;CTRL-V&amp;gt;&lt;br /&gt;
(&amp;lt;CTRL-V&amp;gt; means paste, rather than type out CTRL-V) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In matlab terms, plist now contains a cell array where each entry is the full path to a folder. The folder paths are those for the folders created in step 2). Hence to do this manually for just one of the two folders you&#039;d type something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist={&#039;C:\Users\Richard\Documents\Random_Coding\Gelius_Spectrum_Automated_Jan_2016\open_shell_code\Example_files\other_file&#039;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4) To create either an XPS spectrum or pDoS plots we use the Gen_Gelius_Spectrum script. This takes the following three arguments IN THE FOLLOWING ORDER:&lt;br /&gt;
:a) the plist variable we just made&lt;br /&gt;
:b) the photon energy we want to use (any negative number requests a pDoS rather than an XPS spectrum)&lt;br /&gt;
:c) the FWHM of the peaks to place around each MO energy (units = eV)&lt;br /&gt;
&lt;br /&gt;
So to create a pDoS plot you could type the following into the matlab terminal(Try this one first):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,-1,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To create an XPS spectrum taken at photon energy of 1486eV (standard lab-based value) type the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,1486,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you get an error like &amp;quot;Undefined function &#039;Gen_Gelius_Spectrum&#039; for input arguments of type &#039;cell&#039;.&amp;quot;, then your Gen_Gelius_Spectrum script probably isnt in your matlab path. (see installation instructions, or google a bit)&lt;br /&gt;
&lt;br /&gt;
If your error free then well done. Sub-folders should have been created in &amp;quot;other_file&amp;quot; and &amp;quot;CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&amp;quot;, which in turn will contain a loada output files. See the output files section of the wiki for an explanation of what these are.&lt;br /&gt;
&lt;br /&gt;
====Creating your own input files====&lt;br /&gt;
It can be named anything (except a substring of the fchk file name). The extension must be .test.&lt;br /&gt;
&lt;br /&gt;
If you followed the optional part above and made a vimscript, then a template for the input file can be brought up in vim by typing &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example input file is shown below. Each &amp;quot;fragment&amp;quot; (e.g cation,anion, alkyl group etc.) should have its own input file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
other_file.fchk&lt;br /&gt;
Numb_Fragments=4&lt;br /&gt;
1a=10-13&lt;br /&gt;
1t=a&lt;br /&gt;
1l=TDOS&lt;br /&gt;
2a=10-13&lt;br /&gt;
2t=s&lt;br /&gt;
2l=S3s&lt;br /&gt;
3a=10-13&lt;br /&gt;
3t=p&lt;br /&gt;
3l=S3p&lt;br /&gt;
4a=10-13&lt;br /&gt;
4t=d+&lt;br /&gt;
4l=S3d&lt;br /&gt;
M_factor=1.0&lt;br /&gt;
Link_File=all_frags.test&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The input file can be divided into parts as follows:&lt;br /&gt;
&lt;br /&gt;
1) The top line of the input file tells the code the name of the checkpoint file to use in the calculation. In practice you can write ANYTHING on this top line if using the gen_gelius_input*.sh script, as the script itself replaces the first line (whatevers there) with the names of all .fchks in the current folder. But SOMETHING must be written there.&lt;br /&gt;
&lt;br /&gt;
2)&#039;&#039;&#039;Numb_Fragments&#039;&#039;&#039; is the number of sub-fragments (max 10) that you want to break your pDoS down into (e.g fragment 2 corresponds to all Sulfur 3s atomic orbitals in the example above). Code will break if you get this wrong.&lt;br /&gt;
&lt;br /&gt;
3) &#039;&#039;&#039;1a/1t/1l&#039;&#039;&#039; instruct the code what to use as the total density of states. Hence 1a must be set to ALL the atoms your interested in for this fragment, 1t must be set to &amp;quot;a&amp;quot; and 1l should be set to TDOS (not sure it matters what this is set to, but to be on the safe side just use TDOS). The purpose of this fragment is essentially error checking.&lt;br /&gt;
&lt;br /&gt;
4) &#039;&#039;&#039;2a/3a/*a&#039;&#039;&#039; : a stands for atoms here, so the value of a corresponds to the labels of the atoms you want to be included in the sub-fragment. These labels are the same integers you get in gaussview when you go to view--&amp;gt;labels. Examples of valid options may be &amp;quot;1,4,5-7&amp;quot; or &amp;quot;1,3,5&amp;quot; (basically comma seperated list of integers)&lt;br /&gt;
&lt;br /&gt;
5) &#039;&#039;&#039;2t/3t/*t&#039;&#039;&#039;: t stands for &amp;quot;type of AO&amp;quot;.This is a comma seperated list with possible arguments (any combination) &amp;quot;a,s,p,d,f,g&amp;quot;. &amp;quot;a&amp;quot; corresponds to all types of AO centered of the atoms specified with the 2a/3a/*a line. s means s-type atomc orbitals (0 angular momentum), p means p-type atomic orbitals (1 angular momentum) etc. To get all AOs of a certain angular momentum and higher (up to g-type AOs) add a plus to the end of the relevant letter. e.g &amp;quot;p+&amp;quot; says &amp;quot;include all AOs with angular momemtnum greater than or equal to 1 in this sub-fragment&amp;quot;)&lt;br /&gt;
&#039;&#039;&#039;DON&#039;T&#039;&#039;&#039; use &amp;quot;a&amp;quot; with any other letter, and dont do anything else that will lead to a type of AO being requested twice (e.g p+,d)&lt;br /&gt;
&lt;br /&gt;
6) &#039;&#039;&#039;2l/3l/*l&#039;&#039;&#039;: l stands for label. If you dont care about calculating an XPS spectrum you can essentially set it to whatever you want. This tells the matlab script what cross section to use for calculating the XPS spectrum, hence it must match (case insensitive) a filename in the X_Section_Library folder. e.g S3s tells matlab to get the S3S.txt file when looking for what cross-section to use.&lt;br /&gt;
&lt;br /&gt;
7) &#039;&#039;&#039;M_factor=1.0&#039;&#039;&#039;, you really never need to modify this but make sure its present. It&#039;s purpose is to tell matlab to multiple the pDoS of this fragment (that this input file corresponds to) by the  value M_factor. The purpose is for systems where the real stoichiometry differs from that in your calculation. For example if i have a mixture of 99 water:1 anion but only a calculation on 1 water molecule mixed with 1 anion i could set M_factor for the water fragment input file to M_factor=99.0 to estimate (badly) what the actual DoS of the mixture would look like.&lt;br /&gt;
&lt;br /&gt;
8) &#039;&#039;&#039;Link_File=*&#039;&#039;&#039;. This options for if you have a fragment (e.g an anion) but want it broken into more than 10 sub-fragments (e.g this will be true for any molecule with &amp;gt;3 elements). In this case make 2 files for that fragment, and in the second  file set Link_File to the name of the first file. In the example above, this input file will essentially be merged with &amp;quot;all_frags.test&amp;quot;, and only an output file for all_frags.test will be generated.&lt;br /&gt;
&lt;br /&gt;
====More complex input file options====&lt;br /&gt;
====Gen_Gelius_Spectrum.m====&lt;br /&gt;
This code has the following options that can be changed (all are explained by comments in the .m file):&lt;br /&gt;
&amp;lt;pre&amp;gt;1)min_e/max_e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Matlab ignores any orbitals with energy below min_e or above max_e when generating the XPS spectrum. Note if you want to change this to include core orbitals or very high energy virtual orbitals then you&#039;ll also have to edit Gen_Multiwfn_Input_Comms.py to set the range in multiwfn to the one you want.(Theres currently no variable in that .py code to do that, it just uses the defaults in multiwfn. But the function you&#039;ll need to edit in Gen_Multiwfn_Input_Comms.py is Output_Header.&lt;br /&gt;
&amp;lt;pre&amp;gt;2)min_e_plotted/max_e_plotted&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These refer to the minimum/maximum binding energies to calculate spectral intensity for. The range should probably be slightly wider than the min_e/max_e range really, though thats not the default setting. &lt;br /&gt;
&amp;lt;pre&amp;gt;3)step_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The value (in eV) between calculated data points in the output spectra. For example, if set to 0.001eV then a data point will be calculated for 0eV,0.001eV,0.002eV etc. Lower values=larger files/slower runtimes.&lt;br /&gt;
&amp;lt;pre&amp;gt;4)lorentz_fraction &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Value between 0 and 1 that determines the % Lorentzian character of the lineshape used in the broadening function(the remaining % is set to gaussian). By broadening function i essentially mean the peak thats placed around every MO energy in generating these spectra. lorentz_fraction=0 will give you a pure gaussian peak, while lorentz_fraction=1 gives a pure Lorentzian peak.&lt;br /&gt;
&amp;lt;pre&amp;gt;5)savetext/figsave/savejpeg/all_contribs_output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These all control whether a certain type of output file is saved, with variable names that should be self-explanatory.Values of 1 mean save the file, other values mean dont save. set savetext=0 to not save any .txt output files, figsave=0 to not save any .fig output, savejpeg=0 to not save any .jpeg outputs and all_contribs_output=0 to not save the .txt file with a full breakdown of the spectrum. Leaving them all as 1 (except maybe the savejpeg) is strongly recommended.&lt;br /&gt;
&lt;br /&gt;
====Plot_Atomic_Contribs_V3====&lt;br /&gt;
&lt;br /&gt;
This is an optional script that plots certain breakdowns of your calculated DoS/XPS spectrum (i.e you run it AFTER Gen_Gelius_Spectrum) . Its not too hard to do the same thing in excel using the *ALL_Contribs* output file (see output file sections) but this is a lot faster. There are three types of breakdown this function can do (see pictures below):&lt;br /&gt;
&lt;br /&gt;
1) Atomic breakdown with fragments kept seperate (merge_spd=1,merge_fragments=0)&lt;br /&gt;
&lt;br /&gt;
2) Atomic orbital breakdown (merge_spd=0,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
3) Atomic breakdown (merge_spd=1,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
The function in its uploaded form takes a single argument , though there are two variables in the actual code that you need to mess with (merge_spd and merge_fragments).&lt;br /&gt;
&lt;br /&gt;
So for example, to run this on the output file from the &amp;quot;Using the Example files&amp;quot; i typed into the matlab terminal:&lt;br /&gt;
&lt;br /&gt;
Plot_Atomic_Contribs_V3(&#039;C:\Users\Richard\Desktop\Open_Shell_Code_Some_Stuff\Example_files\other_file\DoS_1ev_0pt3l&#039;)&lt;br /&gt;
&lt;br /&gt;
The argument needs to be a folder containing the output files from the Gen_Gelius_Spectrum script. You&#039;ll then get a saved graph with the breakdown you asked for and also a .txt file containing the breakdown in a comma delimited format. The output file names record the options you used to make the script (e.g &amp;quot;Plotted_Atomic_Contribs_spd0_frag1.txt&amp;quot; means merge_spd was set to 0 and merge_fragments was set to 1).&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag1.jpg|thumbnail|center| merge_spd=1,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted_Atomic_Contribs_spd0_frag1.jpg|thumbnail|center| merge_spd=0,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag0.jpg|thumbnail|center| merge_spd=1,merge_fragments=0 ]]&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
&lt;br /&gt;
The first &amp;quot;output file&amp;quot; is the *MCRF*.txt file, which just contains the commands to build the required fragment in multiwfn.&lt;br /&gt;
&lt;br /&gt;
===Files From Multiwfn===&lt;br /&gt;
Most people should be able to completely ignore these files. But in case your curious:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1) *DOS_curve*.txt&#039;&#039;&#039; Essentially a DoS plot. 1st column is energies in au, second column is TDOS of the fragment. Not really sure what the 3rd column is. No particular use for this file, but it gets auto-generated by multiwfn and i dont go out my way to delete it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2) *DOS_line*.txt&#039;&#039;&#039; Data to create a stick plot (where each MO is a stick). Plot column 1 vs column 2 as a line graph and you get an axis with sticks representing the MOs. 4th column onwards represent contribution of the various sub-fragments to each &amp;quot;stick&amp;quot;. This is the file that gets used to generate the *ML_inpt.txt file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3) *DOS_frag*.txt &#039;&#039;&#039; This file contains the sub-fragment info in a way multiwfn understands. If its renamed to DOS_frag.txt then multiwfn can import it to get the fragments (therefore can be useful for debugging, no further purpose).&lt;br /&gt;
&lt;br /&gt;
===MLinpt.txt File===&lt;br /&gt;
&lt;br /&gt;
Creation of the *ML_inpt.txt files is essentially the point of the gen_gelius_input* script. These are primarily input files for matlab, but they do have useful information in an easy to read format. If you import the file into excel and COMMA DELIMIT ONLY (i.e untick the space delimit option) you can get something like below(there are more decimal places in the actual file):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#M_FACTOR=1.0,													&lt;br /&gt;
#Energy(eV)	TDOS	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	S3S	S3P	S3D&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
-24.5		0.9	0.0	0.0	0.0	0.5	0.1	0.0	0.2	0.1	0.0	0.1	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-19.8		0.3	0.0	0.0	0.0	0.1	-0.1	0.0	0.2	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
-19.7		0.3	0.0	0.0	0.0	0.0	0.0	0.0	0.1	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The shown file is &amp;quot;all_frags_alpha_MLinpt.txt&amp;quot;, which is generated from the example files in the open shell code. As this actually comes from merging two MLinpt.txt files (gen_gelius_input.sh does this part silently) the TDOS in this case doesnt mean anything.&lt;br /&gt;
&lt;br /&gt;
The first column lists the energy of each MO in eV (1 ev ~27.212 au). For any row, columns 3(CO4S)--&amp;gt;end (S3D) list the fractional contributions of each type of atmoic orbital to the MO in that row. For example the MO with energy -19.7 eV is mainly from S3s type atomic orbitals. These fractions were determiend by multiwfn by using Mulliken population analysis.&lt;br /&gt;
&lt;br /&gt;
All the fractional contributions in the file get multiplied by the M_FACTOR value (as explained above in the Creating your own input files section). Therefore the value of M_FACTOR can easily be set after the MLinpt.txt file is created, as opposed to within the initial input file.&lt;br /&gt;
&lt;br /&gt;
===Formatted_UMOs===&lt;br /&gt;
&lt;br /&gt;
The default for the gen_gelius_input* script (i.e the settings for the version i uploaded) is to put only OCCUPIED MO energies/breakdowns into the *MLinpt.txt file. If you want all MOs (I really DONT recommend this) in the MLinpt.txt file then change all_orbs=&#039;cheese&#039; to all_orbs=&#039;ALLORBS&#039; at the top of the gen_gelius_input* script.&lt;br /&gt;
&lt;br /&gt;
Otherwise you will get a *Formatted_UMOs* file for every MLinpt.txt file you get. The format of the file is identical to the MLinpt.txt format except the MO at the top of the file corresponds to the LUMO.&lt;br /&gt;
&lt;br /&gt;
WARNING: If you use the link_files feature, then the output formatted_UMOs files DO NOT get merged. This shouldnt matter as you should never really use the formatted UMOs for anything.&lt;br /&gt;
&lt;br /&gt;
===Output From Matlab Code ===&lt;br /&gt;
&lt;br /&gt;
The matlab code firstly will create a new folder with a name reflecting the input arguments. The format is hv_FWHM_%lorenztian where hv is the photon energy, FWHM is full width half maximum of the broadeing function and %lorenztian is the amount of lorenztian mixed in the broadening function. For example the earlier command (from using example files section) &amp;quot;Gen_Gelius_Spectrum(plist,-1,1)&amp;quot; generates the folder &amp;quot;DoS_1ev_0pt3l&amp;quot;. DoS = Density of states, and means we did not use photoionisation cross sections. The 0pt3l part means our broadening function was 30% lorenztian and 70% Gaussian.&lt;br /&gt;
&lt;br /&gt;
Two .fig files will have been produced from this code, these contain matlab graphs of the output. These .fig files follow the naming (&amp;quot;filename&amp;quot; is the name of the original fchk file):&lt;br /&gt;
&lt;br /&gt;
1) filename_DoS.fig contains the total DoS plot.&lt;br /&gt;
&lt;br /&gt;
2) filename_DoS_frag_contribs.fig contains the DoS AND the pDoS of each of the fragments. For closed shell code you get 1 fragment per input file (assuming you dont use link_files), but for the open shell code each input file leads to two fragments - one for alpha electrons and one for beta electrons.&lt;br /&gt;
&lt;br /&gt;
[[File:Other_file_DoS.jpeg|thumb|center| 1) Total Density of States for a Co(SCN)4 fragment with filename other_file_DoS.fig]]&lt;br /&gt;
&lt;br /&gt;
[[File:Other file DoS frag contribs.jpeg|thumb|center| 2) Contribtuions of alpha and beta electrons to the Total Density of States for Co(SCN)4, filename other_file_DoS_frag_contribs.fig]]&lt;br /&gt;
&lt;br /&gt;
The filename_DoS.fig plot data is output in a .txt file of the same name, while each fragment in filename_DoS_frag_contribs.fig has its own .txt file. For the example above the two fragments have names &amp;quot;all_frags_alpha_other_file_DoS&amp;quot; and &amp;quot;all_frags_beta_other_file_DoS&amp;quot;. The start of the names are taken from the name of the original input file &amp;quot;all_frags.test&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The final file output is the &amp;quot;ALL_Contribs_other_file_DoS.txt&amp;quot; file. This(as the name implies) contains all contributions to the DoS spectra in a comma delimited file. The Plot_Atomic_Contribs*.m code can be run on this file to generate plots with a few different breakdowns (e.g atomic breakdowns) - see the relevant section of this wiki (not done yet....). The file will look something like below (commas replaced with tabs):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#all_frags_alpha	all_frags_beta								&lt;br /&gt;
#Sub fragments in each=	12	12							&lt;br /&gt;
#Energy(eV)	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED,numbers rounded]&lt;br /&gt;
7.5		0.00	0.01	0.31	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.51		0.00	0.01	0.33	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.52		0.00	0.01	0.34	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.53		0.00	0.01	0.35	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.54		0.00	0.01	0.36	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.55		0.00	0.02	0.37	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.56		0.00	0.02	0.39	0.05	0.14	0.00	0.00	0.13	0.00	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hopefully the format is mostly intuitive, the top two rows contain information on what the data is, and the rest contain the data. The top row contains (originally comma delimited) a list of all &amp;quot;fragments&amp;quot; names, which is the number of input files for the closed shell code and 2x the number of input files for the open shell code. The second row contains the number of sub-fragments (which should be atomic orbitals) in each fragment. In the example above each fragment had 12 types of atomic orbital.&lt;br /&gt;
&lt;br /&gt;
So for the example above column 2-14 shows contributions from &amp;quot;all_frags_alpha&amp;quot; while column 15-27 shows contributions from &amp;quot;all_frags_beta&amp;quot; (column 1 lists energies).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Bugs/Things to Watch For==&lt;br /&gt;
===Fragment Names===&lt;br /&gt;
Make sure your fragment names arent a substring of your .fchk file names. For example an input file called &amp;quot;Cl.test&amp;quot; wont work for a file called &amp;quot;BMIM_Cl.fchk&amp;quot;. However, &amp;quot;Cl_frag.test&amp;quot; will work. Therefore personally i add _frag to the end of every input file name. The other way to sort this is to set linked_files=0 in gen_gelius_input_opensh.sh, sincce the link files part of the code is where this bug comes from.&lt;br /&gt;
&lt;br /&gt;
===Fragment Error Checking===&lt;br /&gt;
Unless you manually turn it off (The &amp;quot;error=&amp;quot; option in gen_gelius_input_opensh.sh script) the code tries to check your input file for errors. Specifically it tests whether the TDOS in an input_file really is the sum of the other sub-fragments in the input(.test) file. E.g it will trigger if you request only Sulfur p-type and d-type AOs (but no s-type AOs) in the input file, or if you request all sulfur p-type AOs twice. If the error check triggers then it BREAKS the input file for matlab by putting an error msg in the first line of the &#039;&#039;&#039;*MLinpt.txt file&#039;&#039;&#039;. An example of what the error looks like is:&lt;br /&gt;
&amp;lt;pre&amp;gt;	&lt;br /&gt;
“Fragment Sum incorrect on row 19 for fchk file xxxx.fchk”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you *MLinpt.txt files arent working in matlab then this is probably the reason.&lt;br /&gt;
&lt;br /&gt;
===Pathlengths===&lt;br /&gt;
This code makes a lot of sub-folders based on the name of .fchk files. If you have really long .fchk file names its likely that you&#039;ll end up with some files which exceed the 256 character limit for a pathlength on a windows computer. In matlab 2014 this will cause the code to exit with an error, saying it cant save the .fig files. In newer matlab versions it may just save the output files , but you wont be able to open them on windows if the path length is greater than 256 characters. Ways to avoid this are to shorten .fchk file names where possible, or (less practical) run the code on a folder as close as possible to root (i.e a folder with a short a pathlength as possible).&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:ML_inpt_att2.m&amp;diff=630591</id>
		<title>File:ML inpt att2.m</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:ML_inpt_att2.m&amp;diff=630591"/>
		<updated>2017-07-27T16:28:48Z</updated>

		<summary type="html">&lt;p&gt;Rf614: Matlab parser for *MLinpt.txt files&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Matlab parser for *MLinpt.txt files&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Plot_Atomic_Contribs_V3.m&amp;diff=630590</id>
		<title>File:Plot Atomic Contribs V3.m</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Plot_Atomic_Contribs_V3.m&amp;diff=630590"/>
		<updated>2017-07-27T14:10:27Z</updated>

		<summary type="html">&lt;p&gt;Rf614: Rf614 uploaded a new version of File:Plot Atomic Contribs V3.m&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Matlab script used with code to generate pDoS/Valence XPS spectra&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Gelius_closed_shell_code_Aug2016.zip&amp;diff=630584</id>
		<title>File:Gelius closed shell code Aug2016.zip</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Gelius_closed_shell_code_Aug2016.zip&amp;diff=630584"/>
		<updated>2017-07-25T13:27:36Z</updated>

		<summary type="html">&lt;p&gt;Rf614: Rf614 uploaded a new version of File:Gelius closed shell code Aug2016.zip&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All files needed to calculate pDoS/XPS spectra for closed shell .fchk gaussian files.&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Gelius_open_shell_code_Aug2016.zip&amp;diff=630583</id>
		<title>File:Gelius open shell code Aug2016.zip</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Gelius_open_shell_code_Aug2016.zip&amp;diff=630583"/>
		<updated>2017-07-25T13:27:08Z</updated>

		<summary type="html">&lt;p&gt;Rf614: Rf614 uploaded a new version of File:Gelius open shell code Aug2016.zip&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All code required to calculate XP spectra/pDoS from a gaussian .fchk file.&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630582</id>
		<title>Talk:Mod:Hunt Research Group/Calc XPS Code</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630582"/>
		<updated>2017-07-25T13:25:17Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Some Theory */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Links to Files==&lt;br /&gt;
Open Shell Version: [[Media:Gelius_open_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
Closed Shell Version: [[Media:Gelius_closed_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
Plot Atomic Contribs Script: [[Media:Plot Atomic Contribs V3.m]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
The purpose of this code is to calculate partial density of states (pDoS) plots and Valence band x-ray photoelectron (XP) spectra from .fchk files. There is both an open shell and a closed shell version of the code, they work in exactly the same way.&lt;br /&gt;
&lt;br /&gt;
All code was written using python 2.7 (with numpy), Multiwfn version 3.3.8, Matlab version 2014a and a cygwin(bash) shell on windows 8. It should work on windows or linux if the correct options are set.  It might not work on a mac currently due to Multiwfn not working properly (I haven&#039;t personally tested it though). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Some Theory==&lt;br /&gt;
&lt;br /&gt;
===Mulliken Population Analysis===&lt;br /&gt;
&lt;br /&gt;
A pretty key part to this code is the breakdown of molecular orbitals (MOs) in atomic orbitals (AOs, which are essentially basis functions). This is carried out in multiwfn using Mulliken population analysis, which i&#039;ll briefly summarise due to its importance.&lt;br /&gt;
&lt;br /&gt;
The basic question is &amp;quot;For MO X, how many electrons come from atomic orbital Y?&amp;quot;. Note im going to be using &amp;quot;basis functions&amp;quot; instead of &amp;quot;atomic orbitals&amp;quot; from this point, in terms of DFT calculations we interpret a basis function centered on atom X as an atomic orbital of atom X.We&#039;ll define &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the wavefunction for a &#039;&#039;&#039;single MO containing a single electron&#039;&#039;&#039;. Next we write &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the linear combination of individual basis functions (&amp;lt;math&amp;gt;\phi_{i}&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi = {{\sum\limits_{i} c_{i} \phi_{i} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since we want a number of electrons, we&#039;re interested in the formula for the electron density (&amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;) of this MO:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\rho = \langle{} \Psi | \Psi \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i} \phi_{i} }})({{\sum\limits_{i} c_{i} \phi_{i} }})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }}) + 2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If these formulae are tricky to follow, try doing it for a system with just two basis functions.&lt;br /&gt;
Note that in the third line the indice &#039;&#039;j&#039;&#039; runs over the same coefficients and basis functions as the indice &#039;&#039;i&#039;&#039;, its just used to show that the &amp;lt;math&amp;gt;{{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term only contains products between 2 different basis functions/co-efficients.&lt;br /&gt;
Hence, we now have a formula for the MO density which is purely in terms of (known) basis functions and (known) coefficients. Now its just a case of working out how we should interpret these values.&lt;br /&gt;
&lt;br /&gt;
Firstly note that &amp;lt;math&amp;gt;\phi_{i}^{2}=1&amp;lt;/math&amp;gt; (since we use normalised basis functions) hence:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
{{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }} = {{\sum\limits_{i} c_{i}^{2}}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The values of c_{i} in this expression are easy to interpret, they represent the fractional contribution of AO &#039;&#039;i&#039;&#039; to the wavefunction. The &amp;lt;math&amp;gt;2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term is more difficult to interpret, each expression in the series can be thought of as the number of electrons shared between two basis functions. i.e. the following term would represent the number of electrons shared between basis function 1 and 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{shared} = 2 c_{1}c_{2} \langle{}\phi_{1} | \phi_{2} \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we need to split this &amp;quot;shared&amp;quot; electron density between the two contributing basis functions. In Mulliken Population analysis &amp;quot;shared&amp;quot; electron density is divided equally between the two contributing basis functions. So the total electron density assigned to one basis function can be written as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{i} = c_{i}^{2} + {{\sum\limits_{j \neq i} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; represents the &#039;&#039;&#039;fractional&#039;&#039;&#039; contribution of &#039;&#039;i&#039;&#039; to the wavefunction. Hence if you had a 2-electron MO, you&#039;d simply multiply &amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; by 2.&lt;br /&gt;
&lt;br /&gt;
===What the code actually does (roughly/briefly)===&lt;br /&gt;
&lt;br /&gt;
Step 1 - The first step is to run a Mulliken population analysis on the *.fchk file. This leads to a file containing the energy/AO composition of each MO in the system (the *MLinpt.txt file). Subsequent steps vary depending on if you want partial density of states (pDoS) plots or calculated valence spectra.&lt;br /&gt;
&lt;br /&gt;
If &#039;&#039;&#039;calculating pDoS&#039;&#039;&#039; (not XPS spectra):&lt;br /&gt;
&lt;br /&gt;
For each type of atomic orbital present do the following:&lt;br /&gt;
&lt;br /&gt;
- For each MO, center a gaussian-lorentzian function at that MO energy. Multiply the intensity by the contribution of the current AO to the current MO.&lt;br /&gt;
&lt;br /&gt;
- Sum all the resultant peaks, this generates the pDOS the current atomic orbital&lt;br /&gt;
&lt;br /&gt;
Once all pDoS are generated, the total DoS could be created by summing them all. In practice the code probably just calculates the total DoS first, by just placing a gaussian-lorenztian with area=1 around each MO energy.&lt;br /&gt;
&lt;br /&gt;
If &#039;&#039;&#039;calculating XPS spectra&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
For each type of atomic orbital present do the following:&lt;br /&gt;
&lt;br /&gt;
- Multiply the fractional contributions of this AO to each MO by the AO cross-section. This value will be reffered to as the &amp;quot;intensity&amp;quot; This cross-section depends on both the AO type and the photon energy. Default values in this code are stored in tables in X_Section_Library, and custom/different values can easily be added.&lt;br /&gt;
&lt;br /&gt;
- For each MO, center a gaussian-lorentzian function at that MO energy. This area of this function is equal to the intensity calculated in the step above. &lt;br /&gt;
&lt;br /&gt;
Sum all the resultants peaks, this generates the contribution of the current AO to the valence XPS spectrum&lt;br /&gt;
Once this is repeated for each AO type, sum all those individual contributions to generate the total XPS valence spectrum.&lt;br /&gt;
&lt;br /&gt;
==&amp;quot;Installation&amp;quot; Instructions==&lt;br /&gt;
&lt;br /&gt;
All instructions will be given for the open shell version of the code. However, the process is the same except whenever these instructions say to edit the &amp;quot;gen_gelius_input_opensh.sh&amp;quot;, just do the corresponding edit on the gen_gelius_input.sh file. The Matlab scripts are EXACTLY the same for both open shell/closed shell codes.&lt;br /&gt;
&lt;br /&gt;
0) Make sure you have multiwfn (https://multiwfn.codeplex.com) saved somewhere, python 2.x and numpy installed.&lt;br /&gt;
&lt;br /&gt;
1)Put the following files (all the .py/.sh files) somewhere in system path (e.g i use /usr/local/bin):&lt;br /&gt;
:a)Format_Multiwfn_Output_alpha.py (Format_Multiwfn_Output.py for closed shell)&lt;br /&gt;
:b)Format_Multilwfn_Output_beta.py&lt;br /&gt;
:c)Gen_Multiwfn_Input_Comms.py&lt;br /&gt;
:d)Gen_Multiwfn_Input_Comms_beta.py&lt;br /&gt;
:e)Merge_Fragment_Files.py&lt;br /&gt;
:f)gen_gelius_input_opensh.sh&lt;br /&gt;
&lt;br /&gt;
Make sure all files have executable persmission (navigate to the folder and do &amp;quot;chmod u+x filename&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
2)In the gen_gelius_input_opensh.sh change the current lines accordingly:&lt;br /&gt;
:a) multiwfn_folder = &#039;C:/Users/Richard/Documents/Multiwfn_Installed&#039; to the directory where you store multiwfn and associated files.&lt;br /&gt;
:b) &amp;quot;cygwin=1” to “cygwin=0” if your not using a Cygwin shell.&lt;br /&gt;
:c) “old_sed=1” to “old_sed=0” if your version of sed allows the –i option (edit in place) to be used. I don’t think the standard version on mac does(meaning set old_sed=1),standard version of Cygwin does though.&lt;br /&gt;
:d) POSSIBLY &amp;quot;cp $multiwfn_folder/Multiwfn.exe $curr_folder&amp;quot; to &amp;quot;cp $multiwfn_folder/Multiwfn $curr_folder&amp;quot; if on linux(should be really obvious if this is required). Do the same for the line where multiwfn is deleted from current folder(&amp;quot;rm Multiwfn.exe&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
3)Put the following files somewhere in matlabs path (e.g your matlab folder in documents)&lt;br /&gt;
:a) Get_X_Section.m&lt;br /&gt;
:b) Gen_Gelius_Spectrum.m&lt;br /&gt;
&lt;br /&gt;
The Get_X_Section REALLY does need to be in matlabs path (unless you want to edit some code in Gen_Gelius_Spectrum.m). If you know what your doing in matlab  feel free to put Gen_Gelius_Spectrum.m wherever you want.&lt;br /&gt;
&lt;br /&gt;
4)Put the X_Section_Library folder wherever you want.&lt;br /&gt;
&lt;br /&gt;
5) In Get_X_Section.m modify the following line:&lt;br /&gt;
:&amp;quot;Lib_Path =&#039;C:\Users\Richard\Documents\X_Section_Library&#039; &amp;quot; to the path where you put the X_Section_Library folder in.&lt;br /&gt;
&lt;br /&gt;
6) OPTIONAL: Add the code in vim_template_script to your vimrc (c+p it somewhere in the file). &amp;quot;vim ~/.vimrc&amp;quot; to access your vimrc. You can then bring up a template input file in vim by using &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
Since i forgot to put the relevant text file in to the code folders, just c+p the below into your vimrc to get this to work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function! Gelius_Input()&lt;br /&gt;
        exe &#039;normal aCoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr.fchk\rNumb_Fragments=10\r1a=\r1t=a\r1l=TDOS\r2a=\r2t=\r2l=\r3a=\r3t=\r3l=\r4a=\r4t=\r4l=\r5a=\r5t=\r5l=\r6a=\r6t=\r6l=\r7a=\r7t=\r7l=\r8a=\r8t=\r8l=\r9a=\r9t=\r9l=\r10a=\r10t=\r10l=\rM_factor=1.0\rLink_File=&#039;&lt;br /&gt;
        exe &#039;%s/\\r/\r/g&#039;&lt;br /&gt;
endfunction&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
====Using the Example files====&lt;br /&gt;
1) Navigate (in your shell) to the folder &amp;quot;Example_files&amp;quot;. e.g for me i ran:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;cd /cygdrive/c/Users/Richard/Documents/Random_Coding/Gelius_Spectrum_Automated_Jan_2016/open_shell_code/Example_files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
2) Run this command in console(for closed shell use  gen_gelius_input.sh):&lt;br /&gt;
&lt;br /&gt;
&amp;quot;gen_gelius_input_opensh.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Command 2) will have created a folder for each .fchk file in Example_files/. Therefore you should now have folders:&lt;br /&gt;
:CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&lt;br /&gt;
:other_file&lt;br /&gt;
Within these folders are tons of output files. The most important ones are those ending in &amp;quot;MLinpt.txt&amp;quot; - these will be the input files for step 3.&lt;br /&gt;
&lt;br /&gt;
The script will run on all .fchk files in the current folder, when you do this for real you need to make sure that all the fchks are for the same system (e.g a water molecule) and that the atomic numbering is the same in all files (view--&amp;gt;labels in gaussview gives you what im calling atomic numbering).&lt;br /&gt;
&lt;br /&gt;
If anything went wrong try revisiting the installation instructions.&lt;br /&gt;
&lt;br /&gt;
3) Everything from now on is done using matlab. Theres a file called &amp;quot;pathname_file&amp;quot; in the Example_files folder which was created by the gen_gelius_input_opensh.sh script. Copy its full contents to clipboard and in MATLAB terminal type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist=&amp;lt;CTRL-V&amp;gt;&lt;br /&gt;
(&amp;lt;CTRL-V&amp;gt; means paste, rather than type out CTRL-V) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In matlab terms, plist now contains a cell array where each entry is the full path to a folder. The folder paths are those for the folders created in step 2). Hence to do this manually for just one of the two folders you&#039;d type something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist={&#039;C:\Users\Richard\Documents\Random_Coding\Gelius_Spectrum_Automated_Jan_2016\open_shell_code\Example_files\other_file&#039;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4) To create either an XPS spectrum or pDoS plots we use the Gen_Gelius_Spectrum script. This takes the following three arguments IN THE FOLLOWING ORDER:&lt;br /&gt;
:a) the plist variable we just made&lt;br /&gt;
:b) the photon energy we want to use (any negative number requests a pDoS rather than an XPS spectrum)&lt;br /&gt;
:c) the FWHM of the peaks to place around each MO energy (units = eV)&lt;br /&gt;
&lt;br /&gt;
So to create a pDoS plot you could type the following into the matlab terminal(Try this one first):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,-1,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To create an XPS spectrum taken at photon energy of 1486eV (standard lab-based value) type the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,1486,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you get an error like &amp;quot;Undefined function &#039;Gen_Gelius_Spectrum&#039; for input arguments of type &#039;cell&#039;.&amp;quot;, then your Gen_Gelius_Spectrum script probably isnt in your matlab path. (see installation instructions, or google a bit)&lt;br /&gt;
&lt;br /&gt;
If your error free then well done. Sub-folders should have been created in &amp;quot;other_file&amp;quot; and &amp;quot;CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&amp;quot;, which in turn will contain a loada output files. See the output files section of the wiki for an explanation of what these are.&lt;br /&gt;
&lt;br /&gt;
====Creating your own input files====&lt;br /&gt;
If you followed the optional part above and made a vimscript, then a template for the input file can be brought up in vim by typing &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example input file is shown below. Each &amp;quot;fragment&amp;quot; (e.g cation,anion, alkyl group etc.) should have its own input file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
other_file.fchk&lt;br /&gt;
Numb_Fragments=4&lt;br /&gt;
1a=10-13&lt;br /&gt;
1t=a&lt;br /&gt;
1l=TDOS&lt;br /&gt;
2a=10-13&lt;br /&gt;
2t=s&lt;br /&gt;
2l=S3s&lt;br /&gt;
3a=10-13&lt;br /&gt;
3t=p&lt;br /&gt;
3l=S3p&lt;br /&gt;
4a=10-13&lt;br /&gt;
4t=d+&lt;br /&gt;
4l=S3d&lt;br /&gt;
M_factor=1.0&lt;br /&gt;
Link_File=all_frags.test&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The input file can be divided into parts as follows:&lt;br /&gt;
&lt;br /&gt;
1) The top line of the input file tells the code the name of the checkpoint file to use in the calculation. In practice you can write ANYTHING on this top line if using the gen_gelius_input*.sh script, as the script itself replaces the first line (whatevers there) with the names of all .fchks in the current folder. But SOMETHING must be written there.&lt;br /&gt;
&lt;br /&gt;
2)&#039;&#039;&#039;Numb_Fragments&#039;&#039;&#039; is the number of sub-fragments (max 10) that you want to break your pDoS down into (e.g fragment 2 corresponds to all Sulfur 3s atomic orbitals in the example above). Code will break if you get this wrong.&lt;br /&gt;
&lt;br /&gt;
3) &#039;&#039;&#039;1a/1t/1l&#039;&#039;&#039; instruct the code what to use as the total density of states. Hence 1a must be set to ALL the atoms your interested in for this fragment, 1t must be set to &amp;quot;a&amp;quot; and 1l should be set to TDOS (not sure it matters what this is set to, but to be on the safe side just use TDOS). The purpose of this fragment is essentially error checking.&lt;br /&gt;
&lt;br /&gt;
4) &#039;&#039;&#039;2a/3a/*a&#039;&#039;&#039; : a stands for atoms here, so the value of a corresponds to the labels of the atoms you want to be included in the sub-fragment. These labels are the same integers you get in gaussview when you go to view--&amp;gt;labels. Examples of valid options may be &amp;quot;1,4,5-7&amp;quot; or &amp;quot;1,3,5&amp;quot; (basically comma seperated list of integers)&lt;br /&gt;
&lt;br /&gt;
5) &#039;&#039;&#039;2t/3t/*t&#039;&#039;&#039;: t stands for &amp;quot;type of AO&amp;quot;.This is a comma seperated list with possible arguments (any combination) &amp;quot;a,s,p,d,f,g&amp;quot;. &amp;quot;a&amp;quot; corresponds to all types of AO centered of the atoms specified with the 2a/3a/*a line. s means s-type atomc orbitals (0 angular momentum), p means p-type atomic orbitals (1 angular momentum) etc. To get all AOs of a certain angular momentum and higher (up to g-type AOs) add a plus to the end of the relevant letter. e.g &amp;quot;p+&amp;quot; says &amp;quot;include all AOs with angular momemtnum greater than or equal to 1 in this sub-fragment&amp;quot;)&lt;br /&gt;
&#039;&#039;&#039;DON&#039;T&#039;&#039;&#039; use &amp;quot;a&amp;quot; with any other letter, and dont do anything else that will lead to a type of AO being requested twice (e.g p+,d)&lt;br /&gt;
&lt;br /&gt;
6) &#039;&#039;&#039;2l/3l/*l&#039;&#039;&#039;: l stands for label. If you dont care about calculating an XPS spectrum you can essentially set it to whatever you want. This tells the matlab script what cross section to use for calculating the XPS spectrum, hence it must match (case insensitive) a filename in the X_Section_Library folder. e.g S3s tells matlab to get the S3S.txt file when looking for what cross-section to use.&lt;br /&gt;
&lt;br /&gt;
7) &#039;&#039;&#039;M_factor=1.0&#039;&#039;&#039;, you really never need to modify this but make sure its present. It&#039;s purpose is to tell matlab to multiple the pDoS of this fragment (that this input file corresponds to) by the  value M_factor. The purpose is for systems where the real stoichiometry differs from that in your calculation. For example if i have a mixture of 99 water:1 anion but only a calculation on 1 water molecule mixed with 1 anion i could set M_factor for the water fragment input file to M_factor=99.0 to estimate (badly) what the actual DoS of the mixture would look like.&lt;br /&gt;
&lt;br /&gt;
8) &#039;&#039;&#039;Link_File=*&#039;&#039;&#039;. This options for if you have a fragment (e.g an anion) but want it broken into more than 10 sub-fragments (e.g this will be true for any molecule with &amp;gt;3 elements). In this case make 2 files for that fragment, and in the second  file set Link_File to the name of the first file. In the example above, this input file will essentially be merged with &amp;quot;all_frags.test&amp;quot;, and only an output file for all_frags.test will be generated.&lt;br /&gt;
&lt;br /&gt;
====More complex input file options====&lt;br /&gt;
====Gen_Gelius_Spectrum.m====&lt;br /&gt;
This code has the following options that can be changed (all are explained by comments in the .m file):&lt;br /&gt;
&amp;lt;pre&amp;gt;1)min_e/max_e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Matlab ignores any orbitals with energy below min_e or above max_e when generating the XPS spectrum. Note if you want to change this to include core orbitals or very high energy virtual orbitals then you&#039;ll also have to edit Gen_Multiwfn_Input_Comms.py to set the range in multiwfn to the one you want.(Theres currently no variable in that .py code to do that, it just uses the defaults in multiwfn. But the function you&#039;ll need to edit in Gen_Multiwfn_Input_Comms.py is Output_Header.&lt;br /&gt;
&amp;lt;pre&amp;gt;2)min_e_plotted/max_e_plotted&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These refer to the minimum/maximum binding energies to calculate spectral intensity for. The range should probably be slightly wider than the min_e/max_e range really, though thats not the default setting. &lt;br /&gt;
&amp;lt;pre&amp;gt;3)step_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The value (in eV) between calculated data points in the output spectra. For example, if set to 0.001eV then a data point will be calculated for 0eV,0.001eV,0.002eV etc. Lower values=larger files/slower runtimes.&lt;br /&gt;
&amp;lt;pre&amp;gt;4)lorentz_fraction &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Value between 0 and 1 that determines the % Lorentzian character of the lineshape used in the broadening function(the remaining % is set to gaussian). By broadening function i essentially mean the peak thats placed around every MO energy in generating these spectra. lorentz_fraction=0 will give you a pure gaussian peak, while lorentz_fraction=1 gives a pure Lorentzian peak.&lt;br /&gt;
&amp;lt;pre&amp;gt;5)savetext/figsave/savejpeg/all_contribs_output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These all control whether a certain type of output file is saved, with variable names that should be self-explanatory.Values of 1 mean save the file, other values mean dont save. set savetext=0 to not save any .txt output files, figsave=0 to not save any .fig output, savejpeg=0 to not save any .jpeg outputs and all_contribs_output=0 to not save the .txt file with a full breakdown of the spectrum. Leaving them all as 1 (except maybe the savejpeg) is strongly recommended.&lt;br /&gt;
&lt;br /&gt;
====Plot_Atomic_Contribs_V3====&lt;br /&gt;
&lt;br /&gt;
This is an optional script that plots certain breakdowns of your calculated DoS/XPS spectrum (i.e you run it AFTER Gen_Gelius_Spectrum) . Its not too hard to do the same thing in excel using the *ALL_Contribs* output file (see output file sections) but this is a lot faster. There are three types of breakdown this function can do (see pictures below):&lt;br /&gt;
&lt;br /&gt;
1) Atomic breakdown with fragments kept seperate (merge_spd=1,merge_fragments=0)&lt;br /&gt;
&lt;br /&gt;
2) Atomic orbital breakdown (merge_spd=0,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
3) Atomic breakdown (merge_spd=1,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
The function in its uploaded form takes a single argument , though there are two variables in the actual code that you need to mess with (merge_spd and merge_fragments).&lt;br /&gt;
&lt;br /&gt;
So for example, to run this on the output file from the &amp;quot;Using the Example files&amp;quot; i typed into the matlab terminal:&lt;br /&gt;
&lt;br /&gt;
Plot_Atomic_Contribs_V3(&#039;C:\Users\Richard\Desktop\Open_Shell_Code_Some_Stuff\Example_files\other_file\DoS_1ev_0pt3l&#039;)&lt;br /&gt;
&lt;br /&gt;
The argument needs to be a folder containing the output files from the Gen_Gelius_Spectrum script. You&#039;ll then get a saved graph with the breakdown you asked for and also a .txt file containing the breakdown in a comma delimited format. The output file names record the options you used to make the script (e.g &amp;quot;Plotted_Atomic_Contribs_spd0_frag1.txt&amp;quot; means merge_spd was set to 0 and merge_fragments was set to 1).&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag1.jpg|thumbnail|center| merge_spd=1,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted_Atomic_Contribs_spd0_frag1.jpg|thumbnail|center| merge_spd=0,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag0.jpg|thumbnail|center| merge_spd=1,merge_fragments=0 ]]&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
&lt;br /&gt;
The first &amp;quot;output file&amp;quot; is the *MCRF*.txt file, which just contains the commands to build the required fragment in multiwfn.&lt;br /&gt;
&lt;br /&gt;
===Files From Multiwfn===&lt;br /&gt;
Most people should be able to completely ignore these files. But in case your curious:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1) *DOS_curve*.txt&#039;&#039;&#039; Essentially a DoS plot. 1st column is energies in au, second column is TDOS of the fragment. Not really sure what the 3rd column is. No particular use for this file, but it gets auto-generated by multiwfn and i dont go out my way to delete it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2) *DOS_line*.txt&#039;&#039;&#039; Data to create a stick plot (where each MO is a stick). Plot column 1 vs column 2 as a line graph and you get an axis with sticks representing the MOs. 4th column onwards represent contribution of the various sub-fragments to each &amp;quot;stick&amp;quot;. This is the file that gets used to generate the *ML_inpt.txt file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3) *DOS_frag*.txt &#039;&#039;&#039; This file contains the sub-fragment info in a way multiwfn understands. If its renamed to DOS_frag.txt then multiwfn can import it to get the fragments (therefore can be useful for debugging, no further purpose).&lt;br /&gt;
&lt;br /&gt;
===MLinpt.txt File===&lt;br /&gt;
&lt;br /&gt;
Creation of the *ML_inpt.txt files is essentially the point of the gen_gelius_input* script. These are primarily input files for matlab, but they do have useful information in an easy to read format. If you import the file into excel and COMMA DELIMIT ONLY (i.e untick the space delimit option) you can get something like below(there are more decimal places in the actual file):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#M_FACTOR=1.0,													&lt;br /&gt;
#Energy(eV)	TDOS	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	S3S	S3P	S3D&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
-24.5		0.9	0.0	0.0	0.0	0.5	0.1	0.0	0.2	0.1	0.0	0.1	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-19.8		0.3	0.0	0.0	0.0	0.1	-0.1	0.0	0.2	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
-19.7		0.3	0.0	0.0	0.0	0.0	0.0	0.0	0.1	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The shown file is &amp;quot;all_frags_alpha_MLinpt.txt&amp;quot;, which is generated from the example files in the open shell code. As this actually comes from merging two MLinpt.txt files (gen_gelius_input.sh does this part silently) the TDOS in this case doesnt mean anything.&lt;br /&gt;
&lt;br /&gt;
The first column lists the energy of each MO in eV (1 ev ~27.212 au). For any row, columns 3(CO4S)--&amp;gt;end (S3D) list the fractional contributions of each type of atmoic orbital to the MO in that row. For example the MO with energy -19.7 eV is mainly from S3s type atomic orbitals. These fractions were determiend by multiwfn by using Mulliken population analysis.&lt;br /&gt;
&lt;br /&gt;
All the fractional contributions in the file get multiplied by the M_FACTOR value (as explained above in the Creating your own input files section). Therefore the value of M_FACTOR can easily be set after the MLinpt.txt file is created, as opposed to within the initial input file.&lt;br /&gt;
&lt;br /&gt;
===Formatted_UMOs===&lt;br /&gt;
&lt;br /&gt;
The default for the gen_gelius_input* script (i.e the settings for the version i uploaded) is to put only OCCUPIED MO energies/breakdowns into the *MLinpt.txt file. If you want all MOs (I really DONT recommend this) in the MLinpt.txt file then change all_orbs=&#039;cheese&#039; to all_orbs=&#039;ALLORBS&#039; at the top of the gen_gelius_input* script.&lt;br /&gt;
&lt;br /&gt;
Otherwise you will get a *Formatted_UMOs* file for every MLinpt.txt file you get. The format of the file is identical to the MLinpt.txt format except the MO at the top of the file corresponds to the LUMO.&lt;br /&gt;
&lt;br /&gt;
WARNING: If you use the link_files feature, then the output formatted_UMOs files DO NOT get merged. This shouldnt matter as you should never really use the formatted UMOs for anything.&lt;br /&gt;
&lt;br /&gt;
===Output From Matlab Code ===&lt;br /&gt;
&lt;br /&gt;
The matlab code firstly will create a new folder with a name reflecting the input arguments. The format is hv_FWHM_%lorenztian where hv is the photon energy, FWHM is full width half maximum of the broadeing function and %lorenztian is the amount of lorenztian mixed in the broadening function. For example the earlier command (from using example files section) &amp;quot;Gen_Gelius_Spectrum(plist,-1,1)&amp;quot; generates the folder &amp;quot;DoS_1ev_0pt3l&amp;quot;. DoS = Density of states, and means we did not use photoionisation cross sections. The 0pt3l part means our broadening function was 30% lorenztian and 70% Gaussian.&lt;br /&gt;
&lt;br /&gt;
Two .fig files will have been produced from this code, these contain matlab graphs of the output. These .fig files follow the naming (&amp;quot;filename&amp;quot; is the name of the original fchk file):&lt;br /&gt;
&lt;br /&gt;
1) filename_DoS.fig contains the total DoS plot.&lt;br /&gt;
&lt;br /&gt;
2) filename_DoS_frag_contribs.fig contains the DoS AND the pDoS of each of the fragments. For closed shell code you get 1 fragment per input file (assuming you dont use link_files), but for the open shell code each input file leads to two fragments - one for alpha electrons and one for beta electrons.&lt;br /&gt;
&lt;br /&gt;
[[File:Other_file_DoS.jpeg|thumb|center| 1) Total Density of States for a Co(SCN)4 fragment with filename other_file_DoS.fig]]&lt;br /&gt;
&lt;br /&gt;
[[File:Other file DoS frag contribs.jpeg|thumb|center| 2) Contribtuions of alpha and beta electrons to the Total Density of States for Co(SCN)4, filename other_file_DoS_frag_contribs.fig]]&lt;br /&gt;
&lt;br /&gt;
The filename_DoS.fig plot data is output in a .txt file of the same name, while each fragment in filename_DoS_frag_contribs.fig has its own .txt file. For the example above the two fragments have names &amp;quot;all_frags_alpha_other_file_DoS&amp;quot; and &amp;quot;all_frags_beta_other_file_DoS&amp;quot;. The start of the names are taken from the name of the original input file &amp;quot;all_frags.test&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The final file output is the &amp;quot;ALL_Contribs_other_file_DoS.txt&amp;quot; file. This(as the name implies) contains all contributions to the DoS spectra in a comma delimited file. The Plot_Atomic_Contribs*.m code can be run on this file to generate plots with a few different breakdowns (e.g atomic breakdowns) - see the relevant section of this wiki (not done yet....). The file will look something like below (commas replaced with tabs):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#all_frags_alpha	all_frags_beta								&lt;br /&gt;
#Sub fragments in each=	12	12							&lt;br /&gt;
#Energy(eV)	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED,numbers rounded]&lt;br /&gt;
7.5		0.00	0.01	0.31	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.51		0.00	0.01	0.33	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.52		0.00	0.01	0.34	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.53		0.00	0.01	0.35	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.54		0.00	0.01	0.36	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.55		0.00	0.02	0.37	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.56		0.00	0.02	0.39	0.05	0.14	0.00	0.00	0.13	0.00	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hopefully the format is mostly intuitive, the top two rows contain information on what the data is, and the rest contain the data. The top row contains (originally comma delimited) a list of all &amp;quot;fragments&amp;quot; names, which is the number of input files for the closed shell code and 2x the number of input files for the open shell code. The second row contains the number of sub-fragments (which should be atomic orbitals) in each fragment. In the example above each fragment had 12 types of atomic orbital.&lt;br /&gt;
&lt;br /&gt;
So for the example above column 2-14 shows contributions from &amp;quot;all_frags_alpha&amp;quot; while column 15-27 shows contributions from &amp;quot;all_frags_beta&amp;quot; (column 1 lists energies).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Bugs/Things to Watch For==&lt;br /&gt;
===Fragment Names===&lt;br /&gt;
Make sure your fragment names arent a substring of your .fchk file names. For example an input file called &amp;quot;Cl.test&amp;quot; wont work for a file called &amp;quot;BMIM_Cl.fchk&amp;quot;. However, &amp;quot;Cl_frag.test&amp;quot; will work. Therefore personally i add _frag to the end of every input file name. The other way to sort this is to set linked_files=0 in gen_gelius_input_opensh.sh, sincce the link files part of the code is where this bug comes from.&lt;br /&gt;
&lt;br /&gt;
===Fragment Error Checking===&lt;br /&gt;
Unless you manually turn it off (The &amp;quot;error=&amp;quot; option in gen_gelius_input_opensh.sh script) the code tries to check your input file for errors. Specifically it tests whether the TDOS in an input_file really is the sum of the other sub-fragments in the input(.test) file. E.g it will trigger if you request only Sulfur p-type and d-type AOs (but no s-type AOs) in the input file, or if you request all sulfur p-type AOs twice. If the error check triggers then it BREAKS the input file for matlab by putting an error msg in the first line of the &#039;&#039;&#039;*MLinpt.txt file&#039;&#039;&#039;. An example of what the error looks like is:&lt;br /&gt;
&amp;lt;pre&amp;gt;	&lt;br /&gt;
“Fragment Sum incorrect on row 19 for fchk file xxxx.fchk”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you *MLinpt.txt files arent working in matlab then this is probably the reason.&lt;br /&gt;
&lt;br /&gt;
===Pathlengths===&lt;br /&gt;
This code makes a lot of sub-folders based on the name of .fchk files. If you have really long .fchk file names its likely that you&#039;ll end up with some files which exceed the 256 character limit for a pathlength on a windows computer. In matlab 2014 this will cause the code to exit with an error, saying it cant save the .fig files. In newer matlab versions it may just save the output files , but you wont be able to open them on windows if the path length is greater than 256 characters. Ways to avoid this are to shorten .fchk file names where possible, or (less practical) run the code on a folder as close as possible to root (i.e a folder with a short a pathlength as possible).&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630581</id>
		<title>Talk:Mod:Hunt Research Group/Calc XPS Code</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630581"/>
		<updated>2017-07-25T10:09:32Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Links to Files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Links to Files==&lt;br /&gt;
Open Shell Version: [[Media:Gelius_open_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
Closed Shell Version: [[Media:Gelius_closed_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
Plot Atomic Contribs Script: [[Media:Plot Atomic Contribs V3.m]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
The purpose of this code is to calculate partial density of states (pDoS) plots and Valence band x-ray photoelectron (XP) spectra from .fchk files. There is both an open shell and a closed shell version of the code, they work in exactly the same way.&lt;br /&gt;
&lt;br /&gt;
All code was written using python 2.7 (with numpy), Multiwfn version 3.3.8, Matlab version 2014a and a cygwin(bash) shell on windows 8. It should work on windows or linux if the correct options are set.  It might not work on a mac currently due to Multiwfn not working properly (I haven&#039;t personally tested it though). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Some Theory==&lt;br /&gt;
&lt;br /&gt;
===Mulliken Population Analysis===&lt;br /&gt;
&lt;br /&gt;
A pretty key part to this code is the breakdown of molecular orbitals (MOs) in atomic orbitals (AOs, which are essentially basis functions). This is carried out in multiwfn using Mulliken population analysis, which i&#039;ll briefly summarise due to its importance.&lt;br /&gt;
&lt;br /&gt;
The basic question is &amp;quot;For MO X, how many electrons come from atomic orbital Y?&amp;quot;. Note im going to be using &amp;quot;basis functions&amp;quot; instead of &amp;quot;atomic orbitals&amp;quot; from this point, in terms of DFT calculations we interpret a basis function centered on atom X as an atomic orbital of atom X.We&#039;ll define &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the wavefunction for a &#039;&#039;&#039;single MO containing a single electron&#039;&#039;&#039;. Next we write &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the linear combination of individual basis functions (&amp;lt;math&amp;gt;\phi_{i}&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi = {{\sum\limits_{i} c_{i} \phi_{i} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since we want a number of electrons, we&#039;re interested in the formula for the electron density (&amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;) of this MO:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\rho = \langle{} \Psi | \Psi \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i} \phi_{i} }})({{\sum\limits_{i} c_{i} \phi_{i} }})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }}) + 2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If these formulae are tricky to follow, try doing it for a system with just two basis functions.&lt;br /&gt;
Note that in the third line the indice &#039;&#039;j&#039;&#039; runs over the same coefficients and basis functions as the indice &#039;&#039;i&#039;&#039;, its just used to show that the &amp;lt;math&amp;gt;{{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term only contains products between 2 different basis functions/co-efficients.&lt;br /&gt;
Hence, we now have a formula for the MO density which is purely in terms of (known) basis functions and (known) coefficients. Now its just a case of working out how we should interpret these values.&lt;br /&gt;
&lt;br /&gt;
Firstly note that &amp;lt;math&amp;gt;\phi_{i}^{2}=1&amp;lt;/math&amp;gt; (since we use normalised basis functions) hence:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
{{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }} = {{\sum\limits_{i} c_{i}^{2}}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The values of c_{i} in this expression are easy to interpret, they represent the fractional contribution of AO &#039;&#039;i&#039;&#039; to the wavefunction. The &amp;lt;math&amp;gt;2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term is more difficult to interpret, each expression in the series can be thought of as the number of electrons shared between two basis functions. i.e. the following term would represent the number of electrons shared between basis function 1 and 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{shared} = 2 c_{1}c_{2} \langle{}\phi_{1} | \phi_{2} \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we need to split this &amp;quot;shared&amp;quot; electron density between the two contributing basis functions. In Mulliken Population analysis &amp;quot;shared&amp;quot; electron density is divided equally between the two contributing basis functions. So the total electron density assigned to one basis function can be written as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{i} = c_{i}^{2} + {{\sum\limits_{i \neq j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; represents the &#039;&#039;&#039;fractional&#039;&#039;&#039; contribution of &#039;&#039;i&#039;&#039; to the wavefunction. Hence if you had a 2-electron MO, you&#039;d simply multiply &amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; by 2.&lt;br /&gt;
&lt;br /&gt;
===What the code actually does (roughly/briefly)===&lt;br /&gt;
&lt;br /&gt;
Step 1 - The first step is to run a Mulliken population analysis on the *.fchk file. This leads to a file containing the energy/AO composition of each MO in the system (the *MLinpt.txt file). Subsequent steps vary depending on if you want partial density of states (pDoS) plots or calculated valence spectra.&lt;br /&gt;
&lt;br /&gt;
If &#039;&#039;&#039;calculating pDoS&#039;&#039;&#039; (not XPS spectra):&lt;br /&gt;
&lt;br /&gt;
For each type of atomic orbital present do the following:&lt;br /&gt;
&lt;br /&gt;
- For each MO, center a gaussian-lorentzian function at that MO energy. Multiply the intensity by the contribution of the current AO to the current MO.&lt;br /&gt;
&lt;br /&gt;
- Sum all the resultant peaks, this generates the pDOS the current atomic orbital&lt;br /&gt;
&lt;br /&gt;
Once all pDoS are generated, the total DoS could be created by summing them all. In practice the code probably just calculates the total DoS first, by just placing a gaussian-lorenztian with area=1 around each MO energy.&lt;br /&gt;
&lt;br /&gt;
If &#039;&#039;&#039;calculating XPS spectra&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
For each type of atomic orbital present do the following:&lt;br /&gt;
&lt;br /&gt;
- Multiply the fractional contributions of this AO to each MO by the AO cross-section. This value will be reffered to as the &amp;quot;intensity&amp;quot; This cross-section depends on both the AO type and the photon energy. Default values in this code are stored in tables in X_Section_Library, and custom/different values can easily be added.&lt;br /&gt;
&lt;br /&gt;
- For each MO, center a gaussian-lorentzian function at that MO energy. This area of this function is equal to the intensity calculated in the step above. &lt;br /&gt;
&lt;br /&gt;
Sum all the resultants peaks, this generates the contribution of the current AO to the valence XPS spectrum&lt;br /&gt;
Once this is repeated for each AO type, sum all those individual contributions to generate the total XPS valence spectrum.&lt;br /&gt;
&lt;br /&gt;
==&amp;quot;Installation&amp;quot; Instructions==&lt;br /&gt;
&lt;br /&gt;
All instructions will be given for the open shell version of the code. However, the process is the same except whenever these instructions say to edit the &amp;quot;gen_gelius_input_opensh.sh&amp;quot;, just do the corresponding edit on the gen_gelius_input.sh file. The Matlab scripts are EXACTLY the same for both open shell/closed shell codes.&lt;br /&gt;
&lt;br /&gt;
0) Make sure you have multiwfn (https://multiwfn.codeplex.com) saved somewhere, python 2.x and numpy installed.&lt;br /&gt;
&lt;br /&gt;
1)Put the following files (all the .py/.sh files) somewhere in system path (e.g i use /usr/local/bin):&lt;br /&gt;
:a)Format_Multiwfn_Output_alpha.py (Format_Multiwfn_Output.py for closed shell)&lt;br /&gt;
:b)Format_Multilwfn_Output_beta.py&lt;br /&gt;
:c)Gen_Multiwfn_Input_Comms.py&lt;br /&gt;
:d)Gen_Multiwfn_Input_Comms_beta.py&lt;br /&gt;
:e)Merge_Fragment_Files.py&lt;br /&gt;
:f)gen_gelius_input_opensh.sh&lt;br /&gt;
&lt;br /&gt;
Make sure all files have executable persmission (navigate to the folder and do &amp;quot;chmod u+x filename&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
2)In the gen_gelius_input_opensh.sh change the current lines accordingly:&lt;br /&gt;
:a) multiwfn_folder = &#039;C:/Users/Richard/Documents/Multiwfn_Installed&#039; to the directory where you store multiwfn and associated files.&lt;br /&gt;
:b) &amp;quot;cygwin=1” to “cygwin=0” if your not using a Cygwin shell.&lt;br /&gt;
:c) “old_sed=1” to “old_sed=0” if your version of sed allows the –i option (edit in place) to be used. I don’t think the standard version on mac does(meaning set old_sed=1),standard version of Cygwin does though.&lt;br /&gt;
:d) POSSIBLY &amp;quot;cp $multiwfn_folder/Multiwfn.exe $curr_folder&amp;quot; to &amp;quot;cp $multiwfn_folder/Multiwfn $curr_folder&amp;quot; if on linux(should be really obvious if this is required). Do the same for the line where multiwfn is deleted from current folder(&amp;quot;rm Multiwfn.exe&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
3)Put the following files somewhere in matlabs path (e.g your matlab folder in documents)&lt;br /&gt;
:a) Get_X_Section.m&lt;br /&gt;
:b) Gen_Gelius_Spectrum.m&lt;br /&gt;
&lt;br /&gt;
The Get_X_Section REALLY does need to be in matlabs path (unless you want to edit some code in Gen_Gelius_Spectrum.m). If you know what your doing in matlab  feel free to put Gen_Gelius_Spectrum.m wherever you want.&lt;br /&gt;
&lt;br /&gt;
4)Put the X_Section_Library folder wherever you want.&lt;br /&gt;
&lt;br /&gt;
5) In Get_X_Section.m modify the following line:&lt;br /&gt;
:&amp;quot;Lib_Path =&#039;C:\Users\Richard\Documents\X_Section_Library&#039; &amp;quot; to the path where you put the X_Section_Library folder in.&lt;br /&gt;
&lt;br /&gt;
6) OPTIONAL: Add the code in vim_template_script to your vimrc (c+p it somewhere in the file). &amp;quot;vim ~/.vimrc&amp;quot; to access your vimrc. You can then bring up a template input file in vim by using &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
Since i forgot to put the relevant text file in to the code folders, just c+p the below into your vimrc to get this to work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function! Gelius_Input()&lt;br /&gt;
        exe &#039;normal aCoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr.fchk\rNumb_Fragments=10\r1a=\r1t=a\r1l=TDOS\r2a=\r2t=\r2l=\r3a=\r3t=\r3l=\r4a=\r4t=\r4l=\r5a=\r5t=\r5l=\r6a=\r6t=\r6l=\r7a=\r7t=\r7l=\r8a=\r8t=\r8l=\r9a=\r9t=\r9l=\r10a=\r10t=\r10l=\rM_factor=1.0\rLink_File=&#039;&lt;br /&gt;
        exe &#039;%s/\\r/\r/g&#039;&lt;br /&gt;
endfunction&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
====Using the Example files====&lt;br /&gt;
1) Navigate (in your shell) to the folder &amp;quot;Example_files&amp;quot;. e.g for me i ran:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;cd /cygdrive/c/Users/Richard/Documents/Random_Coding/Gelius_Spectrum_Automated_Jan_2016/open_shell_code/Example_files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
2) Run this command in console(for closed shell use  gen_gelius_input.sh):&lt;br /&gt;
&lt;br /&gt;
&amp;quot;gen_gelius_input_opensh.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Command 2) will have created a folder for each .fchk file in Example_files/. Therefore you should now have folders:&lt;br /&gt;
:CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&lt;br /&gt;
:other_file&lt;br /&gt;
Within these folders are tons of output files. The most important ones are those ending in &amp;quot;MLinpt.txt&amp;quot; - these will be the input files for step 3.&lt;br /&gt;
&lt;br /&gt;
The script will run on all .fchk files in the current folder, when you do this for real you need to make sure that all the fchks are for the same system (e.g a water molecule) and that the atomic numbering is the same in all files (view--&amp;gt;labels in gaussview gives you what im calling atomic numbering).&lt;br /&gt;
&lt;br /&gt;
If anything went wrong try revisiting the installation instructions.&lt;br /&gt;
&lt;br /&gt;
3) Everything from now on is done using matlab. Theres a file called &amp;quot;pathname_file&amp;quot; in the Example_files folder which was created by the gen_gelius_input_opensh.sh script. Copy its full contents to clipboard and in MATLAB terminal type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist=&amp;lt;CTRL-V&amp;gt;&lt;br /&gt;
(&amp;lt;CTRL-V&amp;gt; means paste, rather than type out CTRL-V) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In matlab terms, plist now contains a cell array where each entry is the full path to a folder. The folder paths are those for the folders created in step 2). Hence to do this manually for just one of the two folders you&#039;d type something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist={&#039;C:\Users\Richard\Documents\Random_Coding\Gelius_Spectrum_Automated_Jan_2016\open_shell_code\Example_files\other_file&#039;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4) To create either an XPS spectrum or pDoS plots we use the Gen_Gelius_Spectrum script. This takes the following three arguments IN THE FOLLOWING ORDER:&lt;br /&gt;
:a) the plist variable we just made&lt;br /&gt;
:b) the photon energy we want to use (any negative number requests a pDoS rather than an XPS spectrum)&lt;br /&gt;
:c) the FWHM of the peaks to place around each MO energy (units = eV)&lt;br /&gt;
&lt;br /&gt;
So to create a pDoS plot you could type the following into the matlab terminal(Try this one first):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,-1,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To create an XPS spectrum taken at photon energy of 1486eV (standard lab-based value) type the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,1486,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you get an error like &amp;quot;Undefined function &#039;Gen_Gelius_Spectrum&#039; for input arguments of type &#039;cell&#039;.&amp;quot;, then your Gen_Gelius_Spectrum script probably isnt in your matlab path. (see installation instructions, or google a bit)&lt;br /&gt;
&lt;br /&gt;
If your error free then well done. Sub-folders should have been created in &amp;quot;other_file&amp;quot; and &amp;quot;CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&amp;quot;, which in turn will contain a loada output files. See the output files section of the wiki for an explanation of what these are.&lt;br /&gt;
&lt;br /&gt;
====Creating your own input files====&lt;br /&gt;
If you followed the optional part above and made a vimscript, then a template for the input file can be brought up in vim by typing &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example input file is shown below. Each &amp;quot;fragment&amp;quot; (e.g cation,anion, alkyl group etc.) should have its own input file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
other_file.fchk&lt;br /&gt;
Numb_Fragments=4&lt;br /&gt;
1a=10-13&lt;br /&gt;
1t=a&lt;br /&gt;
1l=TDOS&lt;br /&gt;
2a=10-13&lt;br /&gt;
2t=s&lt;br /&gt;
2l=S3s&lt;br /&gt;
3a=10-13&lt;br /&gt;
3t=p&lt;br /&gt;
3l=S3p&lt;br /&gt;
4a=10-13&lt;br /&gt;
4t=d+&lt;br /&gt;
4l=S3d&lt;br /&gt;
M_factor=1.0&lt;br /&gt;
Link_File=all_frags.test&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The input file can be divided into parts as follows:&lt;br /&gt;
&lt;br /&gt;
1) The top line of the input file tells the code the name of the checkpoint file to use in the calculation. In practice you can write ANYTHING on this top line if using the gen_gelius_input*.sh script, as the script itself replaces the first line (whatevers there) with the names of all .fchks in the current folder. But SOMETHING must be written there.&lt;br /&gt;
&lt;br /&gt;
2)&#039;&#039;&#039;Numb_Fragments&#039;&#039;&#039; is the number of sub-fragments (max 10) that you want to break your pDoS down into (e.g fragment 2 corresponds to all Sulfur 3s atomic orbitals in the example above). Code will break if you get this wrong.&lt;br /&gt;
&lt;br /&gt;
3) &#039;&#039;&#039;1a/1t/1l&#039;&#039;&#039; instruct the code what to use as the total density of states. Hence 1a must be set to ALL the atoms your interested in for this fragment, 1t must be set to &amp;quot;a&amp;quot; and 1l should be set to TDOS (not sure it matters what this is set to, but to be on the safe side just use TDOS). The purpose of this fragment is essentially error checking.&lt;br /&gt;
&lt;br /&gt;
4) &#039;&#039;&#039;2a/3a/*a&#039;&#039;&#039; : a stands for atoms here, so the value of a corresponds to the labels of the atoms you want to be included in the sub-fragment. These labels are the same integers you get in gaussview when you go to view--&amp;gt;labels. Examples of valid options may be &amp;quot;1,4,5-7&amp;quot; or &amp;quot;1,3,5&amp;quot; (basically comma seperated list of integers)&lt;br /&gt;
&lt;br /&gt;
5) &#039;&#039;&#039;2t/3t/*t&#039;&#039;&#039;: t stands for &amp;quot;type of AO&amp;quot;.This is a comma seperated list with possible arguments (any combination) &amp;quot;a,s,p,d,f,g&amp;quot;. &amp;quot;a&amp;quot; corresponds to all types of AO centered of the atoms specified with the 2a/3a/*a line. s means s-type atomc orbitals (0 angular momentum), p means p-type atomic orbitals (1 angular momentum) etc. To get all AOs of a certain angular momentum and higher (up to g-type AOs) add a plus to the end of the relevant letter. e.g &amp;quot;p+&amp;quot; says &amp;quot;include all AOs with angular momemtnum greater than or equal to 1 in this sub-fragment&amp;quot;)&lt;br /&gt;
&#039;&#039;&#039;DON&#039;T&#039;&#039;&#039; use &amp;quot;a&amp;quot; with any other letter, and dont do anything else that will lead to a type of AO being requested twice (e.g p+,d)&lt;br /&gt;
&lt;br /&gt;
6) &#039;&#039;&#039;2l/3l/*l&#039;&#039;&#039;: l stands for label. If you dont care about calculating an XPS spectrum you can essentially set it to whatever you want. This tells the matlab script what cross section to use for calculating the XPS spectrum, hence it must match (case insensitive) a filename in the X_Section_Library folder. e.g S3s tells matlab to get the S3S.txt file when looking for what cross-section to use.&lt;br /&gt;
&lt;br /&gt;
7) &#039;&#039;&#039;M_factor=1.0&#039;&#039;&#039;, you really never need to modify this but make sure its present. It&#039;s purpose is to tell matlab to multiple the pDoS of this fragment (that this input file corresponds to) by the  value M_factor. The purpose is for systems where the real stoichiometry differs from that in your calculation. For example if i have a mixture of 99 water:1 anion but only a calculation on 1 water molecule mixed with 1 anion i could set M_factor for the water fragment input file to M_factor=99.0 to estimate (badly) what the actual DoS of the mixture would look like.&lt;br /&gt;
&lt;br /&gt;
8) &#039;&#039;&#039;Link_File=*&#039;&#039;&#039;. This options for if you have a fragment (e.g an anion) but want it broken into more than 10 sub-fragments (e.g this will be true for any molecule with &amp;gt;3 elements). In this case make 2 files for that fragment, and in the second  file set Link_File to the name of the first file. In the example above, this input file will essentially be merged with &amp;quot;all_frags.test&amp;quot;, and only an output file for all_frags.test will be generated.&lt;br /&gt;
&lt;br /&gt;
====More complex input file options====&lt;br /&gt;
====Gen_Gelius_Spectrum.m====&lt;br /&gt;
This code has the following options that can be changed (all are explained by comments in the .m file):&lt;br /&gt;
&amp;lt;pre&amp;gt;1)min_e/max_e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Matlab ignores any orbitals with energy below min_e or above max_e when generating the XPS spectrum. Note if you want to change this to include core orbitals or very high energy virtual orbitals then you&#039;ll also have to edit Gen_Multiwfn_Input_Comms.py to set the range in multiwfn to the one you want.(Theres currently no variable in that .py code to do that, it just uses the defaults in multiwfn. But the function you&#039;ll need to edit in Gen_Multiwfn_Input_Comms.py is Output_Header.&lt;br /&gt;
&amp;lt;pre&amp;gt;2)min_e_plotted/max_e_plotted&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These refer to the minimum/maximum binding energies to calculate spectral intensity for. The range should probably be slightly wider than the min_e/max_e range really, though thats not the default setting. &lt;br /&gt;
&amp;lt;pre&amp;gt;3)step_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The value (in eV) between calculated data points in the output spectra. For example, if set to 0.001eV then a data point will be calculated for 0eV,0.001eV,0.002eV etc. Lower values=larger files/slower runtimes.&lt;br /&gt;
&amp;lt;pre&amp;gt;4)lorentz_fraction &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Value between 0 and 1 that determines the % Lorentzian character of the lineshape used in the broadening function(the remaining % is set to gaussian). By broadening function i essentially mean the peak thats placed around every MO energy in generating these spectra. lorentz_fraction=0 will give you a pure gaussian peak, while lorentz_fraction=1 gives a pure Lorentzian peak.&lt;br /&gt;
&amp;lt;pre&amp;gt;5)savetext/figsave/savejpeg/all_contribs_output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These all control whether a certain type of output file is saved, with variable names that should be self-explanatory.Values of 1 mean save the file, other values mean dont save. set savetext=0 to not save any .txt output files, figsave=0 to not save any .fig output, savejpeg=0 to not save any .jpeg outputs and all_contribs_output=0 to not save the .txt file with a full breakdown of the spectrum. Leaving them all as 1 (except maybe the savejpeg) is strongly recommended.&lt;br /&gt;
&lt;br /&gt;
====Plot_Atomic_Contribs_V3====&lt;br /&gt;
&lt;br /&gt;
This is an optional script that plots certain breakdowns of your calculated DoS/XPS spectrum (i.e you run it AFTER Gen_Gelius_Spectrum) . Its not too hard to do the same thing in excel using the *ALL_Contribs* output file (see output file sections) but this is a lot faster. There are three types of breakdown this function can do (see pictures below):&lt;br /&gt;
&lt;br /&gt;
1) Atomic breakdown with fragments kept seperate (merge_spd=1,merge_fragments=0)&lt;br /&gt;
&lt;br /&gt;
2) Atomic orbital breakdown (merge_spd=0,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
3) Atomic breakdown (merge_spd=1,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
The function in its uploaded form takes a single argument , though there are two variables in the actual code that you need to mess with (merge_spd and merge_fragments).&lt;br /&gt;
&lt;br /&gt;
So for example, to run this on the output file from the &amp;quot;Using the Example files&amp;quot; i typed into the matlab terminal:&lt;br /&gt;
&lt;br /&gt;
Plot_Atomic_Contribs_V3(&#039;C:\Users\Richard\Desktop\Open_Shell_Code_Some_Stuff\Example_files\other_file\DoS_1ev_0pt3l&#039;)&lt;br /&gt;
&lt;br /&gt;
The argument needs to be a folder containing the output files from the Gen_Gelius_Spectrum script. You&#039;ll then get a saved graph with the breakdown you asked for and also a .txt file containing the breakdown in a comma delimited format. The output file names record the options you used to make the script (e.g &amp;quot;Plotted_Atomic_Contribs_spd0_frag1.txt&amp;quot; means merge_spd was set to 0 and merge_fragments was set to 1).&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag1.jpg|thumbnail|center| merge_spd=1,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted_Atomic_Contribs_spd0_frag1.jpg|thumbnail|center| merge_spd=0,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag0.jpg|thumbnail|center| merge_spd=1,merge_fragments=0 ]]&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
&lt;br /&gt;
The first &amp;quot;output file&amp;quot; is the *MCRF*.txt file, which just contains the commands to build the required fragment in multiwfn.&lt;br /&gt;
&lt;br /&gt;
===Files From Multiwfn===&lt;br /&gt;
Most people should be able to completely ignore these files. But in case your curious:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1) *DOS_curve*.txt&#039;&#039;&#039; Essentially a DoS plot. 1st column is energies in au, second column is TDOS of the fragment. Not really sure what the 3rd column is. No particular use for this file, but it gets auto-generated by multiwfn and i dont go out my way to delete it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2) *DOS_line*.txt&#039;&#039;&#039; Data to create a stick plot (where each MO is a stick). Plot column 1 vs column 2 as a line graph and you get an axis with sticks representing the MOs. 4th column onwards represent contribution of the various sub-fragments to each &amp;quot;stick&amp;quot;. This is the file that gets used to generate the *ML_inpt.txt file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3) *DOS_frag*.txt &#039;&#039;&#039; This file contains the sub-fragment info in a way multiwfn understands. If its renamed to DOS_frag.txt then multiwfn can import it to get the fragments (therefore can be useful for debugging, no further purpose).&lt;br /&gt;
&lt;br /&gt;
===MLinpt.txt File===&lt;br /&gt;
&lt;br /&gt;
Creation of the *ML_inpt.txt files is essentially the point of the gen_gelius_input* script. These are primarily input files for matlab, but they do have useful information in an easy to read format. If you import the file into excel and COMMA DELIMIT ONLY (i.e untick the space delimit option) you can get something like below(there are more decimal places in the actual file):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#M_FACTOR=1.0,													&lt;br /&gt;
#Energy(eV)	TDOS	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	S3S	S3P	S3D&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
-24.5		0.9	0.0	0.0	0.0	0.5	0.1	0.0	0.2	0.1	0.0	0.1	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-19.8		0.3	0.0	0.0	0.0	0.1	-0.1	0.0	0.2	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
-19.7		0.3	0.0	0.0	0.0	0.0	0.0	0.0	0.1	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The shown file is &amp;quot;all_frags_alpha_MLinpt.txt&amp;quot;, which is generated from the example files in the open shell code. As this actually comes from merging two MLinpt.txt files (gen_gelius_input.sh does this part silently) the TDOS in this case doesnt mean anything.&lt;br /&gt;
&lt;br /&gt;
The first column lists the energy of each MO in eV (1 ev ~27.212 au). For any row, columns 3(CO4S)--&amp;gt;end (S3D) list the fractional contributions of each type of atmoic orbital to the MO in that row. For example the MO with energy -19.7 eV is mainly from S3s type atomic orbitals. These fractions were determiend by multiwfn by using Mulliken population analysis.&lt;br /&gt;
&lt;br /&gt;
All the fractional contributions in the file get multiplied by the M_FACTOR value (as explained above in the Creating your own input files section). Therefore the value of M_FACTOR can easily be set after the MLinpt.txt file is created, as opposed to within the initial input file.&lt;br /&gt;
&lt;br /&gt;
===Formatted_UMOs===&lt;br /&gt;
&lt;br /&gt;
The default for the gen_gelius_input* script (i.e the settings for the version i uploaded) is to put only OCCUPIED MO energies/breakdowns into the *MLinpt.txt file. If you want all MOs (I really DONT recommend this) in the MLinpt.txt file then change all_orbs=&#039;cheese&#039; to all_orbs=&#039;ALLORBS&#039; at the top of the gen_gelius_input* script.&lt;br /&gt;
&lt;br /&gt;
Otherwise you will get a *Formatted_UMOs* file for every MLinpt.txt file you get. The format of the file is identical to the MLinpt.txt format except the MO at the top of the file corresponds to the LUMO.&lt;br /&gt;
&lt;br /&gt;
WARNING: If you use the link_files feature, then the output formatted_UMOs files DO NOT get merged. This shouldnt matter as you should never really use the formatted UMOs for anything.&lt;br /&gt;
&lt;br /&gt;
===Output From Matlab Code ===&lt;br /&gt;
&lt;br /&gt;
The matlab code firstly will create a new folder with a name reflecting the input arguments. The format is hv_FWHM_%lorenztian where hv is the photon energy, FWHM is full width half maximum of the broadeing function and %lorenztian is the amount of lorenztian mixed in the broadening function. For example the earlier command (from using example files section) &amp;quot;Gen_Gelius_Spectrum(plist,-1,1)&amp;quot; generates the folder &amp;quot;DoS_1ev_0pt3l&amp;quot;. DoS = Density of states, and means we did not use photoionisation cross sections. The 0pt3l part means our broadening function was 30% lorenztian and 70% Gaussian.&lt;br /&gt;
&lt;br /&gt;
Two .fig files will have been produced from this code, these contain matlab graphs of the output. These .fig files follow the naming (&amp;quot;filename&amp;quot; is the name of the original fchk file):&lt;br /&gt;
&lt;br /&gt;
1) filename_DoS.fig contains the total DoS plot.&lt;br /&gt;
&lt;br /&gt;
2) filename_DoS_frag_contribs.fig contains the DoS AND the pDoS of each of the fragments. For closed shell code you get 1 fragment per input file (assuming you dont use link_files), but for the open shell code each input file leads to two fragments - one for alpha electrons and one for beta electrons.&lt;br /&gt;
&lt;br /&gt;
[[File:Other_file_DoS.jpeg|thumb|center| 1) Total Density of States for a Co(SCN)4 fragment with filename other_file_DoS.fig]]&lt;br /&gt;
&lt;br /&gt;
[[File:Other file DoS frag contribs.jpeg|thumb|center| 2) Contribtuions of alpha and beta electrons to the Total Density of States for Co(SCN)4, filename other_file_DoS_frag_contribs.fig]]&lt;br /&gt;
&lt;br /&gt;
The filename_DoS.fig plot data is output in a .txt file of the same name, while each fragment in filename_DoS_frag_contribs.fig has its own .txt file. For the example above the two fragments have names &amp;quot;all_frags_alpha_other_file_DoS&amp;quot; and &amp;quot;all_frags_beta_other_file_DoS&amp;quot;. The start of the names are taken from the name of the original input file &amp;quot;all_frags.test&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The final file output is the &amp;quot;ALL_Contribs_other_file_DoS.txt&amp;quot; file. This(as the name implies) contains all contributions to the DoS spectra in a comma delimited file. The Plot_Atomic_Contribs*.m code can be run on this file to generate plots with a few different breakdowns (e.g atomic breakdowns) - see the relevant section of this wiki (not done yet....). The file will look something like below (commas replaced with tabs):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#all_frags_alpha	all_frags_beta								&lt;br /&gt;
#Sub fragments in each=	12	12							&lt;br /&gt;
#Energy(eV)	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED,numbers rounded]&lt;br /&gt;
7.5		0.00	0.01	0.31	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.51		0.00	0.01	0.33	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.52		0.00	0.01	0.34	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.53		0.00	0.01	0.35	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.54		0.00	0.01	0.36	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.55		0.00	0.02	0.37	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.56		0.00	0.02	0.39	0.05	0.14	0.00	0.00	0.13	0.00	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hopefully the format is mostly intuitive, the top two rows contain information on what the data is, and the rest contain the data. The top row contains (originally comma delimited) a list of all &amp;quot;fragments&amp;quot; names, which is the number of input files for the closed shell code and 2x the number of input files for the open shell code. The second row contains the number of sub-fragments (which should be atomic orbitals) in each fragment. In the example above each fragment had 12 types of atomic orbital.&lt;br /&gt;
&lt;br /&gt;
So for the example above column 2-14 shows contributions from &amp;quot;all_frags_alpha&amp;quot; while column 15-27 shows contributions from &amp;quot;all_frags_beta&amp;quot; (column 1 lists energies).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Bugs/Things to Watch For==&lt;br /&gt;
===Fragment Names===&lt;br /&gt;
Make sure your fragment names arent a substring of your .fchk file names. For example an input file called &amp;quot;Cl.test&amp;quot; wont work for a file called &amp;quot;BMIM_Cl.fchk&amp;quot;. However, &amp;quot;Cl_frag.test&amp;quot; will work. Therefore personally i add _frag to the end of every input file name. The other way to sort this is to set linked_files=0 in gen_gelius_input_opensh.sh, sincce the link files part of the code is where this bug comes from.&lt;br /&gt;
&lt;br /&gt;
===Fragment Error Checking===&lt;br /&gt;
Unless you manually turn it off (The &amp;quot;error=&amp;quot; option in gen_gelius_input_opensh.sh script) the code tries to check your input file for errors. Specifically it tests whether the TDOS in an input_file really is the sum of the other sub-fragments in the input(.test) file. E.g it will trigger if you request only Sulfur p-type and d-type AOs (but no s-type AOs) in the input file, or if you request all sulfur p-type AOs twice. If the error check triggers then it BREAKS the input file for matlab by putting an error msg in the first line of the &#039;&#039;&#039;*MLinpt.txt file&#039;&#039;&#039;. An example of what the error looks like is:&lt;br /&gt;
&amp;lt;pre&amp;gt;	&lt;br /&gt;
“Fragment Sum incorrect on row 19 for fchk file xxxx.fchk”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you *MLinpt.txt files arent working in matlab then this is probably the reason.&lt;br /&gt;
&lt;br /&gt;
===Pathlengths===&lt;br /&gt;
This code makes a lot of sub-folders based on the name of .fchk files. If you have really long .fchk file names its likely that you&#039;ll end up with some files which exceed the 256 character limit for a pathlength on a windows computer. In matlab 2014 this will cause the code to exit with an error, saying it cant save the .fig files. In newer matlab versions it may just save the output files , but you wont be able to open them on windows if the path length is greater than 256 characters. Ways to avoid this are to shorten .fchk file names where possible, or (less practical) run the code on a folder as close as possible to root (i.e a folder with a short a pathlength as possible).&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Plot_Atomic_Contribs_V3.m&amp;diff=630580</id>
		<title>File:Plot Atomic Contribs V3.m</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Plot_Atomic_Contribs_V3.m&amp;diff=630580"/>
		<updated>2017-07-25T10:08:55Z</updated>

		<summary type="html">&lt;p&gt;Rf614: Matlab script used with code to generate pDoS/Valence XPS spectra&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Matlab script used with code to generate pDoS/Valence XPS spectra&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Gelius_open_shell_code_Aug2016.zip&amp;diff=630579</id>
		<title>File:Gelius open shell code Aug2016.zip</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Gelius_open_shell_code_Aug2016.zip&amp;diff=630579"/>
		<updated>2017-07-24T15:58:59Z</updated>

		<summary type="html">&lt;p&gt;Rf614: Rf614 uploaded a new version of File:Gelius open shell code Aug2016.zip&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All code required to calculate XP spectra/pDoS from a gaussian .fchk file.&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Gelius_closed_shell_code_Aug2016.zip&amp;diff=630578</id>
		<title>File:Gelius closed shell code Aug2016.zip</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Gelius_closed_shell_code_Aug2016.zip&amp;diff=630578"/>
		<updated>2017-07-24T15:58:18Z</updated>

		<summary type="html">&lt;p&gt;Rf614: Rf614 uploaded a new version of File:Gelius closed shell code Aug2016.zip&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;All files needed to calculate pDoS/XPS spectra for closed shell .fchk gaussian files.&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630271</id>
		<title>Talk:Mod:Hunt Research Group/Calc XPS Code</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630271"/>
		<updated>2017-06-07T14:52:29Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Some Theory */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Links to Files==&lt;br /&gt;
Open Shell Version: [[Media:Gelius_open_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
Closed Shell Version: [[Media:Gelius_closed_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
The purpose of this code is to calculate partial density of states (pDoS) plots and Valence band x-ray photoelectron (XP) spectra from .fchk files. There is both an open shell and a closed shell version of the code, they work in exactly the same way.&lt;br /&gt;
&lt;br /&gt;
All code was written using python 2.7 (with numpy), Multiwfn version 3.3.8, Matlab version 2014a and a cygwin(bash) shell on windows 8. It should work on windows or linux if the correct options are set.  It might not work on a mac currently due to Multiwfn not working properly (I haven&#039;t personally tested it though). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Some Theory==&lt;br /&gt;
&lt;br /&gt;
===Mulliken Population Analysis===&lt;br /&gt;
&lt;br /&gt;
A pretty key part to this code is the breakdown of molecular orbitals (MOs) in atomic orbitals (AOs, which are essentially basis functions). This is carried out in multiwfn using Mulliken population analysis, which i&#039;ll briefly summarise due to its importance.&lt;br /&gt;
&lt;br /&gt;
The basic question is &amp;quot;For MO X, how many electrons come from atomic orbital Y?&amp;quot;. Note im going to be using &amp;quot;basis functions&amp;quot; instead of &amp;quot;atomic orbitals&amp;quot; from this point, in terms of DFT calculations we interpret a basis function centered on atom X as an atomic orbital of atom X.We&#039;ll define &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the wavefunction for a &#039;&#039;&#039;single MO containing a single electron&#039;&#039;&#039;. Next we write &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the linear combination of individual basis functions (&amp;lt;math&amp;gt;\phi_{i}&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi = {{\sum\limits_{i} c_{i} \phi_{i} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since we want a number of electrons, we&#039;re interested in the formula for the electron density (&amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;) of this MO:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\rho = \langle{} \Psi | \Psi \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i} \phi_{i} }})({{\sum\limits_{i} c_{i} \phi_{i} }})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }}) + 2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If these formulae are tricky to follow, try doing it for a system with just two basis functions.&lt;br /&gt;
Note that in the third line the indice &#039;&#039;j&#039;&#039; runs over the same coefficients and basis functions as the indice &#039;&#039;i&#039;&#039;, its just used to show that the &amp;lt;math&amp;gt;{{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term only contains products between 2 different basis functions/co-efficients.&lt;br /&gt;
Hence, we now have a formula for the MO density which is purely in terms of (known) basis functions and (known) coefficients. Now its just a case of working out how we should interpret these values.&lt;br /&gt;
&lt;br /&gt;
Firstly note that &amp;lt;math&amp;gt;\phi_{i}^{2}=1&amp;lt;/math&amp;gt; (since we use normalised basis functions) hence:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
{{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }} = {{\sum\limits_{i} c_{i}^{2}}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The values of c_{i} in this expression are easy to interpret, they represent the fractional contribution of AO &#039;&#039;i&#039;&#039; to the wavefunction. The &amp;lt;math&amp;gt;2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term is more difficult to interpret, each expression in the series can be thought of as the number of electrons shared between two basis functions. i.e. the following term would represent the number of electrons shared between basis function 1 and 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{shared} = 2 c_{1}c_{2} \langle{}\phi_{1} | \phi_{2} \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we need to split this &amp;quot;shared&amp;quot; electron density between the two contributing basis functions. In Mulliken Population analysis &amp;quot;shared&amp;quot; electron density is divided equally between the two contributing basis functions. So the total electron density assigned to one basis function can be written as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{i} = c_{i}^{2} + {{\sum\limits_{i \neq j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; represents the &#039;&#039;&#039;fractional&#039;&#039;&#039; contribution of &#039;&#039;i&#039;&#039; to the wavefunction. Hence if you had a 2-electron MO, you&#039;d simply multiply &amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; by 2.&lt;br /&gt;
&lt;br /&gt;
===What the code actually does (roughly/briefly)===&lt;br /&gt;
&lt;br /&gt;
Step 1 - The first step is to run a Mulliken population analysis on the *.fchk file. This leads to a file containing the energy/AO composition of each MO in the system (the *MLinpt.txt file). Subsequent steps vary depending on if you want partial density of states (pDoS) plots or calculated valence spectra.&lt;br /&gt;
&lt;br /&gt;
If &#039;&#039;&#039;calculating pDoS&#039;&#039;&#039; (not XPS spectra):&lt;br /&gt;
&lt;br /&gt;
For each type of atomic orbital present do the following:&lt;br /&gt;
&lt;br /&gt;
- For each MO, center a gaussian-lorentzian function at that MO energy. Multiply the intensity by the contribution of the current AO to the current MO.&lt;br /&gt;
&lt;br /&gt;
- Sum all the resultant peaks, this generates the pDOS the current atomic orbital&lt;br /&gt;
&lt;br /&gt;
Once all pDoS are generated, the total DoS could be created by summing them all. In practice the code probably just calculates the total DoS first, by just placing a gaussian-lorenztian with area=1 around each MO energy.&lt;br /&gt;
&lt;br /&gt;
If &#039;&#039;&#039;calculating XPS spectra&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
For each type of atomic orbital present do the following:&lt;br /&gt;
&lt;br /&gt;
- Multiply the fractional contributions of this AO to each MO by the AO cross-section. This value will be reffered to as the &amp;quot;intensity&amp;quot; This cross-section depends on both the AO type and the photon energy. Default values in this code are stored in tables in X_Section_Library, and custom/different values can easily be added.&lt;br /&gt;
&lt;br /&gt;
- For each MO, center a gaussian-lorentzian function at that MO energy. This area of this function is equal to the intensity calculated in the step above. &lt;br /&gt;
&lt;br /&gt;
Sum all the resultants peaks, this generates the contribution of the current AO to the valence XPS spectrum&lt;br /&gt;
Once this is repeated for each AO type, sum all those individual contributions to generate the total XPS valence spectrum.&lt;br /&gt;
&lt;br /&gt;
==&amp;quot;Installation&amp;quot; Instructions==&lt;br /&gt;
&lt;br /&gt;
All instructions will be given for the open shell version of the code. However, the process is the same except whenever these instructions say to edit the &amp;quot;gen_gelius_input_opensh.sh&amp;quot;, just do the corresponding edit on the gen_gelius_input.sh file. The Matlab scripts are EXACTLY the same for both open shell/closed shell codes.&lt;br /&gt;
&lt;br /&gt;
0) Make sure you have multiwfn (https://multiwfn.codeplex.com) saved somewhere, python 2.x and numpy installed.&lt;br /&gt;
&lt;br /&gt;
1)Put the following files (all the .py/.sh files) somewhere in system path (e.g i use /usr/local/bin):&lt;br /&gt;
:a)Format_Multiwfn_Output_alpha.py (Format_Multiwfn_Output.py for closed shell)&lt;br /&gt;
:b)Format_Multilwfn_Output_beta.py&lt;br /&gt;
:c)Gen_Multiwfn_Input_Comms.py&lt;br /&gt;
:d)Gen_Multiwfn_Input_Comms_beta.py&lt;br /&gt;
:e)Merge_Fragment_Files.py&lt;br /&gt;
:f)gen_gelius_input_opensh.sh&lt;br /&gt;
&lt;br /&gt;
Make sure all files have executable persmission (navigate to the folder and do &amp;quot;chmod u+x filename&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
2)In the gen_gelius_input_opensh.sh change the current lines accordingly:&lt;br /&gt;
:a) multiwfn_folder = &#039;C:/Users/Richard/Documents/Multiwfn_Installed&#039; to the directory where you store multiwfn and associated files.&lt;br /&gt;
:b) &amp;quot;cygwin=1” to “cygwin=0” if your not using a Cygwin shell.&lt;br /&gt;
:c) “old_sed=1” to “old_sed=0” if your version of sed allows the –i option (edit in place) to be used. I don’t think the standard version on mac does(meaning set old_sed=1),standard version of Cygwin does though.&lt;br /&gt;
:d) POSSIBLY &amp;quot;cp $multiwfn_folder/Multiwfn.exe $curr_folder&amp;quot; to &amp;quot;cp $multiwfn_folder/Multiwfn $curr_folder&amp;quot; if on linux(should be really obvious if this is required). Do the same for the line where multiwfn is deleted from current folder(&amp;quot;rm Multiwfn.exe&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
3)Put the following files somewhere in matlabs path (e.g your matlab folder in documents)&lt;br /&gt;
:a) Get_X_Section.m&lt;br /&gt;
:b) Gen_Gelius_Spectrum.m&lt;br /&gt;
&lt;br /&gt;
The Get_X_Section REALLY does need to be in matlabs path (unless you want to edit some code in Gen_Gelius_Spectrum.m). If you know what your doing in matlab  feel free to put Gen_Gelius_Spectrum.m wherever you want.&lt;br /&gt;
&lt;br /&gt;
4)Put the X_Section_Library folder wherever you want.&lt;br /&gt;
&lt;br /&gt;
5) In Get_X_Section.m modify the following line:&lt;br /&gt;
:&amp;quot;Lib_Path =&#039;C:\Users\Richard\Documents\X_Section_Library&#039; &amp;quot; to the path where you put the X_Section_Library folder in.&lt;br /&gt;
&lt;br /&gt;
6) OPTIONAL: Add the code in vim_template_script to your vimrc (c+p it somewhere in the file). &amp;quot;vim ~/.vimrc&amp;quot; to access your vimrc. You can then bring up a template input file in vim by using &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
Since i forgot to put the relevant text file in to the code folders, just c+p the below into your vimrc to get this to work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function! Gelius_Input()&lt;br /&gt;
        exe &#039;normal aCoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr.fchk\rNumb_Fragments=10\r1a=\r1t=a\r1l=TDOS\r2a=\r2t=\r2l=\r3a=\r3t=\r3l=\r4a=\r4t=\r4l=\r5a=\r5t=\r5l=\r6a=\r6t=\r6l=\r7a=\r7t=\r7l=\r8a=\r8t=\r8l=\r9a=\r9t=\r9l=\r10a=\r10t=\r10l=\rM_factor=1.0\rLink_File=&#039;&lt;br /&gt;
        exe &#039;%s/\\r/\r/g&#039;&lt;br /&gt;
endfunction&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
====Using the Example files====&lt;br /&gt;
1) Navigate (in your shell) to the folder &amp;quot;Example_files&amp;quot;. e.g for me i ran:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;cd /cygdrive/c/Users/Richard/Documents/Random_Coding/Gelius_Spectrum_Automated_Jan_2016/open_shell_code/Example_files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
2) Run this command in console(for closed shell use  gen_gelius_input.sh):&lt;br /&gt;
&lt;br /&gt;
&amp;quot;gen_gelius_input_opensh.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Command 2) will have created a folder for each .fchk file in Example_files/. Therefore you should now have folders:&lt;br /&gt;
:CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&lt;br /&gt;
:other_file&lt;br /&gt;
Within these folders are tons of output files. The most important ones are those ending in &amp;quot;MLinpt.txt&amp;quot; - these will be the input files for step 3.&lt;br /&gt;
&lt;br /&gt;
The script will run on all .fchk files in the current folder, when you do this for real you need to make sure that all the fchks are for the same system (e.g a water molecule) and that the atomic numbering is the same in all files (view--&amp;gt;labels in gaussview gives you what im calling atomic numbering).&lt;br /&gt;
&lt;br /&gt;
If anything went wrong try revisiting the installation instructions.&lt;br /&gt;
&lt;br /&gt;
3) Everything from now on is done using matlab. Theres a file called &amp;quot;pathname_file&amp;quot; in the Example_files folder which was created by the gen_gelius_input_opensh.sh script. Copy its full contents to clipboard and in MATLAB terminal type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist=&amp;lt;CTRL-V&amp;gt;&lt;br /&gt;
(&amp;lt;CTRL-V&amp;gt; means paste, rather than type out CTRL-V) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In matlab terms, plist now contains a cell array where each entry is the full path to a folder. The folder paths are those for the folders created in step 2). Hence to do this manually for just one of the two folders you&#039;d type something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist={&#039;C:\Users\Richard\Documents\Random_Coding\Gelius_Spectrum_Automated_Jan_2016\open_shell_code\Example_files\other_file&#039;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4) To create either an XPS spectrum or pDoS plots we use the Gen_Gelius_Spectrum script. This takes the following three arguments IN THE FOLLOWING ORDER:&lt;br /&gt;
:a) the plist variable we just made&lt;br /&gt;
:b) the photon energy we want to use (any negative number requests a pDoS rather than an XPS spectrum)&lt;br /&gt;
:c) the FWHM of the peaks to place around each MO energy (units = eV)&lt;br /&gt;
&lt;br /&gt;
So to create a pDoS plot you could type the following into the matlab terminal(Try this one first):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,-1,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To create an XPS spectrum taken at photon energy of 1486eV (standard lab-based value) type the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,1486,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you get an error like &amp;quot;Undefined function &#039;Gen_Gelius_Spectrum&#039; for input arguments of type &#039;cell&#039;.&amp;quot;, then your Gen_Gelius_Spectrum script probably isnt in your matlab path. (see installation instructions, or google a bit)&lt;br /&gt;
&lt;br /&gt;
If your error free then well done. Sub-folders should have been created in &amp;quot;other_file&amp;quot; and &amp;quot;CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&amp;quot;, which in turn will contain a loada output files. See the output files section of the wiki for an explanation of what these are.&lt;br /&gt;
&lt;br /&gt;
====Creating your own input files====&lt;br /&gt;
If you followed the optional part above and made a vimscript, then a template for the input file can be brought up in vim by typing &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example input file is shown below. Each &amp;quot;fragment&amp;quot; (e.g cation,anion, alkyl group etc.) should have its own input file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
other_file.fchk&lt;br /&gt;
Numb_Fragments=4&lt;br /&gt;
1a=10-13&lt;br /&gt;
1t=a&lt;br /&gt;
1l=TDOS&lt;br /&gt;
2a=10-13&lt;br /&gt;
2t=s&lt;br /&gt;
2l=S3s&lt;br /&gt;
3a=10-13&lt;br /&gt;
3t=p&lt;br /&gt;
3l=S3p&lt;br /&gt;
4a=10-13&lt;br /&gt;
4t=d+&lt;br /&gt;
4l=S3d&lt;br /&gt;
M_factor=1.0&lt;br /&gt;
Link_File=all_frags.test&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The input file can be divided into parts as follows:&lt;br /&gt;
&lt;br /&gt;
1) The top line of the input file tells the code the name of the checkpoint file to use in the calculation. In practice you can write ANYTHING on this top line if using the gen_gelius_input*.sh script, as the script itself replaces the first line (whatevers there) with the names of all .fchks in the current folder. But SOMETHING must be written there.&lt;br /&gt;
&lt;br /&gt;
2)&#039;&#039;&#039;Numb_Fragments&#039;&#039;&#039; is the number of sub-fragments (max 10) that you want to break your pDoS down into (e.g fragment 2 corresponds to all Sulfur 3s atomic orbitals in the example above). Code will break if you get this wrong.&lt;br /&gt;
&lt;br /&gt;
3) &#039;&#039;&#039;1a/1t/1l&#039;&#039;&#039; instruct the code what to use as the total density of states. Hence 1a must be set to ALL the atoms your interested in for this fragment, 1t must be set to &amp;quot;a&amp;quot; and 1l should be set to TDOS (not sure it matters what this is set to, but to be on the safe side just use TDOS). The purpose of this fragment is essentially error checking.&lt;br /&gt;
&lt;br /&gt;
4) &#039;&#039;&#039;2a/3a/*a&#039;&#039;&#039; : a stands for atoms here, so the value of a corresponds to the labels of the atoms you want to be included in the sub-fragment. These labels are the same integers you get in gaussview when you go to view--&amp;gt;labels. Examples of valid options may be &amp;quot;1,4,5-7&amp;quot; or &amp;quot;1,3,5&amp;quot; (basically comma seperated list of integers)&lt;br /&gt;
&lt;br /&gt;
5) &#039;&#039;&#039;2t/3t/*t&#039;&#039;&#039;: t stands for &amp;quot;type of AO&amp;quot;.This is a comma seperated list with possible arguments (any combination) &amp;quot;a,s,p,d,f,g&amp;quot;. &amp;quot;a&amp;quot; corresponds to all types of AO centered of the atoms specified with the 2a/3a/*a line. s means s-type atomc orbitals (0 angular momentum), p means p-type atomic orbitals (1 angular momentum) etc. To get all AOs of a certain angular momentum and higher (up to g-type AOs) add a plus to the end of the relevant letter. e.g &amp;quot;p+&amp;quot; says &amp;quot;include all AOs with angular momemtnum greater than or equal to 1 in this sub-fragment&amp;quot;)&lt;br /&gt;
&#039;&#039;&#039;DON&#039;T&#039;&#039;&#039; use &amp;quot;a&amp;quot; with any other letter, and dont do anything else that will lead to a type of AO being requested twice (e.g p+,d)&lt;br /&gt;
&lt;br /&gt;
6) &#039;&#039;&#039;2l/3l/*l&#039;&#039;&#039;: l stands for label. If you dont care about calculating an XPS spectrum you can essentially set it to whatever you want. This tells the matlab script what cross section to use for calculating the XPS spectrum, hence it must match (case insensitive) a filename in the X_Section_Library folder. e.g S3s tells matlab to get the S3S.txt file when looking for what cross-section to use.&lt;br /&gt;
&lt;br /&gt;
7) &#039;&#039;&#039;M_factor=1.0&#039;&#039;&#039;, you really never need to modify this but make sure its present. It&#039;s purpose is to tell matlab to multiple the pDoS of this fragment (that this input file corresponds to) by the  value M_factor. The purpose is for systems where the real stoichiometry differs from that in your calculation. For example if i have a mixture of 99 water:1 anion but only a calculation on 1 water molecule mixed with 1 anion i could set M_factor for the water fragment input file to M_factor=99.0 to estimate (badly) what the actual DoS of the mixture would look like.&lt;br /&gt;
&lt;br /&gt;
8) &#039;&#039;&#039;Link_File=*&#039;&#039;&#039;. This options for if you have a fragment (e.g an anion) but want it broken into more than 10 sub-fragments (e.g this will be true for any molecule with &amp;gt;3 elements). In this case make 2 files for that fragment, and in the second  file set Link_File to the name of the first file. In the example above, this input file will essentially be merged with &amp;quot;all_frags.test&amp;quot;, and only an output file for all_frags.test will be generated.&lt;br /&gt;
&lt;br /&gt;
====More complex input file options====&lt;br /&gt;
====Gen_Gelius_Spectrum.m====&lt;br /&gt;
This code has the following options that can be changed (all are explained by comments in the .m file):&lt;br /&gt;
&amp;lt;pre&amp;gt;1)min_e/max_e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Matlab ignores any orbitals with energy below min_e or above max_e when generating the XPS spectrum. Note if you want to change this to include core orbitals or very high energy virtual orbitals then you&#039;ll also have to edit Gen_Multiwfn_Input_Comms.py to set the range in multiwfn to the one you want.(Theres currently no variable in that .py code to do that, it just uses the defaults in multiwfn. But the function you&#039;ll need to edit in Gen_Multiwfn_Input_Comms.py is Output_Header.&lt;br /&gt;
&amp;lt;pre&amp;gt;2)min_e_plotted/max_e_plotted&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These refer to the minimum/maximum binding energies to calculate spectral intensity for. The range should probably be slightly wider than the min_e/max_e range really, though thats not the default setting. &lt;br /&gt;
&amp;lt;pre&amp;gt;3)step_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The value (in eV) between calculated data points in the output spectra. For example, if set to 0.001eV then a data point will be calculated for 0eV,0.001eV,0.002eV etc. Lower values=larger files/slower runtimes.&lt;br /&gt;
&amp;lt;pre&amp;gt;4)lorentz_fraction &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Value between 0 and 1 that determines the % Lorentzian character of the lineshape used in the broadening function(the remaining % is set to gaussian). By broadening function i essentially mean the peak thats placed around every MO energy in generating these spectra. lorentz_fraction=0 will give you a pure gaussian peak, while lorentz_fraction=1 gives a pure Lorentzian peak.&lt;br /&gt;
&amp;lt;pre&amp;gt;5)savetext/figsave/savejpeg/all_contribs_output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These all control whether a certain type of output file is saved, with variable names that should be self-explanatory.Values of 1 mean save the file, other values mean dont save. set savetext=0 to not save any .txt output files, figsave=0 to not save any .fig output, savejpeg=0 to not save any .jpeg outputs and all_contribs_output=0 to not save the .txt file with a full breakdown of the spectrum. Leaving them all as 1 (except maybe the savejpeg) is strongly recommended.&lt;br /&gt;
&lt;br /&gt;
====Plot_Atomic_Contribs_V3====&lt;br /&gt;
&lt;br /&gt;
This is an optional script that plots certain breakdowns of your calculated DoS/XPS spectrum (i.e you run it AFTER Gen_Gelius_Spectrum) . Its not too hard to do the same thing in excel using the *ALL_Contribs* output file (see output file sections) but this is a lot faster. There are three types of breakdown this function can do (see pictures below):&lt;br /&gt;
&lt;br /&gt;
1) Atomic breakdown with fragments kept seperate (merge_spd=1,merge_fragments=0)&lt;br /&gt;
&lt;br /&gt;
2) Atomic orbital breakdown (merge_spd=0,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
3) Atomic breakdown (merge_spd=1,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
The function in its uploaded form takes a single argument , though there are two variables in the actual code that you need to mess with (merge_spd and merge_fragments).&lt;br /&gt;
&lt;br /&gt;
So for example, to run this on the output file from the &amp;quot;Using the Example files&amp;quot; i typed into the matlab terminal:&lt;br /&gt;
&lt;br /&gt;
Plot_Atomic_Contribs_V3(&#039;C:\Users\Richard\Desktop\Open_Shell_Code_Some_Stuff\Example_files\other_file\DoS_1ev_0pt3l&#039;)&lt;br /&gt;
&lt;br /&gt;
The argument needs to be a folder containing the output files from the Gen_Gelius_Spectrum script. You&#039;ll then get a saved graph with the breakdown you asked for and also a .txt file containing the breakdown in a comma delimited format. The output file names record the options you used to make the script (e.g &amp;quot;Plotted_Atomic_Contribs_spd0_frag1.txt&amp;quot; means merge_spd was set to 0 and merge_fragments was set to 1).&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag1.jpg|thumbnail|center| merge_spd=1,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted_Atomic_Contribs_spd0_frag1.jpg|thumbnail|center| merge_spd=0,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag0.jpg|thumbnail|center| merge_spd=1,merge_fragments=0 ]]&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
&lt;br /&gt;
The first &amp;quot;output file&amp;quot; is the *MCRF*.txt file, which just contains the commands to build the required fragment in multiwfn.&lt;br /&gt;
&lt;br /&gt;
===Files From Multiwfn===&lt;br /&gt;
Most people should be able to completely ignore these files. But in case your curious:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1) *DOS_curve*.txt&#039;&#039;&#039; Essentially a DoS plot. 1st column is energies in au, second column is TDOS of the fragment. Not really sure what the 3rd column is. No particular use for this file, but it gets auto-generated by multiwfn and i dont go out my way to delete it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2) *DOS_line*.txt&#039;&#039;&#039; Data to create a stick plot (where each MO is a stick). Plot column 1 vs column 2 as a line graph and you get an axis with sticks representing the MOs. 4th column onwards represent contribution of the various sub-fragments to each &amp;quot;stick&amp;quot;. This is the file that gets used to generate the *ML_inpt.txt file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3) *DOS_frag*.txt &#039;&#039;&#039; This file contains the sub-fragment info in a way multiwfn understands. If its renamed to DOS_frag.txt then multiwfn can import it to get the fragments (therefore can be useful for debugging, no further purpose).&lt;br /&gt;
&lt;br /&gt;
===MLinpt.txt File===&lt;br /&gt;
&lt;br /&gt;
Creation of the *ML_inpt.txt files is essentially the point of the gen_gelius_input* script. These are primarily input files for matlab, but they do have useful information in an easy to read format. If you import the file into excel and COMMA DELIMIT ONLY (i.e untick the space delimit option) you can get something like below(there are more decimal places in the actual file):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#M_FACTOR=1.0,													&lt;br /&gt;
#Energy(eV)	TDOS	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	S3S	S3P	S3D&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
-24.5		0.9	0.0	0.0	0.0	0.5	0.1	0.0	0.2	0.1	0.0	0.1	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-19.8		0.3	0.0	0.0	0.0	0.1	-0.1	0.0	0.2	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
-19.7		0.3	0.0	0.0	0.0	0.0	0.0	0.0	0.1	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The shown file is &amp;quot;all_frags_alpha_MLinpt.txt&amp;quot;, which is generated from the example files in the open shell code. As this actually comes from merging two MLinpt.txt files (gen_gelius_input.sh does this part silently) the TDOS in this case doesnt mean anything.&lt;br /&gt;
&lt;br /&gt;
The first column lists the energy of each MO in eV (1 ev ~27.212 au). For any row, columns 3(CO4S)--&amp;gt;end (S3D) list the fractional contributions of each type of atmoic orbital to the MO in that row. For example the MO with energy -19.7 eV is mainly from S3s type atomic orbitals. These fractions were determiend by multiwfn by using Mulliken population analysis.&lt;br /&gt;
&lt;br /&gt;
All the fractional contributions in the file get multiplied by the M_FACTOR value (as explained above in the Creating your own input files section). Therefore the value of M_FACTOR can easily be set after the MLinpt.txt file is created, as opposed to within the initial input file.&lt;br /&gt;
&lt;br /&gt;
===Formatted_UMOs===&lt;br /&gt;
&lt;br /&gt;
The default for the gen_gelius_input* script (i.e the settings for the version i uploaded) is to put only OCCUPIED MO energies/breakdowns into the *MLinpt.txt file. If you want all MOs (I really DONT recommend this) in the MLinpt.txt file then change all_orbs=&#039;cheese&#039; to all_orbs=&#039;ALLORBS&#039; at the top of the gen_gelius_input* script.&lt;br /&gt;
&lt;br /&gt;
Otherwise you will get a *Formatted_UMOs* file for every MLinpt.txt file you get. The format of the file is identical to the MLinpt.txt format except the MO at the top of the file corresponds to the LUMO.&lt;br /&gt;
&lt;br /&gt;
WARNING: If you use the link_files feature, then the output formatted_UMOs files DO NOT get merged. This shouldnt matter as you should never really use the formatted UMOs for anything.&lt;br /&gt;
&lt;br /&gt;
===Output From Matlab Code ===&lt;br /&gt;
&lt;br /&gt;
The matlab code firstly will create a new folder with a name reflecting the input arguments. The format is hv_FWHM_%lorenztian where hv is the photon energy, FWHM is full width half maximum of the broadeing function and %lorenztian is the amount of lorenztian mixed in the broadening function. For example the earlier command (from using example files section) &amp;quot;Gen_Gelius_Spectrum(plist,-1,1)&amp;quot; generates the folder &amp;quot;DoS_1ev_0pt3l&amp;quot;. DoS = Density of states, and means we did not use photoionisation cross sections. The 0pt3l part means our broadening function was 30% lorenztian and 70% Gaussian.&lt;br /&gt;
&lt;br /&gt;
Two .fig files will have been produced from this code, these contain matlab graphs of the output. These .fig files follow the naming (&amp;quot;filename&amp;quot; is the name of the original fchk file):&lt;br /&gt;
&lt;br /&gt;
1) filename_DoS.fig contains the total DoS plot.&lt;br /&gt;
&lt;br /&gt;
2) filename_DoS_frag_contribs.fig contains the DoS AND the pDoS of each of the fragments. For closed shell code you get 1 fragment per input file (assuming you dont use link_files), but for the open shell code each input file leads to two fragments - one for alpha electrons and one for beta electrons.&lt;br /&gt;
&lt;br /&gt;
[[File:Other_file_DoS.jpeg|thumb|center| 1) Total Density of States for a Co(SCN)4 fragment with filename other_file_DoS.fig]]&lt;br /&gt;
&lt;br /&gt;
[[File:Other file DoS frag contribs.jpeg|thumb|center| 2) Contribtuions of alpha and beta electrons to the Total Density of States for Co(SCN)4, filename other_file_DoS_frag_contribs.fig]]&lt;br /&gt;
&lt;br /&gt;
The filename_DoS.fig plot data is output in a .txt file of the same name, while each fragment in filename_DoS_frag_contribs.fig has its own .txt file. For the example above the two fragments have names &amp;quot;all_frags_alpha_other_file_DoS&amp;quot; and &amp;quot;all_frags_beta_other_file_DoS&amp;quot;. The start of the names are taken from the name of the original input file &amp;quot;all_frags.test&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The final file output is the &amp;quot;ALL_Contribs_other_file_DoS.txt&amp;quot; file. This(as the name implies) contains all contributions to the DoS spectra in a comma delimited file. The Plot_Atomic_Contribs*.m code can be run on this file to generate plots with a few different breakdowns (e.g atomic breakdowns) - see the relevant section of this wiki (not done yet....). The file will look something like below (commas replaced with tabs):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#all_frags_alpha	all_frags_beta								&lt;br /&gt;
#Sub fragments in each=	12	12							&lt;br /&gt;
#Energy(eV)	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED,numbers rounded]&lt;br /&gt;
7.5		0.00	0.01	0.31	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.51		0.00	0.01	0.33	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.52		0.00	0.01	0.34	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.53		0.00	0.01	0.35	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.54		0.00	0.01	0.36	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.55		0.00	0.02	0.37	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.56		0.00	0.02	0.39	0.05	0.14	0.00	0.00	0.13	0.00	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hopefully the format is mostly intuitive, the top two rows contain information on what the data is, and the rest contain the data. The top row contains (originally comma delimited) a list of all &amp;quot;fragments&amp;quot; names, which is the number of input files for the closed shell code and 2x the number of input files for the open shell code. The second row contains the number of sub-fragments (which should be atomic orbitals) in each fragment. In the example above each fragment had 12 types of atomic orbital.&lt;br /&gt;
&lt;br /&gt;
So for the example above column 2-14 shows contributions from &amp;quot;all_frags_alpha&amp;quot; while column 15-27 shows contributions from &amp;quot;all_frags_beta&amp;quot; (column 1 lists energies).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Bugs/Things to Watch For==&lt;br /&gt;
===Fragment Names===&lt;br /&gt;
Make sure your fragment names arent a substring of your .fchk file names. For example an input file called &amp;quot;Cl.test&amp;quot; wont work for a file called &amp;quot;BMIM_Cl.fchk&amp;quot;. However, &amp;quot;Cl_frag.test&amp;quot; will work. Therefore personally i add _frag to the end of every input file name. The other way to sort this is to set linked_files=0 in gen_gelius_input_opensh.sh, sincce the link files part of the code is where this bug comes from.&lt;br /&gt;
&lt;br /&gt;
===Fragment Error Checking===&lt;br /&gt;
Unless you manually turn it off (The &amp;quot;error=&amp;quot; option in gen_gelius_input_opensh.sh script) the code tries to check your input file for errors. Specifically it tests whether the TDOS in an input_file really is the sum of the other sub-fragments in the input(.test) file. E.g it will trigger if you request only Sulfur p-type and d-type AOs (but no s-type AOs) in the input file, or if you request all sulfur p-type AOs twice. If the error check triggers then it BREAKS the input file for matlab by putting an error msg in the first line of the &#039;&#039;&#039;*MLinpt.txt file&#039;&#039;&#039;. An example of what the error looks like is:&lt;br /&gt;
&amp;lt;pre&amp;gt;	&lt;br /&gt;
“Fragment Sum incorrect on row 19 for fchk file xxxx.fchk”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you *MLinpt.txt files arent working in matlab then this is probably the reason.&lt;br /&gt;
&lt;br /&gt;
===Pathlengths===&lt;br /&gt;
This code makes a lot of sub-folders based on the name of .fchk files. If you have really long .fchk file names its likely that you&#039;ll end up with some files which exceed the 256 character limit for a pathlength on a windows computer. In matlab 2014 this will cause the code to exit with an error, saying it cant save the .fig files. In newer matlab versions it may just save the output files , but you wont be able to open them on windows if the path length is greater than 256 characters. Ways to avoid this are to shorten .fchk file names where possible, or (less practical) run the code on a folder as close as possible to root (i.e a folder with a short a pathlength as possible).&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630270</id>
		<title>Talk:Mod:Hunt Research Group/Calc XPS Code</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630270"/>
		<updated>2017-06-07T14:29:41Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Some Theory */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Links to Files==&lt;br /&gt;
Open Shell Version: [[Media:Gelius_open_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
Closed Shell Version: [[Media:Gelius_closed_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
The purpose of this code is to calculate partial density of states (pDoS) plots and Valence band x-ray photoelectron (XP) spectra from .fchk files. There is both an open shell and a closed shell version of the code, they work in exactly the same way.&lt;br /&gt;
&lt;br /&gt;
All code was written using python 2.7 (with numpy), Multiwfn version 3.3.8, Matlab version 2014a and a cygwin(bash) shell on windows 8. It should work on windows or linux if the correct options are set.  It might not work on a mac currently due to Multiwfn not working properly (I haven&#039;t personally tested it though). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Some Theory==&lt;br /&gt;
&lt;br /&gt;
===Mulliken Population Analysis===&lt;br /&gt;
&lt;br /&gt;
A pretty key part to this code is the breakdown of molecular orbitals (MOs) in atomic orbitals (AOs, which are essentially basis functions). This is carried out in multiwfn using Mulliken population analysis, which i&#039;ll briefly summarise due to its importance.&lt;br /&gt;
&lt;br /&gt;
The basic question is &amp;quot;For MO X, how many electrons come from atomic orbital Y?&amp;quot;. Note im going to be using &amp;quot;basis functions&amp;quot; instead of &amp;quot;atomic orbitals&amp;quot; from this point, in terms of DFT calculations we interpret a basis function centered on atom X as an atomic orbital of atom X.We&#039;ll define &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the wavefunction for a &#039;&#039;&#039;single MO containing a single electron&#039;&#039;&#039;. Next we write &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the linear combination of individual basis functions (&amp;lt;math&amp;gt;\phi_{i}&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi = {{\sum\limits_{i} c_{i} \phi_{i} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since we want a number of electrons, we&#039;re interested in the formula for the electron density (&amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;) of this MO:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\rho = \langle{} \Psi | \Psi \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i} \phi_{i} }})({{\sum\limits_{i} c_{i} \phi_{i} }})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }}) + 2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If these formulae are tricky to follow, try doing it for a system with just two basis functions.&lt;br /&gt;
Note that in the third line the indice &#039;&#039;j&#039;&#039; runs over the same coefficients and basis functions as the indice &#039;&#039;i&#039;&#039;, its just used to show that the &amp;lt;math&amp;gt;{{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term only contains products between 2 different basis functions/co-efficients.&lt;br /&gt;
Hence, we now have a formula for the MO density which is purely in terms of (known) basis functions and (known) coefficients. Now its just a case of working out how we should interpret these values.&lt;br /&gt;
&lt;br /&gt;
Firstly note that &amp;lt;math&amp;gt;\phi_{i}^{2}=1&amp;lt;/math&amp;gt; (since we use normalised basis functions) hence:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
{{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }} = {{\sum\limits_{i} c_{i}^{2}}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The values of c_{i} in this expression are easy to interpret, they represent the fractional contribution of AO &#039;&#039;i&#039;&#039; to the wavefunction. The &amp;lt;math&amp;gt;2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term is more difficult to interpret, each expression in the series can be thought of as the number of electrons shared between two basis functions. i.e. the following term would represent the number of electrons shared between basis function 1 and 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{shared} = 2 c_{1}c_{2} \langle{}\phi_{1} | \phi_{2} \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we need to split this &amp;quot;shared&amp;quot; electron density between the two contributing basis functions. In Mulliken Population analysis &amp;quot;shared&amp;quot; electron density is divided equally between the two contributing basis functions. So the total electron density assigned to one basis function can be written as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{i} = c_{i}^{2} + {{\sum\limits_{i \neq j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; represents the &#039;&#039;&#039;fractional&#039;&#039;&#039; contribution of &#039;&#039;i&#039;&#039; to the wavefunction. Hence if you had a 2-electron MO, you&#039;d simply multiply &amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; by 2.&lt;br /&gt;
&lt;br /&gt;
===What the code actually does (roughly/briefly)===&lt;br /&gt;
&lt;br /&gt;
==&amp;quot;Installation&amp;quot; Instructions==&lt;br /&gt;
&lt;br /&gt;
All instructions will be given for the open shell version of the code. However, the process is the same except whenever these instructions say to edit the &amp;quot;gen_gelius_input_opensh.sh&amp;quot;, just do the corresponding edit on the gen_gelius_input.sh file. The Matlab scripts are EXACTLY the same for both open shell/closed shell codes.&lt;br /&gt;
&lt;br /&gt;
0) Make sure you have multiwfn (https://multiwfn.codeplex.com) saved somewhere, python 2.x and numpy installed.&lt;br /&gt;
&lt;br /&gt;
1)Put the following files (all the .py/.sh files) somewhere in system path (e.g i use /usr/local/bin):&lt;br /&gt;
:a)Format_Multiwfn_Output_alpha.py (Format_Multiwfn_Output.py for closed shell)&lt;br /&gt;
:b)Format_Multilwfn_Output_beta.py&lt;br /&gt;
:c)Gen_Multiwfn_Input_Comms.py&lt;br /&gt;
:d)Gen_Multiwfn_Input_Comms_beta.py&lt;br /&gt;
:e)Merge_Fragment_Files.py&lt;br /&gt;
:f)gen_gelius_input_opensh.sh&lt;br /&gt;
&lt;br /&gt;
Make sure all files have executable persmission (navigate to the folder and do &amp;quot;chmod u+x filename&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
2)In the gen_gelius_input_opensh.sh change the current lines accordingly:&lt;br /&gt;
:a) multiwfn_folder = &#039;C:/Users/Richard/Documents/Multiwfn_Installed&#039; to the directory where you store multiwfn and associated files.&lt;br /&gt;
:b) &amp;quot;cygwin=1” to “cygwin=0” if your not using a Cygwin shell.&lt;br /&gt;
:c) “old_sed=1” to “old_sed=0” if your version of sed allows the –i option (edit in place) to be used. I don’t think the standard version on mac does(meaning set old_sed=1),standard version of Cygwin does though.&lt;br /&gt;
:d) POSSIBLY &amp;quot;cp $multiwfn_folder/Multiwfn.exe $curr_folder&amp;quot; to &amp;quot;cp $multiwfn_folder/Multiwfn $curr_folder&amp;quot; if on linux(should be really obvious if this is required). Do the same for the line where multiwfn is deleted from current folder(&amp;quot;rm Multiwfn.exe&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
3)Put the following files somewhere in matlabs path (e.g your matlab folder in documents)&lt;br /&gt;
:a) Get_X_Section.m&lt;br /&gt;
:b) Gen_Gelius_Spectrum.m&lt;br /&gt;
&lt;br /&gt;
The Get_X_Section REALLY does need to be in matlabs path (unless you want to edit some code in Gen_Gelius_Spectrum.m). If you know what your doing in matlab  feel free to put Gen_Gelius_Spectrum.m wherever you want.&lt;br /&gt;
&lt;br /&gt;
4)Put the X_Section_Library folder wherever you want.&lt;br /&gt;
&lt;br /&gt;
5) In Get_X_Section.m modify the following line:&lt;br /&gt;
:&amp;quot;Lib_Path =&#039;C:\Users\Richard\Documents\X_Section_Library&#039; &amp;quot; to the path where you put the X_Section_Library folder in.&lt;br /&gt;
&lt;br /&gt;
6) OPTIONAL: Add the code in vim_template_script to your vimrc (c+p it somewhere in the file). &amp;quot;vim ~/.vimrc&amp;quot; to access your vimrc. You can then bring up a template input file in vim by using &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
Since i forgot to put the relevant text file in to the code folders, just c+p the below into your vimrc to get this to work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function! Gelius_Input()&lt;br /&gt;
        exe &#039;normal aCoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr.fchk\rNumb_Fragments=10\r1a=\r1t=a\r1l=TDOS\r2a=\r2t=\r2l=\r3a=\r3t=\r3l=\r4a=\r4t=\r4l=\r5a=\r5t=\r5l=\r6a=\r6t=\r6l=\r7a=\r7t=\r7l=\r8a=\r8t=\r8l=\r9a=\r9t=\r9l=\r10a=\r10t=\r10l=\rM_factor=1.0\rLink_File=&#039;&lt;br /&gt;
        exe &#039;%s/\\r/\r/g&#039;&lt;br /&gt;
endfunction&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
====Using the Example files====&lt;br /&gt;
1) Navigate (in your shell) to the folder &amp;quot;Example_files&amp;quot;. e.g for me i ran:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;cd /cygdrive/c/Users/Richard/Documents/Random_Coding/Gelius_Spectrum_Automated_Jan_2016/open_shell_code/Example_files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
2) Run this command in console(for closed shell use  gen_gelius_input.sh):&lt;br /&gt;
&lt;br /&gt;
&amp;quot;gen_gelius_input_opensh.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Command 2) will have created a folder for each .fchk file in Example_files/. Therefore you should now have folders:&lt;br /&gt;
:CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&lt;br /&gt;
:other_file&lt;br /&gt;
Within these folders are tons of output files. The most important ones are those ending in &amp;quot;MLinpt.txt&amp;quot; - these will be the input files for step 3.&lt;br /&gt;
&lt;br /&gt;
The script will run on all .fchk files in the current folder, when you do this for real you need to make sure that all the fchks are for the same system (e.g a water molecule) and that the atomic numbering is the same in all files (view--&amp;gt;labels in gaussview gives you what im calling atomic numbering).&lt;br /&gt;
&lt;br /&gt;
If anything went wrong try revisiting the installation instructions.&lt;br /&gt;
&lt;br /&gt;
3) Everything from now on is done using matlab. Theres a file called &amp;quot;pathname_file&amp;quot; in the Example_files folder which was created by the gen_gelius_input_opensh.sh script. Copy its full contents to clipboard and in MATLAB terminal type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist=&amp;lt;CTRL-V&amp;gt;&lt;br /&gt;
(&amp;lt;CTRL-V&amp;gt; means paste, rather than type out CTRL-V) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In matlab terms, plist now contains a cell array where each entry is the full path to a folder. The folder paths are those for the folders created in step 2). Hence to do this manually for just one of the two folders you&#039;d type something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist={&#039;C:\Users\Richard\Documents\Random_Coding\Gelius_Spectrum_Automated_Jan_2016\open_shell_code\Example_files\other_file&#039;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4) To create either an XPS spectrum or pDoS plots we use the Gen_Gelius_Spectrum script. This takes the following three arguments IN THE FOLLOWING ORDER:&lt;br /&gt;
:a) the plist variable we just made&lt;br /&gt;
:b) the photon energy we want to use (any negative number requests a pDoS rather than an XPS spectrum)&lt;br /&gt;
:c) the FWHM of the peaks to place around each MO energy (units = eV)&lt;br /&gt;
&lt;br /&gt;
So to create a pDoS plot you could type the following into the matlab terminal(Try this one first):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,-1,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To create an XPS spectrum taken at photon energy of 1486eV (standard lab-based value) type the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,1486,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you get an error like &amp;quot;Undefined function &#039;Gen_Gelius_Spectrum&#039; for input arguments of type &#039;cell&#039;.&amp;quot;, then your Gen_Gelius_Spectrum script probably isnt in your matlab path. (see installation instructions, or google a bit)&lt;br /&gt;
&lt;br /&gt;
If your error free then well done. Sub-folders should have been created in &amp;quot;other_file&amp;quot; and &amp;quot;CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&amp;quot;, which in turn will contain a loada output files. See the output files section of the wiki for an explanation of what these are.&lt;br /&gt;
&lt;br /&gt;
====Creating your own input files====&lt;br /&gt;
If you followed the optional part above and made a vimscript, then a template for the input file can be brought up in vim by typing &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example input file is shown below. Each &amp;quot;fragment&amp;quot; (e.g cation,anion, alkyl group etc.) should have its own input file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
other_file.fchk&lt;br /&gt;
Numb_Fragments=4&lt;br /&gt;
1a=10-13&lt;br /&gt;
1t=a&lt;br /&gt;
1l=TDOS&lt;br /&gt;
2a=10-13&lt;br /&gt;
2t=s&lt;br /&gt;
2l=S3s&lt;br /&gt;
3a=10-13&lt;br /&gt;
3t=p&lt;br /&gt;
3l=S3p&lt;br /&gt;
4a=10-13&lt;br /&gt;
4t=d+&lt;br /&gt;
4l=S3d&lt;br /&gt;
M_factor=1.0&lt;br /&gt;
Link_File=all_frags.test&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The input file can be divided into parts as follows:&lt;br /&gt;
&lt;br /&gt;
1) The top line of the input file tells the code the name of the checkpoint file to use in the calculation. In practice you can write ANYTHING on this top line if using the gen_gelius_input*.sh script, as the script itself replaces the first line (whatevers there) with the names of all .fchks in the current folder. But SOMETHING must be written there.&lt;br /&gt;
&lt;br /&gt;
2)&#039;&#039;&#039;Numb_Fragments&#039;&#039;&#039; is the number of sub-fragments (max 10) that you want to break your pDoS down into (e.g fragment 2 corresponds to all Sulfur 3s atomic orbitals in the example above). Code will break if you get this wrong.&lt;br /&gt;
&lt;br /&gt;
3) &#039;&#039;&#039;1a/1t/1l&#039;&#039;&#039; instruct the code what to use as the total density of states. Hence 1a must be set to ALL the atoms your interested in for this fragment, 1t must be set to &amp;quot;a&amp;quot; and 1l should be set to TDOS (not sure it matters what this is set to, but to be on the safe side just use TDOS). The purpose of this fragment is essentially error checking.&lt;br /&gt;
&lt;br /&gt;
4) &#039;&#039;&#039;2a/3a/*a&#039;&#039;&#039; : a stands for atoms here, so the value of a corresponds to the labels of the atoms you want to be included in the sub-fragment. These labels are the same integers you get in gaussview when you go to view--&amp;gt;labels. Examples of valid options may be &amp;quot;1,4,5-7&amp;quot; or &amp;quot;1,3,5&amp;quot; (basically comma seperated list of integers)&lt;br /&gt;
&lt;br /&gt;
5) &#039;&#039;&#039;2t/3t/*t&#039;&#039;&#039;: t stands for &amp;quot;type of AO&amp;quot;.This is a comma seperated list with possible arguments (any combination) &amp;quot;a,s,p,d,f,g&amp;quot;. &amp;quot;a&amp;quot; corresponds to all types of AO centered of the atoms specified with the 2a/3a/*a line. s means s-type atomc orbitals (0 angular momentum), p means p-type atomic orbitals (1 angular momentum) etc. To get all AOs of a certain angular momentum and higher (up to g-type AOs) add a plus to the end of the relevant letter. e.g &amp;quot;p+&amp;quot; says &amp;quot;include all AOs with angular momemtnum greater than or equal to 1 in this sub-fragment&amp;quot;)&lt;br /&gt;
&#039;&#039;&#039;DON&#039;T&#039;&#039;&#039; use &amp;quot;a&amp;quot; with any other letter, and dont do anything else that will lead to a type of AO being requested twice (e.g p+,d)&lt;br /&gt;
&lt;br /&gt;
6) &#039;&#039;&#039;2l/3l/*l&#039;&#039;&#039;: l stands for label. If you dont care about calculating an XPS spectrum you can essentially set it to whatever you want. This tells the matlab script what cross section to use for calculating the XPS spectrum, hence it must match (case insensitive) a filename in the X_Section_Library folder. e.g S3s tells matlab to get the S3S.txt file when looking for what cross-section to use.&lt;br /&gt;
&lt;br /&gt;
7) &#039;&#039;&#039;M_factor=1.0&#039;&#039;&#039;, you really never need to modify this but make sure its present. It&#039;s purpose is to tell matlab to multiple the pDoS of this fragment (that this input file corresponds to) by the  value M_factor. The purpose is for systems where the real stoichiometry differs from that in your calculation. For example if i have a mixture of 99 water:1 anion but only a calculation on 1 water molecule mixed with 1 anion i could set M_factor for the water fragment input file to M_factor=99.0 to estimate (badly) what the actual DoS of the mixture would look like.&lt;br /&gt;
&lt;br /&gt;
8) &#039;&#039;&#039;Link_File=*&#039;&#039;&#039;. This options for if you have a fragment (e.g an anion) but want it broken into more than 10 sub-fragments (e.g this will be true for any molecule with &amp;gt;3 elements). In this case make 2 files for that fragment, and in the second  file set Link_File to the name of the first file. In the example above, this input file will essentially be merged with &amp;quot;all_frags.test&amp;quot;, and only an output file for all_frags.test will be generated.&lt;br /&gt;
&lt;br /&gt;
====More complex input file options====&lt;br /&gt;
====Gen_Gelius_Spectrum.m====&lt;br /&gt;
This code has the following options that can be changed (all are explained by comments in the .m file):&lt;br /&gt;
&amp;lt;pre&amp;gt;1)min_e/max_e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Matlab ignores any orbitals with energy below min_e or above max_e when generating the XPS spectrum. Note if you want to change this to include core orbitals or very high energy virtual orbitals then you&#039;ll also have to edit Gen_Multiwfn_Input_Comms.py to set the range in multiwfn to the one you want.(Theres currently no variable in that .py code to do that, it just uses the defaults in multiwfn. But the function you&#039;ll need to edit in Gen_Multiwfn_Input_Comms.py is Output_Header.&lt;br /&gt;
&amp;lt;pre&amp;gt;2)min_e_plotted/max_e_plotted&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These refer to the minimum/maximum binding energies to calculate spectral intensity for. The range should probably be slightly wider than the min_e/max_e range really, though thats not the default setting. &lt;br /&gt;
&amp;lt;pre&amp;gt;3)step_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The value (in eV) between calculated data points in the output spectra. For example, if set to 0.001eV then a data point will be calculated for 0eV,0.001eV,0.002eV etc. Lower values=larger files/slower runtimes.&lt;br /&gt;
&amp;lt;pre&amp;gt;4)lorentz_fraction &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Value between 0 and 1 that determines the % Lorentzian character of the lineshape used in the broadening function(the remaining % is set to gaussian). By broadening function i essentially mean the peak thats placed around every MO energy in generating these spectra. lorentz_fraction=0 will give you a pure gaussian peak, while lorentz_fraction=1 gives a pure Lorentzian peak.&lt;br /&gt;
&amp;lt;pre&amp;gt;5)savetext/figsave/savejpeg/all_contribs_output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These all control whether a certain type of output file is saved, with variable names that should be self-explanatory.Values of 1 mean save the file, other values mean dont save. set savetext=0 to not save any .txt output files, figsave=0 to not save any .fig output, savejpeg=0 to not save any .jpeg outputs and all_contribs_output=0 to not save the .txt file with a full breakdown of the spectrum. Leaving them all as 1 (except maybe the savejpeg) is strongly recommended.&lt;br /&gt;
&lt;br /&gt;
====Plot_Atomic_Contribs_V3====&lt;br /&gt;
&lt;br /&gt;
This is an optional script that plots certain breakdowns of your calculated DoS/XPS spectrum (i.e you run it AFTER Gen_Gelius_Spectrum) . Its not too hard to do the same thing in excel using the *ALL_Contribs* output file (see output file sections) but this is a lot faster. There are three types of breakdown this function can do (see pictures below):&lt;br /&gt;
&lt;br /&gt;
1) Atomic breakdown with fragments kept seperate (merge_spd=1,merge_fragments=0)&lt;br /&gt;
&lt;br /&gt;
2) Atomic orbital breakdown (merge_spd=0,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
3) Atomic breakdown (merge_spd=1,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
The function in its uploaded form takes a single argument , though there are two variables in the actual code that you need to mess with (merge_spd and merge_fragments).&lt;br /&gt;
&lt;br /&gt;
So for example, to run this on the output file from the &amp;quot;Using the Example files&amp;quot; i typed into the matlab terminal:&lt;br /&gt;
&lt;br /&gt;
Plot_Atomic_Contribs_V3(&#039;C:\Users\Richard\Desktop\Open_Shell_Code_Some_Stuff\Example_files\other_file\DoS_1ev_0pt3l&#039;)&lt;br /&gt;
&lt;br /&gt;
The argument needs to be a folder containing the output files from the Gen_Gelius_Spectrum script. You&#039;ll then get a saved graph with the breakdown you asked for and also a .txt file containing the breakdown in a comma delimited format. The output file names record the options you used to make the script (e.g &amp;quot;Plotted_Atomic_Contribs_spd0_frag1.txt&amp;quot; means merge_spd was set to 0 and merge_fragments was set to 1).&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag1.jpg|thumbnail|center| merge_spd=1,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted_Atomic_Contribs_spd0_frag1.jpg|thumbnail|center| merge_spd=0,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag0.jpg|thumbnail|center| merge_spd=1,merge_fragments=0 ]]&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
&lt;br /&gt;
The first &amp;quot;output file&amp;quot; is the *MCRF*.txt file, which just contains the commands to build the required fragment in multiwfn.&lt;br /&gt;
&lt;br /&gt;
===Files From Multiwfn===&lt;br /&gt;
Most people should be able to completely ignore these files. But in case your curious:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1) *DOS_curve*.txt&#039;&#039;&#039; Essentially a DoS plot. 1st column is energies in au, second column is TDOS of the fragment. Not really sure what the 3rd column is. No particular use for this file, but it gets auto-generated by multiwfn and i dont go out my way to delete it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2) *DOS_line*.txt&#039;&#039;&#039; Data to create a stick plot (where each MO is a stick). Plot column 1 vs column 2 as a line graph and you get an axis with sticks representing the MOs. 4th column onwards represent contribution of the various sub-fragments to each &amp;quot;stick&amp;quot;. This is the file that gets used to generate the *ML_inpt.txt file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3) *DOS_frag*.txt &#039;&#039;&#039; This file contains the sub-fragment info in a way multiwfn understands. If its renamed to DOS_frag.txt then multiwfn can import it to get the fragments (therefore can be useful for debugging, no further purpose).&lt;br /&gt;
&lt;br /&gt;
===MLinpt.txt File===&lt;br /&gt;
&lt;br /&gt;
Creation of the *ML_inpt.txt files is essentially the point of the gen_gelius_input* script. These are primarily input files for matlab, but they do have useful information in an easy to read format. If you import the file into excel and COMMA DELIMIT ONLY (i.e untick the space delimit option) you can get something like below(there are more decimal places in the actual file):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#M_FACTOR=1.0,													&lt;br /&gt;
#Energy(eV)	TDOS	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	S3S	S3P	S3D&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
-24.5		0.9	0.0	0.0	0.0	0.5	0.1	0.0	0.2	0.1	0.0	0.1	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-19.8		0.3	0.0	0.0	0.0	0.1	-0.1	0.0	0.2	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
-19.7		0.3	0.0	0.0	0.0	0.0	0.0	0.0	0.1	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The shown file is &amp;quot;all_frags_alpha_MLinpt.txt&amp;quot;, which is generated from the example files in the open shell code. As this actually comes from merging two MLinpt.txt files (gen_gelius_input.sh does this part silently) the TDOS in this case doesnt mean anything.&lt;br /&gt;
&lt;br /&gt;
The first column lists the energy of each MO in eV (1 ev ~27.212 au). For any row, columns 3(CO4S)--&amp;gt;end (S3D) list the fractional contributions of each type of atmoic orbital to the MO in that row. For example the MO with energy -19.7 eV is mainly from S3s type atomic orbitals. These fractions were determiend by multiwfn by using Mulliken population analysis.&lt;br /&gt;
&lt;br /&gt;
All the fractional contributions in the file get multiplied by the M_FACTOR value (as explained above in the Creating your own input files section). Therefore the value of M_FACTOR can easily be set after the MLinpt.txt file is created, as opposed to within the initial input file.&lt;br /&gt;
&lt;br /&gt;
===Formatted_UMOs===&lt;br /&gt;
&lt;br /&gt;
The default for the gen_gelius_input* script (i.e the settings for the version i uploaded) is to put only OCCUPIED MO energies/breakdowns into the *MLinpt.txt file. If you want all MOs (I really DONT recommend this) in the MLinpt.txt file then change all_orbs=&#039;cheese&#039; to all_orbs=&#039;ALLORBS&#039; at the top of the gen_gelius_input* script.&lt;br /&gt;
&lt;br /&gt;
Otherwise you will get a *Formatted_UMOs* file for every MLinpt.txt file you get. The format of the file is identical to the MLinpt.txt format except the MO at the top of the file corresponds to the LUMO.&lt;br /&gt;
&lt;br /&gt;
WARNING: If you use the link_files feature, then the output formatted_UMOs files DO NOT get merged. This shouldnt matter as you should never really use the formatted UMOs for anything.&lt;br /&gt;
&lt;br /&gt;
===Output From Matlab Code ===&lt;br /&gt;
&lt;br /&gt;
The matlab code firstly will create a new folder with a name reflecting the input arguments. The format is hv_FWHM_%lorenztian where hv is the photon energy, FWHM is full width half maximum of the broadeing function and %lorenztian is the amount of lorenztian mixed in the broadening function. For example the earlier command (from using example files section) &amp;quot;Gen_Gelius_Spectrum(plist,-1,1)&amp;quot; generates the folder &amp;quot;DoS_1ev_0pt3l&amp;quot;. DoS = Density of states, and means we did not use photoionisation cross sections. The 0pt3l part means our broadening function was 30% lorenztian and 70% Gaussian.&lt;br /&gt;
&lt;br /&gt;
Two .fig files will have been produced from this code, these contain matlab graphs of the output. These .fig files follow the naming (&amp;quot;filename&amp;quot; is the name of the original fchk file):&lt;br /&gt;
&lt;br /&gt;
1) filename_DoS.fig contains the total DoS plot.&lt;br /&gt;
&lt;br /&gt;
2) filename_DoS_frag_contribs.fig contains the DoS AND the pDoS of each of the fragments. For closed shell code you get 1 fragment per input file (assuming you dont use link_files), but for the open shell code each input file leads to two fragments - one for alpha electrons and one for beta electrons.&lt;br /&gt;
&lt;br /&gt;
[[File:Other_file_DoS.jpeg|thumb|center| 1) Total Density of States for a Co(SCN)4 fragment with filename other_file_DoS.fig]]&lt;br /&gt;
&lt;br /&gt;
[[File:Other file DoS frag contribs.jpeg|thumb|center| 2) Contribtuions of alpha and beta electrons to the Total Density of States for Co(SCN)4, filename other_file_DoS_frag_contribs.fig]]&lt;br /&gt;
&lt;br /&gt;
The filename_DoS.fig plot data is output in a .txt file of the same name, while each fragment in filename_DoS_frag_contribs.fig has its own .txt file. For the example above the two fragments have names &amp;quot;all_frags_alpha_other_file_DoS&amp;quot; and &amp;quot;all_frags_beta_other_file_DoS&amp;quot;. The start of the names are taken from the name of the original input file &amp;quot;all_frags.test&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The final file output is the &amp;quot;ALL_Contribs_other_file_DoS.txt&amp;quot; file. This(as the name implies) contains all contributions to the DoS spectra in a comma delimited file. The Plot_Atomic_Contribs*.m code can be run on this file to generate plots with a few different breakdowns (e.g atomic breakdowns) - see the relevant section of this wiki (not done yet....). The file will look something like below (commas replaced with tabs):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#all_frags_alpha	all_frags_beta								&lt;br /&gt;
#Sub fragments in each=	12	12							&lt;br /&gt;
#Energy(eV)	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED,numbers rounded]&lt;br /&gt;
7.5		0.00	0.01	0.31	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.51		0.00	0.01	0.33	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.52		0.00	0.01	0.34	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.53		0.00	0.01	0.35	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.54		0.00	0.01	0.36	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.55		0.00	0.02	0.37	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.56		0.00	0.02	0.39	0.05	0.14	0.00	0.00	0.13	0.00	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hopefully the format is mostly intuitive, the top two rows contain information on what the data is, and the rest contain the data. The top row contains (originally comma delimited) a list of all &amp;quot;fragments&amp;quot; names, which is the number of input files for the closed shell code and 2x the number of input files for the open shell code. The second row contains the number of sub-fragments (which should be atomic orbitals) in each fragment. In the example above each fragment had 12 types of atomic orbital.&lt;br /&gt;
&lt;br /&gt;
So for the example above column 2-14 shows contributions from &amp;quot;all_frags_alpha&amp;quot; while column 15-27 shows contributions from &amp;quot;all_frags_beta&amp;quot; (column 1 lists energies).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Bugs/Things to Watch For==&lt;br /&gt;
===Fragment Names===&lt;br /&gt;
Make sure your fragment names arent a substring of your .fchk file names. For example an input file called &amp;quot;Cl.test&amp;quot; wont work for a file called &amp;quot;BMIM_Cl.fchk&amp;quot;. However, &amp;quot;Cl_frag.test&amp;quot; will work. Therefore personally i add _frag to the end of every input file name. The other way to sort this is to set linked_files=0 in gen_gelius_input_opensh.sh, sincce the link files part of the code is where this bug comes from.&lt;br /&gt;
&lt;br /&gt;
===Fragment Error Checking===&lt;br /&gt;
Unless you manually turn it off (The &amp;quot;error=&amp;quot; option in gen_gelius_input_opensh.sh script) the code tries to check your input file for errors. Specifically it tests whether the TDOS in an input_file really is the sum of the other sub-fragments in the input(.test) file. E.g it will trigger if you request only Sulfur p-type and d-type AOs (but no s-type AOs) in the input file, or if you request all sulfur p-type AOs twice. If the error check triggers then it BREAKS the input file for matlab by putting an error msg in the first line of the &#039;&#039;&#039;*MLinpt.txt file&#039;&#039;&#039;. An example of what the error looks like is:&lt;br /&gt;
&amp;lt;pre&amp;gt;	&lt;br /&gt;
“Fragment Sum incorrect on row 19 for fchk file xxxx.fchk”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you *MLinpt.txt files arent working in matlab then this is probably the reason.&lt;br /&gt;
&lt;br /&gt;
===Pathlengths===&lt;br /&gt;
This code makes a lot of sub-folders based on the name of .fchk files. If you have really long .fchk file names its likely that you&#039;ll end up with some files which exceed the 256 character limit for a pathlength on a windows computer. In matlab 2014 this will cause the code to exit with an error, saying it cant save the .fig files. In newer matlab versions it may just save the output files , but you wont be able to open them on windows if the path length is greater than 256 characters. Ways to avoid this are to shorten .fchk file names where possible, or (less practical) run the code on a folder as close as possible to root (i.e a folder with a short a pathlength as possible).&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630269</id>
		<title>Talk:Mod:Hunt Research Group/Calc XPS Code</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630269"/>
		<updated>2017-06-07T14:28:39Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Mulliken Population Analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Links to Files==&lt;br /&gt;
Open Shell Version: [[Media:Gelius_open_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
Closed Shell Version: [[Media:Gelius_closed_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
The purpose of this code is to calculate partial density of states (pDoS) plots and Valence band x-ray photoelectron (XP) spectra from .fchk files. There is both an open shell and a closed shell version of the code, they work in exactly the same way.&lt;br /&gt;
&lt;br /&gt;
All code was written using python 2.7 (with numpy), Multiwfn version 3.3.8, Matlab version 2014a and a cygwin(bash) shell on windows 8. It should work on windows or linux if the correct options are set.  It might not work on a mac currently due to Multiwfn not working properly (I haven&#039;t personally tested it though). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Some Theory==&lt;br /&gt;
&lt;br /&gt;
===Mulliken Population Analysis===&lt;br /&gt;
&lt;br /&gt;
A pretty key part to this code is the breakdown of molecular orbitals (MOs) in atomic orbitals (AOs, which are essentially basis functions). This is carried out in multiwfn using Mulliken population analysis, which i&#039;ll briefly summarise due to its importance.&lt;br /&gt;
&lt;br /&gt;
The basic question is &amp;quot;For MO X, how many electrons come from atomic orbital Y?&amp;quot;. Note im going to be using &amp;quot;basis functions&amp;quot; instead of &amp;quot;atomic orbitals&amp;quot; from this point, in terms of DFT calculations we interpret a basis function centered on atom X as an atomic orbital of atom X.We&#039;ll define &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the wavefunction for a &#039;&#039;&#039;single MO containing a single electron&#039;&#039;&#039;. Next we write &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the linear combination of individual basis functions (&amp;lt;math&amp;gt;\phi_{i}&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi = {{\sum\limits_{i} c_{i} \phi_{i} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since we want a number of electrons, we&#039;re interested in the formula for the electron density (&amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;) of this MO:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\rho = \langle{} \Psi | \Psi \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i} \phi_{i} }})({{\sum\limits_{i} c_{i} \phi_{i} }})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }}) + 2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If these formulae are tricky to follow, try doing it for a system with just two basis functions.&lt;br /&gt;
Note that in the third line the indice &#039;&#039;j&#039;&#039; runs over the same coefficients and basis functions as the indice &#039;&#039;i&#039;&#039;, its just used to show that the &amp;lt;math&amp;gt;{{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term only contains products between 2 different basis functions/co-efficients.&lt;br /&gt;
Hence, we now have a formula for the MO density which is purely in terms of (known) basis functions and (known) coefficients. Now its just a case of working out how we should interpret these values.&lt;br /&gt;
&lt;br /&gt;
Firstly note that &amp;lt;math&amp;gt;\phi_{i}^{2}=1&amp;lt;/math&amp;gt; (since we use normalised basis functions) hence:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
{{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }} = {{\sum\limits_{i} c_{i}^{2}}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The values of c_{i} in this expression are easy to interpret, they represent the fractional contribution of AO &#039;&#039;i&#039;&#039; to the wavefunction. The &amp;lt;math&amp;gt;2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term is more difficult to interpret, each expression in the series can be thought of as the number of electrons shared between two basis functions. i.e. the following term would represent the number of electrons shared between basis function 1 and 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{shared} = 2 c_{1}c_{2} \langle{}\phi_{1} | \phi_{2} \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we need to split this &amp;quot;shared&amp;quot; electron density between the two contributing basis functions. In Mulliken Population analysis &amp;quot;shared&amp;quot; electron density is divided equally between the two contributing basis functions. So the total electron density assigned to one basis function can be written as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{i} = c_{i} + {{\sum\limits_{i \neq j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; represents the &#039;&#039;&#039;fractional&#039;&#039;&#039; contribution of &#039;&#039;i&#039;&#039; to the wavefunction. Hence if you had a 2-electron MO, you&#039;d simply multiply &amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; by 2.&lt;br /&gt;
&lt;br /&gt;
===What the code actually does (roughly/briefly)===&lt;br /&gt;
&lt;br /&gt;
==&amp;quot;Installation&amp;quot; Instructions==&lt;br /&gt;
&lt;br /&gt;
All instructions will be given for the open shell version of the code. However, the process is the same except whenever these instructions say to edit the &amp;quot;gen_gelius_input_opensh.sh&amp;quot;, just do the corresponding edit on the gen_gelius_input.sh file. The Matlab scripts are EXACTLY the same for both open shell/closed shell codes.&lt;br /&gt;
&lt;br /&gt;
0) Make sure you have multiwfn (https://multiwfn.codeplex.com) saved somewhere, python 2.x and numpy installed.&lt;br /&gt;
&lt;br /&gt;
1)Put the following files (all the .py/.sh files) somewhere in system path (e.g i use /usr/local/bin):&lt;br /&gt;
:a)Format_Multiwfn_Output_alpha.py (Format_Multiwfn_Output.py for closed shell)&lt;br /&gt;
:b)Format_Multilwfn_Output_beta.py&lt;br /&gt;
:c)Gen_Multiwfn_Input_Comms.py&lt;br /&gt;
:d)Gen_Multiwfn_Input_Comms_beta.py&lt;br /&gt;
:e)Merge_Fragment_Files.py&lt;br /&gt;
:f)gen_gelius_input_opensh.sh&lt;br /&gt;
&lt;br /&gt;
Make sure all files have executable persmission (navigate to the folder and do &amp;quot;chmod u+x filename&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
2)In the gen_gelius_input_opensh.sh change the current lines accordingly:&lt;br /&gt;
:a) multiwfn_folder = &#039;C:/Users/Richard/Documents/Multiwfn_Installed&#039; to the directory where you store multiwfn and associated files.&lt;br /&gt;
:b) &amp;quot;cygwin=1” to “cygwin=0” if your not using a Cygwin shell.&lt;br /&gt;
:c) “old_sed=1” to “old_sed=0” if your version of sed allows the –i option (edit in place) to be used. I don’t think the standard version on mac does(meaning set old_sed=1),standard version of Cygwin does though.&lt;br /&gt;
:d) POSSIBLY &amp;quot;cp $multiwfn_folder/Multiwfn.exe $curr_folder&amp;quot; to &amp;quot;cp $multiwfn_folder/Multiwfn $curr_folder&amp;quot; if on linux(should be really obvious if this is required). Do the same for the line where multiwfn is deleted from current folder(&amp;quot;rm Multiwfn.exe&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
3)Put the following files somewhere in matlabs path (e.g your matlab folder in documents)&lt;br /&gt;
:a) Get_X_Section.m&lt;br /&gt;
:b) Gen_Gelius_Spectrum.m&lt;br /&gt;
&lt;br /&gt;
The Get_X_Section REALLY does need to be in matlabs path (unless you want to edit some code in Gen_Gelius_Spectrum.m). If you know what your doing in matlab  feel free to put Gen_Gelius_Spectrum.m wherever you want.&lt;br /&gt;
&lt;br /&gt;
4)Put the X_Section_Library folder wherever you want.&lt;br /&gt;
&lt;br /&gt;
5) In Get_X_Section.m modify the following line:&lt;br /&gt;
:&amp;quot;Lib_Path =&#039;C:\Users\Richard\Documents\X_Section_Library&#039; &amp;quot; to the path where you put the X_Section_Library folder in.&lt;br /&gt;
&lt;br /&gt;
6) OPTIONAL: Add the code in vim_template_script to your vimrc (c+p it somewhere in the file). &amp;quot;vim ~/.vimrc&amp;quot; to access your vimrc. You can then bring up a template input file in vim by using &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
Since i forgot to put the relevant text file in to the code folders, just c+p the below into your vimrc to get this to work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function! Gelius_Input()&lt;br /&gt;
        exe &#039;normal aCoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr.fchk\rNumb_Fragments=10\r1a=\r1t=a\r1l=TDOS\r2a=\r2t=\r2l=\r3a=\r3t=\r3l=\r4a=\r4t=\r4l=\r5a=\r5t=\r5l=\r6a=\r6t=\r6l=\r7a=\r7t=\r7l=\r8a=\r8t=\r8l=\r9a=\r9t=\r9l=\r10a=\r10t=\r10l=\rM_factor=1.0\rLink_File=&#039;&lt;br /&gt;
        exe &#039;%s/\\r/\r/g&#039;&lt;br /&gt;
endfunction&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
====Using the Example files====&lt;br /&gt;
1) Navigate (in your shell) to the folder &amp;quot;Example_files&amp;quot;. e.g for me i ran:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;cd /cygdrive/c/Users/Richard/Documents/Random_Coding/Gelius_Spectrum_Automated_Jan_2016/open_shell_code/Example_files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
2) Run this command in console(for closed shell use  gen_gelius_input.sh):&lt;br /&gt;
&lt;br /&gt;
&amp;quot;gen_gelius_input_opensh.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Command 2) will have created a folder for each .fchk file in Example_files/. Therefore you should now have folders:&lt;br /&gt;
:CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&lt;br /&gt;
:other_file&lt;br /&gt;
Within these folders are tons of output files. The most important ones are those ending in &amp;quot;MLinpt.txt&amp;quot; - these will be the input files for step 3.&lt;br /&gt;
&lt;br /&gt;
The script will run on all .fchk files in the current folder, when you do this for real you need to make sure that all the fchks are for the same system (e.g a water molecule) and that the atomic numbering is the same in all files (view--&amp;gt;labels in gaussview gives you what im calling atomic numbering).&lt;br /&gt;
&lt;br /&gt;
If anything went wrong try revisiting the installation instructions.&lt;br /&gt;
&lt;br /&gt;
3) Everything from now on is done using matlab. Theres a file called &amp;quot;pathname_file&amp;quot; in the Example_files folder which was created by the gen_gelius_input_opensh.sh script. Copy its full contents to clipboard and in MATLAB terminal type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist=&amp;lt;CTRL-V&amp;gt;&lt;br /&gt;
(&amp;lt;CTRL-V&amp;gt; means paste, rather than type out CTRL-V) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In matlab terms, plist now contains a cell array where each entry is the full path to a folder. The folder paths are those for the folders created in step 2). Hence to do this manually for just one of the two folders you&#039;d type something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist={&#039;C:\Users\Richard\Documents\Random_Coding\Gelius_Spectrum_Automated_Jan_2016\open_shell_code\Example_files\other_file&#039;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4) To create either an XPS spectrum or pDoS plots we use the Gen_Gelius_Spectrum script. This takes the following three arguments IN THE FOLLOWING ORDER:&lt;br /&gt;
:a) the plist variable we just made&lt;br /&gt;
:b) the photon energy we want to use (any negative number requests a pDoS rather than an XPS spectrum)&lt;br /&gt;
:c) the FWHM of the peaks to place around each MO energy (units = eV)&lt;br /&gt;
&lt;br /&gt;
So to create a pDoS plot you could type the following into the matlab terminal(Try this one first):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,-1,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To create an XPS spectrum taken at photon energy of 1486eV (standard lab-based value) type the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,1486,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you get an error like &amp;quot;Undefined function &#039;Gen_Gelius_Spectrum&#039; for input arguments of type &#039;cell&#039;.&amp;quot;, then your Gen_Gelius_Spectrum script probably isnt in your matlab path. (see installation instructions, or google a bit)&lt;br /&gt;
&lt;br /&gt;
If your error free then well done. Sub-folders should have been created in &amp;quot;other_file&amp;quot; and &amp;quot;CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&amp;quot;, which in turn will contain a loada output files. See the output files section of the wiki for an explanation of what these are.&lt;br /&gt;
&lt;br /&gt;
====Creating your own input files====&lt;br /&gt;
If you followed the optional part above and made a vimscript, then a template for the input file can be brought up in vim by typing &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example input file is shown below. Each &amp;quot;fragment&amp;quot; (e.g cation,anion, alkyl group etc.) should have its own input file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
other_file.fchk&lt;br /&gt;
Numb_Fragments=4&lt;br /&gt;
1a=10-13&lt;br /&gt;
1t=a&lt;br /&gt;
1l=TDOS&lt;br /&gt;
2a=10-13&lt;br /&gt;
2t=s&lt;br /&gt;
2l=S3s&lt;br /&gt;
3a=10-13&lt;br /&gt;
3t=p&lt;br /&gt;
3l=S3p&lt;br /&gt;
4a=10-13&lt;br /&gt;
4t=d+&lt;br /&gt;
4l=S3d&lt;br /&gt;
M_factor=1.0&lt;br /&gt;
Link_File=all_frags.test&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The input file can be divided into parts as follows:&lt;br /&gt;
&lt;br /&gt;
1) The top line of the input file tells the code the name of the checkpoint file to use in the calculation. In practice you can write ANYTHING on this top line if using the gen_gelius_input*.sh script, as the script itself replaces the first line (whatevers there) with the names of all .fchks in the current folder. But SOMETHING must be written there.&lt;br /&gt;
&lt;br /&gt;
2)&#039;&#039;&#039;Numb_Fragments&#039;&#039;&#039; is the number of sub-fragments (max 10) that you want to break your pDoS down into (e.g fragment 2 corresponds to all Sulfur 3s atomic orbitals in the example above). Code will break if you get this wrong.&lt;br /&gt;
&lt;br /&gt;
3) &#039;&#039;&#039;1a/1t/1l&#039;&#039;&#039; instruct the code what to use as the total density of states. Hence 1a must be set to ALL the atoms your interested in for this fragment, 1t must be set to &amp;quot;a&amp;quot; and 1l should be set to TDOS (not sure it matters what this is set to, but to be on the safe side just use TDOS). The purpose of this fragment is essentially error checking.&lt;br /&gt;
&lt;br /&gt;
4) &#039;&#039;&#039;2a/3a/*a&#039;&#039;&#039; : a stands for atoms here, so the value of a corresponds to the labels of the atoms you want to be included in the sub-fragment. These labels are the same integers you get in gaussview when you go to view--&amp;gt;labels. Examples of valid options may be &amp;quot;1,4,5-7&amp;quot; or &amp;quot;1,3,5&amp;quot; (basically comma seperated list of integers)&lt;br /&gt;
&lt;br /&gt;
5) &#039;&#039;&#039;2t/3t/*t&#039;&#039;&#039;: t stands for &amp;quot;type of AO&amp;quot;.This is a comma seperated list with possible arguments (any combination) &amp;quot;a,s,p,d,f,g&amp;quot;. &amp;quot;a&amp;quot; corresponds to all types of AO centered of the atoms specified with the 2a/3a/*a line. s means s-type atomc orbitals (0 angular momentum), p means p-type atomic orbitals (1 angular momentum) etc. To get all AOs of a certain angular momentum and higher (up to g-type AOs) add a plus to the end of the relevant letter. e.g &amp;quot;p+&amp;quot; says &amp;quot;include all AOs with angular momemtnum greater than or equal to 1 in this sub-fragment&amp;quot;)&lt;br /&gt;
&#039;&#039;&#039;DON&#039;T&#039;&#039;&#039; use &amp;quot;a&amp;quot; with any other letter, and dont do anything else that will lead to a type of AO being requested twice (e.g p+,d)&lt;br /&gt;
&lt;br /&gt;
6) &#039;&#039;&#039;2l/3l/*l&#039;&#039;&#039;: l stands for label. If you dont care about calculating an XPS spectrum you can essentially set it to whatever you want. This tells the matlab script what cross section to use for calculating the XPS spectrum, hence it must match (case insensitive) a filename in the X_Section_Library folder. e.g S3s tells matlab to get the S3S.txt file when looking for what cross-section to use.&lt;br /&gt;
&lt;br /&gt;
7) &#039;&#039;&#039;M_factor=1.0&#039;&#039;&#039;, you really never need to modify this but make sure its present. It&#039;s purpose is to tell matlab to multiple the pDoS of this fragment (that this input file corresponds to) by the  value M_factor. The purpose is for systems where the real stoichiometry differs from that in your calculation. For example if i have a mixture of 99 water:1 anion but only a calculation on 1 water molecule mixed with 1 anion i could set M_factor for the water fragment input file to M_factor=99.0 to estimate (badly) what the actual DoS of the mixture would look like.&lt;br /&gt;
&lt;br /&gt;
8) &#039;&#039;&#039;Link_File=*&#039;&#039;&#039;. This options for if you have a fragment (e.g an anion) but want it broken into more than 10 sub-fragments (e.g this will be true for any molecule with &amp;gt;3 elements). In this case make 2 files for that fragment, and in the second  file set Link_File to the name of the first file. In the example above, this input file will essentially be merged with &amp;quot;all_frags.test&amp;quot;, and only an output file for all_frags.test will be generated.&lt;br /&gt;
&lt;br /&gt;
====More complex input file options====&lt;br /&gt;
====Gen_Gelius_Spectrum.m====&lt;br /&gt;
This code has the following options that can be changed (all are explained by comments in the .m file):&lt;br /&gt;
&amp;lt;pre&amp;gt;1)min_e/max_e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Matlab ignores any orbitals with energy below min_e or above max_e when generating the XPS spectrum. Note if you want to change this to include core orbitals or very high energy virtual orbitals then you&#039;ll also have to edit Gen_Multiwfn_Input_Comms.py to set the range in multiwfn to the one you want.(Theres currently no variable in that .py code to do that, it just uses the defaults in multiwfn. But the function you&#039;ll need to edit in Gen_Multiwfn_Input_Comms.py is Output_Header.&lt;br /&gt;
&amp;lt;pre&amp;gt;2)min_e_plotted/max_e_plotted&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These refer to the minimum/maximum binding energies to calculate spectral intensity for. The range should probably be slightly wider than the min_e/max_e range really, though thats not the default setting. &lt;br /&gt;
&amp;lt;pre&amp;gt;3)step_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The value (in eV) between calculated data points in the output spectra. For example, if set to 0.001eV then a data point will be calculated for 0eV,0.001eV,0.002eV etc. Lower values=larger files/slower runtimes.&lt;br /&gt;
&amp;lt;pre&amp;gt;4)lorentz_fraction &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Value between 0 and 1 that determines the % Lorentzian character of the lineshape used in the broadening function(the remaining % is set to gaussian). By broadening function i essentially mean the peak thats placed around every MO energy in generating these spectra. lorentz_fraction=0 will give you a pure gaussian peak, while lorentz_fraction=1 gives a pure Lorentzian peak.&lt;br /&gt;
&amp;lt;pre&amp;gt;5)savetext/figsave/savejpeg/all_contribs_output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These all control whether a certain type of output file is saved, with variable names that should be self-explanatory.Values of 1 mean save the file, other values mean dont save. set savetext=0 to not save any .txt output files, figsave=0 to not save any .fig output, savejpeg=0 to not save any .jpeg outputs and all_contribs_output=0 to not save the .txt file with a full breakdown of the spectrum. Leaving them all as 1 (except maybe the savejpeg) is strongly recommended.&lt;br /&gt;
&lt;br /&gt;
====Plot_Atomic_Contribs_V3====&lt;br /&gt;
&lt;br /&gt;
This is an optional script that plots certain breakdowns of your calculated DoS/XPS spectrum (i.e you run it AFTER Gen_Gelius_Spectrum) . Its not too hard to do the same thing in excel using the *ALL_Contribs* output file (see output file sections) but this is a lot faster. There are three types of breakdown this function can do (see pictures below):&lt;br /&gt;
&lt;br /&gt;
1) Atomic breakdown with fragments kept seperate (merge_spd=1,merge_fragments=0)&lt;br /&gt;
&lt;br /&gt;
2) Atomic orbital breakdown (merge_spd=0,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
3) Atomic breakdown (merge_spd=1,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
The function in its uploaded form takes a single argument , though there are two variables in the actual code that you need to mess with (merge_spd and merge_fragments).&lt;br /&gt;
&lt;br /&gt;
So for example, to run this on the output file from the &amp;quot;Using the Example files&amp;quot; i typed into the matlab terminal:&lt;br /&gt;
&lt;br /&gt;
Plot_Atomic_Contribs_V3(&#039;C:\Users\Richard\Desktop\Open_Shell_Code_Some_Stuff\Example_files\other_file\DoS_1ev_0pt3l&#039;)&lt;br /&gt;
&lt;br /&gt;
The argument needs to be a folder containing the output files from the Gen_Gelius_Spectrum script. You&#039;ll then get a saved graph with the breakdown you asked for and also a .txt file containing the breakdown in a comma delimited format. The output file names record the options you used to make the script (e.g &amp;quot;Plotted_Atomic_Contribs_spd0_frag1.txt&amp;quot; means merge_spd was set to 0 and merge_fragments was set to 1).&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag1.jpg|thumbnail|center| merge_spd=1,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted_Atomic_Contribs_spd0_frag1.jpg|thumbnail|center| merge_spd=0,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag0.jpg|thumbnail|center| merge_spd=1,merge_fragments=0 ]]&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
&lt;br /&gt;
The first &amp;quot;output file&amp;quot; is the *MCRF*.txt file, which just contains the commands to build the required fragment in multiwfn.&lt;br /&gt;
&lt;br /&gt;
===Files From Multiwfn===&lt;br /&gt;
Most people should be able to completely ignore these files. But in case your curious:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1) *DOS_curve*.txt&#039;&#039;&#039; Essentially a DoS plot. 1st column is energies in au, second column is TDOS of the fragment. Not really sure what the 3rd column is. No particular use for this file, but it gets auto-generated by multiwfn and i dont go out my way to delete it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2) *DOS_line*.txt&#039;&#039;&#039; Data to create a stick plot (where each MO is a stick). Plot column 1 vs column 2 as a line graph and you get an axis with sticks representing the MOs. 4th column onwards represent contribution of the various sub-fragments to each &amp;quot;stick&amp;quot;. This is the file that gets used to generate the *ML_inpt.txt file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3) *DOS_frag*.txt &#039;&#039;&#039; This file contains the sub-fragment info in a way multiwfn understands. If its renamed to DOS_frag.txt then multiwfn can import it to get the fragments (therefore can be useful for debugging, no further purpose).&lt;br /&gt;
&lt;br /&gt;
===MLinpt.txt File===&lt;br /&gt;
&lt;br /&gt;
Creation of the *ML_inpt.txt files is essentially the point of the gen_gelius_input* script. These are primarily input files for matlab, but they do have useful information in an easy to read format. If you import the file into excel and COMMA DELIMIT ONLY (i.e untick the space delimit option) you can get something like below(there are more decimal places in the actual file):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#M_FACTOR=1.0,													&lt;br /&gt;
#Energy(eV)	TDOS	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	S3S	S3P	S3D&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
-24.5		0.9	0.0	0.0	0.0	0.5	0.1	0.0	0.2	0.1	0.0	0.1	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-19.8		0.3	0.0	0.0	0.0	0.1	-0.1	0.0	0.2	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
-19.7		0.3	0.0	0.0	0.0	0.0	0.0	0.0	0.1	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The shown file is &amp;quot;all_frags_alpha_MLinpt.txt&amp;quot;, which is generated from the example files in the open shell code. As this actually comes from merging two MLinpt.txt files (gen_gelius_input.sh does this part silently) the TDOS in this case doesnt mean anything.&lt;br /&gt;
&lt;br /&gt;
The first column lists the energy of each MO in eV (1 ev ~27.212 au). For any row, columns 3(CO4S)--&amp;gt;end (S3D) list the fractional contributions of each type of atmoic orbital to the MO in that row. For example the MO with energy -19.7 eV is mainly from S3s type atomic orbitals. These fractions were determiend by multiwfn by using Mulliken population analysis.&lt;br /&gt;
&lt;br /&gt;
All the fractional contributions in the file get multiplied by the M_FACTOR value (as explained above in the Creating your own input files section). Therefore the value of M_FACTOR can easily be set after the MLinpt.txt file is created, as opposed to within the initial input file.&lt;br /&gt;
&lt;br /&gt;
===Formatted_UMOs===&lt;br /&gt;
&lt;br /&gt;
The default for the gen_gelius_input* script (i.e the settings for the version i uploaded) is to put only OCCUPIED MO energies/breakdowns into the *MLinpt.txt file. If you want all MOs (I really DONT recommend this) in the MLinpt.txt file then change all_orbs=&#039;cheese&#039; to all_orbs=&#039;ALLORBS&#039; at the top of the gen_gelius_input* script.&lt;br /&gt;
&lt;br /&gt;
Otherwise you will get a *Formatted_UMOs* file for every MLinpt.txt file you get. The format of the file is identical to the MLinpt.txt format except the MO at the top of the file corresponds to the LUMO.&lt;br /&gt;
&lt;br /&gt;
WARNING: If you use the link_files feature, then the output formatted_UMOs files DO NOT get merged. This shouldnt matter as you should never really use the formatted UMOs for anything.&lt;br /&gt;
&lt;br /&gt;
===Output From Matlab Code ===&lt;br /&gt;
&lt;br /&gt;
The matlab code firstly will create a new folder with a name reflecting the input arguments. The format is hv_FWHM_%lorenztian where hv is the photon energy, FWHM is full width half maximum of the broadeing function and %lorenztian is the amount of lorenztian mixed in the broadening function. For example the earlier command (from using example files section) &amp;quot;Gen_Gelius_Spectrum(plist,-1,1)&amp;quot; generates the folder &amp;quot;DoS_1ev_0pt3l&amp;quot;. DoS = Density of states, and means we did not use photoionisation cross sections. The 0pt3l part means our broadening function was 30% lorenztian and 70% Gaussian.&lt;br /&gt;
&lt;br /&gt;
Two .fig files will have been produced from this code, these contain matlab graphs of the output. These .fig files follow the naming (&amp;quot;filename&amp;quot; is the name of the original fchk file):&lt;br /&gt;
&lt;br /&gt;
1) filename_DoS.fig contains the total DoS plot.&lt;br /&gt;
&lt;br /&gt;
2) filename_DoS_frag_contribs.fig contains the DoS AND the pDoS of each of the fragments. For closed shell code you get 1 fragment per input file (assuming you dont use link_files), but for the open shell code each input file leads to two fragments - one for alpha electrons and one for beta electrons.&lt;br /&gt;
&lt;br /&gt;
[[File:Other_file_DoS.jpeg|thumb|center| 1) Total Density of States for a Co(SCN)4 fragment with filename other_file_DoS.fig]]&lt;br /&gt;
&lt;br /&gt;
[[File:Other file DoS frag contribs.jpeg|thumb|center| 2) Contribtuions of alpha and beta electrons to the Total Density of States for Co(SCN)4, filename other_file_DoS_frag_contribs.fig]]&lt;br /&gt;
&lt;br /&gt;
The filename_DoS.fig plot data is output in a .txt file of the same name, while each fragment in filename_DoS_frag_contribs.fig has its own .txt file. For the example above the two fragments have names &amp;quot;all_frags_alpha_other_file_DoS&amp;quot; and &amp;quot;all_frags_beta_other_file_DoS&amp;quot;. The start of the names are taken from the name of the original input file &amp;quot;all_frags.test&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The final file output is the &amp;quot;ALL_Contribs_other_file_DoS.txt&amp;quot; file. This(as the name implies) contains all contributions to the DoS spectra in a comma delimited file. The Plot_Atomic_Contribs*.m code can be run on this file to generate plots with a few different breakdowns (e.g atomic breakdowns) - see the relevant section of this wiki (not done yet....). The file will look something like below (commas replaced with tabs):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#all_frags_alpha	all_frags_beta								&lt;br /&gt;
#Sub fragments in each=	12	12							&lt;br /&gt;
#Energy(eV)	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED,numbers rounded]&lt;br /&gt;
7.5		0.00	0.01	0.31	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.51		0.00	0.01	0.33	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.52		0.00	0.01	0.34	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.53		0.00	0.01	0.35	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.54		0.00	0.01	0.36	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.55		0.00	0.02	0.37	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.56		0.00	0.02	0.39	0.05	0.14	0.00	0.00	0.13	0.00	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hopefully the format is mostly intuitive, the top two rows contain information on what the data is, and the rest contain the data. The top row contains (originally comma delimited) a list of all &amp;quot;fragments&amp;quot; names, which is the number of input files for the closed shell code and 2x the number of input files for the open shell code. The second row contains the number of sub-fragments (which should be atomic orbitals) in each fragment. In the example above each fragment had 12 types of atomic orbital.&lt;br /&gt;
&lt;br /&gt;
So for the example above column 2-14 shows contributions from &amp;quot;all_frags_alpha&amp;quot; while column 15-27 shows contributions from &amp;quot;all_frags_beta&amp;quot; (column 1 lists energies).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Bugs/Things to Watch For==&lt;br /&gt;
===Fragment Names===&lt;br /&gt;
Make sure your fragment names arent a substring of your .fchk file names. For example an input file called &amp;quot;Cl.test&amp;quot; wont work for a file called &amp;quot;BMIM_Cl.fchk&amp;quot;. However, &amp;quot;Cl_frag.test&amp;quot; will work. Therefore personally i add _frag to the end of every input file name. The other way to sort this is to set linked_files=0 in gen_gelius_input_opensh.sh, sincce the link files part of the code is where this bug comes from.&lt;br /&gt;
&lt;br /&gt;
===Fragment Error Checking===&lt;br /&gt;
Unless you manually turn it off (The &amp;quot;error=&amp;quot; option in gen_gelius_input_opensh.sh script) the code tries to check your input file for errors. Specifically it tests whether the TDOS in an input_file really is the sum of the other sub-fragments in the input(.test) file. E.g it will trigger if you request only Sulfur p-type and d-type AOs (but no s-type AOs) in the input file, or if you request all sulfur p-type AOs twice. If the error check triggers then it BREAKS the input file for matlab by putting an error msg in the first line of the &#039;&#039;&#039;*MLinpt.txt file&#039;&#039;&#039;. An example of what the error looks like is:&lt;br /&gt;
&amp;lt;pre&amp;gt;	&lt;br /&gt;
“Fragment Sum incorrect on row 19 for fchk file xxxx.fchk”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you *MLinpt.txt files arent working in matlab then this is probably the reason.&lt;br /&gt;
&lt;br /&gt;
===Pathlengths===&lt;br /&gt;
This code makes a lot of sub-folders based on the name of .fchk files. If you have really long .fchk file names its likely that you&#039;ll end up with some files which exceed the 256 character limit for a pathlength on a windows computer. In matlab 2014 this will cause the code to exit with an error, saying it cant save the .fig files. In newer matlab versions it may just save the output files , but you wont be able to open them on windows if the path length is greater than 256 characters. Ways to avoid this are to shorten .fchk file names where possible, or (less practical) run the code on a folder as close as possible to root (i.e a folder with a short a pathlength as possible).&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630268</id>
		<title>Talk:Mod:Hunt Research Group/Calc XPS Code</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630268"/>
		<updated>2017-06-07T14:27:02Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Some Theory */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Links to Files==&lt;br /&gt;
Open Shell Version: [[Media:Gelius_open_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
Closed Shell Version: [[Media:Gelius_closed_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
The purpose of this code is to calculate partial density of states (pDoS) plots and Valence band x-ray photoelectron (XP) spectra from .fchk files. There is both an open shell and a closed shell version of the code, they work in exactly the same way.&lt;br /&gt;
&lt;br /&gt;
All code was written using python 2.7 (with numpy), Multiwfn version 3.3.8, Matlab version 2014a and a cygwin(bash) shell on windows 8. It should work on windows or linux if the correct options are set.  It might not work on a mac currently due to Multiwfn not working properly (I haven&#039;t personally tested it though). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Some Theory==&lt;br /&gt;
&lt;br /&gt;
===Mulliken Population Analysis===&lt;br /&gt;
&lt;br /&gt;
A pretty key part to this code is the breakdown of molecular orbitals (MOs) in atomic orbitals (AOs, which are essentially basis functions). This is carried out in multiwfn using Mulliken population analysis, which i&#039;ll briefly summarise due to its importance.&lt;br /&gt;
&lt;br /&gt;
The basic question is &amp;quot;For MO X, how many electrons come from atomic orbital Y?&amp;quot;. Hence we&#039;ll define &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the wavefunction for a &#039;&#039;&#039;single MO containing a single electron&#039;&#039;&#039;. Next we write &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the linear combination of individual basis functions (&amp;lt;math&amp;gt;\phi_{i}&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi = {{\sum\limits_{i} c_{i} \phi_{i} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since we want a number of electrons, we&#039;re interested in the formula for the electron density (&amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;) of this MO:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\rho = \langle{} \Psi | \Psi \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i} \phi_{i} }})({{\sum\limits_{i} c_{i} \phi_{i} }})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{} = ({{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }}) + 2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If these formulae are tricky to follow, try doing it for a system with just two basis functions.&lt;br /&gt;
Note that in the third line the indice &#039;&#039;j&#039;&#039; runs over the same coefficients and basis functions as the indice &#039;&#039;i&#039;&#039;, its just used to show that the &amp;lt;math&amp;gt;{{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term only contains products between 2 different basis functions/co-efficients.&lt;br /&gt;
Hence, we now have a formula for the MO density which is purely in terms of (known) basis functions and (known) coefficients. Now its just a case of working out how we should interpret these values.&lt;br /&gt;
&lt;br /&gt;
Firstly note that &amp;lt;math&amp;gt;\phi_{i}^{2}=1&amp;lt;/math&amp;gt; (since we use normalised basis functions) hence:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
{{\sum\limits_{i} c_{i}^{2} \phi_{i}^{2} }} = {{\sum\limits_{i} c_{i}^{2}}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The values of c_{i} in this expression are easy to interpret, they represent the fractional contribution of AO &#039;&#039;i&#039;&#039; to the wavefunction. The &amp;lt;math&amp;gt;2 {{ \sum\limits_{i&amp;gt;j}}} {{\sum\limits_{j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{}             }}&amp;lt;/math&amp;gt; term is more difficult to interpret, each expression in the series can be thought of as the number of electrons shared between two basis functions. i.e. the following term would represent the number of electrons shared between basis function 1 and 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{shared} = 2 c_{1}c_{2} \langle{}\phi_{1} | \phi_{2} \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we need to split this &amp;quot;shared&amp;quot; electron density between the two contributing basis functions. In Mulliken Population analysis &amp;quot;shared&amp;quot; electron density is divided equally between the two contributing basis functions. So the total electron density assigned to one basis function can be written as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
n_{i} = c_{i} + {{\sum\limits_{i \neq j} c_{i}c_{j} \langle{}\phi_{j} | \phi_{i} \rangle{} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; represents the &#039;&#039;&#039;fractional&#039;&#039;&#039; contribution of &#039;&#039;i&#039;&#039; to the wavefunction. Hence if you had a 2-electron MO, you&#039;d simply multiply &amp;lt;math&amp;gt;n_{i}&amp;lt;/math&amp;gt; by 2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What the code actually does (roughly/briefly)===&lt;br /&gt;
&lt;br /&gt;
==&amp;quot;Installation&amp;quot; Instructions==&lt;br /&gt;
&lt;br /&gt;
All instructions will be given for the open shell version of the code. However, the process is the same except whenever these instructions say to edit the &amp;quot;gen_gelius_input_opensh.sh&amp;quot;, just do the corresponding edit on the gen_gelius_input.sh file. The Matlab scripts are EXACTLY the same for both open shell/closed shell codes.&lt;br /&gt;
&lt;br /&gt;
0) Make sure you have multiwfn (https://multiwfn.codeplex.com) saved somewhere, python 2.x and numpy installed.&lt;br /&gt;
&lt;br /&gt;
1)Put the following files (all the .py/.sh files) somewhere in system path (e.g i use /usr/local/bin):&lt;br /&gt;
:a)Format_Multiwfn_Output_alpha.py (Format_Multiwfn_Output.py for closed shell)&lt;br /&gt;
:b)Format_Multilwfn_Output_beta.py&lt;br /&gt;
:c)Gen_Multiwfn_Input_Comms.py&lt;br /&gt;
:d)Gen_Multiwfn_Input_Comms_beta.py&lt;br /&gt;
:e)Merge_Fragment_Files.py&lt;br /&gt;
:f)gen_gelius_input_opensh.sh&lt;br /&gt;
&lt;br /&gt;
Make sure all files have executable persmission (navigate to the folder and do &amp;quot;chmod u+x filename&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
2)In the gen_gelius_input_opensh.sh change the current lines accordingly:&lt;br /&gt;
:a) multiwfn_folder = &#039;C:/Users/Richard/Documents/Multiwfn_Installed&#039; to the directory where you store multiwfn and associated files.&lt;br /&gt;
:b) &amp;quot;cygwin=1” to “cygwin=0” if your not using a Cygwin shell.&lt;br /&gt;
:c) “old_sed=1” to “old_sed=0” if your version of sed allows the –i option (edit in place) to be used. I don’t think the standard version on mac does(meaning set old_sed=1),standard version of Cygwin does though.&lt;br /&gt;
:d) POSSIBLY &amp;quot;cp $multiwfn_folder/Multiwfn.exe $curr_folder&amp;quot; to &amp;quot;cp $multiwfn_folder/Multiwfn $curr_folder&amp;quot; if on linux(should be really obvious if this is required). Do the same for the line where multiwfn is deleted from current folder(&amp;quot;rm Multiwfn.exe&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
3)Put the following files somewhere in matlabs path (e.g your matlab folder in documents)&lt;br /&gt;
:a) Get_X_Section.m&lt;br /&gt;
:b) Gen_Gelius_Spectrum.m&lt;br /&gt;
&lt;br /&gt;
The Get_X_Section REALLY does need to be in matlabs path (unless you want to edit some code in Gen_Gelius_Spectrum.m). If you know what your doing in matlab  feel free to put Gen_Gelius_Spectrum.m wherever you want.&lt;br /&gt;
&lt;br /&gt;
4)Put the X_Section_Library folder wherever you want.&lt;br /&gt;
&lt;br /&gt;
5) In Get_X_Section.m modify the following line:&lt;br /&gt;
:&amp;quot;Lib_Path =&#039;C:\Users\Richard\Documents\X_Section_Library&#039; &amp;quot; to the path where you put the X_Section_Library folder in.&lt;br /&gt;
&lt;br /&gt;
6) OPTIONAL: Add the code in vim_template_script to your vimrc (c+p it somewhere in the file). &amp;quot;vim ~/.vimrc&amp;quot; to access your vimrc. You can then bring up a template input file in vim by using &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
Since i forgot to put the relevant text file in to the code folders, just c+p the below into your vimrc to get this to work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function! Gelius_Input()&lt;br /&gt;
        exe &#039;normal aCoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr.fchk\rNumb_Fragments=10\r1a=\r1t=a\r1l=TDOS\r2a=\r2t=\r2l=\r3a=\r3t=\r3l=\r4a=\r4t=\r4l=\r5a=\r5t=\r5l=\r6a=\r6t=\r6l=\r7a=\r7t=\r7l=\r8a=\r8t=\r8l=\r9a=\r9t=\r9l=\r10a=\r10t=\r10l=\rM_factor=1.0\rLink_File=&#039;&lt;br /&gt;
        exe &#039;%s/\\r/\r/g&#039;&lt;br /&gt;
endfunction&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
====Using the Example files====&lt;br /&gt;
1) Navigate (in your shell) to the folder &amp;quot;Example_files&amp;quot;. e.g for me i ran:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;cd /cygdrive/c/Users/Richard/Documents/Random_Coding/Gelius_Spectrum_Automated_Jan_2016/open_shell_code/Example_files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
2) Run this command in console(for closed shell use  gen_gelius_input.sh):&lt;br /&gt;
&lt;br /&gt;
&amp;quot;gen_gelius_input_opensh.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Command 2) will have created a folder for each .fchk file in Example_files/. Therefore you should now have folders:&lt;br /&gt;
:CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&lt;br /&gt;
:other_file&lt;br /&gt;
Within these folders are tons of output files. The most important ones are those ending in &amp;quot;MLinpt.txt&amp;quot; - these will be the input files for step 3.&lt;br /&gt;
&lt;br /&gt;
The script will run on all .fchk files in the current folder, when you do this for real you need to make sure that all the fchks are for the same system (e.g a water molecule) and that the atomic numbering is the same in all files (view--&amp;gt;labels in gaussview gives you what im calling atomic numbering).&lt;br /&gt;
&lt;br /&gt;
If anything went wrong try revisiting the installation instructions.&lt;br /&gt;
&lt;br /&gt;
3) Everything from now on is done using matlab. Theres a file called &amp;quot;pathname_file&amp;quot; in the Example_files folder which was created by the gen_gelius_input_opensh.sh script. Copy its full contents to clipboard and in MATLAB terminal type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist=&amp;lt;CTRL-V&amp;gt;&lt;br /&gt;
(&amp;lt;CTRL-V&amp;gt; means paste, rather than type out CTRL-V) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In matlab terms, plist now contains a cell array where each entry is the full path to a folder. The folder paths are those for the folders created in step 2). Hence to do this manually for just one of the two folders you&#039;d type something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist={&#039;C:\Users\Richard\Documents\Random_Coding\Gelius_Spectrum_Automated_Jan_2016\open_shell_code\Example_files\other_file&#039;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4) To create either an XPS spectrum or pDoS plots we use the Gen_Gelius_Spectrum script. This takes the following three arguments IN THE FOLLOWING ORDER:&lt;br /&gt;
:a) the plist variable we just made&lt;br /&gt;
:b) the photon energy we want to use (any negative number requests a pDoS rather than an XPS spectrum)&lt;br /&gt;
:c) the FWHM of the peaks to place around each MO energy (units = eV)&lt;br /&gt;
&lt;br /&gt;
So to create a pDoS plot you could type the following into the matlab terminal(Try this one first):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,-1,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To create an XPS spectrum taken at photon energy of 1486eV (standard lab-based value) type the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,1486,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you get an error like &amp;quot;Undefined function &#039;Gen_Gelius_Spectrum&#039; for input arguments of type &#039;cell&#039;.&amp;quot;, then your Gen_Gelius_Spectrum script probably isnt in your matlab path. (see installation instructions, or google a bit)&lt;br /&gt;
&lt;br /&gt;
If your error free then well done. Sub-folders should have been created in &amp;quot;other_file&amp;quot; and &amp;quot;CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&amp;quot;, which in turn will contain a loada output files. See the output files section of the wiki for an explanation of what these are.&lt;br /&gt;
&lt;br /&gt;
====Creating your own input files====&lt;br /&gt;
If you followed the optional part above and made a vimscript, then a template for the input file can be brought up in vim by typing &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example input file is shown below. Each &amp;quot;fragment&amp;quot; (e.g cation,anion, alkyl group etc.) should have its own input file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
other_file.fchk&lt;br /&gt;
Numb_Fragments=4&lt;br /&gt;
1a=10-13&lt;br /&gt;
1t=a&lt;br /&gt;
1l=TDOS&lt;br /&gt;
2a=10-13&lt;br /&gt;
2t=s&lt;br /&gt;
2l=S3s&lt;br /&gt;
3a=10-13&lt;br /&gt;
3t=p&lt;br /&gt;
3l=S3p&lt;br /&gt;
4a=10-13&lt;br /&gt;
4t=d+&lt;br /&gt;
4l=S3d&lt;br /&gt;
M_factor=1.0&lt;br /&gt;
Link_File=all_frags.test&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The input file can be divided into parts as follows:&lt;br /&gt;
&lt;br /&gt;
1) The top line of the input file tells the code the name of the checkpoint file to use in the calculation. In practice you can write ANYTHING on this top line if using the gen_gelius_input*.sh script, as the script itself replaces the first line (whatevers there) with the names of all .fchks in the current folder. But SOMETHING must be written there.&lt;br /&gt;
&lt;br /&gt;
2)&#039;&#039;&#039;Numb_Fragments&#039;&#039;&#039; is the number of sub-fragments (max 10) that you want to break your pDoS down into (e.g fragment 2 corresponds to all Sulfur 3s atomic orbitals in the example above). Code will break if you get this wrong.&lt;br /&gt;
&lt;br /&gt;
3) &#039;&#039;&#039;1a/1t/1l&#039;&#039;&#039; instruct the code what to use as the total density of states. Hence 1a must be set to ALL the atoms your interested in for this fragment, 1t must be set to &amp;quot;a&amp;quot; and 1l should be set to TDOS (not sure it matters what this is set to, but to be on the safe side just use TDOS). The purpose of this fragment is essentially error checking.&lt;br /&gt;
&lt;br /&gt;
4) &#039;&#039;&#039;2a/3a/*a&#039;&#039;&#039; : a stands for atoms here, so the value of a corresponds to the labels of the atoms you want to be included in the sub-fragment. These labels are the same integers you get in gaussview when you go to view--&amp;gt;labels. Examples of valid options may be &amp;quot;1,4,5-7&amp;quot; or &amp;quot;1,3,5&amp;quot; (basically comma seperated list of integers)&lt;br /&gt;
&lt;br /&gt;
5) &#039;&#039;&#039;2t/3t/*t&#039;&#039;&#039;: t stands for &amp;quot;type of AO&amp;quot;.This is a comma seperated list with possible arguments (any combination) &amp;quot;a,s,p,d,f,g&amp;quot;. &amp;quot;a&amp;quot; corresponds to all types of AO centered of the atoms specified with the 2a/3a/*a line. s means s-type atomc orbitals (0 angular momentum), p means p-type atomic orbitals (1 angular momentum) etc. To get all AOs of a certain angular momentum and higher (up to g-type AOs) add a plus to the end of the relevant letter. e.g &amp;quot;p+&amp;quot; says &amp;quot;include all AOs with angular momemtnum greater than or equal to 1 in this sub-fragment&amp;quot;)&lt;br /&gt;
&#039;&#039;&#039;DON&#039;T&#039;&#039;&#039; use &amp;quot;a&amp;quot; with any other letter, and dont do anything else that will lead to a type of AO being requested twice (e.g p+,d)&lt;br /&gt;
&lt;br /&gt;
6) &#039;&#039;&#039;2l/3l/*l&#039;&#039;&#039;: l stands for label. If you dont care about calculating an XPS spectrum you can essentially set it to whatever you want. This tells the matlab script what cross section to use for calculating the XPS spectrum, hence it must match (case insensitive) a filename in the X_Section_Library folder. e.g S3s tells matlab to get the S3S.txt file when looking for what cross-section to use.&lt;br /&gt;
&lt;br /&gt;
7) &#039;&#039;&#039;M_factor=1.0&#039;&#039;&#039;, you really never need to modify this but make sure its present. It&#039;s purpose is to tell matlab to multiple the pDoS of this fragment (that this input file corresponds to) by the  value M_factor. The purpose is for systems where the real stoichiometry differs from that in your calculation. For example if i have a mixture of 99 water:1 anion but only a calculation on 1 water molecule mixed with 1 anion i could set M_factor for the water fragment input file to M_factor=99.0 to estimate (badly) what the actual DoS of the mixture would look like.&lt;br /&gt;
&lt;br /&gt;
8) &#039;&#039;&#039;Link_File=*&#039;&#039;&#039;. This options for if you have a fragment (e.g an anion) but want it broken into more than 10 sub-fragments (e.g this will be true for any molecule with &amp;gt;3 elements). In this case make 2 files for that fragment, and in the second  file set Link_File to the name of the first file. In the example above, this input file will essentially be merged with &amp;quot;all_frags.test&amp;quot;, and only an output file for all_frags.test will be generated.&lt;br /&gt;
&lt;br /&gt;
====More complex input file options====&lt;br /&gt;
====Gen_Gelius_Spectrum.m====&lt;br /&gt;
This code has the following options that can be changed (all are explained by comments in the .m file):&lt;br /&gt;
&amp;lt;pre&amp;gt;1)min_e/max_e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Matlab ignores any orbitals with energy below min_e or above max_e when generating the XPS spectrum. Note if you want to change this to include core orbitals or very high energy virtual orbitals then you&#039;ll also have to edit Gen_Multiwfn_Input_Comms.py to set the range in multiwfn to the one you want.(Theres currently no variable in that .py code to do that, it just uses the defaults in multiwfn. But the function you&#039;ll need to edit in Gen_Multiwfn_Input_Comms.py is Output_Header.&lt;br /&gt;
&amp;lt;pre&amp;gt;2)min_e_plotted/max_e_plotted&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These refer to the minimum/maximum binding energies to calculate spectral intensity for. The range should probably be slightly wider than the min_e/max_e range really, though thats not the default setting. &lt;br /&gt;
&amp;lt;pre&amp;gt;3)step_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The value (in eV) between calculated data points in the output spectra. For example, if set to 0.001eV then a data point will be calculated for 0eV,0.001eV,0.002eV etc. Lower values=larger files/slower runtimes.&lt;br /&gt;
&amp;lt;pre&amp;gt;4)lorentz_fraction &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Value between 0 and 1 that determines the % Lorentzian character of the lineshape used in the broadening function(the remaining % is set to gaussian). By broadening function i essentially mean the peak thats placed around every MO energy in generating these spectra. lorentz_fraction=0 will give you a pure gaussian peak, while lorentz_fraction=1 gives a pure Lorentzian peak.&lt;br /&gt;
&amp;lt;pre&amp;gt;5)savetext/figsave/savejpeg/all_contribs_output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These all control whether a certain type of output file is saved, with variable names that should be self-explanatory.Values of 1 mean save the file, other values mean dont save. set savetext=0 to not save any .txt output files, figsave=0 to not save any .fig output, savejpeg=0 to not save any .jpeg outputs and all_contribs_output=0 to not save the .txt file with a full breakdown of the spectrum. Leaving them all as 1 (except maybe the savejpeg) is strongly recommended.&lt;br /&gt;
&lt;br /&gt;
====Plot_Atomic_Contribs_V3====&lt;br /&gt;
&lt;br /&gt;
This is an optional script that plots certain breakdowns of your calculated DoS/XPS spectrum (i.e you run it AFTER Gen_Gelius_Spectrum) . Its not too hard to do the same thing in excel using the *ALL_Contribs* output file (see output file sections) but this is a lot faster. There are three types of breakdown this function can do (see pictures below):&lt;br /&gt;
&lt;br /&gt;
1) Atomic breakdown with fragments kept seperate (merge_spd=1,merge_fragments=0)&lt;br /&gt;
&lt;br /&gt;
2) Atomic orbital breakdown (merge_spd=0,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
3) Atomic breakdown (merge_spd=1,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
The function in its uploaded form takes a single argument , though there are two variables in the actual code that you need to mess with (merge_spd and merge_fragments).&lt;br /&gt;
&lt;br /&gt;
So for example, to run this on the output file from the &amp;quot;Using the Example files&amp;quot; i typed into the matlab terminal:&lt;br /&gt;
&lt;br /&gt;
Plot_Atomic_Contribs_V3(&#039;C:\Users\Richard\Desktop\Open_Shell_Code_Some_Stuff\Example_files\other_file\DoS_1ev_0pt3l&#039;)&lt;br /&gt;
&lt;br /&gt;
The argument needs to be a folder containing the output files from the Gen_Gelius_Spectrum script. You&#039;ll then get a saved graph with the breakdown you asked for and also a .txt file containing the breakdown in a comma delimited format. The output file names record the options you used to make the script (e.g &amp;quot;Plotted_Atomic_Contribs_spd0_frag1.txt&amp;quot; means merge_spd was set to 0 and merge_fragments was set to 1).&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag1.jpg|thumbnail|center| merge_spd=1,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted_Atomic_Contribs_spd0_frag1.jpg|thumbnail|center| merge_spd=0,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag0.jpg|thumbnail|center| merge_spd=1,merge_fragments=0 ]]&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
&lt;br /&gt;
The first &amp;quot;output file&amp;quot; is the *MCRF*.txt file, which just contains the commands to build the required fragment in multiwfn.&lt;br /&gt;
&lt;br /&gt;
===Files From Multiwfn===&lt;br /&gt;
Most people should be able to completely ignore these files. But in case your curious:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1) *DOS_curve*.txt&#039;&#039;&#039; Essentially a DoS plot. 1st column is energies in au, second column is TDOS of the fragment. Not really sure what the 3rd column is. No particular use for this file, but it gets auto-generated by multiwfn and i dont go out my way to delete it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2) *DOS_line*.txt&#039;&#039;&#039; Data to create a stick plot (where each MO is a stick). Plot column 1 vs column 2 as a line graph and you get an axis with sticks representing the MOs. 4th column onwards represent contribution of the various sub-fragments to each &amp;quot;stick&amp;quot;. This is the file that gets used to generate the *ML_inpt.txt file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3) *DOS_frag*.txt &#039;&#039;&#039; This file contains the sub-fragment info in a way multiwfn understands. If its renamed to DOS_frag.txt then multiwfn can import it to get the fragments (therefore can be useful for debugging, no further purpose).&lt;br /&gt;
&lt;br /&gt;
===MLinpt.txt File===&lt;br /&gt;
&lt;br /&gt;
Creation of the *ML_inpt.txt files is essentially the point of the gen_gelius_input* script. These are primarily input files for matlab, but they do have useful information in an easy to read format. If you import the file into excel and COMMA DELIMIT ONLY (i.e untick the space delimit option) you can get something like below(there are more decimal places in the actual file):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#M_FACTOR=1.0,													&lt;br /&gt;
#Energy(eV)	TDOS	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	S3S	S3P	S3D&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
-24.5		0.9	0.0	0.0	0.0	0.5	0.1	0.0	0.2	0.1	0.0	0.1	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-19.8		0.3	0.0	0.0	0.0	0.1	-0.1	0.0	0.2	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
-19.7		0.3	0.0	0.0	0.0	0.0	0.0	0.0	0.1	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The shown file is &amp;quot;all_frags_alpha_MLinpt.txt&amp;quot;, which is generated from the example files in the open shell code. As this actually comes from merging two MLinpt.txt files (gen_gelius_input.sh does this part silently) the TDOS in this case doesnt mean anything.&lt;br /&gt;
&lt;br /&gt;
The first column lists the energy of each MO in eV (1 ev ~27.212 au). For any row, columns 3(CO4S)--&amp;gt;end (S3D) list the fractional contributions of each type of atmoic orbital to the MO in that row. For example the MO with energy -19.7 eV is mainly from S3s type atomic orbitals. These fractions were determiend by multiwfn by using Mulliken population analysis.&lt;br /&gt;
&lt;br /&gt;
All the fractional contributions in the file get multiplied by the M_FACTOR value (as explained above in the Creating your own input files section). Therefore the value of M_FACTOR can easily be set after the MLinpt.txt file is created, as opposed to within the initial input file.&lt;br /&gt;
&lt;br /&gt;
===Formatted_UMOs===&lt;br /&gt;
&lt;br /&gt;
The default for the gen_gelius_input* script (i.e the settings for the version i uploaded) is to put only OCCUPIED MO energies/breakdowns into the *MLinpt.txt file. If you want all MOs (I really DONT recommend this) in the MLinpt.txt file then change all_orbs=&#039;cheese&#039; to all_orbs=&#039;ALLORBS&#039; at the top of the gen_gelius_input* script.&lt;br /&gt;
&lt;br /&gt;
Otherwise you will get a *Formatted_UMOs* file for every MLinpt.txt file you get. The format of the file is identical to the MLinpt.txt format except the MO at the top of the file corresponds to the LUMO.&lt;br /&gt;
&lt;br /&gt;
WARNING: If you use the link_files feature, then the output formatted_UMOs files DO NOT get merged. This shouldnt matter as you should never really use the formatted UMOs for anything.&lt;br /&gt;
&lt;br /&gt;
===Output From Matlab Code ===&lt;br /&gt;
&lt;br /&gt;
The matlab code firstly will create a new folder with a name reflecting the input arguments. The format is hv_FWHM_%lorenztian where hv is the photon energy, FWHM is full width half maximum of the broadeing function and %lorenztian is the amount of lorenztian mixed in the broadening function. For example the earlier command (from using example files section) &amp;quot;Gen_Gelius_Spectrum(plist,-1,1)&amp;quot; generates the folder &amp;quot;DoS_1ev_0pt3l&amp;quot;. DoS = Density of states, and means we did not use photoionisation cross sections. The 0pt3l part means our broadening function was 30% lorenztian and 70% Gaussian.&lt;br /&gt;
&lt;br /&gt;
Two .fig files will have been produced from this code, these contain matlab graphs of the output. These .fig files follow the naming (&amp;quot;filename&amp;quot; is the name of the original fchk file):&lt;br /&gt;
&lt;br /&gt;
1) filename_DoS.fig contains the total DoS plot.&lt;br /&gt;
&lt;br /&gt;
2) filename_DoS_frag_contribs.fig contains the DoS AND the pDoS of each of the fragments. For closed shell code you get 1 fragment per input file (assuming you dont use link_files), but for the open shell code each input file leads to two fragments - one for alpha electrons and one for beta electrons.&lt;br /&gt;
&lt;br /&gt;
[[File:Other_file_DoS.jpeg|thumb|center| 1) Total Density of States for a Co(SCN)4 fragment with filename other_file_DoS.fig]]&lt;br /&gt;
&lt;br /&gt;
[[File:Other file DoS frag contribs.jpeg|thumb|center| 2) Contribtuions of alpha and beta electrons to the Total Density of States for Co(SCN)4, filename other_file_DoS_frag_contribs.fig]]&lt;br /&gt;
&lt;br /&gt;
The filename_DoS.fig plot data is output in a .txt file of the same name, while each fragment in filename_DoS_frag_contribs.fig has its own .txt file. For the example above the two fragments have names &amp;quot;all_frags_alpha_other_file_DoS&amp;quot; and &amp;quot;all_frags_beta_other_file_DoS&amp;quot;. The start of the names are taken from the name of the original input file &amp;quot;all_frags.test&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The final file output is the &amp;quot;ALL_Contribs_other_file_DoS.txt&amp;quot; file. This(as the name implies) contains all contributions to the DoS spectra in a comma delimited file. The Plot_Atomic_Contribs*.m code can be run on this file to generate plots with a few different breakdowns (e.g atomic breakdowns) - see the relevant section of this wiki (not done yet....). The file will look something like below (commas replaced with tabs):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#all_frags_alpha	all_frags_beta								&lt;br /&gt;
#Sub fragments in each=	12	12							&lt;br /&gt;
#Energy(eV)	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED,numbers rounded]&lt;br /&gt;
7.5		0.00	0.01	0.31	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.51		0.00	0.01	0.33	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.52		0.00	0.01	0.34	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.53		0.00	0.01	0.35	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.54		0.00	0.01	0.36	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.55		0.00	0.02	0.37	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.56		0.00	0.02	0.39	0.05	0.14	0.00	0.00	0.13	0.00	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hopefully the format is mostly intuitive, the top two rows contain information on what the data is, and the rest contain the data. The top row contains (originally comma delimited) a list of all &amp;quot;fragments&amp;quot; names, which is the number of input files for the closed shell code and 2x the number of input files for the open shell code. The second row contains the number of sub-fragments (which should be atomic orbitals) in each fragment. In the example above each fragment had 12 types of atomic orbital.&lt;br /&gt;
&lt;br /&gt;
So for the example above column 2-14 shows contributions from &amp;quot;all_frags_alpha&amp;quot; while column 15-27 shows contributions from &amp;quot;all_frags_beta&amp;quot; (column 1 lists energies).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Bugs/Things to Watch For==&lt;br /&gt;
===Fragment Names===&lt;br /&gt;
Make sure your fragment names arent a substring of your .fchk file names. For example an input file called &amp;quot;Cl.test&amp;quot; wont work for a file called &amp;quot;BMIM_Cl.fchk&amp;quot;. However, &amp;quot;Cl_frag.test&amp;quot; will work. Therefore personally i add _frag to the end of every input file name. The other way to sort this is to set linked_files=0 in gen_gelius_input_opensh.sh, sincce the link files part of the code is where this bug comes from.&lt;br /&gt;
&lt;br /&gt;
===Fragment Error Checking===&lt;br /&gt;
Unless you manually turn it off (The &amp;quot;error=&amp;quot; option in gen_gelius_input_opensh.sh script) the code tries to check your input file for errors. Specifically it tests whether the TDOS in an input_file really is the sum of the other sub-fragments in the input(.test) file. E.g it will trigger if you request only Sulfur p-type and d-type AOs (but no s-type AOs) in the input file, or if you request all sulfur p-type AOs twice. If the error check triggers then it BREAKS the input file for matlab by putting an error msg in the first line of the &#039;&#039;&#039;*MLinpt.txt file&#039;&#039;&#039;. An example of what the error looks like is:&lt;br /&gt;
&amp;lt;pre&amp;gt;	&lt;br /&gt;
“Fragment Sum incorrect on row 19 for fchk file xxxx.fchk”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you *MLinpt.txt files arent working in matlab then this is probably the reason.&lt;br /&gt;
&lt;br /&gt;
===Pathlengths===&lt;br /&gt;
This code makes a lot of sub-folders based on the name of .fchk files. If you have really long .fchk file names its likely that you&#039;ll end up with some files which exceed the 256 character limit for a pathlength on a windows computer. In matlab 2014 this will cause the code to exit with an error, saying it cant save the .fig files. In newer matlab versions it may just save the output files , but you wont be able to open them on windows if the path length is greater than 256 characters. Ways to avoid this are to shorten .fchk file names where possible, or (less practical) run the code on a folder as close as possible to root (i.e a folder with a short a pathlength as possible).&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630267</id>
		<title>Talk:Mod:Hunt Research Group/Calc XPS Code</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code&amp;diff=630267"/>
		<updated>2017-06-07T13:56:54Z</updated>

		<summary type="html">&lt;p&gt;Rf614: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Links to Files==&lt;br /&gt;
Open Shell Version: [[Media:Gelius_open_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
Closed Shell Version: [[Media:Gelius_closed_shell_code_Aug2016.zip]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
The purpose of this code is to calculate partial density of states (pDoS) plots and Valence band x-ray photoelectron (XP) spectra from .fchk files. There is both an open shell and a closed shell version of the code, they work in exactly the same way.&lt;br /&gt;
&lt;br /&gt;
All code was written using python 2.7 (with numpy), Multiwfn version 3.3.8, Matlab version 2014a and a cygwin(bash) shell on windows 8. It should work on windows or linux if the correct options are set.  It might not work on a mac currently due to Multiwfn not working properly (I haven&#039;t personally tested it though). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Some Theory==&lt;br /&gt;
&lt;br /&gt;
===Mulliken Population Analysis===&lt;br /&gt;
&lt;br /&gt;
A pretty key part to this code is the breakdown of molecular orbitals (MOs) in atomic orbitals (AOs, which are essentially basis functions). This is carried out in multiwfn using Mulliken population analysis, which i&#039;ll briefly summarise due to its importance.&lt;br /&gt;
&lt;br /&gt;
The basic question is &amp;quot;For MO X, how many electrons come from atomic orbital Y?&amp;quot;. Hence we&#039;ll define &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the wavefunction for a single MO. Next we write &amp;lt;math&amp;gt;\psi&amp;lt;/math&amp;gt; as the linear combination of individual basis functions (&amp;lt;math&amp;gt;\phi_{i}&amp;lt;/math&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi = {{\sum\limits_{i} c_{i} \phi_{i} }}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since we want a number of electrons, we&#039;re interested in the formula for the electron density:&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\langle{}\Psi | \Psi \rangle{}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What the code actually does (roughly/briefly)===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==&amp;quot;Installation&amp;quot; Instructions==&lt;br /&gt;
&lt;br /&gt;
All instructions will be given for the open shell version of the code. However, the process is the same except whenever these instructions say to edit the &amp;quot;gen_gelius_input_opensh.sh&amp;quot;, just do the corresponding edit on the gen_gelius_input.sh file. The Matlab scripts are EXACTLY the same for both open shell/closed shell codes.&lt;br /&gt;
&lt;br /&gt;
0) Make sure you have multiwfn (https://multiwfn.codeplex.com) saved somewhere, python 2.x and numpy installed.&lt;br /&gt;
&lt;br /&gt;
1)Put the following files (all the .py/.sh files) somewhere in system path (e.g i use /usr/local/bin):&lt;br /&gt;
:a)Format_Multiwfn_Output_alpha.py (Format_Multiwfn_Output.py for closed shell)&lt;br /&gt;
:b)Format_Multilwfn_Output_beta.py&lt;br /&gt;
:c)Gen_Multiwfn_Input_Comms.py&lt;br /&gt;
:d)Gen_Multiwfn_Input_Comms_beta.py&lt;br /&gt;
:e)Merge_Fragment_Files.py&lt;br /&gt;
:f)gen_gelius_input_opensh.sh&lt;br /&gt;
&lt;br /&gt;
Make sure all files have executable persmission (navigate to the folder and do &amp;quot;chmod u+x filename&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
2)In the gen_gelius_input_opensh.sh change the current lines accordingly:&lt;br /&gt;
:a) multiwfn_folder = &#039;C:/Users/Richard/Documents/Multiwfn_Installed&#039; to the directory where you store multiwfn and associated files.&lt;br /&gt;
:b) &amp;quot;cygwin=1” to “cygwin=0” if your not using a Cygwin shell.&lt;br /&gt;
:c) “old_sed=1” to “old_sed=0” if your version of sed allows the –i option (edit in place) to be used. I don’t think the standard version on mac does(meaning set old_sed=1),standard version of Cygwin does though.&lt;br /&gt;
:d) POSSIBLY &amp;quot;cp $multiwfn_folder/Multiwfn.exe $curr_folder&amp;quot; to &amp;quot;cp $multiwfn_folder/Multiwfn $curr_folder&amp;quot; if on linux(should be really obvious if this is required). Do the same for the line where multiwfn is deleted from current folder(&amp;quot;rm Multiwfn.exe&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
3)Put the following files somewhere in matlabs path (e.g your matlab folder in documents)&lt;br /&gt;
:a) Get_X_Section.m&lt;br /&gt;
:b) Gen_Gelius_Spectrum.m&lt;br /&gt;
&lt;br /&gt;
The Get_X_Section REALLY does need to be in matlabs path (unless you want to edit some code in Gen_Gelius_Spectrum.m). If you know what your doing in matlab  feel free to put Gen_Gelius_Spectrum.m wherever you want.&lt;br /&gt;
&lt;br /&gt;
4)Put the X_Section_Library folder wherever you want.&lt;br /&gt;
&lt;br /&gt;
5) In Get_X_Section.m modify the following line:&lt;br /&gt;
:&amp;quot;Lib_Path =&#039;C:\Users\Richard\Documents\X_Section_Library&#039; &amp;quot; to the path where you put the X_Section_Library folder in.&lt;br /&gt;
&lt;br /&gt;
6) OPTIONAL: Add the code in vim_template_script to your vimrc (c+p it somewhere in the file). &amp;quot;vim ~/.vimrc&amp;quot; to access your vimrc. You can then bring up a template input file in vim by using &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
Since i forgot to put the relevant text file in to the code folders, just c+p the below into your vimrc to get this to work.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function! Gelius_Input()&lt;br /&gt;
        exe &#039;normal aCoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr.fchk\rNumb_Fragments=10\r1a=\r1t=a\r1l=TDOS\r2a=\r2t=\r2l=\r3a=\r3t=\r3l=\r4a=\r4t=\r4l=\r5a=\r5t=\r5l=\r6a=\r6t=\r6l=\r7a=\r7t=\r7l=\r8a=\r8t=\r8l=\r9a=\r9t=\r9l=\r10a=\r10t=\r10l=\rM_factor=1.0\rLink_File=&#039;&lt;br /&gt;
        exe &#039;%s/\\r/\r/g&#039;&lt;br /&gt;
endfunction&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
====Using the Example files====&lt;br /&gt;
1) Navigate (in your shell) to the folder &amp;quot;Example_files&amp;quot;. e.g for me i ran:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;cd /cygdrive/c/Users/Richard/Documents/Random_Coding/Gelius_Spectrum_Automated_Jan_2016/open_shell_code/Example_files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
2) Run this command in console(for closed shell use  gen_gelius_input.sh):&lt;br /&gt;
&lt;br /&gt;
&amp;quot;gen_gelius_input_opensh.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Command 2) will have created a folder for each .fchk file in Example_files/. Therefore you should now have folders:&lt;br /&gt;
:CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&lt;br /&gt;
:other_file&lt;br /&gt;
Within these folders are tons of output files. The most important ones are those ending in &amp;quot;MLinpt.txt&amp;quot; - these will be the input files for step 3.&lt;br /&gt;
&lt;br /&gt;
The script will run on all .fchk files in the current folder, when you do this for real you need to make sure that all the fchks are for the same system (e.g a water molecule) and that the atomic numbering is the same in all files (view--&amp;gt;labels in gaussview gives you what im calling atomic numbering).&lt;br /&gt;
&lt;br /&gt;
If anything went wrong try revisiting the installation instructions.&lt;br /&gt;
&lt;br /&gt;
3) Everything from now on is done using matlab. Theres a file called &amp;quot;pathname_file&amp;quot; in the Example_files folder which was created by the gen_gelius_input_opensh.sh script. Copy its full contents to clipboard and in MATLAB terminal type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist=&amp;lt;CTRL-V&amp;gt;&lt;br /&gt;
(&amp;lt;CTRL-V&amp;gt; means paste, rather than type out CTRL-V) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In matlab terms, plist now contains a cell array where each entry is the full path to a folder. The folder paths are those for the folders created in step 2). Hence to do this manually for just one of the two folders you&#039;d type something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
plist={&#039;C:\Users\Richard\Documents\Random_Coding\Gelius_Spectrum_Automated_Jan_2016\open_shell_code\Example_files\other_file&#039;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4) To create either an XPS spectrum or pDoS plots we use the Gen_Gelius_Spectrum script. This takes the following three arguments IN THE FOLLOWING ORDER:&lt;br /&gt;
:a) the plist variable we just made&lt;br /&gt;
:b) the photon energy we want to use (any negative number requests a pDoS rather than an XPS spectrum)&lt;br /&gt;
:c) the FWHM of the peaks to place around each MO energy (units = eV)&lt;br /&gt;
&lt;br /&gt;
So to create a pDoS plot you could type the following into the matlab terminal(Try this one first):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,-1,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To create an XPS spectrum taken at photon energy of 1486eV (standard lab-based value) type the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Gen_Gelius_Spectrum(plist,1486,1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you get an error like &amp;quot;Undefined function &#039;Gen_Gelius_Spectrum&#039; for input arguments of type &#039;cell&#039;.&amp;quot;, then your Gen_Gelius_Spectrum script probably isnt in your matlab path. (see installation instructions, or google a bit)&lt;br /&gt;
&lt;br /&gt;
If your error free then well done. Sub-folders should have been created in &amp;quot;other_file&amp;quot; and &amp;quot;CoSCN4_freq_AllNCS_B3LYP_6311plgdp_Tetrahed_BMIMSCNSMD_Abr&amp;quot;, which in turn will contain a loada output files. See the output files section of the wiki for an explanation of what these are.&lt;br /&gt;
&lt;br /&gt;
====Creating your own input files====&lt;br /&gt;
If you followed the optional part above and made a vimscript, then a template for the input file can be brought up in vim by typing &amp;quot;:call Gelius_Input()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
An example input file is shown below. Each &amp;quot;fragment&amp;quot; (e.g cation,anion, alkyl group etc.) should have its own input file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
other_file.fchk&lt;br /&gt;
Numb_Fragments=4&lt;br /&gt;
1a=10-13&lt;br /&gt;
1t=a&lt;br /&gt;
1l=TDOS&lt;br /&gt;
2a=10-13&lt;br /&gt;
2t=s&lt;br /&gt;
2l=S3s&lt;br /&gt;
3a=10-13&lt;br /&gt;
3t=p&lt;br /&gt;
3l=S3p&lt;br /&gt;
4a=10-13&lt;br /&gt;
4t=d+&lt;br /&gt;
4l=S3d&lt;br /&gt;
M_factor=1.0&lt;br /&gt;
Link_File=all_frags.test&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The input file can be divided into parts as follows:&lt;br /&gt;
&lt;br /&gt;
1) The top line of the input file tells the code the name of the checkpoint file to use in the calculation. In practice you can write ANYTHING on this top line if using the gen_gelius_input*.sh script, as the script itself replaces the first line (whatevers there) with the names of all .fchks in the current folder. But SOMETHING must be written there.&lt;br /&gt;
&lt;br /&gt;
2)&#039;&#039;&#039;Numb_Fragments&#039;&#039;&#039; is the number of sub-fragments (max 10) that you want to break your pDoS down into (e.g fragment 2 corresponds to all Sulfur 3s atomic orbitals in the example above). Code will break if you get this wrong.&lt;br /&gt;
&lt;br /&gt;
3) &#039;&#039;&#039;1a/1t/1l&#039;&#039;&#039; instruct the code what to use as the total density of states. Hence 1a must be set to ALL the atoms your interested in for this fragment, 1t must be set to &amp;quot;a&amp;quot; and 1l should be set to TDOS (not sure it matters what this is set to, but to be on the safe side just use TDOS). The purpose of this fragment is essentially error checking.&lt;br /&gt;
&lt;br /&gt;
4) &#039;&#039;&#039;2a/3a/*a&#039;&#039;&#039; : a stands for atoms here, so the value of a corresponds to the labels of the atoms you want to be included in the sub-fragment. These labels are the same integers you get in gaussview when you go to view--&amp;gt;labels. Examples of valid options may be &amp;quot;1,4,5-7&amp;quot; or &amp;quot;1,3,5&amp;quot; (basically comma seperated list of integers)&lt;br /&gt;
&lt;br /&gt;
5) &#039;&#039;&#039;2t/3t/*t&#039;&#039;&#039;: t stands for &amp;quot;type of AO&amp;quot;.This is a comma seperated list with possible arguments (any combination) &amp;quot;a,s,p,d,f,g&amp;quot;. &amp;quot;a&amp;quot; corresponds to all types of AO centered of the atoms specified with the 2a/3a/*a line. s means s-type atomc orbitals (0 angular momentum), p means p-type atomic orbitals (1 angular momentum) etc. To get all AOs of a certain angular momentum and higher (up to g-type AOs) add a plus to the end of the relevant letter. e.g &amp;quot;p+&amp;quot; says &amp;quot;include all AOs with angular momemtnum greater than or equal to 1 in this sub-fragment&amp;quot;)&lt;br /&gt;
&#039;&#039;&#039;DON&#039;T&#039;&#039;&#039; use &amp;quot;a&amp;quot; with any other letter, and dont do anything else that will lead to a type of AO being requested twice (e.g p+,d)&lt;br /&gt;
&lt;br /&gt;
6) &#039;&#039;&#039;2l/3l/*l&#039;&#039;&#039;: l stands for label. If you dont care about calculating an XPS spectrum you can essentially set it to whatever you want. This tells the matlab script what cross section to use for calculating the XPS spectrum, hence it must match (case insensitive) a filename in the X_Section_Library folder. e.g S3s tells matlab to get the S3S.txt file when looking for what cross-section to use.&lt;br /&gt;
&lt;br /&gt;
7) &#039;&#039;&#039;M_factor=1.0&#039;&#039;&#039;, you really never need to modify this but make sure its present. It&#039;s purpose is to tell matlab to multiple the pDoS of this fragment (that this input file corresponds to) by the  value M_factor. The purpose is for systems where the real stoichiometry differs from that in your calculation. For example if i have a mixture of 99 water:1 anion but only a calculation on 1 water molecule mixed with 1 anion i could set M_factor for the water fragment input file to M_factor=99.0 to estimate (badly) what the actual DoS of the mixture would look like.&lt;br /&gt;
&lt;br /&gt;
8) &#039;&#039;&#039;Link_File=*&#039;&#039;&#039;. This options for if you have a fragment (e.g an anion) but want it broken into more than 10 sub-fragments (e.g this will be true for any molecule with &amp;gt;3 elements). In this case make 2 files for that fragment, and in the second  file set Link_File to the name of the first file. In the example above, this input file will essentially be merged with &amp;quot;all_frags.test&amp;quot;, and only an output file for all_frags.test will be generated.&lt;br /&gt;
&lt;br /&gt;
====More complex input file options====&lt;br /&gt;
====Gen_Gelius_Spectrum.m====&lt;br /&gt;
This code has the following options that can be changed (all are explained by comments in the .m file):&lt;br /&gt;
&amp;lt;pre&amp;gt;1)min_e/max_e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Matlab ignores any orbitals with energy below min_e or above max_e when generating the XPS spectrum. Note if you want to change this to include core orbitals or very high energy virtual orbitals then you&#039;ll also have to edit Gen_Multiwfn_Input_Comms.py to set the range in multiwfn to the one you want.(Theres currently no variable in that .py code to do that, it just uses the defaults in multiwfn. But the function you&#039;ll need to edit in Gen_Multiwfn_Input_Comms.py is Output_Header.&lt;br /&gt;
&amp;lt;pre&amp;gt;2)min_e_plotted/max_e_plotted&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These refer to the minimum/maximum binding energies to calculate spectral intensity for. The range should probably be slightly wider than the min_e/max_e range really, though thats not the default setting. &lt;br /&gt;
&amp;lt;pre&amp;gt;3)step_size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The value (in eV) between calculated data points in the output spectra. For example, if set to 0.001eV then a data point will be calculated for 0eV,0.001eV,0.002eV etc. Lower values=larger files/slower runtimes.&lt;br /&gt;
&amp;lt;pre&amp;gt;4)lorentz_fraction &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Value between 0 and 1 that determines the % Lorentzian character of the lineshape used in the broadening function(the remaining % is set to gaussian). By broadening function i essentially mean the peak thats placed around every MO energy in generating these spectra. lorentz_fraction=0 will give you a pure gaussian peak, while lorentz_fraction=1 gives a pure Lorentzian peak.&lt;br /&gt;
&amp;lt;pre&amp;gt;5)savetext/figsave/savejpeg/all_contribs_output&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
These all control whether a certain type of output file is saved, with variable names that should be self-explanatory.Values of 1 mean save the file, other values mean dont save. set savetext=0 to not save any .txt output files, figsave=0 to not save any .fig output, savejpeg=0 to not save any .jpeg outputs and all_contribs_output=0 to not save the .txt file with a full breakdown of the spectrum. Leaving them all as 1 (except maybe the savejpeg) is strongly recommended.&lt;br /&gt;
&lt;br /&gt;
====Plot_Atomic_Contribs_V3====&lt;br /&gt;
&lt;br /&gt;
This is an optional script that plots certain breakdowns of your calculated DoS/XPS spectrum (i.e you run it AFTER Gen_Gelius_Spectrum) . Its not too hard to do the same thing in excel using the *ALL_Contribs* output file (see output file sections) but this is a lot faster. There are three types of breakdown this function can do (see pictures below):&lt;br /&gt;
&lt;br /&gt;
1) Atomic breakdown with fragments kept seperate (merge_spd=1,merge_fragments=0)&lt;br /&gt;
&lt;br /&gt;
2) Atomic orbital breakdown (merge_spd=0,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
3) Atomic breakdown (merge_spd=1,merge_fragments=1)&lt;br /&gt;
&lt;br /&gt;
The function in its uploaded form takes a single argument , though there are two variables in the actual code that you need to mess with (merge_spd and merge_fragments).&lt;br /&gt;
&lt;br /&gt;
So for example, to run this on the output file from the &amp;quot;Using the Example files&amp;quot; i typed into the matlab terminal:&lt;br /&gt;
&lt;br /&gt;
Plot_Atomic_Contribs_V3(&#039;C:\Users\Richard\Desktop\Open_Shell_Code_Some_Stuff\Example_files\other_file\DoS_1ev_0pt3l&#039;)&lt;br /&gt;
&lt;br /&gt;
The argument needs to be a folder containing the output files from the Gen_Gelius_Spectrum script. You&#039;ll then get a saved graph with the breakdown you asked for and also a .txt file containing the breakdown in a comma delimited format. The output file names record the options you used to make the script (e.g &amp;quot;Plotted_Atomic_Contribs_spd0_frag1.txt&amp;quot; means merge_spd was set to 0 and merge_fragments was set to 1).&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag1.jpg|thumbnail|center| merge_spd=1,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted_Atomic_Contribs_spd0_frag1.jpg|thumbnail|center| merge_spd=0,merge_fragments=1 ]]&lt;br /&gt;
&lt;br /&gt;
[[File:Plotted Atomic Contribs spd1 frag0.jpg|thumbnail|center| merge_spd=1,merge_fragments=0 ]]&lt;br /&gt;
&lt;br /&gt;
==Output Files==&lt;br /&gt;
&lt;br /&gt;
The first &amp;quot;output file&amp;quot; is the *MCRF*.txt file, which just contains the commands to build the required fragment in multiwfn.&lt;br /&gt;
&lt;br /&gt;
===Files From Multiwfn===&lt;br /&gt;
Most people should be able to completely ignore these files. But in case your curious:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1) *DOS_curve*.txt&#039;&#039;&#039; Essentially a DoS plot. 1st column is energies in au, second column is TDOS of the fragment. Not really sure what the 3rd column is. No particular use for this file, but it gets auto-generated by multiwfn and i dont go out my way to delete it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2) *DOS_line*.txt&#039;&#039;&#039; Data to create a stick plot (where each MO is a stick). Plot column 1 vs column 2 as a line graph and you get an axis with sticks representing the MOs. 4th column onwards represent contribution of the various sub-fragments to each &amp;quot;stick&amp;quot;. This is the file that gets used to generate the *ML_inpt.txt file.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3) *DOS_frag*.txt &#039;&#039;&#039; This file contains the sub-fragment info in a way multiwfn understands. If its renamed to DOS_frag.txt then multiwfn can import it to get the fragments (therefore can be useful for debugging, no further purpose).&lt;br /&gt;
&lt;br /&gt;
===MLinpt.txt File===&lt;br /&gt;
&lt;br /&gt;
Creation of the *ML_inpt.txt files is essentially the point of the gen_gelius_input* script. These are primarily input files for matlab, but they do have useful information in an easy to read format. If you import the file into excel and COMMA DELIMIT ONLY (i.e untick the space delimit option) you can get something like below(there are more decimal places in the actual file):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#M_FACTOR=1.0,													&lt;br /&gt;
#Energy(eV)	TDOS	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	S3S	S3P	S3D&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
-24.5		0.9	0.0	0.0	0.0	0.5	0.1	0.0	0.2	0.1	0.0	0.1	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-24.4		1.0	0.0	0.0	0.0	0.5	0.1	0.0	0.3	0.1	0.0	0.0	0.0	0.0&lt;br /&gt;
-19.8		0.3	0.0	0.0	0.0	0.1	-0.1	0.0	0.2	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
-19.7		0.3	0.0	0.0	0.0	0.0	0.0	0.0	0.1	0.1	0.0	0.7	0.1	0.0&lt;br /&gt;
[LINES DELETED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The shown file is &amp;quot;all_frags_alpha_MLinpt.txt&amp;quot;, which is generated from the example files in the open shell code. As this actually comes from merging two MLinpt.txt files (gen_gelius_input.sh does this part silently) the TDOS in this case doesnt mean anything.&lt;br /&gt;
&lt;br /&gt;
The first column lists the energy of each MO in eV (1 ev ~27.212 au). For any row, columns 3(CO4S)--&amp;gt;end (S3D) list the fractional contributions of each type of atmoic orbital to the MO in that row. For example the MO with energy -19.7 eV is mainly from S3s type atomic orbitals. These fractions were determiend by multiwfn by using Mulliken population analysis.&lt;br /&gt;
&lt;br /&gt;
All the fractional contributions in the file get multiplied by the M_FACTOR value (as explained above in the Creating your own input files section). Therefore the value of M_FACTOR can easily be set after the MLinpt.txt file is created, as opposed to within the initial input file.&lt;br /&gt;
&lt;br /&gt;
===Formatted_UMOs===&lt;br /&gt;
&lt;br /&gt;
The default for the gen_gelius_input* script (i.e the settings for the version i uploaded) is to put only OCCUPIED MO energies/breakdowns into the *MLinpt.txt file. If you want all MOs (I really DONT recommend this) in the MLinpt.txt file then change all_orbs=&#039;cheese&#039; to all_orbs=&#039;ALLORBS&#039; at the top of the gen_gelius_input* script.&lt;br /&gt;
&lt;br /&gt;
Otherwise you will get a *Formatted_UMOs* file for every MLinpt.txt file you get. The format of the file is identical to the MLinpt.txt format except the MO at the top of the file corresponds to the LUMO.&lt;br /&gt;
&lt;br /&gt;
WARNING: If you use the link_files feature, then the output formatted_UMOs files DO NOT get merged. This shouldnt matter as you should never really use the formatted UMOs for anything.&lt;br /&gt;
&lt;br /&gt;
===Output From Matlab Code ===&lt;br /&gt;
&lt;br /&gt;
The matlab code firstly will create a new folder with a name reflecting the input arguments. The format is hv_FWHM_%lorenztian where hv is the photon energy, FWHM is full width half maximum of the broadeing function and %lorenztian is the amount of lorenztian mixed in the broadening function. For example the earlier command (from using example files section) &amp;quot;Gen_Gelius_Spectrum(plist,-1,1)&amp;quot; generates the folder &amp;quot;DoS_1ev_0pt3l&amp;quot;. DoS = Density of states, and means we did not use photoionisation cross sections. The 0pt3l part means our broadening function was 30% lorenztian and 70% Gaussian.&lt;br /&gt;
&lt;br /&gt;
Two .fig files will have been produced from this code, these contain matlab graphs of the output. These .fig files follow the naming (&amp;quot;filename&amp;quot; is the name of the original fchk file):&lt;br /&gt;
&lt;br /&gt;
1) filename_DoS.fig contains the total DoS plot.&lt;br /&gt;
&lt;br /&gt;
2) filename_DoS_frag_contribs.fig contains the DoS AND the pDoS of each of the fragments. For closed shell code you get 1 fragment per input file (assuming you dont use link_files), but for the open shell code each input file leads to two fragments - one for alpha electrons and one for beta electrons.&lt;br /&gt;
&lt;br /&gt;
[[File:Other_file_DoS.jpeg|thumb|center| 1) Total Density of States for a Co(SCN)4 fragment with filename other_file_DoS.fig]]&lt;br /&gt;
&lt;br /&gt;
[[File:Other file DoS frag contribs.jpeg|thumb|center| 2) Contribtuions of alpha and beta electrons to the Total Density of States for Co(SCN)4, filename other_file_DoS_frag_contribs.fig]]&lt;br /&gt;
&lt;br /&gt;
The filename_DoS.fig plot data is output in a .txt file of the same name, while each fragment in filename_DoS_frag_contribs.fig has its own .txt file. For the example above the two fragments have names &amp;quot;all_frags_alpha_other_file_DoS&amp;quot; and &amp;quot;all_frags_beta_other_file_DoS&amp;quot;. The start of the names are taken from the name of the original input file &amp;quot;all_frags.test&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The final file output is the &amp;quot;ALL_Contribs_other_file_DoS.txt&amp;quot; file. This(as the name implies) contains all contributions to the DoS spectra in a comma delimited file. The Plot_Atomic_Contribs*.m code can be run on this file to generate plots with a few different breakdowns (e.g atomic breakdowns) - see the relevant section of this wiki (not done yet....). The file will look something like below (commas replaced with tabs):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#all_frags_alpha	all_frags_beta								&lt;br /&gt;
#Sub fragments in each=	12	12							&lt;br /&gt;
#Energy(eV)	CO4S	CO3P	CO3D	N2S	N2P	N2D	C2S	C2P	C2D	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED,numbers rounded]&lt;br /&gt;
7.5		0.00	0.01	0.31	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.51		0.00	0.01	0.33	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.52		0.00	0.01	0.34	0.04	0.13	0.00	0.00	0.11	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.53		0.00	0.01	0.35	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.54		0.00	0.01	0.36	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.55		0.00	0.02	0.37	0.04	0.14	0.00	0.00	0.12	0.00	[COLUMNS REMOVED]&lt;br /&gt;
7.56		0.00	0.02	0.39	0.05	0.14	0.00	0.00	0.13	0.00	[COLUMNS REMOVED]&lt;br /&gt;
[ROWS REMOVED]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Hopefully the format is mostly intuitive, the top two rows contain information on what the data is, and the rest contain the data. The top row contains (originally comma delimited) a list of all &amp;quot;fragments&amp;quot; names, which is the number of input files for the closed shell code and 2x the number of input files for the open shell code. The second row contains the number of sub-fragments (which should be atomic orbitals) in each fragment. In the example above each fragment had 12 types of atomic orbital.&lt;br /&gt;
&lt;br /&gt;
So for the example above column 2-14 shows contributions from &amp;quot;all_frags_alpha&amp;quot; while column 15-27 shows contributions from &amp;quot;all_frags_beta&amp;quot; (column 1 lists energies).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Bugs/Things to Watch For==&lt;br /&gt;
===Fragment Names===&lt;br /&gt;
Make sure your fragment names arent a substring of your .fchk file names. For example an input file called &amp;quot;Cl.test&amp;quot; wont work for a file called &amp;quot;BMIM_Cl.fchk&amp;quot;. However, &amp;quot;Cl_frag.test&amp;quot; will work. Therefore personally i add _frag to the end of every input file name. The other way to sort this is to set linked_files=0 in gen_gelius_input_opensh.sh, sincce the link files part of the code is where this bug comes from.&lt;br /&gt;
&lt;br /&gt;
===Fragment Error Checking===&lt;br /&gt;
Unless you manually turn it off (The &amp;quot;error=&amp;quot; option in gen_gelius_input_opensh.sh script) the code tries to check your input file for errors. Specifically it tests whether the TDOS in an input_file really is the sum of the other sub-fragments in the input(.test) file. E.g it will trigger if you request only Sulfur p-type and d-type AOs (but no s-type AOs) in the input file, or if you request all sulfur p-type AOs twice. If the error check triggers then it BREAKS the input file for matlab by putting an error msg in the first line of the &#039;&#039;&#039;*MLinpt.txt file&#039;&#039;&#039;. An example of what the error looks like is:&lt;br /&gt;
&amp;lt;pre&amp;gt;	&lt;br /&gt;
“Fragment Sum incorrect on row 19 for fchk file xxxx.fchk”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you *MLinpt.txt files arent working in matlab then this is probably the reason.&lt;br /&gt;
&lt;br /&gt;
===Pathlengths===&lt;br /&gt;
This code makes a lot of sub-folders based on the name of .fchk files. If you have really long .fchk file names its likely that you&#039;ll end up with some files which exceed the 256 character limit for a pathlength on a windows computer. In matlab 2014 this will cause the code to exit with an error, saying it cant save the .fig files. In newer matlab versions it may just save the output files , but you wont be able to open them on windows if the path length is greater than 256 characters. Ways to avoid this are to shorten .fchk file names where possible, or (less practical) run the code on a folder as close as possible to root (i.e a folder with a short a pathlength as possible).&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630266</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630266"/>
		<updated>2017-06-07T13:38:52Z</updated>

		<summary type="html">&lt;p&gt;Rf614: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Links to files==&lt;br /&gt;
Zip Archive: [[Media:OTRSH_hpc_ver_June3rd_2017.zip]]&lt;br /&gt;
&lt;br /&gt;
==What&#039;s an OTRSH Functional?==&lt;br /&gt;
It is an optimally tuned range separated hybrid functional (OTRSH). This is a class of functionals that are useful for ccalculating electronic properties such as UV-Vis spectra (especially if charge-transfer excitations are important) or photoelectron spectra. Before talking about OTRSH functionals, it is useful to first talk about how standard range separated hybrid functionals work, and why they were created.&lt;br /&gt;
&lt;br /&gt;
===The Problem===&lt;br /&gt;
Standard DFT has problems describing long range interactions, due to the form of the exchange energy in standard functionals. Actual (exact) Exchange energy scales with distance as &amp;lt;math&amp;gt;\frac{1}{r_{12}}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; is the distance between two electrons. However, standard pure DFT exchange functionals depend directly on the electron density, which decays exponentially with distance from an atomic center (i.e. DFT exchange decays faster than actual exchange). This means that standard DFT functionals are poor at describing long-range interactions (charge transfer excitations in DFT is an example). Range seperated hybrid functionals try to fix this by using Hartree-Fock exchange energy (which is exact) at large distances (long-range) while keeping DFT exchange energy at short range.&lt;br /&gt;
&lt;br /&gt;
===One Solution - Normal Range Separated Hybrids===&lt;br /&gt;
A range separated hydrbrid functional divides the exchange energy into two terms - short range exchange (&amp;lt;math&amp;gt; E_{X}^{SR}&amp;lt;/math&amp;gt;) and long range exchange (&amp;lt;math&amp;gt; E_{X}^{LR} &amp;lt;/math&amp;gt;). The exchange energy at any one distance is a weighted combination of short-range and long range exchange, and can essentially be described with three variables; &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (See picture below). &lt;br /&gt;
&lt;br /&gt;
[[File:Frac_HF_Exchange_mu.png|200px|center|Description of the Exchange energy at varying distances in a range-separated hybrid functtional]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The equations for total, short range (DFT) and long-range (HF) exchange are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{Total} = E_{X}^{SR} + E_{X}^{LR}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{SR} = [1-(\alpha + \beta{}.\text{erf}(\mu r_{12})] E_{X}^{DFT}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{LR} = [\alpha + \beta{}.\text{erf}(\mu{}r_{12})] E_{X}^{HF}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where erf is the error function. &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; represents the amount of HF exchange at short range. For example, &amp;lt;math&amp;gt;\alpha=0.2&amp;lt;/math&amp;gt; would mean 20% HF exchange was used at &amp;lt;math&amp;gt;r_{12}=0&amp;lt;/math&amp;gt;. &amp;lt;math&amp;gt;\alpha + \beta &amp;lt;/math&amp;gt; represents the amount of HF exchange at long range (i.e as &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; approaches infinity). A value of &amp;lt;math&amp;gt;\alpha + \beta =1&amp;lt;/math&amp;gt; means that 100% HF exchange is employed at long range, which should give the correct long-range behavior for the exchange energy. &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the range seperation parameter, its value determines how quickly we change from short-range to long-range exchange expresssions. The higher &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is, the faster (shorter distances) we start using the long-range exchange energy expression.&lt;br /&gt;
&lt;br /&gt;
A problem with range separated hybrids is in picking the correct value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (i.e when should we stop using DFT exchange?). This is often determined empirically by varying &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; for a test data set, and seeing which &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value leads to a functional that best reproduces an experimental property (e.g. atomic ionisation energies). This has the same problem as any kind of empirical fitting - its not clear how well the functional will work outside the test set of molecules/properties. Also this empirical tuning of parameters can lead to unphysical values. For example, CAM-B3LYP uses &amp;lt;math&amp;gt;\alpha + \beta =0.65&amp;lt;/math&amp;gt;, meaning it definitely has the wrong long-range behavior.&lt;br /&gt;
&lt;br /&gt;
===OTRSH Functionals===&lt;br /&gt;
&lt;br /&gt;
OTRSH functionals provide a non-empirical method for choosing &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is &amp;quot;tuned&amp;quot; on a per-calculation basis. The &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value is chosen so that the calculated ionisation energy matches the negative of the HOMO energy, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = -E_{HOMO}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = E_{N-1} - E_{N}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;E_{N-1}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_{N}&amp;lt;/math&amp;gt; represent the energy of the N-1 and N electron system (both in the N electron system geometry). Note that all values in the equations above can be obtained from two single-point energy calculations. Also note that &amp;lt;math&amp;gt;IP_{Calc} = -E_{HOMO}&amp;lt;/math&amp;gt; is true for the exact (unknown) KS-DFT functional, hence it is a sensible thing to try to reproduce in a functional.&lt;br /&gt;
&lt;br /&gt;
To summarise an OTRSH functional is one whereby &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is chosen to minimise &amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} + E_{HOMO}&amp;lt;/math&amp;gt;, hence the &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value will be different for every calculation you carry out. Sometimes the IP and HOMO energy of the N-1 electron system are also used to tune &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, but unfortunately thats not possible the code on this page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide (Using the test file)===&lt;br /&gt;
Once you download the .zip archive, copy the files to somewhere on your hpc path [Note: make sure you dont miss the .rng_OTRSH file]. Personally i use &amp;quot;/home/rf614/bin&amp;quot; as the location. To use the gf_OTRSH function straight away you&#039;ll need to put them in $HOME/bin. &amp;quot;echo $HOME&amp;quot; while on the hpc to find where your home directory is if your not sure.&lt;br /&gt;
&lt;br /&gt;
Move the test file (&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin.com&#039;) to whereever you like in your work directory, and navigate to this folder. Then type either of the following commands (assuming you put the scripts in ~/bin):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
qsub -v in=H2O_SPE_6311plgdp_GP_B3LYP_builtin -N test ~/bin/.rng_OTRSH&lt;br /&gt;
gf_OTRSH H2O_SPE_6311plgdp_GP_B3LYP_builtin.com&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you saved the files somewhere else then simply modify &amp;quot;~/bin/.rng_OTRSH&amp;quot; to whatevers appropriate for the top command. For details on how the gf command works see this wiki [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/pimpQSUB link].&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide - The output files===&lt;br /&gt;
Assuming you ran the job above you will now have a loada output files in your current directory, i.e.:&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt.*&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_ionstate_mu_opt.*&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_OTRSH.out&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_OTRSH.out&#039;&#039;&#039; file is essentially a progress file for how the tuning process is going. Once the calculation is over its main purpose is really to keep track of the options you used to create the OTRSH functional. Its a comma delimited file, and the headings should be pretty self-explanatory (at least they will be if you read the above section on &amp;quot;What is an OTRSH&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt&#039;&#039;&#039;* files are for single energy calculations using the OTRSH functional tuned for this particular system. If your goal was to calculate ground state properties with an OTRSH then these files might be all you need. If you want to do something other than a single-point energy calculation, then just add the relevant keywords (e.g TD) to the  H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt.com file - this file contains all the keywords needed to define the OTRSH functional.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_ionstate_mu_opt&#039;&#039;&#039;* files are the single point energy calculations (using the OTRSH) for the ionised system. You probably have no need for these.&lt;br /&gt;
&lt;br /&gt;
You will also have a new folder named &#039;&#039;&#039;temp_files_H2O_SPE_6311plgdp_GP_B3LYP_builtin&#039;&#039;&#039;. At every tested value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, the .log files for the ground and ionised state are written to this folder. The purpose of this folder is to check nothings going wrong during the calculation. If something stops the code extracting scf energies for each &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value, then it might just loop infinitely (or at least for a loooooong time). The code &#039;&#039;&#039;SHOULD&#039;&#039;&#039; catch these sorts of errors and kill the job, but if it runs a long time without any change in the *.out file then make sure the *.log files in this folder are ok. The secondary purpose of this folder is therefore to tell you WHY your job got killed, if it got killed (an error message should be given in the .out file as well but....)&lt;br /&gt;
&lt;br /&gt;
===Quick Note on Creating Input Files===&lt;br /&gt;
&lt;br /&gt;
If you want to run the code, with default options, on your own systems then theres not much to say. Simply prepare a normal &#039;&#039;&#039;SINGLE POINT ENERGY&#039;&#039;&#039; *.com file for your system, but remove the functional from the input line. Also dont use the &amp;quot;#p&amp;quot; command for excess printing - this will break the OTRSH code (sorry, the code essentially uses the # for a search + replace to insert a functional at each step of the tuning process). For example, this input line is fine(and used in the example file):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# 6-311+g(d,p) geom=connectivity int=ultrafine scf=conver=9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you use a &#039;&#039;&#039;single point energy calculation input file&#039;&#039;&#039;, using a keyword like &amp;quot;freq&amp;quot; wont throw any errors, but you&#039;ll be waiting a really long time for your job to finish.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Understanding (And Modifying) The Default Options===&lt;br /&gt;
&lt;br /&gt;
The easily changeable variables in this code are stored in the .rng_OTRSH file. They are (in order of &amp;quot;likelyhood of needing altering&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
es_mult=2&lt;br /&gt;
alpha_val=0&lt;br /&gt;
beta_val=1&lt;br /&gt;
mu_lower=0.1&lt;br /&gt;
mu_upper=0.2&lt;br /&gt;
max_step=0.03&lt;br /&gt;
min_step=0.001&lt;br /&gt;
P5_val=0.81&lt;br /&gt;
xc_funct=&amp;quot;CAM-B3LYP&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Its likely you&#039;ll only ever need/want to change the &#039;&#039;&#039;es_mult&#039;&#039;&#039; here. This is the multiplicity of the ionised state, and is obviously equal to 2 if you have a closed shell system. If you use this code on an open shell system you need to set es_mult to the appropriate value for the ionised state. Personally i create seperate .rng files for each value of multiplicity i use, to save me editing the .rng_OTRSH file too often.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;alpha_val&#039;&#039;&#039; corresponds to the fraction HF exchange at short range. Its plausible that raising this to say alpha_val=0.2 might improve your results in some cases, so it might be worth trying the functional with two different alpha values if your trying to match an experimental spectrum or have something else you can validate with. I personally set it to zero since i think its the least arbitrary value it can be.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;beta_val&#039;&#039;&#039; - as stated above &amp;quot;alpha_val + beta_val&amp;quot; corresponds to the fraction HF exchange at long range. So if you &#039;&#039;&#039;change alpha_val, you need to change beta_val too&#039;&#039;&#039;, otherwise you may end up with &amp;gt;100% HF exchange at long range. I&#039;d advise you keep alpha_val + beta_val =1.0, since that should give you the correct long-range potential.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;mu_lower&#039;&#039;&#039; and &#039;&#039;&#039;mu_upper&#039;&#039;&#039; control the initial range of &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; values to try out. If you have a good idea what your final &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; will be, then settings mu_lower and mu_upper to nearby values should speed up the optimisation process. However, there is &#039;&#039;&#039;NO NEED&#039;&#039;&#039; for the final mu_val to be between these initial search values, it will just take longer if its far away from this range.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;max_step&#039;&#039;&#039; and &#039;&#039;&#039;min_step&#039;&#039;&#039; correspond to the maximum and minimum change in &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;  between optimisation steps. Note that i think the minimum possible min_step=0.0001, so dont set it lower than that or it could cause serious problems (it&#039;ll lead to a gradient of zero between two mu values, i have no idea how the optimiser will react to that but it wont be good). Theres probably &#039;&#039;&#039;NEVER&#039;&#039;&#039; a need to mess with these values. If the optimiser isnt efficient enough, changing these values wont help much. Writing a better optimiser (the current ones pretty terrible by the way,but it works so.....) would probably be easier than working out the best values for these numbers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;P5_val&#039;&#039;&#039; corresponds to a parameter in the DFT functional controlling the amount of non-local correlation to use. Its the same P5 parameter that appears on the gaussian 09/16 guide to &amp;quot;user-defined DFT functionals&amp;quot;. Just leave it alone unless you REALLY know what your doing.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;CAM-B3LYP&#039;&#039;&#039; corresponds to the underlying functional to use. The functional this code generates is essentially CAM-B3LYP with modified &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;,&amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; parameters. The underlying DFT exchange/ DFT correlation functionals are the same as those used in CAM-B3LYP. I&#039;ve never tried modifying this, it would be a massive pain. If you want to try then i suggest you use a range-separated functional as your base and start by passing the relevant arguments to the &amp;quot;init_OTRSH.py&amp;quot; functional, and seeing if you can replicate the original functional (e.g if you want to use wB97XD as your base functional, try and reproduce reslts of that functional by passing relevant options to init_OTRSH.py.&lt;br /&gt;
&lt;br /&gt;
Finally, the convergence criteria for the OTRSH (the IP_HOMO - E_HOMO value) is set to 0.01 eV by default, and controlled by the IP_conver_thres variable in optimiser.py. I guess its possible you may want to relax that criteria in certain circumstances (obviously it would speed up the optimisation and lower the accuracy).&lt;br /&gt;
&lt;br /&gt;
==Further Reading/Links to relevant Papers==&lt;br /&gt;
CAM-B3LYP paper - doi:&#039;&#039;&#039;10.1016/j.cplett.2004.06.011&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Early (first?) OTRSH paper - doi:&#039;&#039;&#039;10.1021/ja8087482&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Review on using OTRSH functional to calculate bandgaps (2012) - doi:&#039;&#039;&#039;10.1021/ct2009363&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use of OTRSH functionals for Ground state properties (2013) - doi:&#039;&#039;&#039;10.1063/1.4807325&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630216</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630216"/>
		<updated>2017-06-03T15:55:37Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* What is an OTRSH Functional? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Links to files==&lt;br /&gt;
Zip Archive: [[Media:OTRSH_hpc_ver_June3rd_2017.zip]]&lt;br /&gt;
&lt;br /&gt;
==What&#039;s an OTRSH Functional?==&lt;br /&gt;
It is an optimally tuned range separated hybrid functional (OTRSH). This is a class of functionals that are useful for ccalculating electronic properties such as UV-Vis spectra (especially if charge-transfer excitations are important) or photoelectron spectra. Before talking about OTRSH functionals, it is useful to first talk about how standard range separated hybrid functionals work, and why they were created.&lt;br /&gt;
&lt;br /&gt;
===The Problem===&lt;br /&gt;
Standard DFT has problems describing long range interactions, due to the form of the exchange energy in standard functionals. Actual (exact) Exchange energy scales with distance as &amp;lt;math&amp;gt;\frac{1}{r_{12}}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; is the distance between two electrons. However, standard pure DFT exchange functionals depend directly on the electron density, which decays exponentially with distance from an atomic center (i.e. DFT exchange decays faster than actual exchange). This means that standard DFT functionals are poor at describing long-range interactions (charge transfer excitations in DFT is an example). Range seperated hybrid functionals try to fix this by using Hartree-Fock exchange energy (which is exact) at large distances (long-range) while keeping DFT exchange energy at short range.&lt;br /&gt;
&lt;br /&gt;
===One Solution - Normal Range Separated Hybrids===&lt;br /&gt;
A range separated hydrbrid functional divides the exchange energy into two terms - short range exchange (&amp;lt;math&amp;gt; E_{X}^{SR}&amp;lt;/math&amp;gt;) and long range exchange (&amp;lt;math&amp;gt; E_{X}^{LR} &amp;lt;/math&amp;gt;). The exchange energy at any one distance is a weighted combination of short-range and long range exchange, and can essentially be described with three variables; &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (See picture below). &lt;br /&gt;
&lt;br /&gt;
[[File:Frac_HF_Exchange_mu.png|200px|center|Description of the Exchange energy at varying distances in a range-separated hybrid functtional]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The equations for total, short range (DFT) and long-range (HF) exchange are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{Total} = E_{X}^{SR} + E_{X}^{LR}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{SR} = [1-(\alpha + \beta{}.\text{erf}(\mu r_{12})] E_{X}^{DFT}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{LR} = [\alpha + \beta{}.\text{erf}(\mu{}r_{12})] E_{X}^{HF}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where erf is the error function. &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; represents the amount of HF exchange at short range. For example, &amp;lt;math&amp;gt;\alpha=0.2&amp;lt;/math&amp;gt; would mean 20% HF exchange was used at &amp;lt;math&amp;gt;r_{12}=0&amp;lt;/math&amp;gt;. &amp;lt;math&amp;gt;\alpha + \beta &amp;lt;/math&amp;gt; represents the amount of HF exchange at long range (i.e as &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; approaches infinity). A value of &amp;lt;math&amp;gt;\alpha + \beta =1&amp;lt;/math&amp;gt; means that 100% HF exchange is employed at long range, which should give the correct long-range behavior for the exchange energy. &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the range seperation parameter, its value determines how quickly we change from short-range to long-range exchange expresssions. The higher &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is, the faster (shorter distances) we start using the long-range exchange energy expression.&lt;br /&gt;
&lt;br /&gt;
A problem with range separated hybrids is in picking the correct value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (i.e when should we stop using DFT exchange?). This is often determined empirically by varying &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; for a test data set, and seeing which &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value leads to a functional that best reproduces an experimental property (e.g. atomic ionisation energies). This has the same problem as any kind of empirical fitting - its not clear how well the functional will work outside the test set of molecules/properties. Also this empirical tuning of parameters can lead to unphysical values. For example, CAM-B3LYP uses &amp;lt;math&amp;gt;\alpha + \beta =0.65&amp;lt;/math&amp;gt;, meaning it definitely has the wrong long-range behavior.&lt;br /&gt;
&lt;br /&gt;
===OTRSH Functionals===&lt;br /&gt;
&lt;br /&gt;
OTRSH functionals provide a non-empirical method for choosing &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is &amp;quot;tuned&amp;quot; on a per-calculation basis. The &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value is chosen so that the calculated ionisation energy matches the negative of the HOMO energy, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = -E_{HOMO}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = E_{N-1} - E_{N}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;E_{N-1}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_{N}&amp;lt;/math&amp;gt; represent the energy of the N-1 and N electron system (both in the N electron system geometry). Note that all values in the equations above can be obtained from two single-point energy calculations. Also note that &amp;lt;math&amp;gt;IP_{Calc} = -E_{HOMO}&amp;lt;/math&amp;gt; is true for the exact (unknown) KS-DFT functional, hence it is a sensible thing to try to reproduce in a functional.&lt;br /&gt;
&lt;br /&gt;
To summarise an OTRSH functional is one whereby &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is chosen to minimise &amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} + E_{HOMO}&amp;lt;/math&amp;gt;, hence the &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value will be different for every calculation you carry out. Sometimes the IP and HOMO energy of the N-1 electron system are also used to tune &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, but unfortunately thats not possible the code on this page.&lt;br /&gt;
&lt;br /&gt;
==What it does(Roughly)==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide (Using the test file)===&lt;br /&gt;
Once you download the .zip archive, copy the files to somewhere on your hpc path [Note: make sure you dont miss the .rng_OTRSH file]. Personally i use &amp;quot;/home/rf614/bin&amp;quot; as the location. To use the gf_OTRSH function straight away you&#039;ll need to put them in $HOME/bin. &amp;quot;echo $HOME&amp;quot; while on the hpc to find where your home directory is if your not sure.&lt;br /&gt;
&lt;br /&gt;
Move the test file (&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin.com&#039;) to whereever you like in your work directory, and navigate to this folder. Then type either of the following commands (assuming you put the scripts in ~/bin):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
qsub -v in=H2O_SPE_6311plgdp_GP_B3LYP_builtin -N test ~/bin/.rng_OTRSH&lt;br /&gt;
gf_OTRSH H2O_SPE_6311plgdp_GP_B3LYP_builtin.com&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you saved the files somewhere else then simply modify &amp;quot;~/bin/.rng_OTRSH&amp;quot; to whatevers appropriate for the top command. For details on how the gf command works see this wiki [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/pimpQSUB link].&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide - The output files===&lt;br /&gt;
Assuming you ran the job above you will now have a loada output files in your current directory, i.e.:&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt.*&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_ionstate_mu_opt.*&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_OTRSH.out&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_OTRSH.out&#039;&#039;&#039; file is essentially a progress file for how the tuning process is going. Once the calculation is over its main purpose is really to keep track of the options you used to create the OTRSH functional. Its a comma delimited file, and the headings should be pretty self-explanatory (at least they will be if you read the above section on &amp;quot;What is an OTRSH&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt&#039;&#039;&#039;* files are for single energy calculations using the OTRSH functional tuned for this particular system. If your goal was to calculate ground state properties with an OTRSH then these files might be all you need. If you want to do something other than a single-point energy calculation, then just add the relevant keywords (e.g TD) to the  H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt.com file - this file contains all the keywords needed to define the OTRSH functional.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_ionstate_mu_opt&#039;&#039;&#039;* files are the single point energy calculations (using the OTRSH) for the ionised system. You probably have no need for these.&lt;br /&gt;
&lt;br /&gt;
You will also have a new folder named &#039;&#039;&#039;temp_files_H2O_SPE_6311plgdp_GP_B3LYP_builtin&#039;&#039;&#039;. At every tested value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, the .log files for the ground and ionised state are written to this folder. The purpose of this folder is to check nothings going wrong during the calculation. If something stops the code extracting scf energies for each &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value, then it might just loop infinitely (or at least for a loooooong time). The code &#039;&#039;&#039;SHOULD&#039;&#039;&#039; catch these sorts of errors and kill the job, but if it runs a long time without any change in the *.out file then make sure the *.log files in this folder are ok. The secondary purpose of this folder is therefore to tell you WHY your job got killed, if it got killed (an error message should be given in the .out file as well but....)&lt;br /&gt;
&lt;br /&gt;
===Quick Note on Creating Input Files===&lt;br /&gt;
&lt;br /&gt;
If you want to run the code, with default options, on your own systems then theres not much to say. Simply prepare a normal &#039;&#039;&#039;SINGLE POINT ENERGY&#039;&#039;&#039; *.com file for your system, but remove the functional from the input line. Also dont use the &amp;quot;#p&amp;quot; command for excess printing - this will break the OTRSH code (sorry, the code essentially uses the # for a search + replace to insert a functional at each step of the tuning process). For example, this input line is fine(and used in the example file):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# 6-311+g(d,p) geom=connectivity int=ultrafine scf=conver=9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you use a &#039;&#039;&#039;single point energy calculation input file&#039;&#039;&#039;, using a keyword like &amp;quot;freq&amp;quot; wont throw any errors, but you&#039;ll be waiting a really long time for your job to finish.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Understanding (And Modifying) The Default Options===&lt;br /&gt;
&lt;br /&gt;
The easily changeable variables in this code are stored in the .rng_OTRSH file. They are (in order of &amp;quot;likelyhood of needing altering&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
es_mult=2&lt;br /&gt;
alpha_val=0&lt;br /&gt;
beta_val=1&lt;br /&gt;
mu_lower=0.1&lt;br /&gt;
mu_upper=0.2&lt;br /&gt;
max_step=0.03&lt;br /&gt;
min_step=0.001&lt;br /&gt;
P5_val=0.81&lt;br /&gt;
xc_funct=&amp;quot;CAM-B3LYP&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Its likely you&#039;ll only ever need/want to change the &#039;&#039;&#039;es_mult&#039;&#039;&#039; here. This is the multiplicity of the ionised state, and is obviously equal to 2 if you have a closed shell system. If you use this code on an open shell system you need to set es_mult to the appropriate value for the ionised state. Personally i create seperate .rng files for each value of multiplicity i use, to save me editing the .rng_OTRSH file too often.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;alpha_val&#039;&#039;&#039; corresponds to the fraction HF exchange at short range. Its plausible that raising this to say alpha_val=0.2 might improve your results in some cases, so it might be worth trying the functional with two different alpha values if your trying to match an experimental spectrum or have something else you can validate with. I personally set it to zero since i think its the least arbitrary value it can be.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;beta_val&#039;&#039;&#039; - as stated above &amp;quot;alpha_val + beta_val&amp;quot; corresponds to the fraction HF exchange at long range. So if you &#039;&#039;&#039;change alpha_val, you need to change beta_val too&#039;&#039;&#039;, otherwise you may end up with &amp;gt;100% HF exchange at long range. I&#039;d advise you keep alpha_val + beta_val =1.0, since that should give you the correct long-range potential.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;mu_lower&#039;&#039;&#039; and &#039;&#039;&#039;mu_upper&#039;&#039;&#039; control the initial range of &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; values to try out. If you have a good idea what your final &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; will be, then settings mu_lower and mu_upper to nearby values should speed up the optimisation process. However, there is &#039;&#039;&#039;NO NEED&#039;&#039;&#039; for the final mu_val to be between these initial search values, it will just take longer if its far away from this range.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;max_step&#039;&#039;&#039; and &#039;&#039;&#039;min_step&#039;&#039;&#039; correspond to the maximum and minimum change in &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;  between optimisation steps. Note that i think the minimum possible min_step=0.0001, so dont set it lower than that or it could cause serious problems (it&#039;ll lead to a gradient of zero between two mu values, i have no idea how the optimiser will react to that but it wont be good). Theres probably &#039;&#039;&#039;NEVER&#039;&#039;&#039; a need to mess with these values. If the optimiser isnt efficient enough, changing these values wont help much. Writing a better optimiser (the current ones pretty terrible by the way,but it works so.....) would probably be easier than working out the best values for these numbers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;P5_val&#039;&#039;&#039; corresponds to a parameter in the DFT functional controlling the amount of non-local correlation to use. Its the same P5 parameter that appears on the gaussian 09/16 guide to &amp;quot;user-defined DFT functionals&amp;quot;. Just leave it alone unless you REALLY know what your doing.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;CAM-B3LYP&#039;&#039;&#039; corresponds to the underlying functional to use. The functional this code generates is essentially CAM-B3LYP with modified &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;,&amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; parameters. The underlying DFT exchange/ DFT correlation functionals are the same as those used in CAM-B3LYP. I&#039;ve never tried modifying this, it would be a massive pain. If you want to try then i suggest you use a range-separated functional as your base and start by passing the relevant arguments to the &amp;quot;init_OTRSH.py&amp;quot; functional, and seeing if you can replicate the original functional (e.g if you want to use wB97XD as your base functional, try and reproduce reslts of that functional by passing relevant options to init_OTRSH.py.&lt;br /&gt;
&lt;br /&gt;
Finally, the convergence criteria for the OTRSH (the IP_HOMO - E_HOMO value) is set to 0.01 eV by default, and controlled by the IP_conver_thres variable in optimiser.py. I guess its possible you may want to relax that criteria in certain circumstances (obviously it would speed up the optimisation and lower the accuracy).&lt;br /&gt;
&lt;br /&gt;
==Further Reading/Links to relevant Papers==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630215</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630215"/>
		<updated>2017-06-03T15:55:21Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* What is an OTRSH Functional */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Links to files==&lt;br /&gt;
Zip Archive: [[Media:OTRSH_hpc_ver_June3rd_2017.zip]]&lt;br /&gt;
&lt;br /&gt;
==What is an OTRSH Functional?==&lt;br /&gt;
It is an optimally tuned range separated hybrid functional (OTRSH). This is a class of functionals that are useful for ccalculating electronic properties such as UV-Vis spectra (especially if charge-transfer excitations are important) or photoelectron spectra. Before talking about OTRSH functionals, it is useful to first talk about how standard range separated hybrid functionals work, and why they were created.&lt;br /&gt;
&lt;br /&gt;
===The Problem===&lt;br /&gt;
Standard DFT has problems describing long range interactions, due to the form of the exchange energy in standard functionals. Actual (exact) Exchange energy scales with distance as &amp;lt;math&amp;gt;\frac{1}{r_{12}}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; is the distance between two electrons. However, standard pure DFT exchange functionals depend directly on the electron density, which decays exponentially with distance from an atomic center (i.e. DFT exchange decays faster than actual exchange). This means that standard DFT functionals are poor at describing long-range interactions (charge transfer excitations in DFT is an example). Range seperated hybrid functionals try to fix this by using Hartree-Fock exchange energy (which is exact) at large distances (long-range) while keeping DFT exchange energy at short range.&lt;br /&gt;
&lt;br /&gt;
===One Solution - Normal Range Separated Hybrids===&lt;br /&gt;
A range separated hydrbrid functional divides the exchange energy into two terms - short range exchange (&amp;lt;math&amp;gt; E_{X}^{SR}&amp;lt;/math&amp;gt;) and long range exchange (&amp;lt;math&amp;gt; E_{X}^{LR} &amp;lt;/math&amp;gt;). The exchange energy at any one distance is a weighted combination of short-range and long range exchange, and can essentially be described with three variables; &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (See picture below). &lt;br /&gt;
&lt;br /&gt;
[[File:Frac_HF_Exchange_mu.png|200px|center|Description of the Exchange energy at varying distances in a range-separated hybrid functtional]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The equations for total, short range (DFT) and long-range (HF) exchange are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{Total} = E_{X}^{SR} + E_{X}^{LR}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{SR} = [1-(\alpha + \beta{}.\text{erf}(\mu r_{12})] E_{X}^{DFT}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{LR} = [\alpha + \beta{}.\text{erf}(\mu{}r_{12})] E_{X}^{HF}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where erf is the error function. &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; represents the amount of HF exchange at short range. For example, &amp;lt;math&amp;gt;\alpha=0.2&amp;lt;/math&amp;gt; would mean 20% HF exchange was used at &amp;lt;math&amp;gt;r_{12}=0&amp;lt;/math&amp;gt;. &amp;lt;math&amp;gt;\alpha + \beta &amp;lt;/math&amp;gt; represents the amount of HF exchange at long range (i.e as &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; approaches infinity). A value of &amp;lt;math&amp;gt;\alpha + \beta =1&amp;lt;/math&amp;gt; means that 100% HF exchange is employed at long range, which should give the correct long-range behavior for the exchange energy. &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the range seperation parameter, its value determines how quickly we change from short-range to long-range exchange expresssions. The higher &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is, the faster (shorter distances) we start using the long-range exchange energy expression.&lt;br /&gt;
&lt;br /&gt;
A problem with range separated hybrids is in picking the correct value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (i.e when should we stop using DFT exchange?). This is often determined empirically by varying &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; for a test data set, and seeing which &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value leads to a functional that best reproduces an experimental property (e.g. atomic ionisation energies). This has the same problem as any kind of empirical fitting - its not clear how well the functional will work outside the test set of molecules/properties. Also this empirical tuning of parameters can lead to unphysical values. For example, CAM-B3LYP uses &amp;lt;math&amp;gt;\alpha + \beta =0.65&amp;lt;/math&amp;gt;, meaning it definitely has the wrong long-range behavior.&lt;br /&gt;
&lt;br /&gt;
===OTRSH Functionals===&lt;br /&gt;
&lt;br /&gt;
OTRSH functionals provide a non-empirical method for choosing &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is &amp;quot;tuned&amp;quot; on a per-calculation basis. The &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value is chosen so that the calculated ionisation energy matches the negative of the HOMO energy, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = -E_{HOMO}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = E_{N-1} - E_{N}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;E_{N-1}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_{N}&amp;lt;/math&amp;gt; represent the energy of the N-1 and N electron system (both in the N electron system geometry). Note that all values in the equations above can be obtained from two single-point energy calculations. Also note that &amp;lt;math&amp;gt;IP_{Calc} = -E_{HOMO}&amp;lt;/math&amp;gt; is true for the exact (unknown) KS-DFT functional, hence it is a sensible thing to try to reproduce in a functional.&lt;br /&gt;
&lt;br /&gt;
To summarise an OTRSH functional is one whereby &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is chosen to minimise &amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} + E_{HOMO}&amp;lt;/math&amp;gt;, hence the &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value will be different for every calculation you carry out. Sometimes the IP and HOMO energy of the N-1 electron system are also used to tune &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, but unfortunately thats not possible the code on this page.&lt;br /&gt;
&lt;br /&gt;
==What it does(Roughly)==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide (Using the test file)===&lt;br /&gt;
Once you download the .zip archive, copy the files to somewhere on your hpc path [Note: make sure you dont miss the .rng_OTRSH file]. Personally i use &amp;quot;/home/rf614/bin&amp;quot; as the location. To use the gf_OTRSH function straight away you&#039;ll need to put them in $HOME/bin. &amp;quot;echo $HOME&amp;quot; while on the hpc to find where your home directory is if your not sure.&lt;br /&gt;
&lt;br /&gt;
Move the test file (&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin.com&#039;) to whereever you like in your work directory, and navigate to this folder. Then type either of the following commands (assuming you put the scripts in ~/bin):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
qsub -v in=H2O_SPE_6311plgdp_GP_B3LYP_builtin -N test ~/bin/.rng_OTRSH&lt;br /&gt;
gf_OTRSH H2O_SPE_6311plgdp_GP_B3LYP_builtin.com&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you saved the files somewhere else then simply modify &amp;quot;~/bin/.rng_OTRSH&amp;quot; to whatevers appropriate for the top command. For details on how the gf command works see this wiki [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/pimpQSUB link].&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide - The output files===&lt;br /&gt;
Assuming you ran the job above you will now have a loada output files in your current directory, i.e.:&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt.*&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_ionstate_mu_opt.*&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_OTRSH.out&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_OTRSH.out&#039;&#039;&#039; file is essentially a progress file for how the tuning process is going. Once the calculation is over its main purpose is really to keep track of the options you used to create the OTRSH functional. Its a comma delimited file, and the headings should be pretty self-explanatory (at least they will be if you read the above section on &amp;quot;What is an OTRSH&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt&#039;&#039;&#039;* files are for single energy calculations using the OTRSH functional tuned for this particular system. If your goal was to calculate ground state properties with an OTRSH then these files might be all you need. If you want to do something other than a single-point energy calculation, then just add the relevant keywords (e.g TD) to the  H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt.com file - this file contains all the keywords needed to define the OTRSH functional.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_ionstate_mu_opt&#039;&#039;&#039;* files are the single point energy calculations (using the OTRSH) for the ionised system. You probably have no need for these.&lt;br /&gt;
&lt;br /&gt;
You will also have a new folder named &#039;&#039;&#039;temp_files_H2O_SPE_6311plgdp_GP_B3LYP_builtin&#039;&#039;&#039;. At every tested value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, the .log files for the ground and ionised state are written to this folder. The purpose of this folder is to check nothings going wrong during the calculation. If something stops the code extracting scf energies for each &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value, then it might just loop infinitely (or at least for a loooooong time). The code &#039;&#039;&#039;SHOULD&#039;&#039;&#039; catch these sorts of errors and kill the job, but if it runs a long time without any change in the *.out file then make sure the *.log files in this folder are ok. The secondary purpose of this folder is therefore to tell you WHY your job got killed, if it got killed (an error message should be given in the .out file as well but....)&lt;br /&gt;
&lt;br /&gt;
===Quick Note on Creating Input Files===&lt;br /&gt;
&lt;br /&gt;
If you want to run the code, with default options, on your own systems then theres not much to say. Simply prepare a normal &#039;&#039;&#039;SINGLE POINT ENERGY&#039;&#039;&#039; *.com file for your system, but remove the functional from the input line. Also dont use the &amp;quot;#p&amp;quot; command for excess printing - this will break the OTRSH code (sorry, the code essentially uses the # for a search + replace to insert a functional at each step of the tuning process). For example, this input line is fine(and used in the example file):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# 6-311+g(d,p) geom=connectivity int=ultrafine scf=conver=9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you use a &#039;&#039;&#039;single point energy calculation input file&#039;&#039;&#039;, using a keyword like &amp;quot;freq&amp;quot; wont throw any errors, but you&#039;ll be waiting a really long time for your job to finish.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Understanding (And Modifying) The Default Options===&lt;br /&gt;
&lt;br /&gt;
The easily changeable variables in this code are stored in the .rng_OTRSH file. They are (in order of &amp;quot;likelyhood of needing altering&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
es_mult=2&lt;br /&gt;
alpha_val=0&lt;br /&gt;
beta_val=1&lt;br /&gt;
mu_lower=0.1&lt;br /&gt;
mu_upper=0.2&lt;br /&gt;
max_step=0.03&lt;br /&gt;
min_step=0.001&lt;br /&gt;
P5_val=0.81&lt;br /&gt;
xc_funct=&amp;quot;CAM-B3LYP&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Its likely you&#039;ll only ever need/want to change the &#039;&#039;&#039;es_mult&#039;&#039;&#039; here. This is the multiplicity of the ionised state, and is obviously equal to 2 if you have a closed shell system. If you use this code on an open shell system you need to set es_mult to the appropriate value for the ionised state. Personally i create seperate .rng files for each value of multiplicity i use, to save me editing the .rng_OTRSH file too often.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;alpha_val&#039;&#039;&#039; corresponds to the fraction HF exchange at short range. Its plausible that raising this to say alpha_val=0.2 might improve your results in some cases, so it might be worth trying the functional with two different alpha values if your trying to match an experimental spectrum or have something else you can validate with. I personally set it to zero since i think its the least arbitrary value it can be.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;beta_val&#039;&#039;&#039; - as stated above &amp;quot;alpha_val + beta_val&amp;quot; corresponds to the fraction HF exchange at long range. So if you &#039;&#039;&#039;change alpha_val, you need to change beta_val too&#039;&#039;&#039;, otherwise you may end up with &amp;gt;100% HF exchange at long range. I&#039;d advise you keep alpha_val + beta_val =1.0, since that should give you the correct long-range potential.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;mu_lower&#039;&#039;&#039; and &#039;&#039;&#039;mu_upper&#039;&#039;&#039; control the initial range of &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; values to try out. If you have a good idea what your final &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; will be, then settings mu_lower and mu_upper to nearby values should speed up the optimisation process. However, there is &#039;&#039;&#039;NO NEED&#039;&#039;&#039; for the final mu_val to be between these initial search values, it will just take longer if its far away from this range.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;max_step&#039;&#039;&#039; and &#039;&#039;&#039;min_step&#039;&#039;&#039; correspond to the maximum and minimum change in &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;  between optimisation steps. Note that i think the minimum possible min_step=0.0001, so dont set it lower than that or it could cause serious problems (it&#039;ll lead to a gradient of zero between two mu values, i have no idea how the optimiser will react to that but it wont be good). Theres probably &#039;&#039;&#039;NEVER&#039;&#039;&#039; a need to mess with these values. If the optimiser isnt efficient enough, changing these values wont help much. Writing a better optimiser (the current ones pretty terrible by the way,but it works so.....) would probably be easier than working out the best values for these numbers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;P5_val&#039;&#039;&#039; corresponds to a parameter in the DFT functional controlling the amount of non-local correlation to use. Its the same P5 parameter that appears on the gaussian 09/16 guide to &amp;quot;user-defined DFT functionals&amp;quot;. Just leave it alone unless you REALLY know what your doing.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;CAM-B3LYP&#039;&#039;&#039; corresponds to the underlying functional to use. The functional this code generates is essentially CAM-B3LYP with modified &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;,&amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; parameters. The underlying DFT exchange/ DFT correlation functionals are the same as those used in CAM-B3LYP. I&#039;ve never tried modifying this, it would be a massive pain. If you want to try then i suggest you use a range-separated functional as your base and start by passing the relevant arguments to the &amp;quot;init_OTRSH.py&amp;quot; functional, and seeing if you can replicate the original functional (e.g if you want to use wB97XD as your base functional, try and reproduce reslts of that functional by passing relevant options to init_OTRSH.py.&lt;br /&gt;
&lt;br /&gt;
Finally, the convergence criteria for the OTRSH (the IP_HOMO - E_HOMO value) is set to 0.01 eV by default, and controlled by the IP_conver_thres variable in optimiser.py. I guess its possible you may want to relax that criteria in certain circumstances (obviously it would speed up the optimisation and lower the accuracy).&lt;br /&gt;
&lt;br /&gt;
==Further Reading/Links to relevant Papers==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630214</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630214"/>
		<updated>2017-06-03T15:54:45Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Running The Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Links to files==&lt;br /&gt;
Zip Archive: [[Media:OTRSH_hpc_ver_June3rd_2017.zip]]&lt;br /&gt;
&lt;br /&gt;
==What is an OTRSH Functional==&lt;br /&gt;
It is an optimally tuned range separated hybrid functional (OTRSH). This is a class of functionals that are useful for ccalculating electronic properties such as UV-Vis spectra (especially if charge-transfer excitations are important) or photoelectron spectra. Before talking about OTRSH functionals, it is useful to first talk about how standard range separated hybrid functionals work, and why they were created.&lt;br /&gt;
&lt;br /&gt;
===The Problem===&lt;br /&gt;
Standard DFT has problems describing long range interactions, due to the form of the exchange energy in standard functionals. Actual (exact) Exchange energy scales with distance as &amp;lt;math&amp;gt;\frac{1}{r_{12}}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; is the distance between two electrons. However, standard pure DFT exchange functionals depend directly on the electron density, which decays exponentially with distance from an atomic center (i.e. DFT exchange decays faster than actual exchange). This means that standard DFT functionals are poor at describing long-range interactions (charge transfer excitations in DFT is an example). Range seperated hybrid functionals try to fix this by using Hartree-Fock exchange energy (which is exact) at large distances (long-range) while keeping DFT exchange energy at short range.&lt;br /&gt;
&lt;br /&gt;
===One Solution - Normal Range Separated Hybrids===&lt;br /&gt;
A range separated hydrbrid functional divides the exchange energy into two terms - short range exchange (&amp;lt;math&amp;gt; E_{X}^{SR}&amp;lt;/math&amp;gt;) and long range exchange (&amp;lt;math&amp;gt; E_{X}^{LR} &amp;lt;/math&amp;gt;). The exchange energy at any one distance is a weighted combination of short-range and long range exchange, and can essentially be described with three variables; &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (See picture below). &lt;br /&gt;
&lt;br /&gt;
[[File:Frac_HF_Exchange_mu.png|200px|center|Description of the Exchange energy at varying distances in a range-separated hybrid functtional]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The equations for total, short range (DFT) and long-range (HF) exchange are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{Total} = E_{X}^{SR} + E_{X}^{LR}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{SR} = [1-(\alpha + \beta{}.\text{erf}(\mu r_{12})] E_{X}^{DFT}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{LR} = [\alpha + \beta{}.\text{erf}(\mu{}r_{12})] E_{X}^{HF}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where erf is the error function. &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; represents the amount of HF exchange at short range. For example, &amp;lt;math&amp;gt;\alpha=0.2&amp;lt;/math&amp;gt; would mean 20% HF exchange was used at &amp;lt;math&amp;gt;r_{12}=0&amp;lt;/math&amp;gt;. &amp;lt;math&amp;gt;\alpha + \beta &amp;lt;/math&amp;gt; represents the amount of HF exchange at long range (i.e as &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; approaches infinity). A value of &amp;lt;math&amp;gt;\alpha + \beta =1&amp;lt;/math&amp;gt; means that 100% HF exchange is employed at long range, which should give the correct long-range behavior for the exchange energy. &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the range seperation parameter, its value determines how quickly we change from short-range to long-range exchange expresssions. The higher &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is, the faster (shorter distances) we start using the long-range exchange energy expression.&lt;br /&gt;
&lt;br /&gt;
A problem with range separated hybrids is in picking the correct value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (i.e when should we stop using DFT exchange?). This is often determined empirically by varying &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; for a test data set, and seeing which &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value leads to a functional that best reproduces an experimental property (e.g. atomic ionisation energies). This has the same problem as any kind of empirical fitting - its not clear how well the functional will work outside the test set of molecules/properties. Also this empirical tuning of parameters can lead to unphysical values. For example, CAM-B3LYP uses &amp;lt;math&amp;gt;\alpha + \beta =0.65&amp;lt;/math&amp;gt;, meaning it definitely has the wrong long-range behavior.&lt;br /&gt;
&lt;br /&gt;
===OTRSH Functionals===&lt;br /&gt;
&lt;br /&gt;
OTRSH functionals provide a non-empirical method for choosing &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is &amp;quot;tuned&amp;quot; on a per-calculation basis. The &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value is chosen so that the calculated ionisation energy matches the negative of the HOMO energy, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = -E_{HOMO}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = E_{N-1} - E_{N}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;E_{N-1}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_{N}&amp;lt;/math&amp;gt; represent the energy of the N-1 and N electron system (both in the N electron system geometry). Note that all values in the equations above can be obtained from two single-point energy calculations. Also note that &amp;lt;math&amp;gt;IP_{Calc} = -E_{HOMO}&amp;lt;/math&amp;gt; is true for the exact (unknown) KS-DFT functional, hence it is a sensible thing to try to reproduce in a functional.&lt;br /&gt;
&lt;br /&gt;
To summarise an OTRSH functional is one whereby &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is chosen to minimise &amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} + E_{HOMO}&amp;lt;/math&amp;gt;, hence the &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value will be different for every calculation you carry out. Sometimes the IP and HOMO energy of the N-1 electron system are also used to tune &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, but unfortunately thats not possible the code on this page.&lt;br /&gt;
&lt;br /&gt;
==What it does(Roughly)==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide (Using the test file)===&lt;br /&gt;
Once you download the .zip archive, copy the files to somewhere on your hpc path [Note: make sure you dont miss the .rng_OTRSH file]. Personally i use &amp;quot;/home/rf614/bin&amp;quot; as the location. To use the gf_OTRSH function straight away you&#039;ll need to put them in $HOME/bin. &amp;quot;echo $HOME&amp;quot; while on the hpc to find where your home directory is if your not sure.&lt;br /&gt;
&lt;br /&gt;
Move the test file (&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin.com&#039;) to whereever you like in your work directory, and navigate to this folder. Then type either of the following commands (assuming you put the scripts in ~/bin):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
qsub -v in=H2O_SPE_6311plgdp_GP_B3LYP_builtin -N test ~/bin/.rng_OTRSH&lt;br /&gt;
gf_OTRSH H2O_SPE_6311plgdp_GP_B3LYP_builtin.com&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you saved the files somewhere else then simply modify &amp;quot;~/bin/.rng_OTRSH&amp;quot; to whatevers appropriate for the top command. For details on how the gf command works see this wiki [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/pimpQSUB link].&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide - The output files===&lt;br /&gt;
Assuming you ran the job above you will now have a loada output files in your current directory, i.e.:&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt.*&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_ionstate_mu_opt.*&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_OTRSH.out&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_OTRSH.out&#039;&#039;&#039; file is essentially a progress file for how the tuning process is going. Once the calculation is over its main purpose is really to keep track of the options you used to create the OTRSH functional. Its a comma delimited file, and the headings should be pretty self-explanatory (at least they will be if you read the above section on &amp;quot;What is an OTRSH&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt&#039;&#039;&#039;* files are for single energy calculations using the OTRSH functional tuned for this particular system. If your goal was to calculate ground state properties with an OTRSH then these files might be all you need. If you want to do something other than a single-point energy calculation, then just add the relevant keywords (e.g TD) to the  H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt.com file - this file contains all the keywords needed to define the OTRSH functional.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_ionstate_mu_opt&#039;&#039;&#039;* files are the single point energy calculations (using the OTRSH) for the ionised system. You probably have no need for these.&lt;br /&gt;
&lt;br /&gt;
You will also have a new folder named &#039;&#039;&#039;temp_files_H2O_SPE_6311plgdp_GP_B3LYP_builtin&#039;&#039;&#039;. At every tested value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, the .log files for the ground and ionised state are written to this folder. The purpose of this folder is to check nothings going wrong during the calculation. If something stops the code extracting scf energies for each &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value, then it might just loop infinitely (or at least for a loooooong time). The code &#039;&#039;&#039;SHOULD&#039;&#039;&#039; catch these sorts of errors and kill the job, but if it runs a long time without any change in the *.out file then make sure the *.log files in this folder are ok. The secondary purpose of this folder is therefore to tell you WHY your job got killed, if it got killed (an error message should be given in the .out file as well but....)&lt;br /&gt;
&lt;br /&gt;
===Quick Note on Creating Input Files===&lt;br /&gt;
&lt;br /&gt;
If you want to run the code, with default options, on your own systems then theres not much to say. Simply prepare a normal &#039;&#039;&#039;SINGLE POINT ENERGY&#039;&#039;&#039; *.com file for your system, but remove the functional from the input line. Also dont use the &amp;quot;#p&amp;quot; command for excess printing - this will break the OTRSH code (sorry, the code essentially uses the # for a search + replace to insert a functional at each step of the tuning process). For example, this input line is fine(and used in the example file):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# 6-311+g(d,p) geom=connectivity int=ultrafine scf=conver=9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you use a &#039;&#039;&#039;single point energy calculation input file&#039;&#039;&#039;, using a keyword like &amp;quot;freq&amp;quot; wont throw any errors, but you&#039;ll be waiting a really long time for your job to finish.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Understanding (And Modifying) The Default Options===&lt;br /&gt;
&lt;br /&gt;
The easily changeable variables in this code are stored in the .rng_OTRSH file. They are (in order of &amp;quot;likelyhood of needing altering&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
es_mult=2&lt;br /&gt;
alpha_val=0&lt;br /&gt;
beta_val=1&lt;br /&gt;
mu_lower=0.1&lt;br /&gt;
mu_upper=0.2&lt;br /&gt;
max_step=0.03&lt;br /&gt;
min_step=0.001&lt;br /&gt;
P5_val=0.81&lt;br /&gt;
xc_funct=&amp;quot;CAM-B3LYP&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Its likely you&#039;ll only ever need/want to change the &#039;&#039;&#039;es_mult&#039;&#039;&#039; here. This is the multiplicity of the ionised state, and is obviously equal to 2 if you have a closed shell system. If you use this code on an open shell system you need to set es_mult to the appropriate value for the ionised state. Personally i create seperate .rng files for each value of multiplicity i use, to save me editing the .rng_OTRSH file too often.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;alpha_val&#039;&#039;&#039; corresponds to the fraction HF exchange at short range. Its plausible that raising this to say alpha_val=0.2 might improve your results in some cases, so it might be worth trying the functional with two different alpha values if your trying to match an experimental spectrum or have something else you can validate with. I personally set it to zero since i think its the least arbitrary value it can be.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;beta_val&#039;&#039;&#039; - as stated above &amp;quot;alpha_val + beta_val&amp;quot; corresponds to the fraction HF exchange at long range. So if you &#039;&#039;&#039;change alpha_val, you need to change beta_val too&#039;&#039;&#039;, otherwise you may end up with &amp;gt;100% HF exchange at long range. I&#039;d advise you keep alpha_val + beta_val =1.0, since that should give you the correct long-range potential.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;mu_lower&#039;&#039;&#039; and &#039;&#039;&#039;mu_upper&#039;&#039;&#039; control the initial range of &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; values to try out. If you have a good idea what your final &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; will be, then settings mu_lower and mu_upper to nearby values should speed up the optimisation process. However, there is &#039;&#039;&#039;NO NEED&#039;&#039;&#039; for the final mu_val to be between these initial search values, it will just take longer if its far away from this range.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;max_step&#039;&#039;&#039; and &#039;&#039;&#039;min_step&#039;&#039;&#039; correspond to the maximum and minimum change in &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;  between optimisation steps. Note that i think the minimum possible min_step=0.0001, so dont set it lower than that or it could cause serious problems (it&#039;ll lead to a gradient of zero between two mu values, i have no idea how the optimiser will react to that but it wont be good). Theres probably &#039;&#039;&#039;NEVER&#039;&#039;&#039; a need to mess with these values. If the optimiser isnt efficient enough, changing these values wont help much. Writing a better optimiser (the current ones pretty terrible by the way,but it works so.....) would probably be easier than working out the best values for these numbers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;P5_val&#039;&#039;&#039; corresponds to a parameter in the DFT functional controlling the amount of non-local correlation to use. Its the same P5 parameter that appears on the gaussian 09/16 guide to &amp;quot;user-defined DFT functionals&amp;quot;. Just leave it alone unless you REALLY know what your doing.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;CAM-B3LYP&#039;&#039;&#039; corresponds to the underlying functional to use. The functional this code generates is essentially CAM-B3LYP with modified &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;,&amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; parameters. The underlying DFT exchange/ DFT correlation functionals are the same as those used in CAM-B3LYP. I&#039;ve never tried modifying this, it would be a massive pain. If you want to try then i suggest you use a range-separated functional as your base and start by passing the relevant arguments to the &amp;quot;init_OTRSH.py&amp;quot; functional, and seeing if you can replicate the original functional (e.g if you want to use wB97XD as your base functional, try and reproduce reslts of that functional by passing relevant options to init_OTRSH.py.&lt;br /&gt;
&lt;br /&gt;
Finally, the convergence criteria for the OTRSH (the IP_HOMO - E_HOMO value) is set to 0.01 eV by default, and controlled by the IP_conver_thres variable in optimiser.py. I guess its possible you may want to relax that criteria in certain circumstances (obviously it would speed up the optimisation and lower the accuracy).&lt;br /&gt;
&lt;br /&gt;
==Further Reading/Links to relevant Papers==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630213</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630213"/>
		<updated>2017-06-03T15:21:26Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Quick Start Guide - The output files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Links to files==&lt;br /&gt;
Zip Archive: [[Media:OTRSH_hpc_ver_June3rd_2017.zip]]&lt;br /&gt;
&lt;br /&gt;
==What is an OTRSH Functional==&lt;br /&gt;
It is an optimally tuned range separated hybrid functional (OTRSH). This is a class of functionals that are useful for ccalculating electronic properties such as UV-Vis spectra (especially if charge-transfer excitations are important) or photoelectron spectra. Before talking about OTRSH functionals, it is useful to first talk about how standard range separated hybrid functionals work, and why they were created.&lt;br /&gt;
&lt;br /&gt;
===The Problem===&lt;br /&gt;
Standard DFT has problems describing long range interactions, due to the form of the exchange energy in standard functionals. Actual (exact) Exchange energy scales with distance as &amp;lt;math&amp;gt;\frac{1}{r_{12}}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; is the distance between two electrons. However, standard pure DFT exchange functionals depend directly on the electron density, which decays exponentially with distance from an atomic center (i.e. DFT exchange decays faster than actual exchange). This means that standard DFT functionals are poor at describing long-range interactions (charge transfer excitations in DFT is an example). Range seperated hybrid functionals try to fix this by using Hartree-Fock exchange energy (which is exact) at large distances (long-range) while keeping DFT exchange energy at short range.&lt;br /&gt;
&lt;br /&gt;
===One Solution - Normal Range Separated Hybrids===&lt;br /&gt;
A range separated hydrbrid functional divides the exchange energy into two terms - short range exchange (&amp;lt;math&amp;gt; E_{X}^{SR}&amp;lt;/math&amp;gt;) and long range exchange (&amp;lt;math&amp;gt; E_{X}^{LR} &amp;lt;/math&amp;gt;). The exchange energy at any one distance is a weighted combination of short-range and long range exchange, and can essentially be described with three variables; &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (See picture below). &lt;br /&gt;
&lt;br /&gt;
[[File:Frac_HF_Exchange_mu.png|200px|center|Description of the Exchange energy at varying distances in a range-separated hybrid functtional]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The equations for total, short range (DFT) and long-range (HF) exchange are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{Total} = E_{X}^{SR} + E_{X}^{LR}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{SR} = [1-(\alpha + \beta{}.\text{erf}(\mu r_{12})] E_{X}^{DFT}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{LR} = [\alpha + \beta{}.\text{erf}(\mu{}r_{12})] E_{X}^{HF}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where erf is the error function. &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; represents the amount of HF exchange at short range. For example, &amp;lt;math&amp;gt;\alpha=0.2&amp;lt;/math&amp;gt; would mean 20% HF exchange was used at &amp;lt;math&amp;gt;r_{12}=0&amp;lt;/math&amp;gt;. &amp;lt;math&amp;gt;\alpha + \beta &amp;lt;/math&amp;gt; represents the amount of HF exchange at long range (i.e as &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; approaches infinity). A value of &amp;lt;math&amp;gt;\alpha + \beta =1&amp;lt;/math&amp;gt; means that 100% HF exchange is employed at long range, which should give the correct long-range behavior for the exchange energy. &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the range seperation parameter, its value determines how quickly we change from short-range to long-range exchange expresssions. The higher &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is, the faster (shorter distances) we start using the long-range exchange energy expression.&lt;br /&gt;
&lt;br /&gt;
A problem with range separated hybrids is in picking the correct value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (i.e when should we stop using DFT exchange?). This is often determined empirically by varying &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; for a test data set, and seeing which &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value leads to a functional that best reproduces an experimental property (e.g. atomic ionisation energies). This has the same problem as any kind of empirical fitting - its not clear how well the functional will work outside the test set of molecules/properties. Also this empirical tuning of parameters can lead to unphysical values. For example, CAM-B3LYP uses &amp;lt;math&amp;gt;\alpha + \beta =0.65&amp;lt;/math&amp;gt;, meaning it definitely has the wrong long-range behavior.&lt;br /&gt;
&lt;br /&gt;
===OTRSH Functionals===&lt;br /&gt;
&lt;br /&gt;
OTRSH functionals provide a non-empirical method for choosing &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is &amp;quot;tuned&amp;quot; on a per-calculation basis. The &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value is chosen so that the calculated ionisation energy matches the negative of the HOMO energy, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = -E_{HOMO}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = E_{N-1} - E_{N}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;E_{N-1}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_{N}&amp;lt;/math&amp;gt; represent the energy of the N-1 and N electron system (both in the N electron system geometry). Note that all values in the equations above can be obtained from two single-point energy calculations. Also note that &amp;lt;math&amp;gt;IP_{Calc} = -E_{HOMO}&amp;lt;/math&amp;gt; is true for the exact (unknown) KS-DFT functional, hence it is a sensible thing to try to reproduce in a functional.&lt;br /&gt;
&lt;br /&gt;
To summarise an OTRSH functional is one whereby &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is chosen to minimise &amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} + E_{HOMO}&amp;lt;/math&amp;gt;, hence the &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value will be different for every calculation you carry out. Sometimes the IP and HOMO energy of the N-1 electron system are also used to tune &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, but unfortunately thats not possible the code on this page.&lt;br /&gt;
&lt;br /&gt;
==What it does(Roughly)==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide (Using the test file)===&lt;br /&gt;
Once you download the .zip archive, copy the files to somewhere on your hpc path [Note: make sure you dont miss the .rng_OTRSH file]. Personally i use &amp;quot;/home/rf614/bin&amp;quot; as the location. To use the gf_OTRSH function straight away you&#039;ll need to put them in $HOME/bin. &amp;quot;echo $HOME&amp;quot; while on the hpc to find where your home directory is if your not sure.&lt;br /&gt;
&lt;br /&gt;
Move the test file (&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin.com&#039;) to whereever you like in your work directory, and navigate to this folder. Then type either of the following commands (assuming you put the scripts in ~/bin):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
qsub -v in=H2O_SPE_6311plgdp_GP_B3LYP_builtin -N test ~/bin/.rng_OTRSH&lt;br /&gt;
gf_OTRSH H2O_SPE_6311plgdp_GP_B3LYP_builtin.com&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you saved the files somewhere else then simply modify &amp;quot;~/bin/.rng_OTRSH&amp;quot; to whatevers appropriate for the top command. For details on how the gf command works see this wiki [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/pimpQSUB link].&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide - The output files===&lt;br /&gt;
Assuming you ran the job above you will now have a loada output files in your current directory, i.e.:&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt.*&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_ionstate_mu_opt.*&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_OTRSH.out&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_OTRSH.out&#039;&#039;&#039; file is essentially a progress file for how the tuning process is going. Once the calculation is over its main purpose is really to keep track of the options you used to create the OTRSH functional. Its a comma delimited file, and the headings should be pretty self-explanatory (at least they will be if you read the above section on &amp;quot;What is an OTRSH&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt&#039;&#039;&#039;* files are for single energy calculations using the OTRSH functional tuned for this particular system. If your goal was to calculate ground state properties with an OTRSH then these files might be all you need. If you want to do something other than a single-point energy calculation, then just add the relevant keywords (e.g TD) to the  H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt.com file - this file contains all the keywords needed to define the OTRSH functional.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_ionstate_mu_opt&#039;&#039;&#039;* files are the single point energy calculations (using the OTRSH) for the ionised system. You probably have no need for these.&lt;br /&gt;
&lt;br /&gt;
You will also have a new folder named &#039;&#039;&#039;temp_files_H2O_SPE_6311plgdp_GP_B3LYP_builtin&#039;&#039;&#039;. At every tested value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, the .log files for the ground and ionised state are written to this folder. The purpose of this folder is to check nothings going wrong during the calculation. If something stops the code extracting scf energies for each &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value, then it might just loop infinitely (or at least for a loooooong time). The code &#039;&#039;&#039;SHOULD&#039;&#039;&#039; catch these sorts of errors and kill the job, but if it runs a long time without any change in the *.out file then make sure the *.log files in this folder are ok. The secondary purpose of this folder is therefore to tell you WHY your job got killed, if it got killed (an error message should be given in the .out file as well but....)&lt;br /&gt;
&lt;br /&gt;
===Quick Note on Creating Input Files===&lt;br /&gt;
&lt;br /&gt;
If you want to run the code, with default options, on your own systems then theres not much to say. Simply prepare a normal &#039;&#039;&#039;SINGLE POINT ENERGY&#039;&#039;&#039; *.com file for your system, but remove the functional from the input line. Also dont use the &amp;quot;#p&amp;quot; command for excess printing - this will break the OTRSH code (sorry, the code essentially uses the # for a search + replace to insert a functional at each step of the tuning process). For example, this input line is fine(and used in the example file):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# 6-311+g(d,p) geom=connectivity int=ultrafine scf=conver=9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you use a &#039;&#039;&#039;single point energy calculation input file&#039;&#039;&#039;, using a keyword like &amp;quot;freq&amp;quot; wont throw any errors, but you&#039;ll be waiting a really long time for your job to finish.&lt;br /&gt;
&lt;br /&gt;
==Further Reading/Links to relevant Papers==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630212</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630212"/>
		<updated>2017-06-03T15:14:39Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Running The Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Links to files==&lt;br /&gt;
Zip Archive: [[Media:OTRSH_hpc_ver_June3rd_2017.zip]]&lt;br /&gt;
&lt;br /&gt;
==What is an OTRSH Functional==&lt;br /&gt;
It is an optimally tuned range separated hybrid functional (OTRSH). This is a class of functionals that are useful for ccalculating electronic properties such as UV-Vis spectra (especially if charge-transfer excitations are important) or photoelectron spectra. Before talking about OTRSH functionals, it is useful to first talk about how standard range separated hybrid functionals work, and why they were created.&lt;br /&gt;
&lt;br /&gt;
===The Problem===&lt;br /&gt;
Standard DFT has problems describing long range interactions, due to the form of the exchange energy in standard functionals. Actual (exact) Exchange energy scales with distance as &amp;lt;math&amp;gt;\frac{1}{r_{12}}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; is the distance between two electrons. However, standard pure DFT exchange functionals depend directly on the electron density, which decays exponentially with distance from an atomic center (i.e. DFT exchange decays faster than actual exchange). This means that standard DFT functionals are poor at describing long-range interactions (charge transfer excitations in DFT is an example). Range seperated hybrid functionals try to fix this by using Hartree-Fock exchange energy (which is exact) at large distances (long-range) while keeping DFT exchange energy at short range.&lt;br /&gt;
&lt;br /&gt;
===One Solution - Normal Range Separated Hybrids===&lt;br /&gt;
A range separated hydrbrid functional divides the exchange energy into two terms - short range exchange (&amp;lt;math&amp;gt; E_{X}^{SR}&amp;lt;/math&amp;gt;) and long range exchange (&amp;lt;math&amp;gt; E_{X}^{LR} &amp;lt;/math&amp;gt;). The exchange energy at any one distance is a weighted combination of short-range and long range exchange, and can essentially be described with three variables; &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (See picture below). &lt;br /&gt;
&lt;br /&gt;
[[File:Frac_HF_Exchange_mu.png|200px|center|Description of the Exchange energy at varying distances in a range-separated hybrid functtional]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The equations for total, short range (DFT) and long-range (HF) exchange are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{Total} = E_{X}^{SR} + E_{X}^{LR}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{SR} = [1-(\alpha + \beta{}.\text{erf}(\mu r_{12})] E_{X}^{DFT}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{LR} = [\alpha + \beta{}.\text{erf}(\mu{}r_{12})] E_{X}^{HF}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where erf is the error function. &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; represents the amount of HF exchange at short range. For example, &amp;lt;math&amp;gt;\alpha=0.2&amp;lt;/math&amp;gt; would mean 20% HF exchange was used at &amp;lt;math&amp;gt;r_{12}=0&amp;lt;/math&amp;gt;. &amp;lt;math&amp;gt;\alpha + \beta &amp;lt;/math&amp;gt; represents the amount of HF exchange at long range (i.e as &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; approaches infinity). A value of &amp;lt;math&amp;gt;\alpha + \beta =1&amp;lt;/math&amp;gt; means that 100% HF exchange is employed at long range, which should give the correct long-range behavior for the exchange energy. &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the range seperation parameter, its value determines how quickly we change from short-range to long-range exchange expresssions. The higher &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is, the faster (shorter distances) we start using the long-range exchange energy expression.&lt;br /&gt;
&lt;br /&gt;
A problem with range separated hybrids is in picking the correct value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (i.e when should we stop using DFT exchange?). This is often determined empirically by varying &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; for a test data set, and seeing which &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value leads to a functional that best reproduces an experimental property (e.g. atomic ionisation energies). This has the same problem as any kind of empirical fitting - its not clear how well the functional will work outside the test set of molecules/properties. Also this empirical tuning of parameters can lead to unphysical values. For example, CAM-B3LYP uses &amp;lt;math&amp;gt;\alpha + \beta =0.65&amp;lt;/math&amp;gt;, meaning it definitely has the wrong long-range behavior.&lt;br /&gt;
&lt;br /&gt;
===OTRSH Functionals===&lt;br /&gt;
&lt;br /&gt;
OTRSH functionals provide a non-empirical method for choosing &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is &amp;quot;tuned&amp;quot; on a per-calculation basis. The &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value is chosen so that the calculated ionisation energy matches the negative of the HOMO energy, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = -E_{HOMO}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = E_{N-1} - E_{N}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;E_{N-1}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_{N}&amp;lt;/math&amp;gt; represent the energy of the N-1 and N electron system (both in the N electron system geometry). Note that all values in the equations above can be obtained from two single-point energy calculations. Also note that &amp;lt;math&amp;gt;IP_{Calc} = -E_{HOMO}&amp;lt;/math&amp;gt; is true for the exact (unknown) KS-DFT functional, hence it is a sensible thing to try to reproduce in a functional.&lt;br /&gt;
&lt;br /&gt;
To summarise an OTRSH functional is one whereby &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is chosen to minimise &amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} + E_{HOMO}&amp;lt;/math&amp;gt;, hence the &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value will be different for every calculation you carry out. Sometimes the IP and HOMO energy of the N-1 electron system are also used to tune &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, but unfortunately thats not possible the code on this page.&lt;br /&gt;
&lt;br /&gt;
==What it does(Roughly)==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide (Using the test file)===&lt;br /&gt;
Once you download the .zip archive, copy the files to somewhere on your hpc path [Note: make sure you dont miss the .rng_OTRSH file]. Personally i use &amp;quot;/home/rf614/bin&amp;quot; as the location. To use the gf_OTRSH function straight away you&#039;ll need to put them in $HOME/bin. &amp;quot;echo $HOME&amp;quot; while on the hpc to find where your home directory is if your not sure.&lt;br /&gt;
&lt;br /&gt;
Move the test file (&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin.com&#039;) to whereever you like in your work directory, and navigate to this folder. Then type either of the following commands (assuming you put the scripts in ~/bin):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
qsub -v in=H2O_SPE_6311plgdp_GP_B3LYP_builtin -N test ~/bin/.rng_OTRSH&lt;br /&gt;
gf_OTRSH H2O_SPE_6311plgdp_GP_B3LYP_builtin.com&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you saved the files somewhere else then simply modify &amp;quot;~/bin/.rng_OTRSH&amp;quot; to whatevers appropriate for the top command. For details on how the gf command works see this wiki [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/pimpQSUB link].&lt;br /&gt;
&lt;br /&gt;
===Quick Start Guide - The output files===&lt;br /&gt;
Assuming you ran the job above you will now have a loada output files in your current directory, i.e.:&lt;br /&gt;
&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt.*&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_ionstate_mu_opt.*&lt;br /&gt;
H2O_SPE_6311plgdp_GP_B3LYP_builtin_OTRSH.out&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_OTRSH.out&#039;&#039;&#039; file is essentially a progress file for how the tuning process is going. Once the calculation is over its main purpose is really to keep track of the options you used to create the OTRSH functional. Its a comma delimited file, and the headings should be pretty self-explanatory (at least they will be if you read the above section on &amp;quot;What is an OTRSH&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt&#039;&#039;&#039;* files are for single energy calculations using the OTRSH functional tuned for this particular system. If your goal was to calculate ground state properties with an OTRSH then these files might be all you need. If you want to do something other than a single-point energy calculation, then just add the relevant keywords (e.g TD) to the  H2O_SPE_6311plgdp_GP_B3LYP_builtin_gsstate_mu_opt.com file - this file contains all the keywords needed to define the OTRSH functional.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;H2O_SPE_6311plgdp_GP_B3LYP_builtin_ionstate_mu_opt&#039;&#039;&#039;* files are the single point energy calculations (using the OTRSH) for the ionised system. You probably have no need for these.&lt;br /&gt;
&lt;br /&gt;
You will also have a new folder named &#039;&#039;&#039;temp_files_H2O_SPE_6311plgdp_GP_B3LYP_builtin&#039;&#039;&#039;. At every tested value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, the .log files for the ground and ionised state are written to this folder. The purpose of this folder is to check nothings going wrong during the calculation. If something stops the code extracting scf energies for each &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value, then it might just loop infinitely (or at least for a loooooong time). The code &#039;&#039;&#039;SHOULD&#039;&#039;&#039; catch these sorts of errors and kill the job, but if it runs a long time without any change in the *.out file then make sure the *.log files in this folder are ok. The secondary purpose of this folder is therefore to tell you WHY your job got killed, if it got killed (an error message should be given in the .out file as well but....)&lt;br /&gt;
&lt;br /&gt;
==Further Reading/Links to relevant Papers==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630211</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630211"/>
		<updated>2017-06-03T14:43:35Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Links to files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Links to files==&lt;br /&gt;
Zip Archive: [[Media:OTRSH_hpc_ver_June3rd_2017.zip]]&lt;br /&gt;
&lt;br /&gt;
==What is an OTRSH Functional==&lt;br /&gt;
It is an optimally tuned range separated hybrid functional (OTRSH). This is a class of functionals that are useful for ccalculating electronic properties such as UV-Vis spectra (especially if charge-transfer excitations are important) or photoelectron spectra. Before talking about OTRSH functionals, it is useful to first talk about how standard range separated hybrid functionals work, and why they were created.&lt;br /&gt;
&lt;br /&gt;
===The Problem===&lt;br /&gt;
Standard DFT has problems describing long range interactions, due to the form of the exchange energy in standard functionals. Actual (exact) Exchange energy scales with distance as &amp;lt;math&amp;gt;\frac{1}{r_{12}}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; is the distance between two electrons. However, standard pure DFT exchange functionals depend directly on the electron density, which decays exponentially with distance from an atomic center (i.e. DFT exchange decays faster than actual exchange). This means that standard DFT functionals are poor at describing long-range interactions (charge transfer excitations in DFT is an example). Range seperated hybrid functionals try to fix this by using Hartree-Fock exchange energy (which is exact) at large distances (long-range) while keeping DFT exchange energy at short range.&lt;br /&gt;
&lt;br /&gt;
===One Solution - Normal Range Separated Hybrids===&lt;br /&gt;
A range separated hydrbrid functional divides the exchange energy into two terms - short range exchange (&amp;lt;math&amp;gt; E_{X}^{SR}&amp;lt;/math&amp;gt;) and long range exchange (&amp;lt;math&amp;gt; E_{X}^{LR} &amp;lt;/math&amp;gt;). The exchange energy at any one distance is a weighted combination of short-range and long range exchange, and can essentially be described with three variables; &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (See picture below). &lt;br /&gt;
&lt;br /&gt;
[[File:Frac_HF_Exchange_mu.png|200px|center|Description of the Exchange energy at varying distances in a range-separated hybrid functtional]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The equations for total, short range (DFT) and long-range (HF) exchange are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{Total} = E_{X}^{SR} + E_{X}^{LR}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{SR} = [1-(\alpha + \beta{}.\text{erf}(\mu r_{12})] E_{X}^{DFT}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{LR} = [\alpha + \beta{}.\text{erf}(\mu{}r_{12})] E_{X}^{HF}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where erf is the error function. &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; represents the amount of HF exchange at short range. For example, &amp;lt;math&amp;gt;\alpha=0.2&amp;lt;/math&amp;gt; would mean 20% HF exchange was used at &amp;lt;math&amp;gt;r_{12}=0&amp;lt;/math&amp;gt;. &amp;lt;math&amp;gt;\alpha + \beta &amp;lt;/math&amp;gt; represents the amount of HF exchange at long range (i.e as &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; approaches infinity). A value of &amp;lt;math&amp;gt;\alpha + \beta =1&amp;lt;/math&amp;gt; means that 100% HF exchange is employed at long range, which should give the correct long-range behavior for the exchange energy. &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the range seperation parameter, its value determines how quickly we change from short-range to long-range exchange expresssions. The higher &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is, the faster (shorter distances) we start using the long-range exchange energy expression.&lt;br /&gt;
&lt;br /&gt;
A problem with range separated hybrids is in picking the correct value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (i.e when should we stop using DFT exchange?). This is often determined empirically by varying &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; for a test data set, and seeing which &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value leads to a functional that best reproduces an experimental property (e.g. atomic ionisation energies). This has the same problem as any kind of empirical fitting - its not clear how well the functional will work outside the test set of molecules/properties. Also this empirical tuning of parameters can lead to unphysical values. For example, CAM-B3LYP uses &amp;lt;math&amp;gt;\alpha + \beta =0.65&amp;lt;/math&amp;gt;, meaning it definitely has the wrong long-range behavior.&lt;br /&gt;
&lt;br /&gt;
===OTRSH Functionals===&lt;br /&gt;
&lt;br /&gt;
OTRSH functionals provide a non-empirical method for choosing &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is &amp;quot;tuned&amp;quot; on a per-calculation basis. The &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value is chosen so that the calculated ionisation energy matches the negative of the HOMO energy, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = -E_{HOMO}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = E_{N-1} - E_{N}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;E_{N-1}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_{N}&amp;lt;/math&amp;gt; represent the energy of the N-1 and N electron system (both in the N electron system geometry). Note that all values in the equations above can be obtained from two single-point energy calculations. Also note that &amp;lt;math&amp;gt;IP_{Calc} = -E_{HOMO}&amp;lt;/math&amp;gt; is true for the exact (unknown) KS-DFT functional, hence it is a sensible thing to try to reproduce in a functional.&lt;br /&gt;
&lt;br /&gt;
To summarise an OTRSH functional is one whereby &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is chosen to minimise &amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} + E_{HOMO}&amp;lt;/math&amp;gt;, hence the &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value will be different for every calculation you carry out. Sometimes the IP and HOMO energy of the N-1 electron system are also used to tune &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, but unfortunately thats not possible the code on this page.&lt;br /&gt;
&lt;br /&gt;
==What it does(Roughly)==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Further Reading/Links to relevant Papers==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:OTRSH_hpc_ver_June3rd_2017.zip&amp;diff=630210</id>
		<title>File:OTRSH hpc ver June3rd 2017.zip</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:OTRSH_hpc_ver_June3rd_2017.zip&amp;diff=630210"/>
		<updated>2017-06-03T14:43:02Z</updated>

		<summary type="html">&lt;p&gt;Rf614: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630209</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630209"/>
		<updated>2017-06-03T12:06:20Z</updated>

		<summary type="html">&lt;p&gt;Rf614: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Links to files==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is an OTRSH Functional==&lt;br /&gt;
It is an optimally tuned range separated hybrid functional (OTRSH). This is a class of functionals that are useful for ccalculating electronic properties such as UV-Vis spectra (especially if charge-transfer excitations are important) or photoelectron spectra. Before talking about OTRSH functionals, it is useful to first talk about how standard range separated hybrid functionals work, and why they were created.&lt;br /&gt;
&lt;br /&gt;
===The Problem===&lt;br /&gt;
Standard DFT has problems describing long range interactions, due to the form of the exchange energy in standard functionals. Actual (exact) Exchange energy scales with distance as &amp;lt;math&amp;gt;\frac{1}{r_{12}}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; is the distance between two electrons. However, standard pure DFT exchange functionals depend directly on the electron density, which decays exponentially with distance from an atomic center (i.e. DFT exchange decays faster than actual exchange). This means that standard DFT functionals are poor at describing long-range interactions (charge transfer excitations in DFT is an example). Range seperated hybrid functionals try to fix this by using Hartree-Fock exchange energy (which is exact) at large distances (long-range) while keeping DFT exchange energy at short range.&lt;br /&gt;
&lt;br /&gt;
===One Solution - Normal Range Separated Hybrids===&lt;br /&gt;
A range separated hydrbrid functional divides the exchange energy into two terms - short range exchange (&amp;lt;math&amp;gt; E_{X}^{SR}&amp;lt;/math&amp;gt;) and long range exchange (&amp;lt;math&amp;gt; E_{X}^{LR} &amp;lt;/math&amp;gt;). The exchange energy at any one distance is a weighted combination of short-range and long range exchange, and can essentially be described with three variables; &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (See picture below). &lt;br /&gt;
&lt;br /&gt;
[[File:Frac_HF_Exchange_mu.png|200px|center|Description of the Exchange energy at varying distances in a range-separated hybrid functtional]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The equations for total, short range (DFT) and long-range (HF) exchange are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{Total} = E_{X}^{SR} + E_{X}^{LR}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{SR} = [1-(\alpha + \beta{}.\text{erf}(\mu r_{12})] E_{X}^{DFT}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{LR} = [\alpha + \beta{}.\text{erf}(\mu{}r_{12})] E_{X}^{HF}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where erf is the error function. &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; represents the amount of HF exchange at short range. For example, &amp;lt;math&amp;gt;\alpha=0.2&amp;lt;/math&amp;gt; would mean 20% HF exchange was used at &amp;lt;math&amp;gt;r_{12}=0&amp;lt;/math&amp;gt;. &amp;lt;math&amp;gt;\alpha + \beta &amp;lt;/math&amp;gt; represents the amount of HF exchange at long range (i.e as &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; approaches infinity). A value of &amp;lt;math&amp;gt;\alpha + \beta =1&amp;lt;/math&amp;gt; means that 100% HF exchange is employed at long range, which should give the correct long-range behavior for the exchange energy. &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the range seperation parameter, its value determines how quickly we change from short-range to long-range exchange expresssions. The higher &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is, the faster (shorter distances) we start using the long-range exchange energy expression.&lt;br /&gt;
&lt;br /&gt;
A problem with range separated hybrids is in picking the correct value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (i.e when should we stop using DFT exchange?). This is often determined empirically by varying &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; for a test data set, and seeing which &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value leads to a functional that best reproduces an experimental property (e.g. atomic ionisation energies). This has the same problem as any kind of empirical fitting - its not clear how well the functional will work outside the test set of molecules/properties. Also this empirical tuning of parameters can lead to unphysical values. For example, CAM-B3LYP uses &amp;lt;math&amp;gt;\alpha + \beta =0.65&amp;lt;/math&amp;gt;, meaning it definitely has the wrong long-range behavior.&lt;br /&gt;
&lt;br /&gt;
===OTRSH Functionals===&lt;br /&gt;
&lt;br /&gt;
OTRSH functionals provide a non-empirical method for choosing &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is &amp;quot;tuned&amp;quot; on a per-calculation basis. The &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value is chosen so that the calculated ionisation energy matches the negative of the HOMO energy, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = -E_{HOMO}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = E_{N-1} - E_{N}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;E_{N-1}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_{N}&amp;lt;/math&amp;gt; represent the energy of the N-1 and N electron system (both in the N electron system geometry). Note that all values in the equations above can be obtained from two single-point energy calculations. Also note that &amp;lt;math&amp;gt;IP_{Calc} = -E_{HOMO}&amp;lt;/math&amp;gt; is true for the exact (unknown) KS-DFT functional, hence it is a sensible thing to try to reproduce in a functional.&lt;br /&gt;
&lt;br /&gt;
To summarise an OTRSH functional is one whereby &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is chosen to minimise &amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} + E_{HOMO}&amp;lt;/math&amp;gt;, hence the &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value will be different for every calculation you carry out. Sometimes the IP and HOMO energy of the N-1 electron system are also used to tune &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, but unfortunately thats not possible the code on this page.&lt;br /&gt;
&lt;br /&gt;
==What it does(Roughly)==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Further Reading/Links to relevant Papers==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630208</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630208"/>
		<updated>2017-06-03T12:05:43Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* What is an OTRSH Functional */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Links to files==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is an OTRSH Functional==&lt;br /&gt;
It is an optimally tuned range separated hybrid functional (OTRSH). This is a class of functionals that are useful for ccalculating electronic properties such as UV-Vis spectra (especially if charge-transfer excitations are important) or photoelectron spectra. Before talking about OTRSH functionals, it is useful to first talk about how standard range separated hybrid functionals work, and why they were created.&lt;br /&gt;
&lt;br /&gt;
===The Problem===&lt;br /&gt;
Standard DFT has problems describing long range interactions, due to the form of the exchange energy in standard functionals. Actual (exact) Exchange energy scales with distance as &amp;lt;math&amp;gt;\frac{1}{r_{12}}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; is the distance between two electrons. However, standard pure DFT exchange functionals depend directly on the electron density, which decays exponentially with distance from an atomic center (i.e. DFT exchange decays faster than actual exchange). This means that standard DFT functionals are poor at describing long-range interactions (charge transfer excitations in DFT is an example). Range seperated hybrid functionals try to fix this by using Hartree-Fock exchange energy (which is exact) at large distances (long-range) while keeping DFT exchange energy at short range.&lt;br /&gt;
&lt;br /&gt;
===One Solution - Normal Range Separated Hybrids===&lt;br /&gt;
A range separated hydrbrid functional divides the exchange energy into two terms - short range exchange (&amp;lt;math&amp;gt; E_{X}^{SR}&amp;lt;/math&amp;gt;) and long range exchange (&amp;lt;math&amp;gt; E_{X}^{LR} &amp;lt;/math&amp;gt;). The exchange energy at any one distance is a weighted combination of short-range and long range exchange, and can essentially be described with three variables; &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (See picture below). &lt;br /&gt;
&lt;br /&gt;
[[File:Frac_HF_Exchange_mu.png|200px|center|Description of the Exchange energy at varying distances in a range-separated hybrid functtional]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The equations for total, short range (DFT) and long-range (HF) exchange are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{Total} = E_{X}^{SR} + E_{X}^{LR}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{SR} = [1-(\alpha + \beta{}.\text{erf}(\mu r_{12})] E_{X}^{DFT}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{LR} = [\alpha + \beta{}.\text{erf}(\mu{}r_{12})] E_{X}^{HF}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where erf is the error function. &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; represents the amount of HF exchange at short range. For example, &amp;lt;math&amp;gt;\alpha=0.2&amp;lt;/math&amp;gt; would mean 20% HF exchange was used at &amp;lt;math&amp;gt;r_{12}=0&amp;lt;/math&amp;gt;. &amp;lt;math&amp;gt;\alpha + \beta &amp;lt;/math&amp;gt; represents the amount of HF exchange at long range (i.e as &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; approaches infinity). A value of &amp;lt;math&amp;gt;\alpha + \beta =1&amp;lt;/math&amp;gt; means that 100% HF exchange is employed at long range, which should give the correct long-range behavior for the exchange energy. &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the range seperation parameter, its value determines how quickly we change from short-range to long-range exchange expresssions. The higher &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is, the faster (shorter distances) we start using the long-range exchange energy expression.&lt;br /&gt;
&lt;br /&gt;
A problem with range separated hybrids is in picking the correct value for &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (i.e when should we stop using DFT exchange?). This is often determined empirically by varying &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; for a test data set, and seeing which &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value leads to a functional that best reproduces an experimental property (e.g. atomic ionisation energies). This has the same problem as any kind of empirical fitting - its not clear how well the functional will work outside the test set of molecules/properties. Also this empirical tuning of parameters can lead to unphysical values. For example, CAM-B3LYP uses &amp;lt;math&amp;gt;\alpha + \beta =0.65&amp;lt;/math&amp;gt;, meaning it definitely has the wrong long-range behavior.&lt;br /&gt;
&lt;br /&gt;
===OTRSH Functionals===&lt;br /&gt;
&lt;br /&gt;
OTRSH functionals provide a non-empirical method for choosing &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;; &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is &amp;quot;tuned&amp;quot; on a per-calculation basis. The &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value is chosen so that the calculated ionisation energy matches the negative of the HOMO energy, i.e.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = -E_{HOMO}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} = E_{N-1} - E_{N}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;E_{N-1}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_{N}&amp;lt;/math&amp;gt; represent the energy of the N-1 and N electron system (both in the N electron system geometry). Note that all values in the equations above can be obtained from two single-point energy calculations. Also note that &amp;lt;math&amp;gt;IP_{Calc} = -E_{HOMO}&amp;lt;/math&amp;gt; is true for the exact (unknown) KS-DFT functional, hence it is a sensible thing to try to reproduce in a functional.&lt;br /&gt;
&lt;br /&gt;
To summarise an OTRSH functional is one whereby &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is chosen to minimise &amp;lt;math&amp;gt;&lt;br /&gt;
IP_{Calc} + E_{HOMO}&amp;lt;/math&amp;gt;, hence the &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; value will be different for every calculation you carry out. Sometimes the IP and HOMO energy of the N-1 electron system are also used to tune &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;, but unfortunately thats not possible the code on this page.&lt;br /&gt;
&lt;br /&gt;
==What it does(Roughly)==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group&amp;diff=630200</id>
		<title>Mod:Hunt Research Group</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group&amp;diff=630200"/>
		<updated>2017-06-02T17:31:23Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Codes to Help Analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Hunt Group Wiki==&lt;br /&gt;
&lt;br /&gt;
Back to the main [http://www.ch.ic.ac.uk/hunt web-page]&lt;br /&gt;
===HPC Resources===&lt;br /&gt;
#Computing resources available in the chemistry department [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/computing_resources link]&lt;br /&gt;
#HPC servers and run scripts [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/hpc link]&lt;br /&gt;
#Setting up a connection to HPC if you have a PC [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/hpc_connections link] &lt;br /&gt;
#How to fix Windows files under UNIX [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/Windowsfiles link] &lt;br /&gt;
#How to make ssh more comfortable [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/pimpSSH link] &lt;br /&gt;
#How to make qsub more comfortable (gfunc) [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/pimpQSUB link] &lt;br /&gt;
#How to set up a SSH keypair [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/SSHkeyfile link] &lt;br /&gt;
#How to use gaussview directly on the HPC [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/gview link] &lt;br /&gt;
#How to comfortably search through old BASH commands [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/searchbash link]&lt;br /&gt;
#How to connect to HPC directory on desktop for file transfers - MacFusion [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/hpc_Directory_on_desktop link]&lt;br /&gt;
#How to set up cx2 [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/cx2 link]&lt;br /&gt;
&lt;br /&gt;
===Visualisation===&lt;br /&gt;
*&#039;&#039;&#039;density based visualisation&#039;&#039;&#039;&lt;br /&gt;
#download [http://aim.tkgristmill.com AIMALL]&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;ESPs&#039;&#039;&#039;&lt;br /&gt;
#Instructions for visualizing electrostatic potentials (Gaussview)[https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/electrostatic_potentials link]&lt;br /&gt;
#Electrostatic Potentials II (Molden) [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/electrostatic_potentials_2 link] &lt;br /&gt;
*&#039;&#039;&#039;VMD: a molecular dynamics visualisation package&#039;&#039;&#039;&lt;br /&gt;
#Download VMD [//wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/download_vmd link]&lt;br /&gt;
#Quick reminder [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/VMDReminder link]&lt;br /&gt;
#Tricks and tips [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/VMDTips link]&lt;br /&gt;
#Changing the graphical representation of your structures [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/vmd link]&lt;br /&gt;
#Basic visualisation of a trajectory [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/VisualisingyourSimulation link] &lt;br /&gt;
#How to turn a Gaussian optimization into a VMD movie [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/VMDmovie link] &lt;br /&gt;
#Using scripts in VMD [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/VmdScripts link]&lt;br /&gt;
#Dealing with periodic boundaries and bonding (under construction) [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/VmdScriptsPeriodic link]&lt;br /&gt;
#Dealing with bonding (under construction) [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/VmdBonding link]&lt;br /&gt;
#Overlapping two structures [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/VmdVisual link]&lt;br /&gt;
*&#039;&#039;&#039;JMol&#039;&#039;&#039;&lt;br /&gt;
#Visualising MOs using Jmol [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:basic_jmol_instructions link]&lt;br /&gt;
#Surfaces (Solvent-Accessible and Connolly) in Jmol [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/jmolsurfaces link]&lt;br /&gt;
*&#039;&#039;&#039;EMO Code&#039;&#039;&#039;&lt;br /&gt;
#How to use Ling&#039;s emo plot code[https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/emoplot link] &lt;br /&gt;
#How to plot EMOs [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/emo link]&lt;br /&gt;
*&#039;&#039;&#039;PyGauss&#039;&#039;&#039;&lt;br /&gt;
#Python API for analysis of Gaussian compuations [https://pygauss.readthedocs.org - Documentation]&lt;br /&gt;
*&#039;&#039;&#039;MD Post processing&#039;&#039;&#039;&lt;br /&gt;
#Code to Recentre DL_PLOY HISTORY file [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/recentre_xyz.py link]&lt;br /&gt;
#Link to the code to convert the DL_POLY HISTORY file to the multi-frame XYZ file[https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/his2xyz.py link]&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;SDFs&#039;&#039;&#039;&lt;br /&gt;
#How to generate SDFs [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/sdfs_generate link]&lt;br /&gt;
&lt;br /&gt;
===Gaussian General===&lt;br /&gt;
#We are starting a database of common errors encountered when running Gaussian jobs [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/gaussian_errors link]&lt;br /&gt;
# Here is an already existing database of common errors [https://www.ace-net.ca/wiki/Gaussian_Error_Messages link]&lt;br /&gt;
# [http://www.ch.ic.ac.uk/hunt/g03_man/index.htm G03 Manual]&lt;br /&gt;
#How to run NBO5.9 on the HPC [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/NBO5.9 link] &lt;br /&gt;
#How to include dispersion [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/dispersion link] &lt;br /&gt;
#Basic ONIOM (Mechanical Embedding) [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/basiconiom link]&lt;br /&gt;
#M0n and DFT-D [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/DFTD link]&lt;br /&gt;
#IL ONIOM clusters [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/oniomclusers link]&lt;br /&gt;
#Molecular volume calculations [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/molecular_volume link]&lt;br /&gt;
#problems with scf convergence [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/scf_convergence link]&lt;br /&gt;
#Using a z-matrix [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/z-matrix link]&lt;br /&gt;
#generating natural transition orbitals [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/nto link]&lt;br /&gt;
#Using solvent models [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/solvent link]&lt;br /&gt;
#Using SMD on ILs [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:_Using_SMD_on_ILs link]&lt;br /&gt;
#computing excited state polarisabilities [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:_ES_alpha link]&lt;br /&gt;
#computing deuterated and/or anharmonic spectra [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:_Danharm link]&lt;br /&gt;
#manipulating checkpoint files [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:usingchkfiles link]&lt;br /&gt;
#AimAll with pseudo potentials [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:aim_pseudopotentials link]&lt;br /&gt;
#Script to pull thermodynamic data and low frequencies from log files [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:freq_script link]&lt;br /&gt;
#General procedure for locating transition state structures [[link]]&lt;br /&gt;
&lt;br /&gt;
===ADF General===&lt;br /&gt;
#Submission script [http://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/ADF_sricpt link]&lt;br /&gt;
&lt;br /&gt;
===Codes to Help Analysis===&lt;br /&gt;
# Extract E2 Values (From NBO Calculations) [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/NBO_Matlab_Code link]&lt;br /&gt;
# Calculate pDoS/XP spectra code (under construction) [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code link]&lt;br /&gt;
# Codes to extract frequency data from gaussian .log files and generate vibrational spectra [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:frequency_spectrum_script link]&lt;br /&gt;
# Optimally Tuned Range Seperated Hybrid Functionals [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct link]&lt;br /&gt;
&lt;br /&gt;
===Setup and Running Ab-Initio MD Simulations===&lt;br /&gt;
#CPMD: Car-Parrinello Molecular Dynamics [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/cpmd link]&lt;br /&gt;
#How to run CPMD to study aqueous solutions [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/cpmd_water link]&lt;br /&gt;
#How to run CP2K [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/cp2k_how link] &lt;br /&gt;
#[bmim]Cl using CPMD [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/bmimCl_cpmd  link] &lt;br /&gt;
#[bmim]Cl using CP2K [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/bmimCl_cp2k  link] &lt;br /&gt;
#mman using CPMD and Gaussian [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/mman link] &lt;br /&gt;
#[emim]SCN using CP2K[https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/emimscn link] &lt;br /&gt;
#CP2K Donts [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/cp2k link] &lt;br /&gt;
&lt;br /&gt;
===Setup and Running Classical MD Simulations===&lt;br /&gt;
#DLPOLY a MD simulation package, Installation on an IMac (old needs to be updated) [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/dlpoly_install  link]&lt;br /&gt;
#DL_POLY FAQs [http://www.stfc.ac.uk/cse/DL_POLY/ccp1gui/38621.aspx] from DL_POLY webpage.&lt;br /&gt;
#Installing Packmol&lt;br /&gt;
#Getting started: generating a solvated structure and &amp;quot;relaxing&amp;quot; it [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/Starting_MD link] &lt;br /&gt;
#Equilibration and production simulations [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/EquilibrationandProduction link] &lt;br /&gt;
#How to equilibrate an MD run[https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/equilibration link] &lt;br /&gt;
#Getting the Force Field [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/Wheretostart link] &lt;br /&gt;
#Choosing an Ensemble [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/Ensembles link] &lt;br /&gt;
#Molten Salt Simulations [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/MoltenSaltSimulation link]&lt;br /&gt;
#Common Errors [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/CommonErrors link]&lt;br /&gt;
#Voids in ILs[https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/voids link] &lt;br /&gt;
#Equilibration of [bmim][BF4] and [bmim][NO3][https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/BmimBF4_equilibration link] &lt;br /&gt;
#Summary of discussions with Ruth[https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/Aug09QtoRuth link]&lt;br /&gt;
&lt;br /&gt;
===Running QM/MM Simulations in ChemShell===&lt;br /&gt;
#ChemShell official website which contains the manual and a tutorial [http://www.stfc.ac.uk/CSE/randd/ccg/36254.aspx link]&lt;br /&gt;
#Introduction to ChemShell - Copper in water [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ChemShell_Introduction link]&lt;br /&gt;
#Defining the system: Cu&amp;lt;sup&amp;gt;2+&amp;lt;/sup&amp;gt; and its first 2 solvation shells [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ChemShell_System_Aqeuous_Cu(II) link] &lt;br /&gt;
#Defining the force field parameters [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ChemShell_Force_Field_Parameters_Aqueous_Cu(II) link] &lt;br /&gt;
#Single point QM/MM energy calculation [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/QMMM_SP_Aqeuous_Cu(II) link] &lt;br /&gt;
#QM/MM Optimisation [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/QMMM_OPT_Aqeuous_Cu(II) link] &lt;br /&gt;
#QM/MM Molecular Dynamics [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/QMMM_MD_Aqeuous_Cu(II) link]&lt;br /&gt;
#Using MolCluster [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/MolCluster link]&lt;br /&gt;
#Running ChemShell [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ChemShell link]&lt;br /&gt;
&lt;br /&gt;
===Research Notes===&lt;br /&gt;
#Cl- in water [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/wannier_centre link] &lt;br /&gt;
#The use of Legendre time correlation functions to study reorientational dynamics in liquids[https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/legendre  link] &lt;br /&gt;
#Functional for ILs using CPMD [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/IL_cpmd_functional link] &lt;br /&gt;
#Solving the angular part of the Schrödinger equation for a hydrogen atom [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/angular_schrodinger link] (notes by Vincent)&lt;br /&gt;
#Systematic conformational scan for ion-pair dimers [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ion_pair_scan link]&lt;br /&gt;
&lt;br /&gt;
===Installing and using other packages===&lt;br /&gt;
#How to install POLYRATE [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/polyrate link] &lt;br /&gt;
#How to install Geomview [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/geomview link] &lt;br /&gt;
#XMGRACE, gfortran, c compilers for Lion [http://hpc.sourceforge.net/]&lt;br /&gt;
&lt;br /&gt;
===Admin Stuff===&lt;br /&gt;
#Not used to writing a wiki, make your test runs [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/testing  on this page]&lt;br /&gt;
#How to set-up new macs [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/mac_setup link]&lt;br /&gt;
#How to set-up remote desktop [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/mac_remote link]&lt;br /&gt;
#[https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/calendar Calendar]&lt;br /&gt;
#How to switch the printer HP CP3525dn duplex on and off [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/printing link]&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630188</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630188"/>
		<updated>2017-06-02T15:21:11Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* What is an OTRSH Functional */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Links to files==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is an OTRSH Functional==&lt;br /&gt;
It is an optimally tuned range separated hybrid functional (OTRSH). This is a class of functionals that are useful for ccalculating electronic properties such as UV-Vis spectra (especially if charge-transfer excitations are important) or photoelectron spectra. Before talking about OTRSH functionals, it is useful to first talk about how standard range separated hybrid functionals work, and why they were created.&lt;br /&gt;
&lt;br /&gt;
Standard DFT has problems describing long range interactions, due to the form of the exchange energy in standard functionals. Actual (exact) Exchange energy scales with distance as &amp;lt;math&amp;gt;\frac{1}{r_{12}}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; is the distance between two electrons. However, standard pure DFT exchange functionals depend directly on the electron density, which decays exponentially with distance from an atomic center (i.e. DFT exchange decays faster than actual exchange). This means that standard DFT functionals are poor at describing long-range interactions (charge transfer excitations in DFT is an example). Range seperated hybrid functionals try to fix this by using Hartree-Fock exchange energy (which is exact) at large distances (long-range) while keeping DFT exchange energy at short range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A range separated hydrbrid functional divides the exchange energy into two terms - short range exchange (&amp;lt;math&amp;gt; E_{X}^{SR}&amp;lt;/math&amp;gt;) and long range exchange (&amp;lt;math&amp;gt; E_{X}^{LR} &amp;lt;/math&amp;gt;). The exchange energy at any one distance is a weighted combination of short-range and long range exchange, and can essentially be described with three variables; &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (See picture below). &lt;br /&gt;
&lt;br /&gt;
[[File:Frac_HF_Exchange_mu.png|200px|center|Description of the Exchange energy at varying distances in a range-separated hybrid functtional]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The equations for total, short range (DFT) and long-range (HF) exchange are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{Total} = E_{X}^{SR} + E_{X}^{LR}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{SR} = [1-(\alpha + \beta{}.\text{erf}(\mu r_{12})] E_{X}^{DFT}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{LR} = [\alpha + \beta{}.\text{erf}(\mu{}r_{12})] E_{X}^{HF}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where erf is the error function. &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; represents the amount of HF exchange at short range. For example, &amp;lt;math&amp;gt;\alpha=0.2&amp;lt;/math&amp;gt; would mean 20% HF exchange was used at &amp;lt;math&amp;gt;r_{12}=0&amp;lt;/math&amp;gt;. &amp;lt;math&amp;gt;\alpha + \beta &amp;lt;/math&amp;gt; represents the amount of HF exchange at long range (i.e as &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; approaches infinity). A value of &amp;lt;math&amp;gt;\alpha + \beta =1&amp;lt;/math&amp;gt; means that 100% HF exchange is employed at long range, which should give the correct long-range behavior for the exchange energy. &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the range seperation parameter, its value determines how quickly we change from short-range to long-range exchange expresssions. The higher &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is, the faster (shorter distances) we start using the long-range exchange energy expression.&lt;br /&gt;
&lt;br /&gt;
==What it does(Roughly)==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=File:Frac_HF_Exchange_mu.png&amp;diff=630186</id>
		<title>File:Frac HF Exchange mu.png</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=File:Frac_HF_Exchange_mu.png&amp;diff=630186"/>
		<updated>2017-06-02T15:11:56Z</updated>

		<summary type="html">&lt;p&gt;Rf614: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630185</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630185"/>
		<updated>2017-06-02T15:10:02Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* What is an OTRSH Functional */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Links to files==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is an OTRSH Functional==&lt;br /&gt;
It is an optimally tuned range separated hybrid functional (OTRSH). This is a class of functionals that are useful for ccalculating electronic properties such as UV-Vis spectra (especially if charge-transfer excitations are important) or photoelectron spectra. Before talking about OTRSH functionals, it is useful to first talk about how standard range separated hybrid functionals work, and why they were created.&lt;br /&gt;
&lt;br /&gt;
Standard DFT has problems describing long range interactions, due to the form of the exchange energy in standard functionals. Actual (exact) Exchange energy scales with distance as &amp;lt;math&amp;gt;\frac{1}{r_{12}}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;r_{12}&amp;lt;/math&amp;gt; is the distance between two electrons. However, standard pure DFT exchange functionals depend directly on the electron density, which decays exponentially with distance from an atomic center (i.e. DFT exchange decays faster than actual exchange). This means that standard DFT functionals are poor at describing long-range interactions (charge transfer excitations in DFT is an example). Range seperated hybrid functionals try to fix this by using Hartree-Fock exchange energy (which is exact) at large distances (long-range) while keeping DFT exchange energy at short range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A range separated hydrbrid functional divides the exchange energy into two terms - short range exchange (&amp;lt;math&amp;gt; E_{X}^{SR}&amp;lt;/math&amp;gt;) and long range exchange (&amp;lt;math&amp;gt; E_{X}^{LR} &amp;lt;/math&amp;gt;). The exchange energy at any one distance is a weighted combination of short-range and long range exchange, and can essentially be described with three variables; &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; (See picture below). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{SR} = [1-(\alpha + \beta{}.\text{erf}(\mu r_{12})] E_{X}^{DFT}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{LR} = [\alpha + \beta{}.\text{erf}(\mu{}r_{12})] E_{X}^{HF}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What it does(Roughly)==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630181</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630181"/>
		<updated>2017-06-02T14:53:39Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* What is an OTRSH Functional */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Links to files==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is an OTRSH Functional==&lt;br /&gt;
It is an optimally tuned range separated hybrid functional.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{SR} = [1-(\alpha + \beta{}.\text{erf}(\mu r_{12})] E_{X}^{DFT}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
E_{X}^{LR} = [\alpha + \beta{}.\text{erf}(\mu{}r_{12})] E_{X}^{HF}(r_{12})&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==What it does(Roughly)==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630180</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630180"/>
		<updated>2017-06-02T14:47:08Z</updated>

		<summary type="html">&lt;p&gt;Rf614: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
==Links to files==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is an OTRSH Functional==&lt;br /&gt;
It is an optimally tuned range separated hybrid functional.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What it does(Roughly)==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running The Code==&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630179</id>
		<title>Mod:Hunt Research Group/OTRSH Funct</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group/OTRSH_Funct&amp;diff=630179"/>
		<updated>2017-06-02T14:44:32Z</updated>

		<summary type="html">&lt;p&gt;Rf614: Created page with &amp;quot;text&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;text&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
	<entry>
		<id>https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group&amp;diff=630177</id>
		<title>Mod:Hunt Research Group</title>
		<link rel="alternate" type="text/html" href="https://chemwiki.ch.ic.ac.uk/index.php?title=Mod:Hunt_Research_Group&amp;diff=630177"/>
		<updated>2017-06-02T14:40:18Z</updated>

		<summary type="html">&lt;p&gt;Rf614: /* Codes to Help Analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Hunt Group Wiki==&lt;br /&gt;
&lt;br /&gt;
Back to the main [http://www.ch.ic.ac.uk/hunt web-page]&lt;br /&gt;
===HPC Resources===&lt;br /&gt;
#Computing resources available in the chemistry department [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/computing_resources link]&lt;br /&gt;
#HPC servers and run scripts [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/hpc link]&lt;br /&gt;
#Setting up a connection to HPC if you have a PC [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/hpc_connections link] &lt;br /&gt;
#How to fix Windows files under UNIX [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/Windowsfiles link] &lt;br /&gt;
#How to make ssh more comfortable [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/pimpSSH link] &lt;br /&gt;
#How to make qsub more comfortable (gfunc) [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/pimpQSUB link] &lt;br /&gt;
#How to set up a SSH keypair [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/SSHkeyfile link] &lt;br /&gt;
#How to use gaussview directly on the HPC [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/gview link] &lt;br /&gt;
#How to comfortably search through old BASH commands [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/searchbash link]&lt;br /&gt;
#How to connect to HPC directory on desktop for file transfers - MacFusion [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/hpc_Directory_on_desktop link]&lt;br /&gt;
#How to set up cx2 [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/cx2 link]&lt;br /&gt;
&lt;br /&gt;
===Visualisation===&lt;br /&gt;
*&#039;&#039;&#039;density based visualisation&#039;&#039;&#039;&lt;br /&gt;
#download [http://aim.tkgristmill.com AIMALL]&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;ESPs&#039;&#039;&#039;&lt;br /&gt;
#Instructions for visualizing electrostatic potentials (Gaussview)[https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/electrostatic_potentials link]&lt;br /&gt;
#Electrostatic Potentials II (Molden) [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/electrostatic_potentials_2 link] &lt;br /&gt;
*&#039;&#039;&#039;VMD: a molecular dynamics visualisation package&#039;&#039;&#039;&lt;br /&gt;
#Download VMD [//wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/download_vmd link]&lt;br /&gt;
#Quick reminder [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/VMDReminder link]&lt;br /&gt;
#Tricks and tips [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/VMDTips link]&lt;br /&gt;
#Changing the graphical representation of your structures [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/vmd link]&lt;br /&gt;
#Basic visualisation of a trajectory [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/VisualisingyourSimulation link] &lt;br /&gt;
#How to turn a Gaussian optimization into a VMD movie [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/VMDmovie link] &lt;br /&gt;
#Using scripts in VMD [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/VmdScripts link]&lt;br /&gt;
#Dealing with periodic boundaries and bonding (under construction) [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/VmdScriptsPeriodic link]&lt;br /&gt;
#Dealing with bonding (under construction) [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/VmdBonding link]&lt;br /&gt;
#Overlapping two structures [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/VmdVisual link]&lt;br /&gt;
*&#039;&#039;&#039;JMol&#039;&#039;&#039;&lt;br /&gt;
#Visualising MOs using Jmol [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:basic_jmol_instructions link]&lt;br /&gt;
#Surfaces (Solvent-Accessible and Connolly) in Jmol [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/jmolsurfaces link]&lt;br /&gt;
*&#039;&#039;&#039;EMO Code&#039;&#039;&#039;&lt;br /&gt;
#How to use Ling&#039;s emo plot code[https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/emoplot link] &lt;br /&gt;
#How to plot EMOs [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/emo link]&lt;br /&gt;
*&#039;&#039;&#039;PyGauss&#039;&#039;&#039;&lt;br /&gt;
#Python API for analysis of Gaussian compuations [https://pygauss.readthedocs.org - Documentation]&lt;br /&gt;
*&#039;&#039;&#039;MD Post processing&#039;&#039;&#039;&lt;br /&gt;
#Code to Recentre DL_PLOY HISTORY file [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/recentre_xyz.py link]&lt;br /&gt;
#Link to the code to convert the DL_POLY HISTORY file to the multi-frame XYZ file[https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/his2xyz.py link]&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;SDFs&#039;&#039;&#039;&lt;br /&gt;
#How to generate SDFs [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/sdfs_generate link]&lt;br /&gt;
&lt;br /&gt;
===Gaussian General===&lt;br /&gt;
#We are starting a database of common errors encountered when running Gaussian jobs [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/gaussian_errors link]&lt;br /&gt;
# Here is an already existing database of common errors [https://www.ace-net.ca/wiki/Gaussian_Error_Messages link]&lt;br /&gt;
# [http://www.ch.ic.ac.uk/hunt/g03_man/index.htm G03 Manual]&lt;br /&gt;
#How to run NBO5.9 on the HPC [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/NBO5.9 link] &lt;br /&gt;
#How to include dispersion [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/dispersion link] &lt;br /&gt;
#Basic ONIOM (Mechanical Embedding) [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/basiconiom link]&lt;br /&gt;
#M0n and DFT-D [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/DFTD link]&lt;br /&gt;
#IL ONIOM clusters [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/oniomclusers link]&lt;br /&gt;
#Molecular volume calculations [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/molecular_volume link]&lt;br /&gt;
#problems with scf convergence [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/scf_convergence link]&lt;br /&gt;
#Using a z-matrix [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/z-matrix link]&lt;br /&gt;
#generating natural transition orbitals [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/nto link]&lt;br /&gt;
#Using solvent models [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/solvent link]&lt;br /&gt;
#Using SMD on ILs [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:_Using_SMD_on_ILs link]&lt;br /&gt;
#computing excited state polarisabilities [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:_ES_alpha link]&lt;br /&gt;
#computing deuterated and/or anharmonic spectra [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:_Danharm link]&lt;br /&gt;
#manipulating checkpoint files [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:usingchkfiles link]&lt;br /&gt;
#AimAll with pseudo potentials [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:aim_pseudopotentials link]&lt;br /&gt;
#Script to pull thermodynamic data and low frequencies from log files [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:freq_script link]&lt;br /&gt;
#General procedure for locating transition state structures [[link]]&lt;br /&gt;
&lt;br /&gt;
===ADF General===&lt;br /&gt;
#Submission script [http://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/ADF_sricpt link]&lt;br /&gt;
&lt;br /&gt;
===Codes to Help Analysis===&lt;br /&gt;
# Extract E2 Values (From NBO Calculations) [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/NBO_Matlab_Code link]&lt;br /&gt;
# Calculate pDoS/XP spectra code (under construction) [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/Calc_XPS_Code link]&lt;br /&gt;
# Codes to extract frequency data from gaussian .log files and generate vibrational spectra [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group:frequency_spectrum_script link]&lt;br /&gt;
# Optimally Tuned Range Seperated Hybrid Functionals [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/OTRSH_Funct link]&lt;br /&gt;
&lt;br /&gt;
===Setup and Running Ab-Initio MD Simulations===&lt;br /&gt;
#CPMD: Car-Parrinello Molecular Dynamics [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/cpmd link]&lt;br /&gt;
#How to run CPMD to study aqueous solutions [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/cpmd_water link]&lt;br /&gt;
#How to run CP2K [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/cp2k_how link] &lt;br /&gt;
#[bmim]Cl using CPMD [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/bmimCl_cpmd  link] &lt;br /&gt;
#[bmim]Cl using CP2K [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/bmimCl_cp2k  link] &lt;br /&gt;
#mman using CPMD and Gaussian [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/mman link] &lt;br /&gt;
#[emim]SCN using CP2K[https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/emimscn link] &lt;br /&gt;
#CP2K Donts [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/cp2k link] &lt;br /&gt;
&lt;br /&gt;
===Setup and Running Classical MD Simulations===&lt;br /&gt;
#DLPOLY a MD simulation package, Installation on an IMac (old needs to be updated) [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/dlpoly_install  link]&lt;br /&gt;
#DL_POLY FAQs [http://www.stfc.ac.uk/cse/DL_POLY/ccp1gui/38621.aspx] from DL_POLY webpage.&lt;br /&gt;
#Installing Packmol&lt;br /&gt;
#Getting started: generating a solvated structure and &amp;quot;relaxing&amp;quot; it [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/Starting_MD link] &lt;br /&gt;
#Equilibration and production simulations [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/EquilibrationandProduction link] &lt;br /&gt;
#How to equilibrate an MD run[https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/equilibration link] &lt;br /&gt;
#Getting the Force Field [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/Wheretostart link] &lt;br /&gt;
#Choosing an Ensemble [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/Ensembles link] &lt;br /&gt;
#Molten Salt Simulations [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/MoltenSaltSimulation link]&lt;br /&gt;
#Common Errors [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Mod:Hunt_Research_Group/CommonErrors link]&lt;br /&gt;
#Voids in ILs[https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/voids link] &lt;br /&gt;
#Equilibration of [bmim][BF4] and [bmim][NO3][https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/BmimBF4_equilibration link] &lt;br /&gt;
#Summary of discussions with Ruth[https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/Aug09QtoRuth link]&lt;br /&gt;
&lt;br /&gt;
===Running QM/MM Simulations in ChemShell===&lt;br /&gt;
#ChemShell official website which contains the manual and a tutorial [http://www.stfc.ac.uk/CSE/randd/ccg/36254.aspx link]&lt;br /&gt;
#Introduction to ChemShell - Copper in water [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ChemShell_Introduction link]&lt;br /&gt;
#Defining the system: Cu&amp;lt;sup&amp;gt;2+&amp;lt;/sup&amp;gt; and its first 2 solvation shells [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ChemShell_System_Aqeuous_Cu(II) link] &lt;br /&gt;
#Defining the force field parameters [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ChemShell_Force_Field_Parameters_Aqueous_Cu(II) link] &lt;br /&gt;
#Single point QM/MM energy calculation [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/QMMM_SP_Aqeuous_Cu(II) link] &lt;br /&gt;
#QM/MM Optimisation [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/QMMM_OPT_Aqeuous_Cu(II) link] &lt;br /&gt;
#QM/MM Molecular Dynamics [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/QMMM_MD_Aqeuous_Cu(II) link]&lt;br /&gt;
#Using MolCluster [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/MolCluster link]&lt;br /&gt;
#Running ChemShell [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ChemShell link]&lt;br /&gt;
&lt;br /&gt;
===Research Notes===&lt;br /&gt;
#Cl- in water [https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/wannier_centre link] &lt;br /&gt;
#The use of Legendre time correlation functions to study reorientational dynamics in liquids[https://www.ch.ic.ac.uk/wiki/index.php/Talk:Mod:Hunt_Research_Group/legendre  link] &lt;br /&gt;
#Functional for ILs using CPMD [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/IL_cpmd_functional link] &lt;br /&gt;
#Solving the angular part of the Schrödinger equation for a hydrogen atom [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/angular_schrodinger link] (notes by Vincent)&lt;br /&gt;
#Systematic conformational scan for ion-pair dimers [https://wiki.ch.ic.ac.uk/wiki/index.php?title=Talk:Mod:Hunt_Research_Group/ion_pair_scan link]&lt;br /&gt;
&lt;br /&gt;
===Installing and using other packages===&lt;br /&gt;
#How to install POLYRATE [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/polyrate link] &lt;br /&gt;
#How to install Geomview [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/geomview link] &lt;br /&gt;
#XMGRACE, gfortran, c compilers for Lion [http://hpc.sourceforge.net/]&lt;br /&gt;
&lt;br /&gt;
===Admin Stuff===&lt;br /&gt;
#Not used to writing a wiki, make your test runs [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/testing  on this page]&lt;br /&gt;
#How to set-up new macs [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/mac_setup link]&lt;br /&gt;
#How to set-up remote desktop [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/mac_remote link]&lt;br /&gt;
#[https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/calendar Calendar]&lt;br /&gt;
#How to switch the printer HP CP3525dn duplex on and off [https://www.ch.ic.ac.uk/wiki/index.php/Mod:Hunt_Research_Group/printing link]&lt;/div&gt;</summary>
		<author><name>Rf614</name></author>
	</entry>
</feed>