<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://jonkragskow.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://jonkragskow.github.io/" rel="alternate" type="text/html" /><updated>2026-03-03T05:04:35-08:00</updated><id>https://jonkragskow.github.io/feed.xml</id><title type="html">Jon Kragskow</title><subtitle></subtitle><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;&quot;bloaty_head.jpg&quot;, &quot;bio&quot;=&gt;&quot;Lecturer in Computational Chemistry&quot;, &quot;location&quot;=&gt;&quot;Bath, UK&quot;, &quot;employer&quot;=&gt;nil, &quot;pubmed&quot;=&gt;nil, &quot;googlescholar&quot;=&gt;&quot;https://scholar.google.co.uk/citations?user=kqImFp4AAAAJ&amp;hl=en&quot;, &quot;email&quot;=&gt;nil, &quot;researchgate&quot;=&gt;nil, &quot;uri&quot;=&gt;nil, &quot;bitbucket&quot;=&gt;nil, &quot;codepen&quot;=&gt;nil, &quot;dribbble&quot;=&gt;nil, &quot;flickr&quot;=&gt;nil, &quot;facebook&quot;=&gt;nil, &quot;foursquare&quot;=&gt;nil, &quot;github&quot;=&gt;&quot;jonkragskow&quot;, &quot;gitlab&quot;=&gt;&quot;jonkragskow&quot;, &quot;google_plus&quot;=&gt;nil, &quot;keybase&quot;=&gt;nil, &quot;instagram&quot;=&gt;nil, &quot;impactstory&quot;=&gt;nil, &quot;lastfm&quot;=&gt;nil, &quot;linkedin&quot;=&gt;nil, &quot;orcid&quot;=&gt;&quot;https://orcid.org/0000-0001-9488-8204&quot;, &quot;pinterest&quot;=&gt;nil, &quot;soundcloud&quot;=&gt;nil, &quot;stackoverflow&quot;=&gt;nil, &quot;steam&quot;=&gt;nil, &quot;tumblr&quot;=&gt;nil, &quot;twitter&quot;=&gt;nil, &quot;vine&quot;=&gt;nil, &quot;weibo&quot;=&gt;nil, &quot;xing&quot;=&gt;nil, &quot;youtube&quot;=&gt;nil, &quot;wikipedia&quot;=&gt;nil}</name></author><entry><title type="html">UV-Vis Spectra from ORCA</title><link href="https://jonkragskow.github.io/posts/2024/01/blog-post-1/" rel="alternate" type="text/html" title="UV-Vis Spectra from ORCA" /><published>2024-04-03T00:00:00-07:00</published><updated>2024-04-03T00:00:00-07:00</updated><id>https://jonkragskow.github.io/posts/2024/01/blog-post-1</id><content type="html" xml:base="https://jonkragskow.github.io/posts/2024/01/blog-post-1/"><![CDATA[<p>I’ve been using TD-DFT to simulate some UV-Vis spectra for a collaborator, and wanted to understand what ORCA’s <code class="language-plaintext highlighter-rouge">orca_mapspc</code> utility is actually doing. Here’s how to plot exactly the same spectrum as <code class="language-plaintext highlighter-rouge">orca_mapspc</code>.</p>

<h2 id="running-the-calculation">Running the calculation</h2>

<p>The ORCA manual, and the ORCA input library, should be consulted for instructions on how to run a <a href="https://sites.google.com/site/orcainputlibrary/excited-state-calculations/tddft">TD-DFT calculation</a>, or any sort of CI calculation.</p>

<h2 id="understanding-the-result">Understanding the result</h2>

<p>ORCA will print the information you need to the output file in a section with the following header</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>         ABSORPTION SPECTRUM VIA TRANSITION ELECTRIC DIPOLE MOMENTS
-----------------------------------------------------------------------------
State   Energy    Wavelength  fosc         T2        TX        TY        TZ
        (cm-1)      (nm)                 (au**2)    (au)      (au)      (au)
-----------------------------------------------------------------------------
</code></pre></div></div>

<p>We only need the <code class="language-plaintext highlighter-rouge">Energy</code> and <code class="language-plaintext highlighter-rouge">fosc</code> entries to plot a spectrum. The <code class="language-plaintext highlighter-rouge">fosc</code> column contains the oscillator strength of each transition. In order to understand what this means, recall the integrated absorption coefficient of a given absorption band</p>

\[\mathcal{A}_\mathrm{e}= \int_\mathrm{band}{\alpha_\mathrm{e}\left(\widetilde{\nu}\right)\ \mathrm{d}\widetilde{\nu}} = \frac{1}{nl}\int_\mathrm{band}{A_\mathrm{e}\left(\widetilde{\nu}\right)\ \mathrm{d}\widetilde{\nu}} \\ = \frac{1}{nl}\int_\mathrm{band}{\ln\left[\frac{I_0(\widetilde{\nu})}{I(\widetilde{\nu})}\right]\left(\widetilde{\nu}\right)\ \mathrm{d}\widetilde{\nu}}\ \ \ \ \ \ \ \left[\mathrm{m \ mol^{-1}}\right]\]

<p>Where $n$ is concentration $[\mathrm{mol \ m^{-3}}]$, $l$ is path length $[\mathrm{m}]$, $A_\mathrm{e}$ is the napierian absorbance, $\alpha_\mathrm{e}$ is the napierian absorption coefficient $[\mathrm{m^2 \ mol^{-1}}]$, $I$ and $I_0$ are the transmitted and incident radiation intensity respectively, and $\widetilde{\nu}$ is the wavenumber $[\mathrm{cm}^{-1}]$.</p>

<p>The oscillator strength $f$ is defined as the ratio of $\mathcal{A}_\mathrm{e}$ for a given band to the (constant) value for that of a harmonically oscillating electron.</p>

\[f = \frac{\int_\mathrm{band}{\epsilon_\mathrm{e}\left(\widetilde{\nu}\right)\ \mathrm{d}\widetilde{\nu}}}{\mathcal{A}_\mathrm{e}^{\mathrm{electron}}} = \frac{\mathcal{A}_\mathrm{e}^{\mathrm{ORCA}}}{\mathcal{A}_\mathrm{e}^{\mathrm{electron}}}\]

<p>and usually has a value between 0 and 1. In order to plot the spectrum, we need to convert $f$ back into $\mathcal{A}_\mathrm{e}^\mathrm{ORCA}$ since this tells us how large each absorption band will be.</p>

\[\mathcal{A}_\mathrm{e}^\mathrm{ORCA} \ [\mathrm{1000 \ cm \ mol^{-1}}] = f \cdot \mathcal{A}_\mathrm{e}^{\mathrm{electron}} =  f \cdot 2.31\times 10^8 \ [\mathrm{1000 \ cm \ mol^{-1}}]\]

<p>An explanation of the oscillator strength can be found on Pages 80 and 81 of Barrow’s <em>Introduction to Molecular Spectroscopy</em>.</p>

<h2 id="plotting-a-spectrum">Plotting a spectrum</h2>

<p>To generate the UV-Vis spectrum <code class="language-plaintext highlighter-rouge">orca_mapspc</code> uses an area-normalised Lorentzian lineshape $L(x)$ for each transition</p>

\[L(x) = \frac{1}{\pi} \frac{\frac{1}{2}\Gamma}{\left(x-x_0\right)^2 + \left(\frac{1}{2}\Gamma\right)^2} \ \ \ \ [\mathrm{cm}] \\
\ \\

\int_{-\infty}^\infty L(x) \ \ \mathrm{d}x = 1\]

<p>where $\Gamma$ is the full-width-at-half-maximum (FWHM) of the curve, $x$ is the wavenumber of the incident radiation, and $x_0$ is the wavenumber of the transition.</p>

<p>For a given transition, the corresponing Lorentzian is multiplied by the <em>linear</em> integrated absorption coefficent $\mathcal{A}^\mathrm{ORCA}$ obtained by dividing $\mathcal{A}_\mathrm{e}^\mathrm{ORCA} \ [\mathrm{1000 \ cm \ mol^{-1}}]$ by $\ln(10)$. The multiplication of $L(x) \ [\mathrm{cm}]$ by $\mathcal{A}^\mathrm{ORCA} \ \ [\mathrm{1000 \ cm \ mol^{-1}}]$ gives a function with units of $[\mathrm{1000 \ cm^{2} \ mol^{-1}}] = [\mathrm{L \ mol^{-1} \ cm^{-1}}] = [\mathrm{M^{-1} \ cm^{-1}}]$, i.e. common units of the linear molar extinction coefficient $\epsilon$.</p>

<p>To combine all of the transitions as a single spectrum, simply sum $L(x) \cdot \mathcal{A}^\mathrm{ORCA}$ for each transition, and plot against wavenumber.</p>

<h2 id="what-about-velocity">What about Velocity?</h2>

<p>You might have noticed that ORCA prints an identical absorption spectrum table with the title</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>         ABSORPTION SPECTRUM VIA TRANSITION VELOCITY DIPOLE MOMENTS
</code></pre></div></div>

<p>which contains an identical set of transitions with slightly different oscillator strengths. This stems from the use of a different operator in calculating transition intensities which should give equivalent results, but rarely does due to the approximations used in quantum chemistry.</p>

<p>In order to calculate the oscillator strength of a transition between two states we need to know the value of the transition dipole moment for that transition.</p>

<p>The transition dipole moment is a matrix element of the dipole operator</p>

\[\mu_{ba} = \langle \psi_b | \hat{\mu} | \psi_a \rangle\]

<p>In the case of the electric dipole moment and a particle in three-dimensions</p>

\[\mu_{ba} = \langle \psi_b | q\mathbf{r} | \psi_a \rangle = q\int \psi_b^*(r) \ \mathbf{r} \ \psi_a(\mathbf{r}) \ \mathrm{d}^3\mathbf{r}\]

<p>where $q$ is the charge of the particle, and $\mathbf{r}$ the position operator.</p>

<p>The position operator and Hamiltonian operator have the well-known commutation relation</p>

\[\left[\hat{H}, \mathbf{r}\right] = -\frac{\hbar^2}{m}\vec{\nabla}\ .\]

<p>This can be obtained from the derivation for a single dimension</p>

\[\left[\hat{H}, x\right] = \left[\frac{p_x^2}{2m} + V, x\right] = \left[\frac{p_x^2}{2m}, x\right] + \left[V, x\right] = \frac{\hbar}{im} p_x\]

<p>where</p>

\[\left[\frac{p_x^2}{2m}, x\right] = \frac{1}{2m}\left(p_x[p_x,x] + [p_x,x]p_x\right)\]

<p>and</p>

\[[p_x,x] = -i\hbar , \ \ \ \ \ \ \ \ p = -i \hbar \vec{\nabla} \ .\]

<p>Alternatively $\left[\hat{H}, \mathbf{r}\right]$ can be evaluated directly</p>

\[\left \langle a \left | \left[\hat{H}, \mathbf{r}\right] \right | b \right \rangle = \left \langle a \left | \hat{H} \mathbf{r} \right | b \right \rangle - \left \langle a \left | \mathbf{r} \hat{H} \right | b \right \rangle = \left(E_a - E_b \right) \left \langle a \left | \mathbf{r} \right | b \right \rangle\]

<p>so then</p>

\[\left(E_a - E_b \right) \left \langle a | \mathbf{r} | b \right \rangle = - \frac{\hbar^2}{m}\left \langle a \left | \vec{\nabla} \right | b \right \rangle\]

<p>Meaning that we can obtain transition dipole moment values by either computing the position operator directly, or by computing the velocity operator and using the above relationship.</p>

<p>Due to the number of approximations used in computational chemistry these two approaches rarely give the same answer. Therefore, ORCA and <code class="language-plaintext highlighter-rouge">orca_mapspc</code> allow the user to choose which value to use, and by default <code class="language-plaintext highlighter-rouge">orca_mapspc</code> uses the position form which they refer to as the electric dipole.</p>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;&quot;bloaty_head.jpg&quot;, &quot;bio&quot;=&gt;&quot;Lecturer in Computational Chemistry&quot;, &quot;location&quot;=&gt;&quot;Bath, UK&quot;, &quot;employer&quot;=&gt;nil, &quot;pubmed&quot;=&gt;nil, &quot;googlescholar&quot;=&gt;&quot;https://scholar.google.co.uk/citations?user=kqImFp4AAAAJ&amp;hl=en&quot;, &quot;email&quot;=&gt;nil, &quot;researchgate&quot;=&gt;nil, &quot;uri&quot;=&gt;nil, &quot;bitbucket&quot;=&gt;nil, &quot;codepen&quot;=&gt;nil, &quot;dribbble&quot;=&gt;nil, &quot;flickr&quot;=&gt;nil, &quot;facebook&quot;=&gt;nil, &quot;foursquare&quot;=&gt;nil, &quot;github&quot;=&gt;&quot;jonkragskow&quot;, &quot;gitlab&quot;=&gt;&quot;jonkragskow&quot;, &quot;google_plus&quot;=&gt;nil, &quot;keybase&quot;=&gt;nil, &quot;instagram&quot;=&gt;nil, &quot;impactstory&quot;=&gt;nil, &quot;lastfm&quot;=&gt;nil, &quot;linkedin&quot;=&gt;nil, &quot;orcid&quot;=&gt;&quot;https://orcid.org/0000-0001-9488-8204&quot;, &quot;pinterest&quot;=&gt;nil, &quot;soundcloud&quot;=&gt;nil, &quot;stackoverflow&quot;=&gt;nil, &quot;steam&quot;=&gt;nil, &quot;tumblr&quot;=&gt;nil, &quot;twitter&quot;=&gt;nil, &quot;vine&quot;=&gt;nil, &quot;weibo&quot;=&gt;nil, &quot;xing&quot;=&gt;nil, &quot;youtube&quot;=&gt;nil, &quot;wikipedia&quot;=&gt;nil}</name></author><category term="ORCA" /><category term="UV-Vis" /><summary type="html"><![CDATA[I’ve been using TD-DFT to simulate some UV-Vis spectra for a collaborator, and wanted to understand what ORCA’s orca_mapspc utility is actually doing. Here’s how to plot exactly the same spectrum as orca_mapspc.]]></summary></entry><entry><title type="html">Obtaining pseudospin-1/2 g-values from crystal field wavefunctions</title><link href="https://jonkragskow.github.io/posts/2023/01/blog-post-1/" rel="alternate" type="text/html" title="Obtaining pseudospin-1/2 g-values from crystal field wavefunctions" /><published>2023-01-12T00:00:00-08:00</published><updated>2023-01-12T00:00:00-08:00</updated><id>https://jonkragskow.github.io/posts/2023/01/blog-post-1</id><content type="html" xml:base="https://jonkragskow.github.io/posts/2023/01/blog-post-1/"><![CDATA[<p>Pseudospin Hamiltonians and wavefunctions are often employed in the single-molecule-magnet and qubit literature as a means of describing a small subset of a much larger group of states. Here I’ll cover how you can obtain pseudospin 1/2 g-values which describe a set of crystal field states.</p>

<h2 id="the-zeeman-effect">The Zeeman effect</h2>

<p>$\newcommand{\tensor}[1]{\bar{\bar{#1}}}$</p>

<p>The magnetic moment $\vec{\mu}$ of a particle is a vector quantity and is proportional to the particle’s spin $\vec{S}$, with a dimensionless proportionality constant called the $g$ value. For an single isolated electron, the free electron $g$ value $g_\mathrm{e}$ is used.</p>

\[\vec{\mu} = -g_\mathrm{e} \mu_\mathrm{B} \vec{S}\]

<p>where $\mu_\mathrm{B}$ is the Bohr magneton, which is a constant that essentially accounts for the units of the magnetic moment.</p>

<p>Magnetic moments can interact with magnetic fields $\vec{B}$ in a process known as the Zeeman effect, and this interaction is described by the Zeeman Hamiltonian</p>

\[\hat{H}_\mathrm{Zeeman} = -\vec{\mu}\cdot\vec{B} = g_\mathrm
{e}\mu_\mathrm{B}\hat{\vec{S}}\cdot\vec{B}\]

<p>where the hat denotes the operator nature of the spin. If $\vec{B}$ and $\hat{\vec{S}}$ are known then the energies of the electronic spin states can be calculated. The vector operator $\hat{\vec{S}}$ is made up of spin operators for the three cartesian axes</p>

\[\hat{\vec{S}} = \left [ \hat{S}_x, \hat{S}_y, \hat{S}_z\right]^\mathrm{T} \ \ ,\]

<p>where $\mathrm{T}$ indicates the transpose and the field vector $\vec{B}$ has components along $x$, $y$, and $z$</p>

\[\vec{B} = \left [ B_x, B_y, B_z\right] \ \ ,\]

<p>so the dot-product in $\hat{H}_\mathrm{Zee}$ can be evaluated to give</p>

\[\hat{H}_\mathrm{Zeeman} = g_\mathrm{e} \mu_\mathrm{B} (\hat{S}_x B_x + \hat{S}_y B_y + \hat{S}_z B_z ) \ \ .\]

<p>As an example, we can define $B_x=B_y=0\neq B_z$ so that $\hat{H}_\mathrm{Zee}$ becomes</p>

\[\hat{H}_\mathrm{Zeeman} = g_\mathrm{e} \mu_\mathrm{B} \hat{S}_z B_z \ \ ,\]

<p>and from this it is trivial to obtain the (hopefully) familiar equation for the energy of the electron when its spin is aligned either with or against the magnetic field (Zeeman splitting)</p>

\[E = \pm\frac{g_\mathrm{e}\mu_\mathrm{B}B}{2}\\
\Delta E = g_\mathrm{e}\mu_\mathrm{B}B \ \ .\]

<p>But what if the system is not a free electron? Very often electronic spins are confined to molecules and ions, and so the electrons experience a variety of potentials and fields. To account for this, the $g$ value can be modified and becomes a so called <em>phenomenological</em> quantity since it describes the interaction of spin states with a field, but doesnt really explain how or why. This phenomenological usage could even be taken a step further, since experimentally one might find that $g$ changes as a function of direction, and so $g$ is more generally represented by a tensor $\tensor{g}$ which has components $g_{\alpha,\beta}$ describing the effect of an arbitrarily oriented magnetic field on a set of spin states.</p>

\[\tensor{g} = \begin{bmatrix}
g_{xx} &amp; g_{xy} &amp; g_{xz}\\
g_{yx} &amp; g_{yy} &amp; g_{yz}\\
g_{zx} &amp; g_{zy} &amp; g_{zz}\\
\end{bmatrix}\]

<p>and so the Hamiltonian is</p>

\[\hat{H}_\mathrm{Zeeman} = \mu_\mathrm{B}\vec{B}\cdot\tensor{g}\cdot\hat{\vec{S}}\]

<p>So in short: <strong>The g-tensor is a compact method for describing the effect of a magnetic field on a two level system (or more specifically a (pseudo) spin‑1/2 doublet) and contains a set of values $g_{\alpha, \beta}$.</strong></p>

<p>One particularly useful feature of this (3x3) tensor is that it describes <em>real space</em>, and so if we find its “principal axes” (eigenvectors), we can then describe how readily this pair of states will be affected by a magnetic field in a given cartesian direction. Let’s pick a more interesting pair of states to look at, and then revisit this idea.</p>

<h2 id="crystal-fields">Crystal Fields</h2>

<p>The electronic structures of lanthanide qubits and SMMs are often discussed in terms of the Hund’s rule ground term of the lanthanide in question. For example, Dy(III) is commonly used in SMMs and has a $^6 \mathrm{H}$ Hund’s rule ground term arising from its 4f<sup>9</sup> electron configuration. Within this term the $J=15/2$ multiplet is lowest in energy, and contains a set of 16 $m_J$ states which are degenerate in the absence of any crystal or magnetic field. When such fields are applied, this degeneracy is lifted, and in the case of the crystal field (CF), this effect can be described using a CF Hamiltonian</p>

\[\hat{H}_\mathrm{CF} = \sum_{k=2, 4, ..., 2J} \sum_{q=-k}^{k} \theta^k B_k^q \hat{O}_k^q\]

<p>where $\theta^k$ are a set of numerical factors which are constant for a given lanthanide ion, $B_k^q$ is a crystal field parameter which is unique to a given system, and $\hat{O}_k^q$ is a Stevens operator that can be calculated from the angular momentum operators $\hat{J}_i, \hat{J}^2 \ \ (i = x, y, z, +, -)$.</p>

<p>Considering a (hypothetical) perfectly axial CF allows $\hat{H}_\mathrm{CF}$ to be reduced to just the terms with $q=0$, and a further simplification can come from only including terms with $k=2,4,6$, since terms with $k&gt;6$ make little difference to the states. Inputting the values $B_2^0 = 1000 \ \mathrm{cm}^{-1}$, $B_4^0 = 100 \ \mathrm{cm}^{-1}$, and $B_6^0 = 10 \ \mathrm{cm}^{-1}$ into the above Hamiltonian and diagonalising the resulting matrix representation yields a set of crystal field wavefunctions $\psi_i$ (Figure 1).</p>

<p><img src="/images/axial_cf.png" alt="Axial Crystal Field" style="margin-left: auto; margin-right: auto; width: 50%; display: block" /></p>
<p style="text-align: center;">Figure 1: States of the J = 15/2 multiplet of Dy(III) in a perfectly axial crystal field.</p>

<p>In this example there are 8 pairs of degenerate states (doublets) with opposite values of $m_J$. The low energy (&lt; 1000 cm<sup>-1</sup>) doublets are well separated from each other, and so each doublet could be treated as a <em>pseudo</em> $S=1/2$ system with its own $\tensor{g}$. Then, the main magnetic axes of each doublet could be quantified and visualised, and we could start gain insight into how the molecular structure affects the electronic states.</p>

<h2 id="finding-the-pseudospin-g-values">Finding the pseudospin g values</h2>

<p>The question is of course, how are the elements of $\tensor{g}$ found? We could apply a magnetic field $\vec{B}$ to our CF states and record how they change as the orientation of $\vec{B}$ is varied, but this is a long and laborious process which would be at the mercy of numerical instabilities.</p>

<p>Instead, we use a formula proposed by Gerloch and McMeeking which connects elements of the total magnetic moment operator $\hat{\mu}$ to the g-tensor. The total magnetic moment operator $\hat{\mu}_\alpha$ for a given direction $\alpha$ is analogous to the free electron magnetic moment operator</p>

\[\hat{\mu}_\alpha = g_J \mu_\mathrm{B} \hat{J}_\alpha \ .\]

<p>Where $\alpha$ and $\beta$ specify the cartesian directions $x$, $y$, and $z$, and the $g_\mathrm{e}$ has been replaced with the Landé g-factor $g_J$ which is a scalar that can be calculated from the $L$, $S$, and $J$ quantum numbers. Typically, these operators would be constructed in a basis of pure (or <em>free ion</em>) angular momentum states, but we’re working with crystal field states which usually are not <em>pure</em>, and consist of mixtures of angular momentum states. To transform between the two, we can pre and post multiply the matrix representations of $\hat{\mu}_\alpha$ by the eigenvectors of the crystal field Hamiltonian.</p>

<p>So then, with the correct matrix representations of $\hat{\mu}_\alpha$ in hand, we can use Gerloch and McMeeking’s formula to calculate the elements of $\tensor{g}$</p>

\[(g \cdot g^\mathrm{T})_{\alpha,\beta} = G_{\alpha,\beta} = 2 \sum_{u=\psi, \psi'}\sum_{v=\psi, \psi'}\mu_{\alpha_{u,v}}\mu_{\beta_{v,u}} \ \ .\]

<p>Where $\psi$ and $\psi’$ are the CF wavefunctions of a given doublet. The final step is to take  $\tensor{G}$ that we’ve just calculated, and obtain $\tensor{g}$ from the matrix square root</p>

\[\tensor{G}_\mathrm{diag} = \tensor{V}^{-1}\tensor{G}\tensor{V}\\
\tensor{g} = \tensor{V}\tensor{G}_\mathrm{diag}^{1/2}\tensor{V}^{-1} \ \ ,\]

<p>where $\tensor{G}_\mathrm{diag}$ is a matrix containing the eigenvalues of $\tensor{G}$, and $\tensor{V}$ contains the corresponding eigenvectors.</p>

<p>Then, the principal axes (eigenvectors) of the g-tensor can be obtained by diagonalisation, and can be visualised as three-dimensional vectors on top of the molecular structure. Additionally the respective g-values (eigenvalues) can be used to describe how easily the system is magnetised along each of the principal axes. In the case of the ground doublet these are $\left[0,0,20\right] = \left[g_x, g_y, g_z\right]$ and so a magnetic field on $x$ and $y$ will essentially have no impact on the ground doublet. Why? The strong axial CF makes the ground doublet energetically well isolated, and when coupled with its strong magnetic moment along the $z$ axis means that a very very large magnetic field along $x$ or $y$ will be required to start affecting these states.<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup></p>

<h2 id="example">Example</h2>

<p>The following python code will calculate the g-tensors for each doublet of the system illustrated in Figure 1. The only dependencies are <code class="language-plaintext highlighter-rouge">angmom_suite==1.10.2</code> and <code class="language-plaintext highlighter-rouge">numpy</code>.</p>

<script src="https://gist.github.com/JonKragskow/4d59a2625c642e86b65dba2c2bf86621.js"></script>

<p>The expected output is</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Doublet 1
Energy = 0.0000 cm^-1
g_x = 0.0000 g_y = 0.0000 g_z = 20.0000
g-vectors (columns)
g_x    g_y    g_z
1.0000 0.0000 0.0000
0.0000 1.0000 0.0000
0.0000 0.0000 1.0000

Doublet 2
Energy = 369.8524 cm^-1
g_x = 0.0000 g_y = 0.0000 g_z = 17.3333
g-vectors (columns)
g_x    g_y    g_z
1.0000 0.0000 0.0000
0.0000 1.0000 0.0000
0.0000 0.0000 1.0000

Doublet 3
Energy = 655.7887 cm^-1
g_x = 0.0000 g_y = 0.0000 g_z = 14.6667
g-vectors (columns)
g_x    g_y    g_z
1.0000 0.0000 0.0000
0.0000 1.0000 0.0000
0.0000 0.0000 1.0000

Doublet 4
Energy = 853.2186 cm^-1
g_x = 0.0000 g_y = 0.0000 g_z = 12.0000
g-vectors (columns)
g_x    g_y    g_z
1.0000 0.0000 0.0000
0.0000 1.0000 0.0000
0.0000 0.0000 1.0000

Doublet 5
Energy = 974.0960 cm^-1
g_x = 0.0000 g_y = 0.0000 g_z = 9.3333
g-vectors (columns)
g_x    g_y    g_z
1.0000 0.0000 0.0000
0.0000 1.0000 0.0000
0.0000 0.0000 1.0000

Doublet 6
Energy = 1038.3121 cm^-1
g_x = 0.0000 g_y = 0.0000 g_z = 6.6667
g-vectors (columns)
g_x    g_y    g_z
1.0000 0.0000 0.0000
0.0000 1.0000 0.0000
0.0000 0.0000 1.0000

Doublet 7
Energy = 1066.8101 cm^-1
g_x = 0.0000 g_y = 0.0000 g_z = 4.0000
g-vectors (columns)
g_x    g_y    g_z
1.0000 0.0000 0.0000
0.0000 1.0000 0.0000
0.0000 0.0000 1.0000

Doublet 8
Energy = 1076.4210 cm^-1
g_x = 1.3333 g_y = 10.6667 g_z = 10.6667
g-vectors (columns)
g_x    g_y    g_z
0.0000 0.0000 1.0000
0.0000 1.0000 0.0000
1.0000 0.0000 0.0000 
</code></pre></div></div>
<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1" role="doc-endnote">
      <p>When the field is this large, the whole idea of a “ground doublet” is nonsense. <a href="#fnref:1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;&quot;bloaty_head.jpg&quot;, &quot;bio&quot;=&gt;&quot;Lecturer in Computational Chemistry&quot;, &quot;location&quot;=&gt;&quot;Bath, UK&quot;, &quot;employer&quot;=&gt;nil, &quot;pubmed&quot;=&gt;nil, &quot;googlescholar&quot;=&gt;&quot;https://scholar.google.co.uk/citations?user=kqImFp4AAAAJ&amp;hl=en&quot;, &quot;email&quot;=&gt;nil, &quot;researchgate&quot;=&gt;nil, &quot;uri&quot;=&gt;nil, &quot;bitbucket&quot;=&gt;nil, &quot;codepen&quot;=&gt;nil, &quot;dribbble&quot;=&gt;nil, &quot;flickr&quot;=&gt;nil, &quot;facebook&quot;=&gt;nil, &quot;foursquare&quot;=&gt;nil, &quot;github&quot;=&gt;&quot;jonkragskow&quot;, &quot;gitlab&quot;=&gt;&quot;jonkragskow&quot;, &quot;google_plus&quot;=&gt;nil, &quot;keybase&quot;=&gt;nil, &quot;instagram&quot;=&gt;nil, &quot;impactstory&quot;=&gt;nil, &quot;lastfm&quot;=&gt;nil, &quot;linkedin&quot;=&gt;nil, &quot;orcid&quot;=&gt;&quot;https://orcid.org/0000-0001-9488-8204&quot;, &quot;pinterest&quot;=&gt;nil, &quot;soundcloud&quot;=&gt;nil, &quot;stackoverflow&quot;=&gt;nil, &quot;steam&quot;=&gt;nil, &quot;tumblr&quot;=&gt;nil, &quot;twitter&quot;=&gt;nil, &quot;vine&quot;=&gt;nil, &quot;weibo&quot;=&gt;nil, &quot;xing&quot;=&gt;nil, &quot;youtube&quot;=&gt;nil, &quot;wikipedia&quot;=&gt;nil}</name></author><category term="Crystal Field Theory" /><category term="Pseudospin Hamiltonians" /><summary type="html"><![CDATA[Pseudospin Hamiltonians and wavefunctions are often employed in the single-molecule-magnet and qubit literature as a means of describing a small subset of a much larger group of states. Here I’ll cover how you can obtain pseudospin 1/2 g-values which describe a set of crystal field states.]]></summary></entry><entry><title type="html">Using Let’s Encrypt with Plotly/Dash (On NearlyFreeSpeech.net)</title><link href="https://jonkragskow.github.io/posts/2023/01/blog-post-2/" rel="alternate" type="text/html" title="Using Let’s Encrypt with Plotly/Dash (On NearlyFreeSpeech.net)" /><published>2023-01-12T00:00:00-08:00</published><updated>2023-01-12T00:00:00-08:00</updated><id>https://jonkragskow.github.io/posts/2023/01/blog-post-1</id><content type="html" xml:base="https://jonkragskow.github.io/posts/2023/01/blog-post-2/"><![CDATA[<p>If you use NearlyFreeSpeech, Dash/Flask and want to enable HTTPS support, then this highly specific article is for you!</p>

<h2 id="nearlyfreespeech-and-csas">NearlyFreeSpeech and CSAs</h2>

<p>I use <a href="https://www.nearlyfreespeech.net">NearlyFreeSpeech</a> to host my Dash/Flask app <a href="https://www.waveplot.com">Waveplot</a> and it works quite well. Part of running a website is caring about users and their data, so its best to always use https so that data is encrypyted when sent between the server and the user. Not everyone does this however, and turning on the chrome warning for non https sites is quite alarming!</p>

<p>To use https you need an SSL certificate to prove to the user that you are who you say you are. This way, any attempt to intercept data should be stopped if the correct certificate isn’t produced somewhere along the line. Certificates are handed out by certificate signing authorities (CSAs) and they usually make you go through a process of adding a small file to your website, or a DNS record to your DNS config, so that they can authenticate you as the owner of the site and give you a certificate.</p>

<p>There are loads of CSAs - some charge, some don’t, some are attached to businesses and governments. Like everything, it’s complicated. If you want to know more, then take a look at the <a href="https://www.cloudflare.com/en-gb/learning/">Cloudflare Learning Center</a>.</p>

<p>NearlyFreeSpeech provides a bash script <code class="language-plaintext highlighter-rouge">tls-setup.sh</code> which uses <a href="https://letsencrypt.org/">Let’s Encrypt</a> to create certificates for your website for free. Alternatively you can do it manually using <a href="https://github.com/dehydrated-io/dehydrated"><code class="language-plaintext highlighter-rouge">dehydrated</code></a> - no thanks!</p>

<p>The <code class="language-plaintext highlighter-rouge">tls-setup.sh</code> script uses a <a href="https://letsencrypt.org/docs/challenge-types/">http01 challenge</a> to verify that you’re certificating your own website. In short, it temporarily adds a file at <code class="language-plaintext highlighter-rouge">www.YOUR_WEBSITE_NAME.TLD/.well-known/acme-challenge/FILENAME</code>, checks that these files can be accessed by the CSA, and deletes them.</p>

<h2 id="the-problem">The problem</h2>

<p>My Dash app uses the <a href="https://dash.plotly.com/urls">Dash Pages</a> functionality to have multiple pages in a single app. It works really well, and redirects you to the app you want based on a couple of rules that you configure. One feature of this is that if no <code class="language-plaintext highlighter-rouge">page_name.py</code> exists for the page you want, then you get a 404. Unfortunately this means that when the challenge is issued, any attempt to access the file at <code class="language-plaintext highlighter-rouge">/.well-known/acme-challenge/FILENAME</code> fails.You might think that you can just quickly add a <code class="language-plaintext highlighter-rouge">.py</code> file for the http01 challenge file, but this doesn’t work since its name is totally random! Instead, you can add a flask route to the location of the challenge file using a wildcard.</p>

<p>The <a href="https://www.gitlab.com/jonkragskow/waveplot">Waveplot</a> directory is laid out as</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>app.py
index.py
pages
├─ app_1.py
├─ app_2.py
├─ app_3.py
site.wsgi
</code></pre></div></div>
<p>where <code class="language-plaintext highlighter-rouge">site.wsgi</code> contains instructions for <a href="https://wsgi.readthedocs.io/en/latest/what.html"><code class="language-plaintext highlighter-rouge">wsgi</code></a> to run my site. In my NearlyFreeSpeech site storage space, I’ve put the <code class="language-plaintext highlighter-rouge">waveplot</code> directory in <code class="language-plaintext highlighter-rouge">/home/protected</code>, and I want to point to the <code class="language-plaintext highlighter-rouge">public/.well_known/acme-challenge</code> directory where the challenge file will be placed, so I added the following lines to <code class="language-plaintext highlighter-rouge">app.py</code> (after defining <code class="language-plaintext highlighter-rouge">app=dash.Dash(...)</code>)</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">flask</span>
<span class="c1"># Certificate http01 challenge
</span><span class="o">@</span><span class="n">app</span><span class="p">.</span><span class="n">server</span><span class="p">.</span><span class="n">route</span><span class="p">(</span><span class="s">"/.well-known/acme-challenge/&lt;path:filename&gt;"</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">http01_respond</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">flask</span><span class="p">.</span><span class="n">send_file</span><span class="p">(</span>
        <span class="s">"../../public/.well-known/acme-challenge/{}"</span><span class="p">.</span><span class="nb">format</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
    <span class="p">)</span>
</code></pre></div></div>

<p>and restarted the daemon running <code class="language-plaintext highlighter-rouge">wsgi</code>. Then I ran <code class="language-plaintext highlighter-rouge">tls-setup.sh</code> (it doesn’t matter where), which produced all the certificates I needed and handed them to NearlyFreeSpeech.</p>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;&quot;bloaty_head.jpg&quot;, &quot;bio&quot;=&gt;&quot;Lecturer in Computational Chemistry&quot;, &quot;location&quot;=&gt;&quot;Bath, UK&quot;, &quot;employer&quot;=&gt;nil, &quot;pubmed&quot;=&gt;nil, &quot;googlescholar&quot;=&gt;&quot;https://scholar.google.co.uk/citations?user=kqImFp4AAAAJ&amp;hl=en&quot;, &quot;email&quot;=&gt;nil, &quot;researchgate&quot;=&gt;nil, &quot;uri&quot;=&gt;nil, &quot;bitbucket&quot;=&gt;nil, &quot;codepen&quot;=&gt;nil, &quot;dribbble&quot;=&gt;nil, &quot;flickr&quot;=&gt;nil, &quot;facebook&quot;=&gt;nil, &quot;foursquare&quot;=&gt;nil, &quot;github&quot;=&gt;&quot;jonkragskow&quot;, &quot;gitlab&quot;=&gt;&quot;jonkragskow&quot;, &quot;google_plus&quot;=&gt;nil, &quot;keybase&quot;=&gt;nil, &quot;instagram&quot;=&gt;nil, &quot;impactstory&quot;=&gt;nil, &quot;lastfm&quot;=&gt;nil, &quot;linkedin&quot;=&gt;nil, &quot;orcid&quot;=&gt;&quot;https://orcid.org/0000-0001-9488-8204&quot;, &quot;pinterest&quot;=&gt;nil, &quot;soundcloud&quot;=&gt;nil, &quot;stackoverflow&quot;=&gt;nil, &quot;steam&quot;=&gt;nil, &quot;tumblr&quot;=&gt;nil, &quot;twitter&quot;=&gt;nil, &quot;vine&quot;=&gt;nil, &quot;weibo&quot;=&gt;nil, &quot;xing&quot;=&gt;nil, &quot;youtube&quot;=&gt;nil, &quot;wikipedia&quot;=&gt;nil}</name></author><category term="TLS" /><category term="https" /><category term="Dash" /><category term="NearlyFreeSpeech" /><category term="Waveplot" /><summary type="html"><![CDATA[If you use NearlyFreeSpeech, Dash/Flask and want to enable HTTPS support, then this highly specific article is for you!]]></summary></entry><entry><title type="html">Plotting theoretical infrared spectra</title><link href="https://jonkragskow.github.io/posts/2022/09/blog-post-1/" rel="alternate" type="text/html" title="Plotting theoretical infrared spectra" /><published>2022-09-16T00:00:00-07:00</published><updated>2022-09-16T00:00:00-07:00</updated><id>https://jonkragskow.github.io/posts/2022/09/blog-post-1</id><content type="html" xml:base="https://jonkragskow.github.io/posts/2022/09/blog-post-1/"><![CDATA[<p>I recently had to plot some theoretical infrared spectra using the output
of a DFT optimisation and frequency calculation performed in Gaussian and didn’t
want to have to plot everything in Gaussview. Here’s how to plot exactly the
same spectrum as Gaussview, and hopefully a clear explanation of what Gaussian means by <code class="language-plaintext highlighter-rouge">IR Intensities</code>.</p>

<h2 id="running-the-calculation">Running the calculation</h2>

<p>Here’s an example optimisation and frequency (<code class="language-plaintext highlighter-rouge">opt+freq</code>) calculation for
CO<sub>2</sub> using DFT (B3LYP XC Functional), and a reasonable basis set.</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$RunGauss 
#p opt freq=HPModes b3lyp int=grid=ultrafine

DFT B3LYP OPT FREQ This-is-a-comment-line

0 1
O1     0      0.0000000   0.0000000   1.1600000
C1     0      0.0000000   0.0000000   0.0000000
O2     0      0.0000000   0.0000000  -1.1600000

C 0 
cc-pVTZ
**** 
O 0 
cc-pVTZ
</code></pre></div></div>

<p>I’m not going to explain how to run a calculation here in detail, but you’ll need
<code class="language-plaintext highlighter-rouge">freq</code> in your routecard as above, and I would recommend <code class="language-plaintext highlighter-rouge">freq=HPModes</code> to print
vibrational mode information with a reasonable number of significant figures.</p>

<h2 id="understanding-the-result">Understanding the result</h2>

<p>Gaussian will print the information you need to the output (<code class="language-plaintext highlighter-rouge">.log</code>) file in a
section with the following header</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code> Harmonic frequencies (cm**-1), IR intensities (KM/Mole), Raman scattering
 activities (A**4/AMU), depolarization ratios for plane and unpolarized
 incident light, reduced masses (AMU), force constants (mDyne/A),
 and normal coordinates:
</code></pre></div></div>

<p>When using <code class="language-plaintext highlighter-rouge">freq=HPModes</code> as above, it will print this header twice, where the
first section contains more precise displacements.</p>

<p>Sticking with the CO<sub>2</sub> example, the <code class="language-plaintext highlighter-rouge">.log</code> file contains</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>                          PIU       PIU       SGG       SGU
       Frequencies ---   487.4740  487.4740 1269.3077 2381.0728
    Reduced masses ---    12.8774   12.8774   15.9949   12.8774
   Force constants ---     1.8029    1.8029   15.1833   43.0153
    IR Intensities ---     9.2871    9.2871    0.0000   88.9346
 Coord Atom Element:
   1     1     8          0.00041  -0.33138  -0.00000  -0.00000
   2     1     8         -0.33138  -0.00041   0.00000  -0.00000
   3     1     8          0.00000  -0.00000   0.70711  -0.33138
   1     2     6         -0.00111   0.88339   0.00000   0.00000
   2     2     6          0.88339   0.00111  -0.00000   0.00000
   3     2     6         -0.00000  -0.00000  -0.00000   0.88339
   1     3     8          0.00041  -0.33138  -0.00000  -0.00000
   2     3     8         -0.33138  -0.00041   0.00000  -0.00000
   3     3     8         -0.00000   0.00000  -0.70711  -0.33138
</code></pre></div></div>

<p>We only need the <code class="language-plaintext highlighter-rouge">Frequencies</code> and <code class="language-plaintext highlighter-rouge">IR Intensities</code> which are in units
of cm<sup>-1</sup> and km mol<sup>-1</sup> respectively.</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>       Frequencies ---   487.4740  487.4740 1269.3077 2381.0728
    IR Intensities ---     9.2871    9.2871    0.0000   88.9346
</code></pre></div></div>

<p>The former are easy to understand, they’re the fundamental frequency of each vibrational mode computed within the harmonic approximation. The latter are more complicated, and are the integrated napierian (natural logarithmic) absorbances of each mode.</p>

<p>Experimentally, this is the integral of an absorption band</p>

\[\mathcal{A}_\mathrm{e}= \int_\mathrm{band}{\alpha_\mathrm{e}\left(\widetilde{\nu}\right)\ \mathrm{d}\widetilde{\nu}} = \frac{1}{nl}\int_\mathrm{band}{A_\mathrm{e}\left(\widetilde{\nu}\right)\ \mathrm{d}\widetilde{\nu}} \\ = \frac{1}{nl}\int_\mathrm{band}{\ln\left[\frac{I_0(\widetilde{\nu})}{I(\widetilde{\nu})}\right]\left(\widetilde{\nu}\right)\ \mathrm{d}\widetilde{\nu}}\ \ \ \ \ \ \ \left[\mathrm{m \ mol^{-1}}\right]\]

<p>Where $n$ is concentration $[\mathrm{mol \ m^{-3}]}$, $l$ is path length $[\mathrm{m}]$, 
$A_\mathrm{e}$ is the napierian absorbance, $\alpha_\mathrm{e}$ is the napierian absorption coefficient $[\mathrm{m^2 \ mol^{-1}}]$, $I$ and $I_0$ are the transmitted and incident
radiation intensity respectively, and $\widetilde{\nu}$ is the wavenumber $[\mathrm{cm}^{-1}]$.</p>

<p>This quantity is calculated theoretically as</p>

\[\mathcal{A}_\mathrm{e}=\frac{N_\mathrm{A}d}{12\epsilon_0c^2}\left|\frac{\partial\mathbf{\mu}_\mathrm{elec}}{\partial Q}\right|^2\cdot \mathrm{kg\left(u\right)\cdot \mathrm{D^2\left(C^2Å^2\right)} \ \ \ \ \ \ \ \ \ [m \ mol^{-1}] }\]

<p>Where $N\mathrm{_A}$ is Avogadro’s number $\mathrm{[mol^{-1}]}$, $d$ is the degeneracy of the mode (assumed to be 1 for all modes), $c$ is the speed of light $\mathrm{[m \ s^{-1}]}$, and $\epsilon_0$ is the permittivity of free space $\mathrm{[F \ m^{-1}]}$. The derivative is that of the electric dipole moment with respect to displacement along the $x$, $y$, and $z$ components of the mode vector $\mathrm{[D \ Å^{-1} u^{-1/2}]}$. The final two terms explicitly detail the conversion factors required to arrive at the final units of $[\mathrm{m \ mol^{-1}}]$:</p>

\[\mathrm{kg\left(u\right)} = \left(1.661\times{10}^{-27}\right)^{-1}\left[\mathrm{u\ kg}^{-1}\right]\\
\mathrm{D^2\left(C^2Å^2\right)}=\left(3.336\times10^{-20}\right)^2 \left[\mathrm{C^2Å^2D^{-2}}\right]\]

<p>So when Gaussian prints the <code class="language-plaintext highlighter-rouge">IR Intensities</code> of the modes it means
$\mathcal{A}_\mathrm{e}$ - the IR intensities are proportional to the integrated absorption of each band, <strong>not</strong> the peak height.</p>

<h2 id="plotting-a-spectrum">Plotting a spectrum</h2>

<p>Gaussview uses an area-normalised Lorentzian lineshape $L(x)$ for each vibrational mode</p>

\[L(x) = \frac{1}{\pi} \frac{\frac{1}{2}\Gamma}{\left(x-x_0\right)^2 + \left(\frac{1}{2}\Gamma\right)^2} \ \ \ \ [\mathrm{cm}] \\
\ \\

\int_{-\infty}^\infty L(x) \ \ \mathrm{d}x = 1\]

<p>where $\Gamma$ is the full-width-at-half-maximum (FWHM) of the curve, $x$ is the wavenumber of the incident radiation, 
and $x_0$ is the wavenumber of the vibrational mode.</p>

<p>The area of this function is then scaled to match the <em>decadic</em> integrated absorption coefficient $\mathcal{A}$, which is defined analogously to $\mathcal{A}_\mathrm{e}$ but using a decadic (base-10) logarithm.</p>

\[\mathcal{A}= \int_\mathrm{band}{\alpha\left(\widetilde{\nu}\right)\ \mathrm{d}\widetilde{\nu}} = \frac{1}{nl}\int_\mathrm{band}{A\left(\widetilde{\nu}\right)\ \mathrm{d}\widetilde{\nu}} \\ = \frac{1}{nl}\int_\mathrm{band}{\log_{10}\left[\frac{I_0(\widetilde{\nu})}{I(\widetilde{\nu})}\right]\left(\widetilde{\nu}\right)\ \mathrm{d}\widetilde{\nu}}\ \ \ \ \ \ \ \left[\mathrm{m \ mol^{-1}}\right]\]

<p>Where $n$ is concentration $[\mathrm{mol \ m^{-3}]}$, $l$ is path length $[\mathrm{m}]$, 
$A$ is the decadic absorbance, $\alpha$ is the decadic absorption coefficient $[\mathrm{m^2 \ mol^{-1}}]$, $I$ and $I_0$ are the transmitted and incident
radiation intensity respectively, and $\widetilde{\nu}$ is the wavenumber $[\mathrm{cm}^{-1}]$.</p>

<p>The conversion factor between napierian and decadic integrated absorption coefficients is</p>

\[\mathcal{A} \ \ [\mathrm{m \ mol^{-1}}] = \frac{1}{\ln{10}} \cdot \mathcal{A}_\mathrm{e} \ \ \ \ [\mathrm{m \ mol^{-1}}]\]

<p>Therefore, we divide Gaussian’s value of $\mathcal{A}_\mathrm{e} \ \ [\mathrm{km \ mol^{-1}}]$ by $\ln(10)$ to move from napierian to decadic integrated
absorption coefficient. Then, it’s useful (see below) to multiply by 100 to change from $[\mathrm{km \ mol^{-1}}]$ to $[\mathrm{1000 \ cm \ mol^{-1}}]$. This may seem
confusing, but if you realise that $[\mathrm{km \ mol^{-1}}] = [\mathrm{1000 \ m \ mol^{-1}}]$ then it might make this step clearer. To sum up</p>

\[\mathcal{A} \ \ [\mathrm{1000 \ cm \ mol^{-1}}] = \frac{100}{\ln{10}} \cdot \mathcal{A}_\mathrm{e} \ \ \ \ [\mathrm{km \ mol^{-1}}],\]

<p>The multiplication of $L(x) \ [\mathrm{cm}]$ by $\mathcal{A} \ \ [\mathrm{1000 \ cm \ mol^{-1}}]$ gives a function with units of $[\mathrm{1000 \ cm^{2} \ mol^{-1}}] = [\mathrm{L \ mol^{-1} \ cm^{-1}}] = [\mathrm{M^{-1} \ cm^{-1}}]$, i.e. common units of the linear molar extinction coefficient $\epsilon$.</p>

<p>To combine all of the modes as a single spectrum, simply sum $L(x) \cdot \mathcal{A}$ for each mode, and plot against wavenumber.</p>

<h2 id="addendum---understanding-dipole-derivatives-from-gaussian">Addendum - understanding Dipole Derivatives from Gaussian</h2>

<p>If you want to obtain dipole derivatives with respect to normal modes using <code class="language-plaintext highlighter-rouge">iop(7/33=1)</code>, then Gaussian will print these in units of $\mathrm{\sqrt{km\,mol^{−1}}}$ (without saying so). Various forum posts and online resources tell you to divide by the square root of 42.2561 to get a dipole derivative in more reasonable units (i.e. in the above definition), but they often don’t tell you where this number comes from.</p>

<p>The Gaussian <a href="https://gaussian.com/constants/">website</a> also lists the conversion factor</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1 Debye2-angstrom-2-amu-1 (IR intensity unit) = 42.2561 km-mol-1
</code></pre></div></div>

<p>This value comes from evaluating the constant terms in the definition of $\mathcal{A}_\mathrm{e}$.</p>

\[\frac{N_\mathrm{A}}{12\epsilon_0c^2}\cdot \mathrm{kg\left(u\right)\cdot \mathrm{D^2\left(C^2Å^2\right)}} = 42.2561\, \left[\mathrm{km\,mol^{−1}\,u\,Å^2\,D^{−2}}\right]\]

<p>All of this goes to say, be careful when using the output of Gaussian!</p>

<h2 id="addendum---dipole-derivatives-in-cartesian-basis">Addendum - Dipole Derivatives in Cartesian basis</h2>

<p>You can also obtain dipole derivatives with respect to normal modes <strong>without</strong> <code class="language-plaintext highlighter-rouge">iop(7/33=1)</code> by looking in the <code class="language-plaintext highlighter-rouge">.fchk</code> file for your calculation (obtained with Gaussian’s <code class="language-plaintext highlighter-rouge">formchk</code> utility). You will quickly notice, however, that these numbers do not match those in the output file, as they are the derivatives with respect to single atom displacements along $x$, $y$, and $z$.</p>

<p>To obtain the derivatives with respect to normal modes, you first must generate the matrix of cartesian displacements $\mathbf{L_\mathrm{CART}}$, as detailed in the Gaussian vibrational analysis <a href="https://gaussian.com/wp-content/uploads/dl/vib.pdf">whitepaper</a>. You can take this matrix from the output file but <strong>beware</strong>, these are scaled by the square root of the reduced mass and so this scaling must be undone to get the true $\mathbf{L_\mathrm{CART}}$.</p>

<p>Then, for each mode, multiply each element of $\mathbf{L_\mathrm{CART}}$ by the per-atom dipole derivative vector from the <code class="language-plaintext highlighter-rouge">.fchk</code> file, and sum up all contributions in each direction to give a single three element vector describing the dipole derivative with respect to a given mode in $x$, $y$, and $z$. Finally, convert these values from $\left[\mathrm{e\,u^{-\frac{1}{2}}}\right]$ to $\left[\sqrt{\mathrm{km\, mol^{-1}}}\right]$ by multiplying by 31.2231, this then gives the same values as those printed by the IOp command.</p>

\[31.2231 \left[\mathrm{e^{-1}\,u^{1/2}\,km^{1/2}\,mol^{-1/2}}\right] = \frac{\sqrt{42.2561\left[\mathrm{km\,mol^{-1}\,u\,Å^2\,D^{-2}}\right]}\cdot 1.602\times10^{-19}\left[\mathrm{C\,e^{-1}}\right]}{3.3356\times 10^{-20} \left[\mathrm{C\,Å\,D^{-1}}\right]}\]]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;&quot;bloaty_head.jpg&quot;, &quot;bio&quot;=&gt;&quot;Lecturer in Computational Chemistry&quot;, &quot;location&quot;=&gt;&quot;Bath, UK&quot;, &quot;employer&quot;=&gt;nil, &quot;pubmed&quot;=&gt;nil, &quot;googlescholar&quot;=&gt;&quot;https://scholar.google.co.uk/citations?user=kqImFp4AAAAJ&amp;hl=en&quot;, &quot;email&quot;=&gt;nil, &quot;researchgate&quot;=&gt;nil, &quot;uri&quot;=&gt;nil, &quot;bitbucket&quot;=&gt;nil, &quot;codepen&quot;=&gt;nil, &quot;dribbble&quot;=&gt;nil, &quot;flickr&quot;=&gt;nil, &quot;facebook&quot;=&gt;nil, &quot;foursquare&quot;=&gt;nil, &quot;github&quot;=&gt;&quot;jonkragskow&quot;, &quot;gitlab&quot;=&gt;&quot;jonkragskow&quot;, &quot;google_plus&quot;=&gt;nil, &quot;keybase&quot;=&gt;nil, &quot;instagram&quot;=&gt;nil, &quot;impactstory&quot;=&gt;nil, &quot;lastfm&quot;=&gt;nil, &quot;linkedin&quot;=&gt;nil, &quot;orcid&quot;=&gt;&quot;https://orcid.org/0000-0001-9488-8204&quot;, &quot;pinterest&quot;=&gt;nil, &quot;soundcloud&quot;=&gt;nil, &quot;stackoverflow&quot;=&gt;nil, &quot;steam&quot;=&gt;nil, &quot;tumblr&quot;=&gt;nil, &quot;twitter&quot;=&gt;nil, &quot;vine&quot;=&gt;nil, &quot;weibo&quot;=&gt;nil, &quot;xing&quot;=&gt;nil, &quot;youtube&quot;=&gt;nil, &quot;wikipedia&quot;=&gt;nil}</name></author><category term="Gaussian" /><category term="Infrared Spectroscopy" /><category term="DFT" /><summary type="html"><![CDATA[I recently had to plot some theoretical infrared spectra using the output of a DFT optimisation and frequency calculation performed in Gaussian and didn’t want to have to plot everything in Gaussview. Here’s how to plot exactly the same spectrum as Gaussview, and hopefully a clear explanation of what Gaussian means by IR Intensities.]]></summary></entry><entry><title type="html">Setting up an X11 Server on WSL2</title><link href="https://jonkragskow.github.io/posts/2022/06/blog-post-1/" rel="alternate" type="text/html" title="Setting up an X11 Server on WSL2" /><published>2022-06-28T00:00:00-07:00</published><updated>2022-06-28T00:00:00-07:00</updated><id>https://jonkragskow.github.io/posts/2022/06/blog-post-1</id><content type="html" xml:base="https://jonkragskow.github.io/posts/2022/06/blog-post-1/"><![CDATA[<p>A set of instructions for setting up an X11 server for the Windows Subsystem for Linux (WSL2).</p>

<h1 id="instructions">Instructions</h1>

<p>Download and install <a href="https://sourceforge.net/projects/vcxsrv/">VcXsrv</a> on your Windows machine.</p>

<p>Create a file called <code class="language-plaintext highlighter-rouge">config.xlaunch</code> in notepad containing the following lines</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;XLaunch WindowMode="MultiWindow" ClientMode="NoClient" LocalClient="False" Display="0" LocalProgram="xcalc" RemoteProgram="xterm" RemotePassword="" PrivateKey="" RemoteHost="" RemoteUser="" XDMCPHost="" XDMCPBroadcast="False" XDMCPIndirect="False" Clipboard="True" ClipboardPrimary="False" ExtraParams="" Wgl="True" DisableAC="True" XDMCPTerminate="False"/&gt;
</code></pre></div></div>
<p>and then save this file to</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>%AppData%\Microsoft\Windows\Start Menu\Programs\Startup
</code></pre></div></div>

<p>Now open your <strong>Linux</strong> terminal and edit the file <code class="language-plaintext highlighter-rouge">~/.bashrc</code> with either <code class="language-plaintext highlighter-rouge">nano</code> or <code class="language-plaintext highlighter-rouge">vim</code></p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>nano ~/.bashrc
</code></pre></div></div>

<p>and add the following lines</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">export </span><span class="nv">DISPLAY</span><span class="o">=</span><span class="sb">`</span><span class="nb">grep</span> <span class="nt">-oP</span> <span class="s2">"(?&lt;=nameserver ).+"</span> /etc/resolv.conf<span class="sb">`</span>:0.0
<span class="nb">export </span><span class="nv">XDG_RUNTIME_DIR</span><span class="o">=</span>/tmp/my-x-server
<span class="nb">export </span><span class="nv">RUNLEVEL</span><span class="o">=</span>3
</code></pre></div></div>

<p>then save and exit (for <code class="language-plaintext highlighter-rouge">nano</code> CTRL+O then CTRL+X).</p>

<p>Run these commands</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir</span> /tmp/my-x-server
<span class="nb">sudo chmod </span>700 /tmp/my-x-server
</code></pre></div></div>

<p>and finally run</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">source</span> ~/.bashrc
</code></pre></div></div>

<p>Now your X11 server will start every time Windows boots, and every Linux shell you open will be automatically connected to the X11 server. There is no need to ever do any other configuration steps at any point.</p>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;&quot;bloaty_head.jpg&quot;, &quot;bio&quot;=&gt;&quot;Lecturer in Computational Chemistry&quot;, &quot;location&quot;=&gt;&quot;Bath, UK&quot;, &quot;employer&quot;=&gt;nil, &quot;pubmed&quot;=&gt;nil, &quot;googlescholar&quot;=&gt;&quot;https://scholar.google.co.uk/citations?user=kqImFp4AAAAJ&amp;hl=en&quot;, &quot;email&quot;=&gt;nil, &quot;researchgate&quot;=&gt;nil, &quot;uri&quot;=&gt;nil, &quot;bitbucket&quot;=&gt;nil, &quot;codepen&quot;=&gt;nil, &quot;dribbble&quot;=&gt;nil, &quot;flickr&quot;=&gt;nil, &quot;facebook&quot;=&gt;nil, &quot;foursquare&quot;=&gt;nil, &quot;github&quot;=&gt;&quot;jonkragskow&quot;, &quot;gitlab&quot;=&gt;&quot;jonkragskow&quot;, &quot;google_plus&quot;=&gt;nil, &quot;keybase&quot;=&gt;nil, &quot;instagram&quot;=&gt;nil, &quot;impactstory&quot;=&gt;nil, &quot;lastfm&quot;=&gt;nil, &quot;linkedin&quot;=&gt;nil, &quot;orcid&quot;=&gt;&quot;https://orcid.org/0000-0001-9488-8204&quot;, &quot;pinterest&quot;=&gt;nil, &quot;soundcloud&quot;=&gt;nil, &quot;stackoverflow&quot;=&gt;nil, &quot;steam&quot;=&gt;nil, &quot;tumblr&quot;=&gt;nil, &quot;twitter&quot;=&gt;nil, &quot;vine&quot;=&gt;nil, &quot;weibo&quot;=&gt;nil, &quot;xing&quot;=&gt;nil, &quot;youtube&quot;=&gt;nil, &quot;wikipedia&quot;=&gt;nil}</name></author><category term="Windows Subsystem for Linux" /><category term="X11" /><summary type="html"><![CDATA[A set of instructions for setting up an X11 server for the Windows Subsystem for Linux (WSL2).]]></summary></entry><entry><title type="html">Lanthanide Ion 4f Electron Densities</title><link href="https://jonkragskow.github.io/posts/2022/06/blog-post-2/" rel="alternate" type="text/html" title="Lanthanide Ion 4f Electron Densities" /><published>2022-06-27T00:00:00-07:00</published><updated>2022-06-27T00:00:00-07:00</updated><id>https://jonkragskow.github.io/posts/2022/06/blog-post-1</id><content type="html" xml:base="https://jonkragskow.github.io/posts/2022/06/blog-post-2/"><![CDATA[<p>If you want to plot or visualise 4f charge densities, then look no further.</p>

<h1 id="sievers-approach">Sievers Approach</h1>

<p><img src="/images/webversion.webp" alt="Ln(III) Ground Term 4f Charge Densities" /></p>

<p>These are the free-ion charge density plots for the $m_J$ states of the ground Hund’s rule term of each Ln(III) ion as calculated and derived by <a href="https://dx.doi.org/10.1007/BF01321865" title="J. Sievers, Zeitschrift für Phys. B Condens. Matter, 1982, 45, 289–296.">Sievers</a> . The plot is produced in the same style as Reinhart and Long but instead uses The University of Manchester’s gold and purple colours. Eu(III) and Gd(III) are missing as they have $J=0$ and $L=0$ ground states respectively.</p>

<p>A high-resolution version of this plot is available <a href="/files/LnIonsPosterScaled.png">here</a>.</p>

<p>Each spheroid is calculated using a radius vector $R(\phi)$ which is
a function of the polar angle $\phi$. This vector describes the
angular dependence of the electron or charge density of a given $m_J$ state.</p>

\[R(\phi) = \sqrt[3]{\tilde{c}_0 + \sum_{i=2,4,6}c_i Y_{i,0}(\phi)}\]

<p>where $ \tilde{c}_0 = 3\pi/4 $ .</p>

<p>The $Y_{k0}$ are spherical harmonics, while the
values $ c_k $ are listed by Sievers for the Ln(III) ions in terms of $A_k$, and can be
calculated for other oxidation states using the procedure he outlines.</p>

<p>The conversion from $A_k$ to $c_k$ is straightforward</p>

\[A_k  = \sqrt{4\pi/(2k+1)}c_k\]

<p>The $A_k$ values given by Sievers can be downloaded as a text file <a href="/files/sievers_ln3_vals.txt">here</a>.</p>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;&quot;bloaty_head.jpg&quot;, &quot;bio&quot;=&gt;&quot;Lecturer in Computational Chemistry&quot;, &quot;location&quot;=&gt;&quot;Bath, UK&quot;, &quot;employer&quot;=&gt;nil, &quot;pubmed&quot;=&gt;nil, &quot;googlescholar&quot;=&gt;&quot;https://scholar.google.co.uk/citations?user=kqImFp4AAAAJ&amp;hl=en&quot;, &quot;email&quot;=&gt;nil, &quot;researchgate&quot;=&gt;nil, &quot;uri&quot;=&gt;nil, &quot;bitbucket&quot;=&gt;nil, &quot;codepen&quot;=&gt;nil, &quot;dribbble&quot;=&gt;nil, &quot;flickr&quot;=&gt;nil, &quot;facebook&quot;=&gt;nil, &quot;foursquare&quot;=&gt;nil, &quot;github&quot;=&gt;&quot;jonkragskow&quot;, &quot;gitlab&quot;=&gt;&quot;jonkragskow&quot;, &quot;google_plus&quot;=&gt;nil, &quot;keybase&quot;=&gt;nil, &quot;instagram&quot;=&gt;nil, &quot;impactstory&quot;=&gt;nil, &quot;lastfm&quot;=&gt;nil, &quot;linkedin&quot;=&gt;nil, &quot;orcid&quot;=&gt;&quot;https://orcid.org/0000-0001-9488-8204&quot;, &quot;pinterest&quot;=&gt;nil, &quot;soundcloud&quot;=&gt;nil, &quot;stackoverflow&quot;=&gt;nil, &quot;steam&quot;=&gt;nil, &quot;tumblr&quot;=&gt;nil, &quot;twitter&quot;=&gt;nil, &quot;vine&quot;=&gt;nil, &quot;weibo&quot;=&gt;nil, &quot;xing&quot;=&gt;nil, &quot;youtube&quot;=&gt;nil, &quot;wikipedia&quot;=&gt;nil}</name></author><category term="Single Molecule Magnets" /><category term="Sievers" /><category term="Lanthanides" /><summary type="html"><![CDATA[If you want to plot or visualise 4f charge densities, then look no further.]]></summary></entry></feed>