<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://spindynamics.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Suturina</id>
	<title>Spinach Documentation Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://spindynamics.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Suturina"/>
	<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Special:Contributions/Suturina"/>
	<updated>2026-12-04T11:15:04Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.15</generator>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1918</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1918"/>
		<updated>2017-01-06T11:06:06Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Distributed paramagnetic centre model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial page that goes through the different types of pseudocontact shift analysis that are available in &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;. It also summarises basic facts from the theory of pseudocontact shift. Please refer to our [[Appendix_C:_literature_citations|recent publications]] on the subject for the technical details of the three-dimensional PCS analysis process, and to standard reviews (from Florence and Otting groups) for the point PCS model description.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
The presence of rapidly relaxing unpaired electrons generates extra nuclear chemical shifts (called paramagnetic shifts) because the unpaired electrons respond nearly instantaneoulsy to the changes in the applied magnetic field and therefore provide additional nuclear shielding that is much stronger then what would be available from a closed-shell electronic structure. Paramagnetic chemical shift has two contributions:&lt;br /&gt;
&lt;br /&gt;
# Contact shift, which arises from the isotropic part of the hyperfine coupling between the electrons and the nuclei located in their close vicinity (typically less than 5 Angstrom).&lt;br /&gt;
# Pseudocontact shift, which is generated by the long-range (up to 50 Angstroms) electron-nuclear dipolar interaction.&lt;br /&gt;
&lt;br /&gt;
Both contributions may be obtained from classical physics expressions if the electron-nuclear hyperfine coupling tensor and the electron magnetic susceptibiity tensors are known. The contact shift depends on the isotropic part of the magnetic susceptibility tensor, and the pseudocontact shift on the anisotropic part.&lt;br /&gt;
&lt;br /&gt;
==Point dipole approximation==&lt;br /&gt;
This is historically the first and the simplest approach. It is based on the point dipole approximation for the electron. The expression for the pseudocontact shift for a nucleus at position &amp;lt;math&amp;gt;\mathbf{r}&amp;lt;/math&amp;gt; relative to the electron with a magnetic susceptibility tensor &amp;lt;math&amp;gt;\mathbf{\chi }&amp;lt;/math&amp;gt; is: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\sigma =\frac{1}{4\pi {{r}^{3}}}\text{Tr}\left[ \left( \frac{\mathbf{r}\otimes {{\mathbf{r}}^{\text{T}}}}{{{r}^{2}}}-\frac{1}{3} \right)\cdot \mathbf{\chi } \right]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This approach is valid for the distances at which the paramagnetic centre may be viewed as a point - typically at least 10 Angstroms away. The PCS of any nuclei located at closer distances would not fit this model. The &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; function that calculates pseudocontact shifts from user-specified coordinates and electron susceptibility tensors is [[ppcs.m]]. The function that extracts the paramagnetic centre position and the susceptibility tensor from user-specified nuclear coordinates and pseudocontact shifts using the point electron model is [[ippcs.m]].&lt;br /&gt;
&lt;br /&gt;
Note that the magnetic susceptibility tensor may be estimated from the g-tensor for S=1/2 using the following expression:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The function that performs this estimation for an arbitary g-tensor is [[g2chi.m]]. The resulting estimate is only valid at high temperature.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; PCS calculation using the point dipole approximation=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|&amp;#039;&amp;#039;&amp;#039;Figure 1.&amp;#039;&amp;#039;&amp;#039; Structure of metal porphyrin. Colour code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we compute the PCS on the protons of a Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS. The following steps should be taken:&lt;br /&gt;
&lt;br /&gt;
*Specify the coordinates of all protons:&lt;br /&gt;
&lt;br /&gt;
     % Porphyrin ring proton coordinates&lt;br /&gt;
     nxyz=[ 4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
&lt;br /&gt;
*Specify (or compute from the &amp;#039;&amp;#039;g&amp;#039;&amp;#039;-tensor) the susceptibility tensor (cubic Angstrom) in the same coordinate system as the one used for the proton coordinates above:&lt;br /&gt;
&lt;br /&gt;
     % Co(II) g-tensor&lt;br /&gt;
     g_co=diag([3.0 3.0 2.0]);&lt;br /&gt;
 &lt;br /&gt;
     % Cu(II) g-tensor&lt;br /&gt;
     g_cu=diag([2.0 2.0 2.2]);&lt;br /&gt;
 &lt;br /&gt;
     % Curie susceptibility tensors&lt;br /&gt;
     chi_co=[[g2chi.m|g2chi]](g_co,298);&lt;br /&gt;
     chi_cu=[[g2chi.m|g2chi]](g_cu,298);&lt;br /&gt;
&lt;br /&gt;
*Specify the metal position&lt;br /&gt;
      &lt;br /&gt;
     % Metal position &lt;br /&gt;
     mxyz=[0 0 0];&lt;br /&gt;
&lt;br /&gt;
*Call [[ppcs.m]] function&lt;br /&gt;
&lt;br /&gt;
     % PCS calculation&lt;br /&gt;
     point_pcs_co=[[ppcs.m|ppcs]](nxyz,mxyz,chi_co);&lt;br /&gt;
     point_pcs_cu=[[ppcs.m|ppcs]](nxyz,mxyz,chi_cu);&lt;br /&gt;
&lt;br /&gt;
*Print the output to the console&lt;br /&gt;
&lt;br /&gt;
     % Output&lt;br /&gt;
     disp(&amp;#039;Pseudocontact shifts [Co, Cu], ppm&amp;#039;);&lt;br /&gt;
     disp([point_pcs_co point_pcs_cu]);&lt;br /&gt;
&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule:&lt;br /&gt;
&lt;br /&gt;
     PCS [Co, Cu], ppm&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     9.3458   -1.5701&lt;br /&gt;
     9.3458   -1.5701&lt;br /&gt;
     9.3458   -1.5701&lt;br /&gt;
     9.3458   -1.5701&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; PCS fitting using the point dipole approximation=====&lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|&amp;#039;&amp;#039;&amp;#039;Figure 2.&amp;#039;&amp;#039;&amp;#039; Comparison of the point dipole model PCS with the experiment for Tm(III) substituted calbindin D9K.]]&lt;br /&gt;
In this example we will process the experimental PCS data from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63] for calbindin D9K, in which one of the two calcium ions has been replaced by a thulium ion. The corresponding example file is located in nmr_paramag/calbindin directory of the example set supplied with &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The calculation proceeds in the following stages:&lt;br /&gt;
*Import the data. It may be pyped in explicitly, as above. In this case, atomic coordinates and pseudocontact shifts are supplied in a Matlab file:&lt;br /&gt;
&lt;br /&gt;
     % Load experimental data&lt;br /&gt;
     load(&amp;#039;tm_1igv_pcs.mat&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
*Call the point model fit function [[ippcs.m]] with the initial guess of the thulium metal position set to [-5 5 -15]:&lt;br /&gt;
&lt;br /&gt;
     % Solve the inverse problem&lt;br /&gt;
     [mxyz,chi,pred_pcs]=[[ippcs.m|ippcs]]([x y z],[-5 5 -15],expt_pcs);&lt;br /&gt;
&lt;br /&gt;
The other variables are contained in the file loaded in the previous line. In practice, several attempts with different paramagnetic centre location guesses may be necessary.&lt;br /&gt;
&lt;br /&gt;
*Plot the results&lt;br /&gt;
&lt;br /&gt;
     % Plot experimental vs predicted PCS&lt;br /&gt;
     figure(); plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;); hold on; grid on;&lt;br /&gt;
     plot([min(expt_pcs) max(expt_pcs)],[min(expt_pcs) max(expt_pcs)],&amp;#039;r-&amp;#039;);&lt;br /&gt;
     xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;); ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
*Print the position of Tm and the traceless part of the magnetic susceptibility tensor in molecular frame&lt;br /&gt;
&lt;br /&gt;
     % Report the parameters&lt;br /&gt;
     disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
     disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
&lt;br /&gt;
The output appears below:&lt;br /&gt;
&lt;br /&gt;
     Susceptibility tensor:&lt;br /&gt;
         0.0585   -0.0878    0.0729&lt;br /&gt;
        -0.0878   -0.0773    0.0341&lt;br /&gt;
         0.0729    0.0341    0.0189&lt;br /&gt;
     &lt;br /&gt;
     Point electron location:&lt;br /&gt;
         3.6610   17.7074   15.4140&lt;br /&gt;
&lt;br /&gt;
It is clear from the figure that the point dipole model does fit the data, but does not fit it particularly well.&lt;br /&gt;
&lt;br /&gt;
==Magnetic multipole approximation==&lt;br /&gt;
The next level of theory that improves on the point dipole approximation is based on the spherical harmonic expansion of the electron probability density:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\rho \left( \mathbf{r} \right)=\sum\limits_{l,m}{\alpha _{l}^{m}\left( r \right)Y_{l}^{m}\left( \theta ,\varphi  \right)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It works for nuclei positioned outside the bounding sphere of the electron probability density. PCS calculation is performed using [[lpcs.m]] function and the fitting is performed using [[ilpcs.m]] function. In both cases, the list of &amp;lt;math&amp;gt;l&amp;lt;/math&amp;gt; ranks to be included into the expansion must be supplied by the user.&lt;br /&gt;
 &lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Computing PCS using the multipole model=====&lt;br /&gt;
The spin density in the copper porphyrin from Example 1a is clearly not a point object; some density is located on the nitrogen atoms because the corresponding isotropic hyperfine couplings are clearly visible in ESR spectra. If the spin populations on all relevant atoms are known (for example, from electronic structure theory calculations, or as fitting parameters), the multipole moments of the overall distribution may be estimated using [[points2mult.m]] function. If the spin density is given on a 3D grid, the same function would calculate its multipole moments by numerical integration. A typical calculation would proceed in the following stages:&lt;br /&gt;
&lt;br /&gt;
*Specify nuclear coordinates and the corresponding Mulliken spin populations:&lt;br /&gt;
&lt;br /&gt;
     % Nuclear coordinates&lt;br /&gt;
     xyz=[ 0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
          -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
           1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
          -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
           1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
 &lt;br /&gt;
     % Multipole centre coordinates&lt;br /&gt;
     mxyz=[0 0 0];&lt;br /&gt;
  &lt;br /&gt;
     % Mulliken spin populations&lt;br /&gt;
     rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
*Compute multipole moments relative to the centre, in this case up to spherical harmonic rank 14&lt;br /&gt;
&lt;br /&gt;
     % Compute multipole moments&lt;br /&gt;
     Ilm=[[points2mult.m|points2mult]](xyz,mxyz,rho,0:14,&amp;#039;points&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
*Get the susceptibility tensor from the &amp;#039;&amp;#039;g&amp;#039;&amp;#039;-tensor&lt;br /&gt;
&lt;br /&gt;
     % Cu(II) g-tensor&lt;br /&gt;
     g_cu=diag([2.0 2.0 2.2]);&lt;br /&gt;
 &lt;br /&gt;
     % Curie susceptibility tensor&lt;br /&gt;
     chi_cu=[[g2chi.m|g2chi]](g_cu,298);&lt;br /&gt;
&lt;br /&gt;
*Compute PCS using the multipole moments&lt;br /&gt;
&lt;br /&gt;
     % Get the pseudocontact shifts&lt;br /&gt;
     theor_pcs=[[lpcs.m|lpcs]](nxyz,mxyz,0:14,Ilm,chi_cu)&lt;br /&gt;
&lt;br /&gt;
A visual inspection of the resulting PCS values shows that the effect of the spin delocalisation on the PCS is significant: the point dipole model predicts shifts at -1.00 and -1.57 ppm, and the multipole model at -1.21 and -1.81 ppm, respectively. This example is located in nmr_paramag directory of the example set supplied with &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Fitting PCS to the multipole model=====&lt;br /&gt;
[[File:calb_pcs_mult.png|right|thumb|300px|alt=Alt text|&amp;#039;&amp;#039;&amp;#039;Figure 3.&amp;#039;&amp;#039;&amp;#039; Comparison of the multipole model PCS with the experiment for Tm(III) substituted calbindin D9K.]]&lt;br /&gt;
Fitting experimental data to the multipole model can account for the possible mobility of the lanthanide centre; this is often the case in proteins. If we repeat Example 1b identically, except for the solver line:&lt;br /&gt;
&lt;br /&gt;
     % Solve the inverse problem&lt;br /&gt;
     [mxyz,chi,~,pred_pcs]=[[ilpcs.m|ilpcs]]([x y z],expt_pcs,[0 1 2],[-5 5 -15]);&lt;br /&gt;
&lt;br /&gt;
where now the fit is to the multipole model with up to the second spherical rank in the probability density distribution, we would see a much better fit - the residual drops by almost a factor of three. Specifying &amp;lt;math&amp;gt;l=\left[ \begin{matrix} 0 &amp;amp; 1 &amp;amp; 2 \end{matrix} \right]&amp;lt;/math&amp;gt; is typically sufficient; &amp;lt;math&amp;gt;l=0&amp;lt;/math&amp;gt; makes the calculation equivalent to the point dipole approximation. Spherical ranks higher than 4 are not well constrained by fitting.&lt;br /&gt;
&lt;br /&gt;
==Using hyperfine tensors from electronic structure theory==&lt;br /&gt;
Another way to account for the paramagnetic centre delocalisation is to use hyperfine tensors obtained from electronic structure theory calculations. Those are integrals over the unpaired electron probability density and therefore include all delocalisation effects. Only anisotropic part of the hyperfine tensor affects the PCS; for light nuclei it is just the dipolar hyperfine interaction, for heavy elements the orbital part also contributes.&lt;br /&gt;
&lt;br /&gt;
Spinach has two electronic structure theory package parsers: [[gparse.m]] for outputs from &amp;#039;&amp;#039;Gaussian&amp;#039;&amp;#039; and [[oparse.m]] for outputs from &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039;. Both extract hyperfine tensors from the logs produced by the program. The function [[hfc2pcs.m]] then computes PCS by multiplying the traceless part of the hyperfine tensor by the traceless part of the susceptibility tensor and taking the trace of the result. To keep the traces (and therefore the contact part of the full paramagnetic shift), use [[hfc2pms.m]] function. The general equation is:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\sigma _{\text{CS}}^{\left( k \right)}+\sigma _{\text{PCS}}^{\left( k \right)}=-\frac{1}{3}\text{Tr}\left[ \frac{{{\mathbf{A}}^{\left( k \right)}}\cdot \boldsymbol{\chi }}{{{\mu }_{0}}{{\gamma }_{\text{e}}}\gamma _{\text{n}}^{\left( k \right)}\hbar } \right]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See http://dx.doi.org/10.1039/C4CP03106G for further information. Note that this method essentially requires the molecule to be rigid; realistically, it is only applicable to small molecules, for which it is strongly recommended. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; Computing PCS using hyperfine tensors from DFT=====&lt;br /&gt;
You should refer to &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; and &amp;#039;&amp;#039;Gaussian&amp;#039;&amp;#039; manuals to find out how to calculate hyperfine tensors. An example &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; output file is located in the nmr_paramag folder of the example set supplied with &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;. The calculation proceeds in the following stages:&lt;br /&gt;
&lt;br /&gt;
*&amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; log file is parsed by &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
    % Parse the ORCA log&lt;br /&gt;
    props=oparse(&amp;#039;cu_porph_hfc.out&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
*Relevant hyperfine tensors are extracted:&lt;br /&gt;
&lt;br /&gt;
    % Extract hyperfine tensors&lt;br /&gt;
    hfcs=props.hfc.full.matrix(26:37);&lt;br /&gt;
&lt;br /&gt;
*PCS values are computed&lt;br /&gt;
&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    for n=1:numel(hfcs)&lt;br /&gt;
         hfc_pcs_cu(n)=hfc2pcs(gauss2mhz(hfcs{n}),chi_cu,&amp;#039;1H&amp;#039;);&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The same susceptibility tensor as in Examples 1a and 2a is used here. The point model in Example 1a was predicting PCS at -1.00 and -1.57 ppm; the multipole model in Example 2a put the PCS at -1.21 and -1.81 ppm; DFT hyperfines give even larger PCS values: -1.53 and -1.90 ppm.&lt;br /&gt;
&lt;br /&gt;
==Distributed paramagnetic centre model==&lt;br /&gt;
The most general approach that works for any paramagnetic centre probability distribution is based on the partial differential equation obeyed by the pseudocontact shift, described in http://dx.doi.org/10.1039/C4CP03106G and implemented in the functions [[kpcs.m]] for the direct problems, and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the probability density defined on three-dimensional grids. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 4a.&amp;#039;&amp;#039; Computing PCS using DFT spin density=====&lt;br /&gt;
[[File:cu_porph_sd1.png|thumb|300px|&amp;#039;&amp;#039;&amp;#039;Figure 4.&amp;#039;&amp;#039;&amp;#039; DFT spin density of Cu(II) porphyrin.]]&lt;br /&gt;
[[File:cu_porph_sd.png|thumb|300px|&amp;#039;&amp;#039;&amp;#039;Figure 5.&amp;#039;&amp;#039;&amp;#039; PCS field of Cu(II) porphyrin.]]&lt;br /&gt;
You should refer to &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; and &amp;#039;&amp;#039;Gaussian&amp;#039;&amp;#039; manuals to find out how to calculate spin density cubes. An example &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; cube is located in the nmr_paramag folder of the example set supplied with Spinach. The calculation proceeds in the following stages (some of the parameters have already been computed in Examples 2a and 3a): &lt;br /&gt;
&lt;br /&gt;
* An &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; spin density cube is parsed by &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; and padded&lt;br /&gt;
&lt;br /&gt;
    % Parse ORCA cube and pad the density with zeros to avoid PBC effects &lt;br /&gt;
    pad_size=2; [density,ext]=[[ocparse.m|ocparse]](&amp;#039;cu_porph_sd80.spindens.3d&amp;#039;,pad_size);&lt;br /&gt;
&lt;br /&gt;
* PCS from distributed density is computed:&lt;br /&gt;
&lt;br /&gt;
    % Solve Kuprov equation&lt;br /&gt;
    [pde_pcs_cu,pcs_cube]=[[kpcs.m|kpcs]](density,chi_cu,ext,nxyz,&amp;#039;fft&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
The partial differential equation is solved using the Fourier transform, and the spin density cube therefore requires padding by zeros on all sides to avoid self-interaction artefacts from the periodic boundary conditions - hence the pad argument in [[ocparse.m]] function.&lt;br /&gt;
&lt;br /&gt;
Comparison of the PCS from the DFT hyperfine and from the partial differential equation (PDE) with imported DFT spin density defined on 80x80x80 grid shows the good agreement (-1.53 -1.90 ppm from DFT and -1.43 -1.84 ppm from PDE). Using this method one can compute DFT spin density for a small subsystem (i.e. protein active site) and recompute PCS in full system (entire protein) using [[kpcs.m]] without a need to do DFT for the full system.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 4b.&amp;#039;&amp;#039; Reconstructing PCS tag distributions in proteins===== &lt;br /&gt;
When pseudocontact shifts and the corresponding nuclear coordinates are available, it is possible to approximately reconstruct the three-dimensional probability density of the paramagnetic centre that generated the pseudocontact shifts. The particulars are given in the forthcoming paper from the IK group; multiple examples are available in nmr_paramag/calbindin and nmr_paramag/carb_anh directories of the standard example set supplied with &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;. The primary function involved is [[ipcs.m]]; this section contains some practical advice on using it. A typical reconstruction run would proceed in the following stages:&lt;br /&gt;
&lt;br /&gt;
1. &amp;#039;&amp;#039;&amp;#039;Compile the primary data.&amp;#039;&amp;#039;&amp;#039; You will need the following: (a) Cartesian coordinates of the nuclei for which the PCS is measured, as Nx3 array in Matlab - call this array &amp;#039;xyz&amp;#039;; (b) Cartesian coordinates of all atoms in the molecule, as Mx3 array in Matlab - call this array &amp;#039;xyz_all&amp;#039;; (c) Pseudocontact shifts, in the same order as the coordinates in &amp;#039;xyz&amp;#039; variable, as Nx1 vector. Include all pseudocontact shifts that you managed to measure, including those in the immediate vicinity of the paramagnetic centre.&lt;br /&gt;
&lt;br /&gt;
2. &amp;#039;&amp;#039;&amp;#039;Locate the paramagnetic centre.&amp;#039;&amp;#039;&amp;#039; You likely have an approximate idea of where your paramagnetic centre is located. Use that location as the initial guess for the point dipole model fit, for example:&lt;br /&gt;
&lt;br /&gt;
     [mxyz,chi,pred_pcs]=[[ippcs.m|ippcs]](xyz,[-27.0  13.0  18.0],expt_pcs);&lt;br /&gt;
&lt;br /&gt;
Optionally, plot the theoretical against the experimental PCS, for example:&lt;br /&gt;
&lt;br /&gt;
     figure(); plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;); hold on; grid on;&lt;br /&gt;
     plot([min(expt_pcs) max(expt_pcs)],[min(expt_pcs) max(expt_pcs)],&amp;#039;r-&amp;#039;);&lt;br /&gt;
     xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;); ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
If the fit is very poor, re-run from a different initial guess for the metal position. Even the best point model fit probably isn&amp;#039;t particularly good, or you wouldn&amp;#039;t be reading this, but it would give you a better idea of where your paramagnetic centre roughly is.&lt;br /&gt;
&lt;br /&gt;
3. &amp;#039;&amp;#039;&amp;#039;Run the multipolar fit.&amp;#039;&amp;#039;&amp;#039; Use the paramagnetic centre position from the previous stage as the initial guess, for example:&lt;br /&gt;
&lt;br /&gt;
     [mxyz,chi,~,pred_pcs]=[[ilpcs.m|ilpcs]](xyz,expt_pcs,[0 1 2],[-27.0  13.0  18.0]);&lt;br /&gt;
&lt;br /&gt;
Optionally, plot the theoretical against the experimental PCS again, for example:&lt;br /&gt;
&lt;br /&gt;
     figure(); plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;); hold on; grid on;&lt;br /&gt;
     plot([min(expt_pcs) max(expt_pcs)],[min(expt_pcs) max(expt_pcs)],&amp;#039;r-&amp;#039;);&lt;br /&gt;
     xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;); ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
The fit would likely be much improved - Figure 6 below provides an illustration. &lt;br /&gt;
[[File:multipolar_vs_point_pcs.png|center|frame|&amp;#039;&amp;#039;&amp;#039;Figure 6.&amp;#039;&amp;#039;&amp;#039; Comparison of the point model fit (left) with the multipolar model fit (right) for a mutant of human carbonic anhydrase.]]&lt;br /&gt;
The important parameters to keep at this point are the effective magnetic susceptibility tensor (&amp;#039;chi&amp;#039;) and the magnetic multipole centre (&amp;#039;mxyz&amp;#039;).&lt;br /&gt;
&lt;br /&gt;
4. &amp;#039;&amp;#039;&amp;#039;Run the draft three-dimensional reconstruction.&amp;#039;&amp;#039;&amp;#039; The [[ipcs.m]] function performing three-dimensional reconstructions is very rich in options; it is recommended that you read its manual section carefully. The following options are recommended:&lt;br /&gt;
&lt;br /&gt;
     % Set inverse problem parameters&lt;br /&gt;
     parameters.plot={&amp;#039;diagnostics&amp;#039;,&amp;#039;density&amp;#039;,&amp;#039;molecule&amp;#039;,&amp;#039;tightzoom&amp;#039;,&amp;#039;box&amp;#039;};&lt;br /&gt;
     parameters.box_cent=[### ### ###];&lt;br /&gt;
     parameters.box_size=[ 25.0 25.0 25.0];&lt;br /&gt;
     parameters.margins=50*ones(1,6);&lt;br /&gt;
     parameters.confine=[2.0 12.0];&lt;br /&gt;
     parameters.sharpen=0.0;&lt;br /&gt;
     parameters.xyz_all=xyz_all;&lt;br /&gt;
     parameters.expt_pcs=expt_pcs;&lt;br /&gt;
     parameters.xyz=xyz;&lt;br /&gt;
     parameters.chi=chi;&lt;br /&gt;
     parameters.gpu=0;&lt;br /&gt;
&lt;br /&gt;
*The first line tells &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; to produce maximum visual output - see [[ipcs.m]] options for further details.&lt;br /&gt;
*The second one specifies the coordinates of the centre of the source box in Angstrom - use the multipole coordinates from the previous stage here. &lt;br /&gt;
*The third line specifies the size of the source box in Angstrom - set the three numbers to the suspected width of your distribution; 25 Angstrom is usually sufficient. &lt;br /&gt;
*The fourth line deals with preventing the periodic boundary condition effects from appearing - it tells &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; to run the solver with the box that has been padded with 50 Angstroms of zeros on each side; that is normally sufficient. &lt;br /&gt;
*The fifth line tells &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; to confine the solution space to include all points that are &amp;#039;&amp;#039;at least&amp;#039;&amp;#039; 2.0 Angstroms away from any atom in &amp;#039;xyz_all&amp;#039; and &amp;#039;&amp;#039;at most&amp;#039;&amp;#039; 12.0 Angstrom from the nearest atom in &amp;#039;xyz_all&amp;#039;. This corresponds to the set of physically realistic positions of a lanthanide atom in a spin label attached to the protein surface. If you are reconstructing the distribution of the lanthanide that is internal to the structure, you would need to reduce the first number.&lt;br /&gt;
*The sixth line switches off source sharpening - a penalty functional that drives values below average to zero and values above average to infinity. Increase the coefficient if you have minor low-amplitude clouds in your solution, but remember that this algorithm is hard to justify on physical grounds.&lt;br /&gt;
* Lines 7-10 simply provide the information we already have from the previous sections.&lt;br /&gt;
* The last line may be used to enable GPU processing if you have an NVidia GPU. It assumes that you have no NVidia GPUs in the system. If you do, set the value to 1; the calculations would go faster on any serious gaming card and &amp;#039;&amp;#039;massively&amp;#039;&amp;#039; faster if you have a Tesla coprocessor installed.&lt;br /&gt;
&lt;br /&gt;
Run a rough reconstruction with these options;&lt;br /&gt;
&lt;br /&gt;
     [source_cube,ranges]=ipcs(parameters,64,0.125);&lt;br /&gt;
&lt;br /&gt;
where 64 is the number of points in each direction of the grid and 0.125 is a fairly typical value of the Tikhonov regularisation parameter. Visually inspect the answer (see Figure 7 below for an example). &lt;br /&gt;
[[File:moving_the_cube.png|center|frame|&amp;#039;&amp;#039;&amp;#039;Figure 7.&amp;#039;&amp;#039;&amp;#039; Centering the variational cube during the draft reconstruction process. &amp;#039;&amp;#039;&amp;#039;Left:&amp;#039;&amp;#039;&amp;#039; the density is smeared along one of the cube sides, the cube must be moved right. &amp;#039;&amp;#039;&amp;#039;Right:&amp;#039;&amp;#039;&amp;#039; correctly positioned variational cube.]]&lt;br /&gt;
If the red cloud is smudged against any side of the cube, move it in that direction. Increase and shrink the cube as necessary until the red cloud sits comfortably within it.&lt;br /&gt;
&lt;br /&gt;
5. &amp;#039;&amp;#039;&amp;#039;Run the L-curve analysis.&amp;#039;&amp;#039;&amp;#039; Double the size of the cube on every direction and run the reconstruction process multiple times, recording the value of the least squares penalty and the Tikhonov regularisation penalty for a range of regularisation parameters. There are multiple examples in the standard example set, the following is typical:&lt;br /&gt;
&lt;br /&gt;
     % Regularisation parameter array&lt;br /&gt;
     lam=10.^linspace(-2.0,2.0,30);&lt;br /&gt;
 &lt;br /&gt;
     % Result arrays&lt;br /&gt;
     err=zeros(30,1); reg=zeros(30,1);&lt;br /&gt;
 &lt;br /&gt;
     % Run a parallel loop&lt;br /&gt;
     parfor n=1:30 %#ok&amp;lt;*PFOUS,*PFBNS&amp;gt;&lt;br /&gt;
         [~,~,~,err(n),~,reg(n)]=[[ipcs.m|ipcs]](parameters,64,lam(n));&lt;br /&gt;
         reg(n)=reg(n)/lam(n);&lt;br /&gt;
     end&lt;br /&gt;
 &lt;br /&gt;
     % L-curve analysis&lt;br /&gt;
     figure(); S=[[lcurve.m|lcurve]](lam,err,reg,&amp;#039;log&amp;#039;);&lt;br /&gt;
     disp([&amp;#039;Optimum smoothing parameter: &amp;#039; num2str(S)]);&lt;br /&gt;
&lt;br /&gt;
The optimum value of the regularisation parameter corresponds to the point of maximum curvature on the L-curve. A typical example appears in Figure 8 below.&lt;br /&gt;
[[File:lcurve.png|center|frame|&amp;#039;&amp;#039;&amp;#039;Figure 8.&amp;#039;&amp;#039;&amp;#039; A typical L-curve with the maximum curvature point indicated by a red circle.]]&lt;br /&gt;
&lt;br /&gt;
6. &amp;#039;&amp;#039;&amp;#039;Run the accurate reconstruction.&amp;#039;&amp;#039;&amp;#039; Use the optimal value of the Tikhonov regularisation parameter to run the reconstruction on a finer grid. An iterative approach is suggested, for example:&lt;br /&gt;
&lt;br /&gt;
     % Solve and refine the grid&lt;br /&gt;
     for n=[64 128 256]&lt;br /&gt;
         [source_cube,ranges]=[[ipcs.m|ipcs]](parameters,n,0.125);&lt;br /&gt;
         parameters.guess=source_cube;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
At the end of the calculation (very long if you don&amp;#039;t have a Tesla card) you will obtain a high quality reconstruction.&lt;br /&gt;
&lt;br /&gt;
7. &amp;#039;&amp;#039;&amp;#039;Refine the effective susceptibility tensor.&amp;#039;&amp;#039;&amp;#039; Optionally, &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; can now use your probability density to update the susceptibility tensor that you have obtained from the multipolar fit. Run the following call:&lt;br /&gt;
&lt;br /&gt;
     [chi,~]=[[chi_eff.m|chi_eff]](source_cube,ranges,xyz,expt_pcs);&lt;br /&gt;
&lt;br /&gt;
to obtain your new susceptibility tensor. If it is significantly different from the previous one, repeat Steps 6 and 7 until self-consistency is achieved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Version 1.9, authors: [[Elizaveta Suturina]], [[Ilya Kuprov]]&amp;#039;&amp;#039;&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1917</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1917"/>
		<updated>2017-01-06T11:03:55Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Using hyperfine tensors from electronic structure theory */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial page that goes through the different types of pseudocontact shift analysis that are available in &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;. It also summarises basic facts from the theory of pseudocontact shift. Please refer to our [[Appendix_C:_literature_citations|recent publications]] on the subject for the technical details of the three-dimensional PCS analysis process, and to standard reviews (from Florence and Otting groups) for the point PCS model description.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
The presence of rapidly relaxing unpaired electrons generates extra nuclear chemical shifts (called paramagnetic shifts) because the unpaired electrons respond nearly instantaneoulsy to the changes in the applied magnetic field and therefore provide additional nuclear shielding that is much stronger then what would be available from a closed-shell electronic structure. Paramagnetic chemical shift has two contributions:&lt;br /&gt;
&lt;br /&gt;
# Contact shift, which arises from the isotropic part of the hyperfine coupling between the electrons and the nuclei located in their close vicinity (typically less than 5 Angstrom).&lt;br /&gt;
# Pseudocontact shift, which is generated by the long-range (up to 50 Angstroms) electron-nuclear dipolar interaction.&lt;br /&gt;
&lt;br /&gt;
Both contributions may be obtained from classical physics expressions if the electron-nuclear hyperfine coupling tensor and the electron magnetic susceptibiity tensors are known. The contact shift depends on the isotropic part of the magnetic susceptibility tensor, and the pseudocontact shift on the anisotropic part.&lt;br /&gt;
&lt;br /&gt;
==Point dipole approximation==&lt;br /&gt;
This is historically the first and the simplest approach. It is based on the point dipole approximation for the electron. The expression for the pseudocontact shift for a nucleus at position &amp;lt;math&amp;gt;\mathbf{r}&amp;lt;/math&amp;gt; relative to the electron with a magnetic susceptibility tensor &amp;lt;math&amp;gt;\mathbf{\chi }&amp;lt;/math&amp;gt; is: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\sigma =\frac{1}{4\pi {{r}^{3}}}\text{Tr}\left[ \left( \frac{\mathbf{r}\otimes {{\mathbf{r}}^{\text{T}}}}{{{r}^{2}}}-\frac{1}{3} \right)\cdot \mathbf{\chi } \right]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This approach is valid for the distances at which the paramagnetic centre may be viewed as a point - typically at least 10 Angstroms away. The PCS of any nuclei located at closer distances would not fit this model. The &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; function that calculates pseudocontact shifts from user-specified coordinates and electron susceptibility tensors is [[ppcs.m]]. The function that extracts the paramagnetic centre position and the susceptibility tensor from user-specified nuclear coordinates and pseudocontact shifts using the point electron model is [[ippcs.m]].&lt;br /&gt;
&lt;br /&gt;
Note that the magnetic susceptibility tensor may be estimated from the g-tensor for S=1/2 using the following expression:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The function that performs this estimation for an arbitary g-tensor is [[g2chi.m]]. The resulting estimate is only valid at high temperature.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; PCS calculation using the point dipole approximation=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|&amp;#039;&amp;#039;&amp;#039;Figure 1.&amp;#039;&amp;#039;&amp;#039; Structure of metal porphyrin. Colour code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we compute the PCS on the protons of a Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS. The following steps should be taken:&lt;br /&gt;
&lt;br /&gt;
*Specify the coordinates of all protons:&lt;br /&gt;
&lt;br /&gt;
     % Porphyrin ring proton coordinates&lt;br /&gt;
     nxyz=[ 4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
&lt;br /&gt;
*Specify (or compute from the &amp;#039;&amp;#039;g&amp;#039;&amp;#039;-tensor) the susceptibility tensor (cubic Angstrom) in the same coordinate system as the one used for the proton coordinates above:&lt;br /&gt;
&lt;br /&gt;
     % Co(II) g-tensor&lt;br /&gt;
     g_co=diag([3.0 3.0 2.0]);&lt;br /&gt;
 &lt;br /&gt;
     % Cu(II) g-tensor&lt;br /&gt;
     g_cu=diag([2.0 2.0 2.2]);&lt;br /&gt;
 &lt;br /&gt;
     % Curie susceptibility tensors&lt;br /&gt;
     chi_co=[[g2chi.m|g2chi]](g_co,298);&lt;br /&gt;
     chi_cu=[[g2chi.m|g2chi]](g_cu,298);&lt;br /&gt;
&lt;br /&gt;
*Specify the metal position&lt;br /&gt;
      &lt;br /&gt;
     % Metal position &lt;br /&gt;
     mxyz=[0 0 0];&lt;br /&gt;
&lt;br /&gt;
*Call [[ppcs.m]] function&lt;br /&gt;
&lt;br /&gt;
     % PCS calculation&lt;br /&gt;
     point_pcs_co=[[ppcs.m|ppcs]](nxyz,mxyz,chi_co);&lt;br /&gt;
     point_pcs_cu=[[ppcs.m|ppcs]](nxyz,mxyz,chi_cu);&lt;br /&gt;
&lt;br /&gt;
*Print the output to the console&lt;br /&gt;
&lt;br /&gt;
     % Output&lt;br /&gt;
     disp(&amp;#039;Pseudocontact shifts [Co, Cu], ppm&amp;#039;);&lt;br /&gt;
     disp([point_pcs_co point_pcs_cu]);&lt;br /&gt;
&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule:&lt;br /&gt;
&lt;br /&gt;
     PCS [Co, Cu], ppm&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     9.3458   -1.5701&lt;br /&gt;
     9.3458   -1.5701&lt;br /&gt;
     9.3458   -1.5701&lt;br /&gt;
     9.3458   -1.5701&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; PCS fitting using the point dipole approximation=====&lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|&amp;#039;&amp;#039;&amp;#039;Figure 2.&amp;#039;&amp;#039;&amp;#039; Comparison of the point dipole model PCS with the experiment for Tm(III) substituted calbindin D9K.]]&lt;br /&gt;
In this example we will process the experimental PCS data from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63] for calbindin D9K, in which one of the two calcium ions has been replaced by a thulium ion. The corresponding example file is located in nmr_paramag/calbindin directory of the example set supplied with &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The calculation proceeds in the following stages:&lt;br /&gt;
*Import the data. It may be pyped in explicitly, as above. In this case, atomic coordinates and pseudocontact shifts are supplied in a Matlab file:&lt;br /&gt;
&lt;br /&gt;
     % Load experimental data&lt;br /&gt;
     load(&amp;#039;tm_1igv_pcs.mat&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
*Call the point model fit function [[ippcs.m]] with the initial guess of the thulium metal position set to [-5 5 -15]:&lt;br /&gt;
&lt;br /&gt;
     % Solve the inverse problem&lt;br /&gt;
     [mxyz,chi,pred_pcs]=[[ippcs.m|ippcs]]([x y z],[-5 5 -15],expt_pcs);&lt;br /&gt;
&lt;br /&gt;
The other variables are contained in the file loaded in the previous line. In practice, several attempts with different paramagnetic centre location guesses may be necessary.&lt;br /&gt;
&lt;br /&gt;
*Plot the results&lt;br /&gt;
&lt;br /&gt;
     % Plot experimental vs predicted PCS&lt;br /&gt;
     figure(); plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;); hold on; grid on;&lt;br /&gt;
     plot([min(expt_pcs) max(expt_pcs)],[min(expt_pcs) max(expt_pcs)],&amp;#039;r-&amp;#039;);&lt;br /&gt;
     xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;); ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
*Print the position of Tm and the traceless part of the magnetic susceptibility tensor in molecular frame&lt;br /&gt;
&lt;br /&gt;
     % Report the parameters&lt;br /&gt;
     disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
     disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
&lt;br /&gt;
The output appears below:&lt;br /&gt;
&lt;br /&gt;
     Susceptibility tensor:&lt;br /&gt;
         0.0585   -0.0878    0.0729&lt;br /&gt;
        -0.0878   -0.0773    0.0341&lt;br /&gt;
         0.0729    0.0341    0.0189&lt;br /&gt;
     &lt;br /&gt;
     Point electron location:&lt;br /&gt;
         3.6610   17.7074   15.4140&lt;br /&gt;
&lt;br /&gt;
It is clear from the figure that the point dipole model does fit the data, but does not fit it particularly well.&lt;br /&gt;
&lt;br /&gt;
==Magnetic multipole approximation==&lt;br /&gt;
The next level of theory that improves on the point dipole approximation is based on the spherical harmonic expansion of the electron probability density:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\rho \left( \mathbf{r} \right)=\sum\limits_{l,m}{\alpha _{l}^{m}\left( r \right)Y_{l}^{m}\left( \theta ,\varphi  \right)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It works for nuclei positioned outside the bounding sphere of the electron probability density. PCS calculation is performed using [[lpcs.m]] function and the fitting is performed using [[ilpcs.m]] function. In both cases, the list of &amp;lt;math&amp;gt;l&amp;lt;/math&amp;gt; ranks to be included into the expansion must be supplied by the user.&lt;br /&gt;
 &lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Computing PCS using the multipole model=====&lt;br /&gt;
The spin density in the copper porphyrin from Example 1a is clearly not a point object; some density is located on the nitrogen atoms because the corresponding isotropic hyperfine couplings are clearly visible in ESR spectra. If the spin populations on all relevant atoms are known (for example, from electronic structure theory calculations, or as fitting parameters), the multipole moments of the overall distribution may be estimated using [[points2mult.m]] function. If the spin density is given on a 3D grid, the same function would calculate its multipole moments by numerical integration. A typical calculation would proceed in the following stages:&lt;br /&gt;
&lt;br /&gt;
*Specify nuclear coordinates and the corresponding Mulliken spin populations:&lt;br /&gt;
&lt;br /&gt;
     % Nuclear coordinates&lt;br /&gt;
     xyz=[ 0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
          -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
           1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
          -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
           1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
 &lt;br /&gt;
     % Multipole centre coordinates&lt;br /&gt;
     mxyz=[0 0 0];&lt;br /&gt;
  &lt;br /&gt;
     % Mulliken spin populations&lt;br /&gt;
     rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
*Compute multipole moments relative to the centre, in this case up to spherical harmonic rank 14&lt;br /&gt;
&lt;br /&gt;
     % Compute multipole moments&lt;br /&gt;
     Ilm=[[points2mult.m|points2mult]](xyz,mxyz,rho,0:14,&amp;#039;points&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
*Get the susceptibility tensor from the &amp;#039;&amp;#039;g&amp;#039;&amp;#039;-tensor&lt;br /&gt;
&lt;br /&gt;
     % Cu(II) g-tensor&lt;br /&gt;
     g_cu=diag([2.0 2.0 2.2]);&lt;br /&gt;
 &lt;br /&gt;
     % Curie susceptibility tensor&lt;br /&gt;
     chi_cu=[[g2chi.m|g2chi]](g_cu,298);&lt;br /&gt;
&lt;br /&gt;
*Compute PCS using the multipole moments&lt;br /&gt;
&lt;br /&gt;
     % Get the pseudocontact shifts&lt;br /&gt;
     theor_pcs=[[lpcs.m|lpcs]](nxyz,mxyz,0:14,Ilm,chi_cu)&lt;br /&gt;
&lt;br /&gt;
A visual inspection of the resulting PCS values shows that the effect of the spin delocalisation on the PCS is significant: the point dipole model predicts shifts at -1.00 and -1.57 ppm, and the multipole model at -1.21 and -1.81 ppm, respectively. This example is located in nmr_paramag directory of the example set supplied with &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Fitting PCS to the multipole model=====&lt;br /&gt;
[[File:calb_pcs_mult.png|right|thumb|300px|alt=Alt text|&amp;#039;&amp;#039;&amp;#039;Figure 3.&amp;#039;&amp;#039;&amp;#039; Comparison of the multipole model PCS with the experiment for Tm(III) substituted calbindin D9K.]]&lt;br /&gt;
Fitting experimental data to the multipole model can account for the possible mobility of the lanthanide centre; this is often the case in proteins. If we repeat Example 1b identically, except for the solver line:&lt;br /&gt;
&lt;br /&gt;
     % Solve the inverse problem&lt;br /&gt;
     [mxyz,chi,~,pred_pcs]=[[ilpcs.m|ilpcs]]([x y z],expt_pcs,[0 1 2],[-5 5 -15]);&lt;br /&gt;
&lt;br /&gt;
where now the fit is to the multipole model with up to the second spherical rank in the probability density distribution, we would see a much better fit - the residual drops by almost a factor of three. Specifying &amp;lt;math&amp;gt;l=\left[ \begin{matrix} 0 &amp;amp; 1 &amp;amp; 2 \end{matrix} \right]&amp;lt;/math&amp;gt; is typically sufficient; &amp;lt;math&amp;gt;l=0&amp;lt;/math&amp;gt; makes the calculation equivalent to the point dipole approximation. Spherical ranks higher than 4 are not well constrained by fitting.&lt;br /&gt;
&lt;br /&gt;
==Using hyperfine tensors from electronic structure theory==&lt;br /&gt;
Another way to account for the paramagnetic centre delocalisation is to use hyperfine tensors obtained from electronic structure theory calculations. Those are integrals over the unpaired electron probability density and therefore include all delocalisation effects. Only anisotropic part of the hyperfine tensor affects the PCS; for light nuclei it is just the dipolar hyperfine interaction, for heavy elements the orbital part also contributes.&lt;br /&gt;
&lt;br /&gt;
Spinach has two electronic structure theory package parsers: [[gparse.m]] for outputs from &amp;#039;&amp;#039;Gaussian&amp;#039;&amp;#039; and [[oparse.m]] for outputs from &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039;. Both extract hyperfine tensors from the logs produced by the program. The function [[hfc2pcs.m]] then computes PCS by multiplying the traceless part of the hyperfine tensor by the traceless part of the susceptibility tensor and taking the trace of the result. To keep the traces (and therefore the contact part of the full paramagnetic shift), use [[hfc2pms.m]] function. The general equation is:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\sigma _{\text{CS}}^{\left( k \right)}+\sigma _{\text{PCS}}^{\left( k \right)}=-\frac{1}{3}\text{Tr}\left[ \frac{{{\mathbf{A}}^{\left( k \right)}}\cdot \boldsymbol{\chi }}{{{\mu }_{0}}{{\gamma }_{\text{e}}}\gamma _{\text{n}}^{\left( k \right)}\hbar } \right]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See http://dx.doi.org/10.1039/C4CP03106G for further information. Note that this method essentially requires the molecule to be rigid; realistically, it is only applicable to small molecules, for which it is strongly recommended. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; Computing PCS using hyperfine tensors from DFT=====&lt;br /&gt;
You should refer to &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; and &amp;#039;&amp;#039;Gaussian&amp;#039;&amp;#039; manuals to find out how to calculate hyperfine tensors. An example &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; output file is located in the nmr_paramag folder of the example set supplied with &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;. The calculation proceeds in the following stages:&lt;br /&gt;
&lt;br /&gt;
*&amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; log file is parsed by &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
    % Parse the ORCA log&lt;br /&gt;
    props=oparse(&amp;#039;cu_porph_hfc.out&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
*Relevant hyperfine tensors are extracted:&lt;br /&gt;
&lt;br /&gt;
    % Extract hyperfine tensors&lt;br /&gt;
    hfcs=props.hfc.full.matrix(26:37);&lt;br /&gt;
&lt;br /&gt;
*PCS values are computed&lt;br /&gt;
&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    for n=1:numel(hfcs)&lt;br /&gt;
         hfc_pcs_cu(n)=hfc2pcs(gauss2mhz(hfcs{n}),chi_cu,&amp;#039;1H&amp;#039;);&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The same susceptibility tensor as in Examples 1a and 2a is used here. The point model in Example 1a was predicting PCS at -1.00 and -1.57 ppm; the multipole model in Example 2a put the PCS at -1.21 and -1.81 ppm; DFT hyperfines give even larger PCS values: -1.53 and -1.90 ppm.&lt;br /&gt;
&lt;br /&gt;
==Distributed paramagnetic centre model==&lt;br /&gt;
The most general approach that works for any paramagnetic centre probability distribution is based on the partial differential equation obeyed by the pseudocontact shift, described in http://dx.doi.org/10.1039/C4CP03106G and implemented in the functions [[kpcs.m]] for the direct problems, and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the probability density defined on three-dimensional grids. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 4a.&amp;#039;&amp;#039; Computing PCS using DFT spin density=====&lt;br /&gt;
[[File:cu_porph_sd1.png|thumb|300px|&amp;#039;&amp;#039;&amp;#039;Figure 4.&amp;#039;&amp;#039;&amp;#039; DFT spin density of Cu(II) porphyrin.]]&lt;br /&gt;
[[File:cu_porph_sd.png|thumb|300px|&amp;#039;&amp;#039;&amp;#039;Figure 5.&amp;#039;&amp;#039;&amp;#039; PCS field of Cu(II) porphyrin.]]&lt;br /&gt;
You should refer to &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; and &amp;#039;&amp;#039;Gaussian&amp;#039;&amp;#039; manuals to find out how to calculate spin density cubes. An example &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; cube is located in the nmr_paramag folder of the example set supplied with Spinach. The calculation proceeds in the following stages (some of the parameters have already been computed in Examples 2a and 3a): &lt;br /&gt;
&lt;br /&gt;
* An &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; spin density cube is parsed by &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; and padded&lt;br /&gt;
&lt;br /&gt;
    % Parse ORCA cube and pad the density with zeros to avoid PBC effects &lt;br /&gt;
    pad_size=2; [density,ext]=[[ocparse.m|ocparse]](&amp;#039;cu_porph_sd80.spindens.3d&amp;#039;,pad_size);&lt;br /&gt;
&lt;br /&gt;
* Charnock-Kuprov equation is solved:&lt;br /&gt;
&lt;br /&gt;
    % Solve Kuprov equation&lt;br /&gt;
    [pde_pcs_cu,pcs_cube]=[[kpcs.m|kpcs]](density,chi_cu,ext,nxyz,&amp;#039;fft&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
The partial differential equation is solved using the Fourier transform, and the spin density cube therefore requires padding by zeros on all sides to avoid self-interaction artefacts from the periodic boundary conditions - hence the pad argument in [[ocparse.m]] function.&lt;br /&gt;
&lt;br /&gt;
Comparison of the PCS from the DFT hyperfine and from the partial differential equation (PDE) with imported DFT spin density defined on 80x80x80 grid shows the good agreement (-1.53 -1.90 ppm from DFT and -1.43 -1.84 ppm from PDE). Using this method one can compute DFT spin density for a small subsystem (i.e. protein active site) and recompute PCS in full system (entire protein) using [[kpcs.m]] without a need to do DFT for the full system.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 4b.&amp;#039;&amp;#039; Reconstructing PCS tag distributions in proteins===== &lt;br /&gt;
When pseudocontact shifts and the corresponding nuclear coordinates are available, it is possible to approximately reconstruct the three-dimensional probability density of the paramagnetic centre that generated the pseudocontact shifts. The particulars are given in the forthcoming paper from the IK group; multiple examples are available in nmr_paramag/calbindin and nmr_paramag/carb_anh directories of the standard example set supplied with &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;. The primary function involved is [[ipcs.m]]; this section contains some practical advice on using it. A typical reconstruction run would proceed in the following stages:&lt;br /&gt;
&lt;br /&gt;
1. &amp;#039;&amp;#039;&amp;#039;Compile the primary data.&amp;#039;&amp;#039;&amp;#039; You will need the following: (a) Cartesian coordinates of the nuclei for which the PCS is measured, as Nx3 array in Matlab - call this array &amp;#039;xyz&amp;#039;; (b) Cartesian coordinates of all atoms in the molecule, as Mx3 array in Matlab - call this array &amp;#039;xyz_all&amp;#039;; (c) Pseudocontact shifts, in the same order as the coordinates in &amp;#039;xyz&amp;#039; variable, as Nx1 vector. Include all pseudocontact shifts that you managed to measure, including those in the immediate vicinity of the paramagnetic centre.&lt;br /&gt;
&lt;br /&gt;
2. &amp;#039;&amp;#039;&amp;#039;Locate the paramagnetic centre.&amp;#039;&amp;#039;&amp;#039; You likely have an approximate idea of where your paramagnetic centre is located. Use that location as the initial guess for the point dipole model fit, for example:&lt;br /&gt;
&lt;br /&gt;
     [mxyz,chi,pred_pcs]=[[ippcs.m|ippcs]](xyz,[-27.0  13.0  18.0],expt_pcs);&lt;br /&gt;
&lt;br /&gt;
Optionally, plot the theoretical against the experimental PCS, for example:&lt;br /&gt;
&lt;br /&gt;
     figure(); plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;); hold on; grid on;&lt;br /&gt;
     plot([min(expt_pcs) max(expt_pcs)],[min(expt_pcs) max(expt_pcs)],&amp;#039;r-&amp;#039;);&lt;br /&gt;
     xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;); ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
If the fit is very poor, re-run from a different initial guess for the metal position. Even the best point model fit probably isn&amp;#039;t particularly good, or you wouldn&amp;#039;t be reading this, but it would give you a better idea of where your paramagnetic centre roughly is.&lt;br /&gt;
&lt;br /&gt;
3. &amp;#039;&amp;#039;&amp;#039;Run the multipolar fit.&amp;#039;&amp;#039;&amp;#039; Use the paramagnetic centre position from the previous stage as the initial guess, for example:&lt;br /&gt;
&lt;br /&gt;
     [mxyz,chi,~,pred_pcs]=[[ilpcs.m|ilpcs]](xyz,expt_pcs,[0 1 2],[-27.0  13.0  18.0]);&lt;br /&gt;
&lt;br /&gt;
Optionally, plot the theoretical against the experimental PCS again, for example:&lt;br /&gt;
&lt;br /&gt;
     figure(); plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;); hold on; grid on;&lt;br /&gt;
     plot([min(expt_pcs) max(expt_pcs)],[min(expt_pcs) max(expt_pcs)],&amp;#039;r-&amp;#039;);&lt;br /&gt;
     xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;); ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
The fit would likely be much improved - Figure 6 below provides an illustration. &lt;br /&gt;
[[File:multipolar_vs_point_pcs.png|center|frame|&amp;#039;&amp;#039;&amp;#039;Figure 6.&amp;#039;&amp;#039;&amp;#039; Comparison of the point model fit (left) with the multipolar model fit (right) for a mutant of human carbonic anhydrase.]]&lt;br /&gt;
The important parameters to keep at this point are the effective magnetic susceptibility tensor (&amp;#039;chi&amp;#039;) and the magnetic multipole centre (&amp;#039;mxyz&amp;#039;).&lt;br /&gt;
&lt;br /&gt;
4. &amp;#039;&amp;#039;&amp;#039;Run the draft three-dimensional reconstruction.&amp;#039;&amp;#039;&amp;#039; The [[ipcs.m]] function performing three-dimensional reconstructions is very rich in options; it is recommended that you read its manual section carefully. The following options are recommended:&lt;br /&gt;
&lt;br /&gt;
     % Set inverse problem parameters&lt;br /&gt;
     parameters.plot={&amp;#039;diagnostics&amp;#039;,&amp;#039;density&amp;#039;,&amp;#039;molecule&amp;#039;,&amp;#039;tightzoom&amp;#039;,&amp;#039;box&amp;#039;};&lt;br /&gt;
     parameters.box_cent=[### ### ###];&lt;br /&gt;
     parameters.box_size=[ 25.0 25.0 25.0];&lt;br /&gt;
     parameters.margins=50*ones(1,6);&lt;br /&gt;
     parameters.confine=[2.0 12.0];&lt;br /&gt;
     parameters.sharpen=0.0;&lt;br /&gt;
     parameters.xyz_all=xyz_all;&lt;br /&gt;
     parameters.expt_pcs=expt_pcs;&lt;br /&gt;
     parameters.xyz=xyz;&lt;br /&gt;
     parameters.chi=chi;&lt;br /&gt;
     parameters.gpu=0;&lt;br /&gt;
&lt;br /&gt;
*The first line tells &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; to produce maximum visual output - see [[ipcs.m]] options for further details.&lt;br /&gt;
*The second one specifies the coordinates of the centre of the source box in Angstrom - use the multipole coordinates from the previous stage here. &lt;br /&gt;
*The third line specifies the size of the source box in Angstrom - set the three numbers to the suspected width of your distribution; 25 Angstrom is usually sufficient. &lt;br /&gt;
*The fourth line deals with preventing the periodic boundary condition effects from appearing - it tells &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; to run the solver with the box that has been padded with 50 Angstroms of zeros on each side; that is normally sufficient. &lt;br /&gt;
*The fifth line tells &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; to confine the solution space to include all points that are &amp;#039;&amp;#039;at least&amp;#039;&amp;#039; 2.0 Angstroms away from any atom in &amp;#039;xyz_all&amp;#039; and &amp;#039;&amp;#039;at most&amp;#039;&amp;#039; 12.0 Angstrom from the nearest atom in &amp;#039;xyz_all&amp;#039;. This corresponds to the set of physically realistic positions of a lanthanide atom in a spin label attached to the protein surface. If you are reconstructing the distribution of the lanthanide that is internal to the structure, you would need to reduce the first number.&lt;br /&gt;
*The sixth line switches off source sharpening - a penalty functional that drives values below average to zero and values above average to infinity. Increase the coefficient if you have minor low-amplitude clouds in your solution, but remember that this algorithm is hard to justify on physical grounds.&lt;br /&gt;
* Lines 7-10 simply provide the information we already have from the previous sections.&lt;br /&gt;
* The last line may be used to enable GPU processing if you have an NVidia GPU. It assumes that you have no NVidia GPUs in the system. If you do, set the value to 1; the calculations would go faster on any serious gaming card and &amp;#039;&amp;#039;massively&amp;#039;&amp;#039; faster if you have a Tesla coprocessor installed.&lt;br /&gt;
&lt;br /&gt;
Run a rough reconstruction with these options;&lt;br /&gt;
&lt;br /&gt;
     [source_cube,ranges]=ipcs(parameters,64,0.125);&lt;br /&gt;
&lt;br /&gt;
where 64 is the number of points in each direction of the grid and 0.125 is a fairly typical value of the Tikhonov regularisation parameter. Visually inspect the answer (see Figure 7 below for an example). &lt;br /&gt;
[[File:moving_the_cube.png|center|frame|&amp;#039;&amp;#039;&amp;#039;Figure 7.&amp;#039;&amp;#039;&amp;#039; Centering the variational cube during the draft reconstruction process. &amp;#039;&amp;#039;&amp;#039;Left:&amp;#039;&amp;#039;&amp;#039; the density is smeared along one of the cube sides, the cube must be moved right. &amp;#039;&amp;#039;&amp;#039;Right:&amp;#039;&amp;#039;&amp;#039; correctly positioned variational cube.]]&lt;br /&gt;
If the red cloud is smudged against any side of the cube, move it in that direction. Increase and shrink the cube as necessary until the red cloud sits comfortably within it.&lt;br /&gt;
&lt;br /&gt;
5. &amp;#039;&amp;#039;&amp;#039;Run the L-curve analysis.&amp;#039;&amp;#039;&amp;#039; Double the size of the cube on every direction and run the reconstruction process multiple times, recording the value of the least squares penalty and the Tikhonov regularisation penalty for a range of regularisation parameters. There are multiple examples in the standard example set, the following is typical:&lt;br /&gt;
&lt;br /&gt;
     % Regularisation parameter array&lt;br /&gt;
     lam=10.^linspace(-2.0,2.0,30);&lt;br /&gt;
 &lt;br /&gt;
     % Result arrays&lt;br /&gt;
     err=zeros(30,1); reg=zeros(30,1);&lt;br /&gt;
 &lt;br /&gt;
     % Run a parallel loop&lt;br /&gt;
     parfor n=1:30 %#ok&amp;lt;*PFOUS,*PFBNS&amp;gt;&lt;br /&gt;
         [~,~,~,err(n),~,reg(n)]=[[ipcs.m|ipcs]](parameters,64,lam(n));&lt;br /&gt;
         reg(n)=reg(n)/lam(n);&lt;br /&gt;
     end&lt;br /&gt;
 &lt;br /&gt;
     % L-curve analysis&lt;br /&gt;
     figure(); S=[[lcurve.m|lcurve]](lam,err,reg,&amp;#039;log&amp;#039;);&lt;br /&gt;
     disp([&amp;#039;Optimum smoothing parameter: &amp;#039; num2str(S)]);&lt;br /&gt;
&lt;br /&gt;
The optimum value of the regularisation parameter corresponds to the point of maximum curvature on the L-curve. A typical example appears in Figure 8 below.&lt;br /&gt;
[[File:lcurve.png|center|frame|&amp;#039;&amp;#039;&amp;#039;Figure 8.&amp;#039;&amp;#039;&amp;#039; A typical L-curve with the maximum curvature point indicated by a red circle.]]&lt;br /&gt;
&lt;br /&gt;
6. &amp;#039;&amp;#039;&amp;#039;Run the accurate reconstruction.&amp;#039;&amp;#039;&amp;#039; Use the optimal value of the Tikhonov regularisation parameter to run the reconstruction on a finer grid. An iterative approach is suggested, for example:&lt;br /&gt;
&lt;br /&gt;
     % Solve and refine the grid&lt;br /&gt;
     for n=[64 128 256]&lt;br /&gt;
         [source_cube,ranges]=[[ipcs.m|ipcs]](parameters,n,0.125);&lt;br /&gt;
         parameters.guess=source_cube;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
At the end of the calculation (very long if you don&amp;#039;t have a Tesla card) you will obtain a high quality reconstruction.&lt;br /&gt;
&lt;br /&gt;
7. &amp;#039;&amp;#039;&amp;#039;Refine the effective susceptibility tensor.&amp;#039;&amp;#039;&amp;#039; Optionally, &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; can now use your probability density to update the susceptibility tensor that you have obtained from the multipolar fit. Run the following call:&lt;br /&gt;
&lt;br /&gt;
     [chi,~]=[[chi_eff.m|chi_eff]](source_cube,ranges,xyz,expt_pcs);&lt;br /&gt;
&lt;br /&gt;
to obtain your new susceptibility tensor. If it is significantly different from the previous one, repeat Steps 6 and 7 until self-consistency is achieved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Version 1.9, authors: [[Elizaveta Suturina]], [[Ilya Kuprov]]&amp;#039;&amp;#039;&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1916</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1916"/>
		<updated>2017-01-06T10:56:14Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Point dipole approximation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial page that goes through the different types of pseudocontact shift analysis that are available in &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;. It also summarises basic facts from the theory of pseudocontact shift. Please refer to our [[Appendix_C:_literature_citations|recent publications]] on the subject for the technical details of the three-dimensional PCS analysis process, and to standard reviews (from Florence and Otting groups) for the point PCS model description.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
The presence of rapidly relaxing unpaired electrons generates extra nuclear chemical shifts (called paramagnetic shifts) because the unpaired electrons respond nearly instantaneoulsy to the changes in the applied magnetic field and therefore provide additional nuclear shielding that is much stronger then what would be available from a closed-shell electronic structure. Paramagnetic chemical shift has two contributions:&lt;br /&gt;
&lt;br /&gt;
# Contact shift, which arises from the isotropic part of the hyperfine coupling between the electrons and the nuclei located in their close vicinity (typically less than 5 Angstrom).&lt;br /&gt;
# Pseudocontact shift, which is generated by the long-range (up to 50 Angstroms) electron-nuclear dipolar interaction.&lt;br /&gt;
&lt;br /&gt;
Both contributions may be obtained from classical physics expressions if the electron-nuclear hyperfine coupling tensor and the electron magnetic susceptibiity tensors are known. The contact shift depends on the isotropic part of the magnetic susceptibility tensor, and the pseudocontact shift on the anisotropic part.&lt;br /&gt;
&lt;br /&gt;
==Point dipole approximation==&lt;br /&gt;
This is historically the first and the simplest approach. It is based on the point dipole approximation for the electron. The expression for the pseudocontact shift for a nucleus at position &amp;lt;math&amp;gt;\mathbf{r}&amp;lt;/math&amp;gt; relative to the electron with a magnetic susceptibility tensor &amp;lt;math&amp;gt;\mathbf{\chi }&amp;lt;/math&amp;gt; is: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\sigma =\frac{1}{4\pi {{r}^{3}}}\text{Tr}\left[ \left( \frac{\mathbf{r}\otimes {{\mathbf{r}}^{\text{T}}}}{{{r}^{2}}}-\frac{1}{3} \right)\cdot \mathbf{\chi } \right]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This approach is valid for the distances at which the paramagnetic centre may be viewed as a point - typically at least 10 Angstroms away. The PCS of any nuclei located at closer distances would not fit this model. The &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; function that calculates pseudocontact shifts from user-specified coordinates and electron susceptibility tensors is [[ppcs.m]]. The function that extracts the paramagnetic centre position and the susceptibility tensor from user-specified nuclear coordinates and pseudocontact shifts using the point electron model is [[ippcs.m]].&lt;br /&gt;
&lt;br /&gt;
Note that the magnetic susceptibility tensor may be estimated from the g-tensor for S=1/2 using the following expression:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The function that performs this estimation for an arbitary g-tensor is [[g2chi.m]]. The resulting estimate is only valid at high temperature.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; PCS calculation using the point dipole approximation=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|&amp;#039;&amp;#039;&amp;#039;Figure 1.&amp;#039;&amp;#039;&amp;#039; Structure of metal porphyrin. Colour code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we compute the PCS on the protons of a Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS. The following steps should be taken:&lt;br /&gt;
&lt;br /&gt;
*Specify the coordinates of all protons:&lt;br /&gt;
&lt;br /&gt;
     % Porphyrin ring proton coordinates&lt;br /&gt;
     nxyz=[ 4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
&lt;br /&gt;
*Specify (or compute from the &amp;#039;&amp;#039;g&amp;#039;&amp;#039;-tensor) the susceptibility tensor (cubic Angstrom) in the same coordinate system as the one used for the proton coordinates above:&lt;br /&gt;
&lt;br /&gt;
     % Co(II) g-tensor&lt;br /&gt;
     g_co=diag([3.0 3.0 2.0]);&lt;br /&gt;
 &lt;br /&gt;
     % Cu(II) g-tensor&lt;br /&gt;
     g_cu=diag([2.0 2.0 2.2]);&lt;br /&gt;
 &lt;br /&gt;
     % Curie susceptibility tensors&lt;br /&gt;
     chi_co=[[g2chi.m|g2chi]](g_co,298);&lt;br /&gt;
     chi_cu=[[g2chi.m|g2chi]](g_cu,298);&lt;br /&gt;
&lt;br /&gt;
*Specify the metal position&lt;br /&gt;
      &lt;br /&gt;
     % Metal position &lt;br /&gt;
     mxyz=[0 0 0];&lt;br /&gt;
&lt;br /&gt;
*Call [[ppcs.m]] function&lt;br /&gt;
&lt;br /&gt;
     % PCS calculation&lt;br /&gt;
     point_pcs_co=[[ppcs.m|ppcs]](nxyz,mxyz,chi_co);&lt;br /&gt;
     point_pcs_cu=[[ppcs.m|ppcs]](nxyz,mxyz,chi_cu);&lt;br /&gt;
&lt;br /&gt;
*Print the output to the console&lt;br /&gt;
&lt;br /&gt;
     % Output&lt;br /&gt;
     disp(&amp;#039;Pseudocontact shifts [Co, Cu], ppm&amp;#039;);&lt;br /&gt;
     disp([point_pcs_co point_pcs_cu]);&lt;br /&gt;
&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule:&lt;br /&gt;
&lt;br /&gt;
     PCS [Co, Cu], ppm&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     5.9471   -0.9991&lt;br /&gt;
     9.3458   -1.5701&lt;br /&gt;
     9.3458   -1.5701&lt;br /&gt;
     9.3458   -1.5701&lt;br /&gt;
     9.3458   -1.5701&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; PCS fitting using the point dipole approximation=====&lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|&amp;#039;&amp;#039;&amp;#039;Figure 2.&amp;#039;&amp;#039;&amp;#039; Comparison of the point dipole model PCS with the experiment for Tm(III) substituted calbindin D9K.]]&lt;br /&gt;
In this example we will process the experimental PCS data from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63] for calbindin D9K, in which one of the two calcium ions has been replaced by a thulium ion. The corresponding example file is located in nmr_paramag/calbindin directory of the example set supplied with &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The calculation proceeds in the following stages:&lt;br /&gt;
*Import the data. It may be pyped in explicitly, as above. In this case, atomic coordinates and pseudocontact shifts are supplied in a Matlab file:&lt;br /&gt;
&lt;br /&gt;
     % Load experimental data&lt;br /&gt;
     load(&amp;#039;tm_1igv_pcs.mat&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
*Call the point model fit function [[ippcs.m]] with the initial guess of the thulium metal position set to [-5 5 -15]:&lt;br /&gt;
&lt;br /&gt;
     % Solve the inverse problem&lt;br /&gt;
     [mxyz,chi,pred_pcs]=[[ippcs.m|ippcs]]([x y z],[-5 5 -15],expt_pcs);&lt;br /&gt;
&lt;br /&gt;
The other variables are contained in the file loaded in the previous line. In practice, several attempts with different paramagnetic centre location guesses may be necessary.&lt;br /&gt;
&lt;br /&gt;
*Plot the results&lt;br /&gt;
&lt;br /&gt;
     % Plot experimental vs predicted PCS&lt;br /&gt;
     figure(); plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;); hold on; grid on;&lt;br /&gt;
     plot([min(expt_pcs) max(expt_pcs)],[min(expt_pcs) max(expt_pcs)],&amp;#039;r-&amp;#039;);&lt;br /&gt;
     xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;); ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
*Print the position of Tm and the traceless part of the magnetic susceptibility tensor in molecular frame&lt;br /&gt;
&lt;br /&gt;
     % Report the parameters&lt;br /&gt;
     disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
     disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
&lt;br /&gt;
The output appears below:&lt;br /&gt;
&lt;br /&gt;
     Susceptibility tensor:&lt;br /&gt;
         0.0585   -0.0878    0.0729&lt;br /&gt;
        -0.0878   -0.0773    0.0341&lt;br /&gt;
         0.0729    0.0341    0.0189&lt;br /&gt;
     &lt;br /&gt;
     Point electron location:&lt;br /&gt;
         3.6610   17.7074   15.4140&lt;br /&gt;
&lt;br /&gt;
It is clear from the figure that the point dipole model does fit the data, but does not fit it particularly well.&lt;br /&gt;
&lt;br /&gt;
==Magnetic multipole approximation==&lt;br /&gt;
The next level of theory that improves on the point dipole approximation is based on the spherical harmonic expansion of the electron probability density:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\rho \left( \mathbf{r} \right)=\sum\limits_{l,m}{\alpha _{l}^{m}\left( r \right)Y_{l}^{m}\left( \theta ,\varphi  \right)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It works for nuclei positioned outside the bounding sphere of the electron probability density. PCS calculation is performed using [[lpcs.m]] function and the fitting is performed using [[ilpcs.m]] function. In both cases, the list of &amp;lt;math&amp;gt;l&amp;lt;/math&amp;gt; ranks to be included into the expansion must be supplied by the user.&lt;br /&gt;
 &lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Computing PCS using the multipole model=====&lt;br /&gt;
The spin density in the copper porphyrin from Example 1a is clearly not a point object; some density is located on the nitrogen atoms because the corresponding isotropic hyperfine couplings are clearly visible in ESR spectra. If the spin populations on all relevant atoms are known (for example, from electronic structure theory calculations, or as fitting parameters), the multipole moments of the overall distribution may be estimated using [[points2mult.m]] function. If the spin density is given on a 3D grid, the same function would calculate its multipole moments by numerical integration. A typical calculation would proceed in the following stages:&lt;br /&gt;
&lt;br /&gt;
*Specify nuclear coordinates and the corresponding Mulliken spin populations:&lt;br /&gt;
&lt;br /&gt;
     % Nuclear coordinates&lt;br /&gt;
     xyz=[ 0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
          -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
           1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
          -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
           1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
 &lt;br /&gt;
     % Multipole centre coordinates&lt;br /&gt;
     mxyz=[0 0 0];&lt;br /&gt;
  &lt;br /&gt;
     % Mulliken spin populations&lt;br /&gt;
     rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
*Compute multipole moments relative to the centre, in this case up to spherical harmonic rank 14&lt;br /&gt;
&lt;br /&gt;
     % Compute multipole moments&lt;br /&gt;
     Ilm=[[points2mult.m|points2mult]](xyz,mxyz,rho,0:14,&amp;#039;points&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
*Get the susceptibility tensor from the &amp;#039;&amp;#039;g&amp;#039;&amp;#039;-tensor&lt;br /&gt;
&lt;br /&gt;
     % Cu(II) g-tensor&lt;br /&gt;
     g_cu=diag([2.0 2.0 2.2]);&lt;br /&gt;
 &lt;br /&gt;
     % Curie susceptibility tensor&lt;br /&gt;
     chi_cu=[[g2chi.m|g2chi]](g_cu,298);&lt;br /&gt;
&lt;br /&gt;
*Compute PCS using the multipole moments&lt;br /&gt;
&lt;br /&gt;
     % Get the pseudocontact shifts&lt;br /&gt;
     theor_pcs=[[lpcs.m|lpcs]](nxyz,mxyz,0:14,Ilm,chi_cu)&lt;br /&gt;
&lt;br /&gt;
A visual inspection of the resulting PCS values shows that the effect of the spin delocalisation on the PCS is significant: the point dipole model predicts shifts at -1.00 and -1.57 ppm, and the multipole model at -1.21 and -1.81 ppm, respectively. This example is located in nmr_paramag directory of the example set supplied with &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Fitting PCS to the multipole model=====&lt;br /&gt;
[[File:calb_pcs_mult.png|right|thumb|300px|alt=Alt text|&amp;#039;&amp;#039;&amp;#039;Figure 3.&amp;#039;&amp;#039;&amp;#039; Comparison of the multipole model PCS with the experiment for Tm(III) substituted calbindin D9K.]]&lt;br /&gt;
Fitting experimental data to the multipole model can account for the possible mobility of the lanthanide centre; this is often the case in proteins. If we repeat Example 1b identically, except for the solver line:&lt;br /&gt;
&lt;br /&gt;
     % Solve the inverse problem&lt;br /&gt;
     [mxyz,chi,~,pred_pcs]=[[ilpcs.m|ilpcs]]([x y z],expt_pcs,[0 1 2],[-5 5 -15]);&lt;br /&gt;
&lt;br /&gt;
where now the fit is to the multipole model with up to the second spherical rank in the probability density distribution, we would see a much better fit - the residual drops by almost a factor of three. Specifying &amp;lt;math&amp;gt;l=\left[ \begin{matrix} 0 &amp;amp; 1 &amp;amp; 2 \end{matrix} \right]&amp;lt;/math&amp;gt; is typically sufficient; &amp;lt;math&amp;gt;l=0&amp;lt;/math&amp;gt; makes the calculation equivalent to the point dipole approximation. Spherical ranks higher than 4 are not well constrained by fitting.&lt;br /&gt;
&lt;br /&gt;
==Using hyperfine tensors from electronic structure theory==&lt;br /&gt;
Another way to account for the paramagnetic centre delocalisation is to use hyperfine tensors obtained from electronic structure theory calculations. Those are integrals over the unpaired electron probability density and therefore include all delocalisation effects. Only anisotropic part of the hyperfine tensor affects the PCS; for light nuclei it is just the dipolar hyperfine interaction, for heavy elements the orbital part also contributes.&lt;br /&gt;
&lt;br /&gt;
Spinach has two electronic structure theory package parsers: [[gparse.m]] for outputs from &amp;#039;&amp;#039;Gaussian&amp;#039;&amp;#039; and [[oparse.m]] for outputs from &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039;. Both extract hyperfine tensors from the logs produced by the program. The function [[hfc2pcs.m]] then computes PCS by multiplying the traceless part of the hyperfine tensor by the traceless part of the susceptibility tensor and taking the trace of the result. To keep the traces (and therefore the contact part of the full paramagnetic shift), use [[hfc2pms.m]] function. The general equation is:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\sigma _{\text{CS}}^{\left( k \right)}+\sigma _{\text{PCS}}^{\left( k \right)}=-\frac{1}{3}\text{Tr}\left[ \frac{{{\mathbf{A}}^{\left( k \right)}}\cdot \mathbf{\chi }}{{{\mu }_{0}}{{\gamma }_{\text{e}}}\gamma _{\text{n}}^{\left( k \right)}\hbar } \right]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See http://dx.doi.org/10.1039/C4CP03106G for further information. Note that this method essentially requires the molecule to be rigid; realistically, it is only applicable to small molecules, for which it is strongly recommended. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; Computing PCS using hyperfine tensors from DFT=====&lt;br /&gt;
You should refer to &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; and &amp;#039;&amp;#039;Gaussian&amp;#039;&amp;#039; manuals to find out how to calculate hyperfine tensors. An example &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; output file is located in the nmr_paramag folder of the example set supplied with &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;. The calculation proceeds in the following stages:&lt;br /&gt;
&lt;br /&gt;
*&amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; log file is parsed by &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
    % Parse the ORCA log&lt;br /&gt;
    props=oparse(&amp;#039;cu_porph_hfc.out&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
*Relevant hyperfine tensors are extracted:&lt;br /&gt;
&lt;br /&gt;
    % Extract hyperfine tensors&lt;br /&gt;
    hfcs=props.hfc.full.matrix(26:37);&lt;br /&gt;
&lt;br /&gt;
*PCS values are computed&lt;br /&gt;
&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    for n=1:numel(hfcs)&lt;br /&gt;
         hfc_pcs_cu(n)=hfc2pcs(gauss2mhz(hfcs{n}),chi_cu,&amp;#039;1H&amp;#039;);&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The same susceptibility tensor as in Examples 1a and 2a is used here. The point model in Example 1a was predicting PCS at -1.00 and -1.57 ppm; the multipole model in Example 2a put the PCS at -1.21 and -1.81 ppm; DFT hyperfines give even larger PCS values: -1.53 and -1.90 ppm.&lt;br /&gt;
&lt;br /&gt;
==Distributed paramagnetic centre model==&lt;br /&gt;
The most general approach that works for any paramagnetic centre probability distribution is based on the partial differential equation obeyed by the pseudocontact shift, described in http://dx.doi.org/10.1039/C4CP03106G and implemented in the functions [[kpcs.m]] for the direct problems, and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the probability density defined on three-dimensional grids. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 4a.&amp;#039;&amp;#039; Computing PCS using DFT spin density=====&lt;br /&gt;
[[File:cu_porph_sd1.png|thumb|300px|&amp;#039;&amp;#039;&amp;#039;Figure 4.&amp;#039;&amp;#039;&amp;#039; DFT spin density of Cu(II) porphyrin.]]&lt;br /&gt;
[[File:cu_porph_sd.png|thumb|300px|&amp;#039;&amp;#039;&amp;#039;Figure 5.&amp;#039;&amp;#039;&amp;#039; PCS field of Cu(II) porphyrin.]]&lt;br /&gt;
You should refer to &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; and &amp;#039;&amp;#039;Gaussian&amp;#039;&amp;#039; manuals to find out how to calculate spin density cubes. An example &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; cube is located in the nmr_paramag folder of the example set supplied with Spinach. The calculation proceeds in the following stages (some of the parameters have already been computed in Examples 2a and 3a): &lt;br /&gt;
&lt;br /&gt;
* An &amp;#039;&amp;#039;ORCA&amp;#039;&amp;#039; spin density cube is parsed by &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; and padded&lt;br /&gt;
&lt;br /&gt;
    % Parse ORCA cube and pad the density with zeros to avoid PBC effects &lt;br /&gt;
    pad_size=2; [density,ext]=[[ocparse.m|ocparse]](&amp;#039;cu_porph_sd80.spindens.3d&amp;#039;,pad_size);&lt;br /&gt;
&lt;br /&gt;
* Charnock-Kuprov equation is solved:&lt;br /&gt;
&lt;br /&gt;
    % Solve Kuprov equation&lt;br /&gt;
    [pde_pcs_cu,pcs_cube]=[[kpcs.m|kpcs]](density,chi_cu,ext,nxyz,&amp;#039;fft&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
The partial differential equation is solved using the Fourier transform, and the spin density cube therefore requires padding by zeros on all sides to avoid self-interaction artefacts from the periodic boundary conditions - hence the pad argument in [[ocparse.m]] function.&lt;br /&gt;
&lt;br /&gt;
Comparison of the PCS from the DFT hyperfine and from the partial differential equation (PDE) with imported DFT spin density defined on 80x80x80 grid shows the good agreement (-1.53 -1.90 ppm from DFT and -1.43 -1.84 ppm from PDE). Using this method one can compute DFT spin density for a small subsystem (i.e. protein active site) and recompute PCS in full system (entire protein) using [[kpcs.m]] without a need to do DFT for the full system.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 4b.&amp;#039;&amp;#039; Reconstructing PCS tag distributions in proteins===== &lt;br /&gt;
When pseudocontact shifts and the corresponding nuclear coordinates are available, it is possible to approximately reconstruct the three-dimensional probability density of the paramagnetic centre that generated the pseudocontact shifts. The particulars are given in the forthcoming paper from the IK group; multiple examples are available in nmr_paramag/calbindin and nmr_paramag/carb_anh directories of the standard example set supplied with &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039;. The primary function involved is [[ipcs.m]]; this section contains some practical advice on using it. A typical reconstruction run would proceed in the following stages:&lt;br /&gt;
&lt;br /&gt;
1. &amp;#039;&amp;#039;&amp;#039;Compile the primary data.&amp;#039;&amp;#039;&amp;#039; You will need the following: (a) Cartesian coordinates of the nuclei for which the PCS is measured, as Nx3 array in Matlab - call this array &amp;#039;xyz&amp;#039;; (b) Cartesian coordinates of all atoms in the molecule, as Mx3 array in Matlab - call this array &amp;#039;xyz_all&amp;#039;; (c) Pseudocontact shifts, in the same order as the coordinates in &amp;#039;xyz&amp;#039; variable, as Nx1 vector. Include all pseudocontact shifts that you managed to measure, including those in the immediate vicinity of the paramagnetic centre.&lt;br /&gt;
&lt;br /&gt;
2. &amp;#039;&amp;#039;&amp;#039;Locate the paramagnetic centre.&amp;#039;&amp;#039;&amp;#039; You likely have an approximate idea of where your paramagnetic centre is located. Use that location as the initial guess for the point dipole model fit, for example:&lt;br /&gt;
&lt;br /&gt;
     [mxyz,chi,pred_pcs]=[[ippcs.m|ippcs]](xyz,[-27.0  13.0  18.0],expt_pcs);&lt;br /&gt;
&lt;br /&gt;
Optionally, plot the theoretical against the experimental PCS, for example:&lt;br /&gt;
&lt;br /&gt;
     figure(); plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;); hold on; grid on;&lt;br /&gt;
     plot([min(expt_pcs) max(expt_pcs)],[min(expt_pcs) max(expt_pcs)],&amp;#039;r-&amp;#039;);&lt;br /&gt;
     xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;); ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
If the fit is very poor, re-run from a different initial guess for the metal position. Even the best point model fit probably isn&amp;#039;t particularly good, or you wouldn&amp;#039;t be reading this, but it would give you a better idea of where your paramagnetic centre roughly is.&lt;br /&gt;
&lt;br /&gt;
3. &amp;#039;&amp;#039;&amp;#039;Run the multipolar fit.&amp;#039;&amp;#039;&amp;#039; Use the paramagnetic centre position from the previous stage as the initial guess, for example:&lt;br /&gt;
&lt;br /&gt;
     [mxyz,chi,~,pred_pcs]=[[ilpcs.m|ilpcs]](xyz,expt_pcs,[0 1 2],[-27.0  13.0  18.0]);&lt;br /&gt;
&lt;br /&gt;
Optionally, plot the theoretical against the experimental PCS again, for example:&lt;br /&gt;
&lt;br /&gt;
     figure(); plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;); hold on; grid on;&lt;br /&gt;
     plot([min(expt_pcs) max(expt_pcs)],[min(expt_pcs) max(expt_pcs)],&amp;#039;r-&amp;#039;);&lt;br /&gt;
     xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;); ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
The fit would likely be much improved - Figure 6 below provides an illustration. &lt;br /&gt;
[[File:multipolar_vs_point_pcs.png|center|frame|&amp;#039;&amp;#039;&amp;#039;Figure 6.&amp;#039;&amp;#039;&amp;#039; Comparison of the point model fit (left) with the multipolar model fit (right) for a mutant of human carbonic anhydrase.]]&lt;br /&gt;
The important parameters to keep at this point are the effective magnetic susceptibility tensor (&amp;#039;chi&amp;#039;) and the magnetic multipole centre (&amp;#039;mxyz&amp;#039;).&lt;br /&gt;
&lt;br /&gt;
4. &amp;#039;&amp;#039;&amp;#039;Run the draft three-dimensional reconstruction.&amp;#039;&amp;#039;&amp;#039; The [[ipcs.m]] function performing three-dimensional reconstructions is very rich in options; it is recommended that you read its manual section carefully. The following options are recommended:&lt;br /&gt;
&lt;br /&gt;
     % Set inverse problem parameters&lt;br /&gt;
     parameters.plot={&amp;#039;diagnostics&amp;#039;,&amp;#039;density&amp;#039;,&amp;#039;molecule&amp;#039;,&amp;#039;tightzoom&amp;#039;,&amp;#039;box&amp;#039;};&lt;br /&gt;
     parameters.box_cent=[### ### ###];&lt;br /&gt;
     parameters.box_size=[ 25.0 25.0 25.0];&lt;br /&gt;
     parameters.margins=50*ones(1,6);&lt;br /&gt;
     parameters.confine=[2.0 12.0];&lt;br /&gt;
     parameters.sharpen=0.0;&lt;br /&gt;
     parameters.xyz_all=xyz_all;&lt;br /&gt;
     parameters.expt_pcs=expt_pcs;&lt;br /&gt;
     parameters.xyz=xyz;&lt;br /&gt;
     parameters.chi=chi;&lt;br /&gt;
     parameters.gpu=0;&lt;br /&gt;
&lt;br /&gt;
*The first line tells &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; to produce maximum visual output - see [[ipcs.m]] options for further details.&lt;br /&gt;
*The second one specifies the coordinates of the centre of the source box in Angstrom - use the multipole coordinates from the previous stage here. &lt;br /&gt;
*The third line specifies the size of the source box in Angstrom - set the three numbers to the suspected width of your distribution; 25 Angstrom is usually sufficient. &lt;br /&gt;
*The fourth line deals with preventing the periodic boundary condition effects from appearing - it tells &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; to run the solver with the box that has been padded with 50 Angstroms of zeros on each side; that is normally sufficient. &lt;br /&gt;
*The fifth line tells &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; to confine the solution space to include all points that are &amp;#039;&amp;#039;at least&amp;#039;&amp;#039; 2.0 Angstroms away from any atom in &amp;#039;xyz_all&amp;#039; and &amp;#039;&amp;#039;at most&amp;#039;&amp;#039; 12.0 Angstrom from the nearest atom in &amp;#039;xyz_all&amp;#039;. This corresponds to the set of physically realistic positions of a lanthanide atom in a spin label attached to the protein surface. If you are reconstructing the distribution of the lanthanide that is internal to the structure, you would need to reduce the first number.&lt;br /&gt;
*The sixth line switches off source sharpening - a penalty functional that drives values below average to zero and values above average to infinity. Increase the coefficient if you have minor low-amplitude clouds in your solution, but remember that this algorithm is hard to justify on physical grounds.&lt;br /&gt;
* Lines 7-10 simply provide the information we already have from the previous sections.&lt;br /&gt;
* The last line may be used to enable GPU processing if you have an NVidia GPU. It assumes that you have no NVidia GPUs in the system. If you do, set the value to 1; the calculations would go faster on any serious gaming card and &amp;#039;&amp;#039;massively&amp;#039;&amp;#039; faster if you have a Tesla coprocessor installed.&lt;br /&gt;
&lt;br /&gt;
Run a rough reconstruction with these options;&lt;br /&gt;
&lt;br /&gt;
     [source_cube,ranges]=ipcs(parameters,64,0.125);&lt;br /&gt;
&lt;br /&gt;
where 64 is the number of points in each direction of the grid and 0.125 is a fairly typical value of the Tikhonov regularisation parameter. Visually inspect the answer (see Figure 7 below for an example). &lt;br /&gt;
[[File:moving_the_cube.png|center|frame|&amp;#039;&amp;#039;&amp;#039;Figure 7.&amp;#039;&amp;#039;&amp;#039; Centering the variational cube during the draft reconstruction process. &amp;#039;&amp;#039;&amp;#039;Left:&amp;#039;&amp;#039;&amp;#039; the density is smeared along one of the cube sides, the cube must be moved right. &amp;#039;&amp;#039;&amp;#039;Right:&amp;#039;&amp;#039;&amp;#039; correctly positioned variational cube.]]&lt;br /&gt;
If the red cloud is smudged against any side of the cube, move it in that direction. Increase and shrink the cube as necessary until the red cloud sits comfortably within it.&lt;br /&gt;
&lt;br /&gt;
5. &amp;#039;&amp;#039;&amp;#039;Run the L-curve analysis.&amp;#039;&amp;#039;&amp;#039; Double the size of the cube on every direction and run the reconstruction process multiple times, recording the value of the least squares penalty and the Tikhonov regularisation penalty for a range of regularisation parameters. There are multiple examples in the standard example set, the following is typical:&lt;br /&gt;
&lt;br /&gt;
     % Regularisation parameter array&lt;br /&gt;
     lam=10.^linspace(-2.0,2.0,30);&lt;br /&gt;
 &lt;br /&gt;
     % Result arrays&lt;br /&gt;
     err=zeros(30,1); reg=zeros(30,1);&lt;br /&gt;
 &lt;br /&gt;
     % Run a parallel loop&lt;br /&gt;
     parfor n=1:30 %#ok&amp;lt;*PFOUS,*PFBNS&amp;gt;&lt;br /&gt;
         [~,~,~,err(n),~,reg(n)]=[[ipcs.m|ipcs]](parameters,64,lam(n));&lt;br /&gt;
         reg(n)=reg(n)/lam(n);&lt;br /&gt;
     end&lt;br /&gt;
 &lt;br /&gt;
     % L-curve analysis&lt;br /&gt;
     figure(); S=[[lcurve.m|lcurve]](lam,err,reg,&amp;#039;log&amp;#039;);&lt;br /&gt;
     disp([&amp;#039;Optimum smoothing parameter: &amp;#039; num2str(S)]);&lt;br /&gt;
&lt;br /&gt;
The optimum value of the regularisation parameter corresponds to the point of maximum curvature on the L-curve. A typical example appears in Figure 8 below.&lt;br /&gt;
[[File:lcurve.png|center|frame|&amp;#039;&amp;#039;&amp;#039;Figure 8.&amp;#039;&amp;#039;&amp;#039; A typical L-curve with the maximum curvature point indicated by a red circle.]]&lt;br /&gt;
&lt;br /&gt;
6. &amp;#039;&amp;#039;&amp;#039;Run the accurate reconstruction.&amp;#039;&amp;#039;&amp;#039; Use the optimal value of the Tikhonov regularisation parameter to run the reconstruction on a finer grid. An iterative approach is suggested, for example:&lt;br /&gt;
&lt;br /&gt;
     % Solve and refine the grid&lt;br /&gt;
     for n=[64 128 256]&lt;br /&gt;
         [source_cube,ranges]=[[ipcs.m|ipcs]](parameters,n,0.125);&lt;br /&gt;
         parameters.guess=source_cube;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
At the end of the calculation (very long if you don&amp;#039;t have a Tesla card) you will obtain a high quality reconstruction.&lt;br /&gt;
&lt;br /&gt;
7. &amp;#039;&amp;#039;&amp;#039;Refine the effective susceptibility tensor.&amp;#039;&amp;#039;&amp;#039; Optionally, &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; can now use your probability density to update the susceptibility tensor that you have obtained from the multipolar fit. Run the following call:&lt;br /&gt;
&lt;br /&gt;
     [chi,~]=[[chi_eff.m|chi_eff]](source_cube,ranges,xyz,expt_pcs);&lt;br /&gt;
&lt;br /&gt;
to obtain your new susceptibility tensor. If it is significantly different from the previous one, repeat Steps 6 and 7 until self-consistency is achieved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Version 1.9, authors: [[Elizaveta Suturina]], [[Ilya Kuprov]]&amp;#039;&amp;#039;&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1323</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1323"/>
		<updated>2016-09-01T14:54:36Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* &amp;quot;Example 4b.&amp;quot; Numerical solution to inverse problem. Calbindin. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy-plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy-axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt; (shown on the left). In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics (the case of limiting rhombisity is shown on the right).&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see http://arxiv.org/abs/1607.08869 for details). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbindin PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    % Parse the ORCA log&lt;br /&gt;
    props=oparse(&amp;#039;cu_porph_hfc.out&amp;#039;);&lt;br /&gt;
    % Extract hyperfine tensors&lt;br /&gt;
    hfcs=props.hfc.full.matrix(26:37);&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    for n=1:numel(hfcs)&lt;br /&gt;
    hfc_pcs_cu(n)=hfc2pcs(gauss2mhz(hfcs{n}),chi_cu,&amp;#039;1H&amp;#039;); %#ok&amp;lt;AGROW&amp;gt;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines give even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;br /&gt;
&lt;br /&gt;
==Distributed model==&lt;br /&gt;
The most general approach that works for any density distribution is described in (http://dx.doi.org/10.1039/C4CP03106G) and implemented in the functions [[kpcs.m]] for the direct problems and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the density distribution defined on three dimensional grid. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 4a&amp;#039;&amp;#039; PCS from DFT spin density. Copper(II) porphyrin=====&lt;br /&gt;
[[File:cu_porph_sd1.png|thumb|300px|alt=Alt text|DFT spin density of Cu(II) porphyrin.]]&lt;br /&gt;
In this example the protons PCS of Copper(II) porphyrin are computed from the spin density generated by DFT using [[kpcs.m]]. ORCA_PLOT offers several options to generate the spin density file. In this example we use the &amp;quot;3D simple format&amp;quot; file &amp;quot;cu_porph_sd80.spindens.3d&amp;quot;. &lt;br /&gt;
To import the density into the format that [[kpcs.m]] needs we do:&lt;br /&gt;
    % Import spin density from ORCA in &amp;quot;3D simple fromat&amp;quot;&lt;br /&gt;
    A=importdata(&amp;#039;cu_porph_sd80.spindens.3d&amp;#039;);&lt;br /&gt;
    % read number of points along [x y z]&lt;br /&gt;
    dim=str2num(A.textdata{2});&lt;br /&gt;
    % read coordinates of the corner &lt;br /&gt;
    min=str2num(A.textdata{3});&lt;br /&gt;
    % read step size [dx dy dz]&lt;br /&gt;
    d3r=str2num(A.textdata{4});&lt;br /&gt;
    % form the absolute density cube&lt;br /&gt;
    density=reshape(abs(A.data),dim(2),dim(3),dim(1));&lt;br /&gt;
    density=permute(density,[2 3 1]);&lt;br /&gt;
    % normalize the density&lt;br /&gt;
    density=density/(simps(simps(simps(density)))*prod(d3r));&lt;br /&gt;
    % compute extents&lt;br /&gt;
    ext=[min(1) (min(1)+(dim(1)-1)*d3r(1))...&lt;br /&gt;
         min(2) (min(2)+(dim(2)-1)*d3r(2))...&lt;br /&gt;
         min(3) (min(3)+(dim(3)-1)*d3r(3))];&lt;br /&gt;
The numerical costs for [[kpcs.m]] are defined by the grid size. New version of [[kpcs.m]] uses the fast Fourier transform (FFT) method that improves the scaling significantly (for details see http://arxiv.org/abs/1607.08869). FFT has the periodic boundary conditions (PBC), therefore we have to make sure that borders are far enough from the molecule by padding the density array with zeros:&lt;br /&gt;
&lt;br /&gt;
    % Pad the density with zeros to avoid PBC effects&lt;br /&gt;
    pad_size=2;&lt;br /&gt;
    pad_density=padarray(density,pad_size*size(density),0,&amp;#039;both&amp;#039;);&lt;br /&gt;
    pad_ext=(2*pad_size+1)*ext;&lt;br /&gt;
&lt;br /&gt;
The actual calculation takes place here:&lt;br /&gt;
    % Solve PDE using FFT&lt;br /&gt;
   [pde_pcs_cu,pcs_cube]=kpcs(pad_density,chi_cu,pad_ext,nxyz,&amp;#039;fft&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
Comparison of the PCS from the DFT hyperfine and from the partial differential equation (PDE) with imported DFT spin density defined on 80x80x80 grid&lt;br /&gt;
   % Compare HFC PCS with PDE PCS&lt;br /&gt;
   disp(&amp;#039;Pseudocontact shifts [hfc, pde], ppm&amp;#039;);&lt;br /&gt;
   disp([hfc_pcs_cu&amp;#039; pde_pcs_cu]);&lt;br /&gt;
shows the good agreement (-1.53 -1.90 ppm from DFT and -1.43 -1.84 ppm from PDE). Using this method one can compute DFT spin density for a small subsystem (i.e. protein active cite) and recompute PCS in full system (entire protein) using [[kpcs.m]] without a need to do DFT for the full system.&lt;br /&gt;
[[File:cu_porph_sd.png|center|thumb|500px|PCS field of Cu(II) porphyrin.]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 4b.&amp;#039;&amp;#039; Numerical solution to inverse problem. Calbindin.===== &lt;br /&gt;
This example shows how to extract the density distribution of paramagnetic center from PCS data. The input file for this example is located in Spinach\examples\nmr_paramag\calbindin/dft_density.m together with all supporting files.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1322</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1322"/>
		<updated>2016-09-01T14:54:22Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* &amp;quot;Example 4a.&amp;quot; PCS from DFT spin density. Copper(II) porphyrin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy-plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy-axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt; (shown on the left). In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics (the case of limiting rhombisity is shown on the right).&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see http://arxiv.org/abs/1607.08869 for details). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbindin PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    % Parse the ORCA log&lt;br /&gt;
    props=oparse(&amp;#039;cu_porph_hfc.out&amp;#039;);&lt;br /&gt;
    % Extract hyperfine tensors&lt;br /&gt;
    hfcs=props.hfc.full.matrix(26:37);&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    for n=1:numel(hfcs)&lt;br /&gt;
    hfc_pcs_cu(n)=hfc2pcs(gauss2mhz(hfcs{n}),chi_cu,&amp;#039;1H&amp;#039;); %#ok&amp;lt;AGROW&amp;gt;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines give even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;br /&gt;
&lt;br /&gt;
==Distributed model==&lt;br /&gt;
The most general approach that works for any density distribution is described in (http://dx.doi.org/10.1039/C4CP03106G) and implemented in the functions [[kpcs.m]] for the direct problems and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the density distribution defined on three dimensional grid. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 4a&amp;#039;&amp;#039; PCS from DFT spin density. Copper(II) porphyrin=====&lt;br /&gt;
[[File:cu_porph_sd1.png|thumb|300px|alt=Alt text|DFT spin density of Cu(II) porphyrin.]]&lt;br /&gt;
In this example the protons PCS of Copper(II) porphyrin are computed from the spin density generated by DFT using [[kpcs.m]]. ORCA_PLOT offers several options to generate the spin density file. In this example we use the &amp;quot;3D simple format&amp;quot; file &amp;quot;cu_porph_sd80.spindens.3d&amp;quot;. &lt;br /&gt;
To import the density into the format that [[kpcs.m]] needs we do:&lt;br /&gt;
    % Import spin density from ORCA in &amp;quot;3D simple fromat&amp;quot;&lt;br /&gt;
    A=importdata(&amp;#039;cu_porph_sd80.spindens.3d&amp;#039;);&lt;br /&gt;
    % read number of points along [x y z]&lt;br /&gt;
    dim=str2num(A.textdata{2});&lt;br /&gt;
    % read coordinates of the corner &lt;br /&gt;
    min=str2num(A.textdata{3});&lt;br /&gt;
    % read step size [dx dy dz]&lt;br /&gt;
    d3r=str2num(A.textdata{4});&lt;br /&gt;
    % form the absolute density cube&lt;br /&gt;
    density=reshape(abs(A.data),dim(2),dim(3),dim(1));&lt;br /&gt;
    density=permute(density,[2 3 1]);&lt;br /&gt;
    % normalize the density&lt;br /&gt;
    density=density/(simps(simps(simps(density)))*prod(d3r));&lt;br /&gt;
    % compute extents&lt;br /&gt;
    ext=[min(1) (min(1)+(dim(1)-1)*d3r(1))...&lt;br /&gt;
         min(2) (min(2)+(dim(2)-1)*d3r(2))...&lt;br /&gt;
         min(3) (min(3)+(dim(3)-1)*d3r(3))];&lt;br /&gt;
The numerical costs for [[kpcs.m]] are defined by the grid size. New version of [[kpcs.m]] uses the fast Fourier transform (FFT) method that improves the scaling significantly (for details see http://arxiv.org/abs/1607.08869). FFT has the periodic boundary conditions (PBC), therefore we have to make sure that borders are far enough from the molecule by padding the density array with zeros:&lt;br /&gt;
&lt;br /&gt;
    % Pad the density with zeros to avoid PBC effects&lt;br /&gt;
    pad_size=2;&lt;br /&gt;
    pad_density=padarray(density,pad_size*size(density),0,&amp;#039;both&amp;#039;);&lt;br /&gt;
    pad_ext=(2*pad_size+1)*ext;&lt;br /&gt;
&lt;br /&gt;
The actual calculation takes place here:&lt;br /&gt;
    % Solve PDE using FFT&lt;br /&gt;
   [pde_pcs_cu,pcs_cube]=kpcs(pad_density,chi_cu,pad_ext,nxyz,&amp;#039;fft&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
Comparison of the PCS from the DFT hyperfine and from the partial differential equation (PDE) with imported DFT spin density defined on 80x80x80 grid&lt;br /&gt;
   % Compare HFC PCS with PDE PCS&lt;br /&gt;
   disp(&amp;#039;Pseudocontact shifts [hfc, pde], ppm&amp;#039;);&lt;br /&gt;
   disp([hfc_pcs_cu&amp;#039; pde_pcs_cu]);&lt;br /&gt;
shows the good agreement (-1.53 -1.90 ppm from DFT and -1.43 -1.84 ppm from PDE). Using this method one can compute DFT spin density for a small subsystem (i.e. protein active cite) and recompute PCS in full system (entire protein) using [[kpcs.m]] without a need to do DFT for the full system.&lt;br /&gt;
[[File:cu_porph_sd.png|center|thumb|500px|PCS field of Cu(II) porphyrin.]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4b.&amp;quot; Numerical solution to inverse problem. Calbindin.===== &lt;br /&gt;
This example shows how to extract the density distribution of paramagnetic center from PCS data. The input file for this example is located in Spinach\examples\nmr_paramag\calbindin/dft_density.m together with all supporting files.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1320</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1320"/>
		<updated>2016-09-01T14:53:26Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* &amp;quot;Example 4a.&amp;quot; PCS from DFT spin density. Copper(II) porphyrin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy-plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy-axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt; (shown on the left). In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics (the case of limiting rhombisity is shown on the right).&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see http://arxiv.org/abs/1607.08869 for details). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbindin PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    % Parse the ORCA log&lt;br /&gt;
    props=oparse(&amp;#039;cu_porph_hfc.out&amp;#039;);&lt;br /&gt;
    % Extract hyperfine tensors&lt;br /&gt;
    hfcs=props.hfc.full.matrix(26:37);&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    for n=1:numel(hfcs)&lt;br /&gt;
    hfc_pcs_cu(n)=hfc2pcs(gauss2mhz(hfcs{n}),chi_cu,&amp;#039;1H&amp;#039;); %#ok&amp;lt;AGROW&amp;gt;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines give even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;br /&gt;
&lt;br /&gt;
==Distributed model==&lt;br /&gt;
The most general approach that works for any density distribution is described in (http://dx.doi.org/10.1039/C4CP03106G) and implemented in the functions [[kpcs.m]] for the direct problems and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the density distribution defined on three dimensional grid. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4a.&amp;quot; PCS from DFT spin density. Copper(II) porphyrin=====&lt;br /&gt;
[[File:cu_porph_sd1.png|thumb|300px|alt=Alt text|DFT spin density of Cu(II) porphyrin.]]&lt;br /&gt;
In this example the protons PCS of Copper(II) porphyrin are computed from the spin density generated by DFT using [[kpcs.m]]. ORCA_PLOT offers several options to generate the spin density file. In this example we use the &amp;quot;3D simple format&amp;quot; file &amp;quot;cu_porph_sd80.spindens.3d&amp;quot;. &lt;br /&gt;
To import the density into the format that [[kpcs.m]] needs we do:&lt;br /&gt;
    % Import spin density from ORCA in &amp;quot;3D simple fromat&amp;quot;&lt;br /&gt;
    A=importdata(&amp;#039;cu_porph_sd80.spindens.3d&amp;#039;);&lt;br /&gt;
    % read number of points along [x y z]&lt;br /&gt;
    dim=str2num(A.textdata{2});&lt;br /&gt;
    % read coordinates of the corner &lt;br /&gt;
    min=str2num(A.textdata{3});&lt;br /&gt;
    % read step size [dx dy dz]&lt;br /&gt;
    d3r=str2num(A.textdata{4});&lt;br /&gt;
    % form the absolute density cube&lt;br /&gt;
    density=reshape(abs(A.data),dim(2),dim(3),dim(1));&lt;br /&gt;
    density=permute(density,[2 3 1]);&lt;br /&gt;
    % normalize the density&lt;br /&gt;
    density=density/(simps(simps(simps(density)))*prod(d3r));&lt;br /&gt;
    % compute extents&lt;br /&gt;
    ext=[min(1) (min(1)+(dim(1)-1)*d3r(1))...&lt;br /&gt;
         min(2) (min(2)+(dim(2)-1)*d3r(2))...&lt;br /&gt;
         min(3) (min(3)+(dim(3)-1)*d3r(3))];&lt;br /&gt;
The numerical costs for [[kpcs.m]] are defined by the grid size. New version of [[kpcs.m]] uses the fast Fourier transform (FFT) method that improves the scaling significantly (for details see http://arxiv.org/abs/1607.08869). FFT has the periodic boundary conditions (PBC), therefore we have to make sure that borders are far enough from the molecule by padding the density array with zeros:&lt;br /&gt;
&lt;br /&gt;
    % Pad the density with zeros to avoid PBC effects&lt;br /&gt;
    pad_size=2;&lt;br /&gt;
    pad_density=padarray(density,pad_size*size(density),0,&amp;#039;both&amp;#039;);&lt;br /&gt;
    pad_ext=(2*pad_size+1)*ext;&lt;br /&gt;
&lt;br /&gt;
The actual calculation takes place here:&lt;br /&gt;
    % Solve PDE using FFT&lt;br /&gt;
   [pde_pcs_cu,pcs_cube]=kpcs(pad_density,chi_cu,pad_ext,nxyz,&amp;#039;fft&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
Comparison of the PCS from the DFT hyperfine and from the partial differential equation (PDE) with imported DFT spin density defined on 80x80x80 grid&lt;br /&gt;
   % Compare HFC PCS with PDE PCS&lt;br /&gt;
   disp(&amp;#039;Pseudocontact shifts [hfc, pde], ppm&amp;#039;);&lt;br /&gt;
   disp([hfc_pcs_cu&amp;#039; pde_pcs_cu]);&lt;br /&gt;
shows the good agreement (-1.53 -1.90 ppm from DFT and -1.43 -1.84 ppm from PDE). Using this method one can compute DFT spin density for a small subsystem (i.e. protein active cite) and recompute PCS in full system (entire protein) using [[kpcs.m]] without a need to do DFT for the full system.&lt;br /&gt;
[[File:cu_porph_sd.png|center|thumb|500px|PCS field of Cu(II) porphyrin.]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4b.&amp;quot; Numerical solution to inverse problem. Calbindin.===== &lt;br /&gt;
This example shows how to extract the density distribution of paramagnetic center from PCS data. The input file for this example is located in Spinach\examples\nmr_paramag\calbindin/dft_density.m together with all supporting files.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1316</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1316"/>
		<updated>2016-09-01T14:49:26Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Example 3a. DFT hyperfine. Copper porphyrin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy-plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy-axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt; (shown on the left). In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics (the case of limiting rhombisity is shown on the right).&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see http://arxiv.org/abs/1607.08869 for details). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbindin PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    % Parse the ORCA log&lt;br /&gt;
    props=oparse(&amp;#039;cu_porph_hfc.out&amp;#039;);&lt;br /&gt;
    % Extract hyperfine tensors&lt;br /&gt;
    hfcs=props.hfc.full.matrix(26:37);&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    for n=1:numel(hfcs)&lt;br /&gt;
    hfc_pcs_cu(n)=hfc2pcs(gauss2mhz(hfcs{n}),chi_cu,&amp;#039;1H&amp;#039;); %#ok&amp;lt;AGROW&amp;gt;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines give even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;br /&gt;
&lt;br /&gt;
==Distributed model==&lt;br /&gt;
The most general approach that works for any density distribution is described in (http://dx.doi.org/10.1039/C4CP03106G) and implemented in the functions [[kpcs.m]] for the direct problems and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the density distribution defined on three dimensional grid. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4a.&amp;quot; PCS from DFT spin density. Copper(II) porphyrin=====&lt;br /&gt;
[[File:cu_porph_sd1.png|thumb|300px|alt=Alt text|DFT spin density of Cu(II) porphyrin.]]&lt;br /&gt;
In this example the protons PCS of Copper(II) porphyrin are computed from the spin density generated by DFT using [[kpcs.m]]. ORCA_PLOT offers several options to generate the spin density file. In this example we use the &amp;quot;3D simple format&amp;quot; file &amp;quot;cu_porph_sd80.spindens.3d&amp;quot;. &lt;br /&gt;
To import the density into the format that [[kpcs.m]] needs we do:&lt;br /&gt;
    % Import spin density from ORCA in &amp;quot;3D simple fromat&amp;quot;&lt;br /&gt;
    A=importdata(&amp;#039;cu_porph_sd80.spindens.3d&amp;#039;);&lt;br /&gt;
    % read number of points along [x y z]&lt;br /&gt;
    dim=str2num(A.textdata{2});&lt;br /&gt;
    % read coordinates of the corner &lt;br /&gt;
    min=str2num(A.textdata{3});&lt;br /&gt;
    % read step size [dx dy dz]&lt;br /&gt;
    d3r=str2num(A.textdata{4});&lt;br /&gt;
    % form the absolute density cube&lt;br /&gt;
    density=reshape(abs(A.data),dim(2),dim(3),dim(1));&lt;br /&gt;
    density=permute(density,[2 3 1]);&lt;br /&gt;
    % normalize the density&lt;br /&gt;
    density=density/(simps(simps(simps(density)))*prod(d3r));&lt;br /&gt;
    % compute extents&lt;br /&gt;
    ext=[min(1) (min(1)+(dim(1)-1)*d3r(1))...&lt;br /&gt;
         min(2) (min(2)+(dim(2)-1)*d3r(2))...&lt;br /&gt;
         min(3) (min(3)+(dim(3)-1)*d3r(3))];&lt;br /&gt;
The numerical costs for [[kpcs.m]] are defined by the grid size. New version of [[kpcs.m]] uses the fast Fourier transform (FFT) method that improves the scaling significantly (for details see http://arxiv.org/abs/1607.08869). FFT has the periodic boundary conditions (PBC), therefore we have to make sure that borders are far enough from the molecule by padding the density array with zeros:&lt;br /&gt;
&lt;br /&gt;
    % Pad the density with zeros to avoid PBC effects&lt;br /&gt;
    pad_size=2;&lt;br /&gt;
    pad_density=padarray(density,pad_size*size(density),0,&amp;#039;both&amp;#039;);&lt;br /&gt;
    pad_ext=(2*pad_size+1)*ext;&lt;br /&gt;
&lt;br /&gt;
The actual calculation takes place here:&lt;br /&gt;
    % Solve PDE using FFT&lt;br /&gt;
   [pde_pcs_cu,pcs_cube]=kpcs(pad_density,chi_cu,pad_ext,nxyz,&amp;#039;fft&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
Comparison of the PCS from the DFT hyperfine and from the partial differential equation (PDE) with imported DFT spin density&lt;br /&gt;
   % Compare HFC PCS with PDE PCS&lt;br /&gt;
   disp(&amp;#039;Pseudocontact shifts [hfc, pde], ppm&amp;#039;);&lt;br /&gt;
   disp([hfc_pcs_cu&amp;#039; pde_pcs_cu]);&lt;br /&gt;
shows the good agreement (-1.53 -1.90 ppm from DFT and -1.43 -1.84 ppm from PDE). Using this method one can compute DFT spin density using a small subsystem (i.e. protein active cite) and recompute PCS in full system (entire protein) by means of [[kpcs.m]] without a need to do DFT for the full system.&lt;br /&gt;
[[File:cu_porph_sd.png|center|thumb|500px|PCS field of Cu(II) porphyrin.]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4b.&amp;quot; Numerical solution to inverse problem. Calbindin.===== &lt;br /&gt;
This example shows how to extract the density distribution of paramagnetic center from PCS data. The input file for this example is located in Spinach\examples\nmr_paramag\calbindin/dft_density.m together with all supporting files.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1315</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1315"/>
		<updated>2016-09-01T14:48:06Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* &amp;quot;Example 4a.&amp;quot; PCS from DFT spin density. Copper(II) porphyrin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy-plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy-axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt; (shown on the left). In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics (the case of limiting rhombisity is shown on the right).&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see http://arxiv.org/abs/1607.08869 for details). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbindin PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    % Parse the ORCA log&lt;br /&gt;
    props=oparse(&amp;#039;cu_porph_hfc.out&amp;#039;);&lt;br /&gt;
    % Extract hyperfine tensors&lt;br /&gt;
    hfcs=props.hfc.full.matrix(26:37);&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    for n=1:numel(hfcs)&lt;br /&gt;
    dft_pcs_cu(n)=hfc2pcs(gauss2mhz(hfcs{n}),chi_cu,&amp;#039;1H&amp;#039;); %#ok&amp;lt;AGROW&amp;gt;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines give even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;br /&gt;
&lt;br /&gt;
==Distributed model==&lt;br /&gt;
The most general approach that works for any density distribution is described in (http://dx.doi.org/10.1039/C4CP03106G) and implemented in the functions [[kpcs.m]] for the direct problems and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the density distribution defined on three dimensional grid. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4a.&amp;quot; PCS from DFT spin density. Copper(II) porphyrin=====&lt;br /&gt;
[[File:cu_porph_sd1.png|thumb|300px|alt=Alt text|DFT spin density of Cu(II) porphyrin.]]&lt;br /&gt;
In this example the protons PCS of Copper(II) porphyrin are computed from the spin density generated by DFT using [[kpcs.m]]. ORCA_PLOT offers several options to generate the spin density file. In this example we use the &amp;quot;3D simple format&amp;quot; file &amp;quot;cu_porph_sd80.spindens.3d&amp;quot;. &lt;br /&gt;
To import the density into the format that [[kpcs.m]] needs we do:&lt;br /&gt;
    % Import spin density from ORCA in &amp;quot;3D simple fromat&amp;quot;&lt;br /&gt;
    A=importdata(&amp;#039;cu_porph_sd80.spindens.3d&amp;#039;);&lt;br /&gt;
    % read number of points along [x y z]&lt;br /&gt;
    dim=str2num(A.textdata{2});&lt;br /&gt;
    % read coordinates of the corner &lt;br /&gt;
    min=str2num(A.textdata{3});&lt;br /&gt;
    % read step size [dx dy dz]&lt;br /&gt;
    d3r=str2num(A.textdata{4});&lt;br /&gt;
    % form the absolute density cube&lt;br /&gt;
    density=reshape(abs(A.data),dim(2),dim(3),dim(1));&lt;br /&gt;
    density=permute(density,[2 3 1]);&lt;br /&gt;
    % normalize the density&lt;br /&gt;
    density=density/(simps(simps(simps(density)))*prod(d3r));&lt;br /&gt;
    % compute extents&lt;br /&gt;
    ext=[min(1) (min(1)+(dim(1)-1)*d3r(1))...&lt;br /&gt;
         min(2) (min(2)+(dim(2)-1)*d3r(2))...&lt;br /&gt;
         min(3) (min(3)+(dim(3)-1)*d3r(3))];&lt;br /&gt;
The numerical costs for [[kpcs.m]] are defined by the grid size. New version of [[kpcs.m]] uses the fast Fourier transform (FFT) method that improves the scaling significantly (for details see http://arxiv.org/abs/1607.08869). FFT has the periodic boundary conditions (PBC), therefore we have to make sure that borders are far enough from the molecule by padding the density array with zeros:&lt;br /&gt;
&lt;br /&gt;
    % Pad the density with zeros to avoid PBC effects&lt;br /&gt;
    pad_size=2;&lt;br /&gt;
    pad_density=padarray(density,pad_size*size(density),0,&amp;#039;both&amp;#039;);&lt;br /&gt;
    pad_ext=(2*pad_size+1)*ext;&lt;br /&gt;
&lt;br /&gt;
The actual calculation takes place here:&lt;br /&gt;
    % Solve PDE using FFT&lt;br /&gt;
   [pde_pcs_cu,pcs_cube]=kpcs(pad_density,chi_cu,pad_ext,nxyz,&amp;#039;fft&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
Comparison of the PCS from the DFT hyperfine and from the partial differential equation (PDE) with imported DFT spin density&lt;br /&gt;
   % Compare HFC PCS with PDE PCS&lt;br /&gt;
   disp(&amp;#039;Pseudocontact shifts [hfc, pde], ppm&amp;#039;);&lt;br /&gt;
   disp([hfc_pcs_cu&amp;#039; pde_pcs_cu]);&lt;br /&gt;
shows the good agreement (-1.53 -1.90 ppm from DFT and -1.43 -1.84 ppm from PDE). Using this method one can compute DFT spin density using a small subsystem (i.e. protein active cite) and recompute PCS in full system (entire protein) by means of [[kpcs.m]] without a need to do DFT for the full system.&lt;br /&gt;
[[File:cu_porph_sd.png|center|thumb|500px|PCS field of Cu(II) porphyrin.]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4b.&amp;quot; Numerical solution to inverse problem. Calbindin.===== &lt;br /&gt;
This example shows how to extract the density distribution of paramagnetic center from PCS data. The input file for this example is located in Spinach\examples\nmr_paramag\calbindin/dft_density.m together with all supporting files.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1314</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1314"/>
		<updated>2016-09-01T14:47:22Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy-plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy-axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt; (shown on the left). In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics (the case of limiting rhombisity is shown on the right).&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see http://arxiv.org/abs/1607.08869 for details). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbindin PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    % Parse the ORCA log&lt;br /&gt;
    props=oparse(&amp;#039;cu_porph_hfc.out&amp;#039;);&lt;br /&gt;
    % Extract hyperfine tensors&lt;br /&gt;
    hfcs=props.hfc.full.matrix(26:37);&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    for n=1:numel(hfcs)&lt;br /&gt;
    dft_pcs_cu(n)=hfc2pcs(gauss2mhz(hfcs{n}),chi_cu,&amp;#039;1H&amp;#039;); %#ok&amp;lt;AGROW&amp;gt;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines give even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;br /&gt;
&lt;br /&gt;
==Distributed model==&lt;br /&gt;
The most general approach that works for any density distribution is described in (http://dx.doi.org/10.1039/C4CP03106G) and implemented in the functions [[kpcs.m]] for the direct problems and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the density distribution defined on three dimensional grid. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4a.&amp;quot; PCS from DFT spin density. Copper(II) porphyrin=====&lt;br /&gt;
[[File:cu_porph_sd1.png|thumb|200px|alt=Alt text|DFT spin density of Cu(II) porphyrin.]]&lt;br /&gt;
In this example the protons PCS of Copper(II) porphyrin are computed from the spin density generated by DFT using [[kpcs.m]]. ORCA_PLOT offers several options to generate the spin density file. In this example we use the &amp;quot;3D simple format&amp;quot; file &amp;quot;cu_porph_sd80.spindens.3d&amp;quot;. &lt;br /&gt;
To import the density into the format that [[kpcs.m]] needs we do:&lt;br /&gt;
    % Import spin density from ORCA in &amp;quot;3D simple fromat&amp;quot;&lt;br /&gt;
    A=importdata(&amp;#039;cu_porph_sd80.spindens.3d&amp;#039;);&lt;br /&gt;
    % read number of points along [x y z]&lt;br /&gt;
    dim=str2num(A.textdata{2});&lt;br /&gt;
    % read coordinates of the corner &lt;br /&gt;
    min=str2num(A.textdata{3});&lt;br /&gt;
    % read step size [dx dy dz]&lt;br /&gt;
    d3r=str2num(A.textdata{4});&lt;br /&gt;
    % form the absolute density cube&lt;br /&gt;
    density=reshape(abs(A.data),dim(2),dim(3),dim(1));&lt;br /&gt;
    density=permute(density,[2 3 1]);&lt;br /&gt;
    % normalize the density&lt;br /&gt;
    density=density/(simps(simps(simps(density)))*prod(d3r));&lt;br /&gt;
    % compute extents&lt;br /&gt;
    ext=[min(1) (min(1)+(dim(1)-1)*d3r(1))...&lt;br /&gt;
         min(2) (min(2)+(dim(2)-1)*d3r(2))...&lt;br /&gt;
         min(3) (min(3)+(dim(3)-1)*d3r(3))];&lt;br /&gt;
The numerical costs for [[kpcs.m]] are defined by the grid size. New version of [[kpcs.m]] uses the fast Fourier transform (FFT) method that improves the scaling significantly (for details see http://arxiv.org/abs/1607.08869). FFT has the periodic boundary conditions (PBC), therefore we have to make sure that borders are far enough from the molecule by padding the density array with zeros:&lt;br /&gt;
&lt;br /&gt;
    % Pad the density with zeros to avoid PBC effects&lt;br /&gt;
    pad_size=2;&lt;br /&gt;
    pad_density=padarray(density,pad_size*size(density),0,&amp;#039;both&amp;#039;);&lt;br /&gt;
    pad_ext=(2*pad_size+1)*ext;&lt;br /&gt;
&lt;br /&gt;
The actual calculation takes place here:&lt;br /&gt;
    % Solve PDE using FFT&lt;br /&gt;
   [pde_pcs_cu,pcs_cube]=kpcs(pad_density,chi_cu,pad_ext,nxyz,&amp;#039;fft&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
Comparison of the PCS from the DFT hyperfine and from the partial differential equation (PDE) with imported DFT spin density&lt;br /&gt;
   % Compare HFC PCS with PDE PCS&lt;br /&gt;
   disp(&amp;#039;Pseudocontact shifts [hfc, pde], ppm&amp;#039;);&lt;br /&gt;
   disp([hfc_pcs_cu&amp;#039; pde_pcs_cu]);&lt;br /&gt;
shows the good agreement (-1.53 -1.90 ppm from DFT and -1.43 -1.84 ppm from PDE). Using this method one can compute DFT spin density using a small subsystem (i.e. protein active cite) and recompute PCS in full system (entire protein) by means of [[kpcs.m]] without a need to do DFT for the full system.&lt;br /&gt;
[[File:cu_porph_sd.png|center|thumb|500px|PCS field of Cu(II) porphyrin.]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4b.&amp;quot; Numerical solution to inverse problem. Calbindin.===== &lt;br /&gt;
This example shows how to extract the density distribution of paramagnetic center from PCS data. The input file for this example is located in Spinach\examples\nmr_paramag\calbindin/dft_density.m together with all supporting files.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=File:Cu_porph_sd1.png&amp;diff=1312</id>
		<title>File:Cu porph sd1.png</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=File:Cu_porph_sd1.png&amp;diff=1312"/>
		<updated>2016-09-01T14:46:29Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1306</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1306"/>
		<updated>2016-09-01T14:41:44Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* &amp;quot;Example 4a.&amp;quot; Numerical solution for direct problem. Copper(II) porphyrin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy-plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy-axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt; (shown on the left). In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics (the case of limiting rhombisity is shown on the right).&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see http://arxiv.org/abs/1607.08869 for details). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbindin PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    % Parse the ORCA log&lt;br /&gt;
    props=oparse(&amp;#039;cu_porph_hfc.out&amp;#039;);&lt;br /&gt;
    % Extract hyperfine tensors&lt;br /&gt;
    hfcs=props.hfc.full.matrix(26:37);&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    for n=1:numel(hfcs)&lt;br /&gt;
    dft_pcs_cu(n)=hfc2pcs(gauss2mhz(hfcs{n}),chi_cu,&amp;#039;1H&amp;#039;); %#ok&amp;lt;AGROW&amp;gt;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines give even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;br /&gt;
&lt;br /&gt;
==Distributed model==&lt;br /&gt;
The most general approach that works for any density distribution is described in (http://dx.doi.org/10.1039/C4CP03106G) and implemented in the functions [[kpcs.m]] for the direct problems and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the density distribution defined on three dimensional grid. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4a.&amp;quot; Numerical solution for direct problem. Copper(II) porphyrin=====&lt;br /&gt;
In this example the protons PCS of Copper(II) porphyrin are computed from the spin density generated by DFT using [[kpcs.m]]. ORCA_PLOT offers several options to generate the spin density file. In this example we use the &amp;quot;3D simple format&amp;quot; file &amp;quot;cu_porph_sd80.spindens.3d&amp;quot;. &lt;br /&gt;
To import the density into the format that [[kpcs.m]] needs we do:&lt;br /&gt;
    % Import spin density from ORCA in &amp;quot;3D simple fromat&amp;quot;&lt;br /&gt;
    A=importdata(&amp;#039;cu_porph_sd80.spindens.3d&amp;#039;);&lt;br /&gt;
    % read number of points along [x y z]&lt;br /&gt;
    dim=str2num(A.textdata{2});&lt;br /&gt;
    % read coordinates of the corner &lt;br /&gt;
    min=str2num(A.textdata{3});&lt;br /&gt;
    % read step size [dx dy dz]&lt;br /&gt;
    d3r=str2num(A.textdata{4});&lt;br /&gt;
    % form the absolute density cube&lt;br /&gt;
    density=reshape(abs(A.data),dim(2),dim(3),dim(1));&lt;br /&gt;
    density=permute(density,[2 3 1]);&lt;br /&gt;
    % normalize the density&lt;br /&gt;
    density=density/(simps(simps(simps(density)))*prod(d3r));&lt;br /&gt;
    % compute extents&lt;br /&gt;
    ext=[min(1) (min(1)+(dim(1)-1)*d3r(1))...&lt;br /&gt;
         min(2) (min(2)+(dim(2)-1)*d3r(2))...&lt;br /&gt;
         min(3) (min(3)+(dim(3)-1)*d3r(3))];&lt;br /&gt;
The numerical costs for [[kpcs.m]] are defined by the grid size. New version of [[kpcs.m]] uses the fast Fourier transform (FFT) method that improves the scaling significantly (for details see http://arxiv.org/abs/1607.08869). FFT has the periodic boundary conditions (PBC), therefore we have to make sure that borders are far enough from the molecule by padding the density array with zeros:&lt;br /&gt;
&lt;br /&gt;
    % Pad the density with zeros to avoid PBC effects&lt;br /&gt;
    pad_size=2;&lt;br /&gt;
    pad_density=padarray(density,pad_size*size(density),0,&amp;#039;both&amp;#039;);&lt;br /&gt;
    pad_ext=(2*pad_size+1)*ext;&lt;br /&gt;
&lt;br /&gt;
The actual calculation takes place here:&lt;br /&gt;
    % Solve PDE using FFT&lt;br /&gt;
   [pde_pcs_cu,pcs_cube]=kpcs(pad_density,chi_cu,pad_ext,nxyz,&amp;#039;fft&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
Comparison of the PCS from the DFT hyperfine and from the partial differential equation (PDE) with imported DFT spin density&lt;br /&gt;
   % Compare HFC PCS with PDE PCS&lt;br /&gt;
   disp(&amp;#039;Pseudocontact shifts [hfc, pde], ppm&amp;#039;);&lt;br /&gt;
   disp([hfc_pcs_cu&amp;#039; pde_pcs_cu]);&lt;br /&gt;
shows the good agreement (-1.53 -1.90 ppm from DFT and -1.43 -1.84 ppm from PDE). Using this method one can compute DFT spin density using a small subsystem (i.e. protein active cite) and recompute PCS in full system (entire protein) by means of [[kpcs.m]].&lt;br /&gt;
[[File:cu_porph_sd.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4b.&amp;quot; Numerical solution to inverse problem. Calbindin.===== &lt;br /&gt;
This example shows how to extract the density distribution of paramagnetic center from PCS data. The input file for this example is located in Spinach\examples\nmr_paramag\calbindin/dft_density.m together with all supporting files.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=File:Cu_porph_sd.png&amp;diff=1305</id>
		<title>File:Cu porph sd.png</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=File:Cu_porph_sd.png&amp;diff=1305"/>
		<updated>2016-09-01T14:41:30Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1299</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1299"/>
		<updated>2016-09-01T14:35:37Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* &amp;quot;Example 4a.&amp;quot; Numerical solution for direct problem. Europium(III) complex */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy-plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy-axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt; (shown on the left). In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics (the case of limiting rhombisity is shown on the right).&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see http://arxiv.org/abs/1607.08869 for details). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbindin PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    % Parse the ORCA log&lt;br /&gt;
    props=oparse(&amp;#039;cu_porph_hfc.out&amp;#039;);&lt;br /&gt;
    % Extract hyperfine tensors&lt;br /&gt;
    hfcs=props.hfc.full.matrix(26:37);&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    for n=1:numel(hfcs)&lt;br /&gt;
    dft_pcs_cu(n)=hfc2pcs(gauss2mhz(hfcs{n}),chi_cu,&amp;#039;1H&amp;#039;); %#ok&amp;lt;AGROW&amp;gt;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines give even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;br /&gt;
&lt;br /&gt;
==Distributed model==&lt;br /&gt;
The most general approach that works for any density distribution is described in (http://dx.doi.org/10.1039/C4CP03106G) and implemented in the functions [[kpcs.m]] for the direct problems and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the density distribution defined on three dimensional grid. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4a.&amp;quot; Numerical solution for direct problem. Copper(II) porphyrin=====&lt;br /&gt;
In this example the protons PCS of Copper(II) porphyrin are computed from the spin density generated by DFT using [[kpcs.m]]. ORCA_PLOT offers several options to generate the spin density file. In this example we use the &amp;quot;3D simple format&amp;quot; file &amp;quot;cu_porph_sd80.spindens.3d&amp;quot;. &lt;br /&gt;
To import the density into the format that [[kpcs.m]] needs we do:&lt;br /&gt;
    % Import spin density from ORCA in &amp;quot;3D simple fromat&amp;quot;&lt;br /&gt;
    A=importdata(&amp;#039;cu_porph_sd80.spindens.3d&amp;#039;);&lt;br /&gt;
    % read number of points along [x y z]&lt;br /&gt;
    dim=str2num(A.textdata{2});&lt;br /&gt;
    % read coordinates of the corner &lt;br /&gt;
    min=str2num(A.textdata{3});&lt;br /&gt;
    % read step size [dx dy dz]&lt;br /&gt;
    d3r=str2num(A.textdata{4});&lt;br /&gt;
    % form the absolute density cube&lt;br /&gt;
    density=reshape(abs(A.data),dim(2),dim(3),dim(1));&lt;br /&gt;
    density=permute(density,[2 3 1]);&lt;br /&gt;
    % normalize the density&lt;br /&gt;
    density=density/(simps(simps(simps(density)))*prod(d3r));&lt;br /&gt;
    % compute extents&lt;br /&gt;
    ext=[min(1) (min(1)+(dim(1)-1)*d3r(1))...&lt;br /&gt;
         min(2) (min(2)+(dim(2)-1)*d3r(2))...&lt;br /&gt;
         min(3) (min(3)+(dim(3)-1)*d3r(3))];&lt;br /&gt;
The numerical costs for [[kpcs.m]] are defined by the grid size. New version of [[kpcs.m]] uses the fast Fourier transform (FFT) method that improves the scaling significantly (for details see http://arxiv.org/abs/1607.08869). FFT has the periodic boundary conditions (PBC), therefore we have to make sure that borders are far enough from the molecule by padding the density array with zeros:&lt;br /&gt;
&lt;br /&gt;
    % Pad the density with zeros to avoid PBC effects&lt;br /&gt;
    pad_size=2;&lt;br /&gt;
    pad_density=padarray(density,pad_size*size(density),0,&amp;#039;both&amp;#039;);&lt;br /&gt;
    pad_ext=(2*pad_size+1)*ext;&lt;br /&gt;
&lt;br /&gt;
The actual calculation takes place here:&lt;br /&gt;
    % Solve PDE using FFT&lt;br /&gt;
   [pde_pcs_cu,pcs_cube]=kpcs(pad_density,chi_cu,pad_ext,nxyz,&amp;#039;fft&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
Comparison of the PCS from the DFT hyperfine and from the partial differential equation (PDE) with imported DFT spin density&lt;br /&gt;
   % Compare HFC PCS with PDE PCS&lt;br /&gt;
   disp(&amp;#039;Pseudocontact shifts [hfc, pde], ppm&amp;#039;);&lt;br /&gt;
   disp([hfc_pcs_cu&amp;#039; pde_pcs_cu]);&lt;br /&gt;
shows the good agreement (-1.53 -1.90 ppm from DFT and -1.43 -1.84 ppm from PDE). Using this method one can compute DFT spin density using a small subsystem (i.e. protein active cite) and recompute PCS in full system (entire protein) by means of [[kpcs.m]].&lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4b.&amp;quot; Numerical solution to inverse problem. Calbindin.===== &lt;br /&gt;
This example shows how to extract the density distribution of paramagnetic center from PCS data. The input file for this example is located in Spinach\examples\nmr_paramag\calbindin/dft_density.m together with all supporting files.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1272</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1272"/>
		<updated>2016-08-31T14:22:33Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Example 3a. DFT hyperfine. Copper porphyrin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy-plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy-axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt; (shown on the left). In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics (the case of limiting rhombisity is shown on the right).&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see http://arxiv.org/abs/1607.08869 for details). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbindin PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    % Parse the ORCA log&lt;br /&gt;
    props=oparse(&amp;#039;cu_porph_hfc.out&amp;#039;);&lt;br /&gt;
    % Extract hyperfine tensors&lt;br /&gt;
    hfcs=props.hfc.full.matrix(26:37);&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    for n=1:numel(hfcs)&lt;br /&gt;
    dft_pcs_cu(n)=hfc2pcs(gauss2mhz(hfcs{n}),chi_cu,&amp;#039;1H&amp;#039;); %#ok&amp;lt;AGROW&amp;gt;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines give even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;br /&gt;
&lt;br /&gt;
==Distributed model==&lt;br /&gt;
The most general approach that works for any density distribution is described in (http://dx.doi.org/10.1039/C4CP03106G) and implemented in the functions [[kpcs.m]] for the direct problems and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the density distribution defined on three dimensional grid. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4a.&amp;quot; Numerical solution for direct problem. Europium(III) complex=====&lt;br /&gt;
In this example the PCS is computed from the density generated by DFT calculation. The input for this example can be found in Spinach\examples\nmr_paramag/dft_density.m. The supporting files are in the same directory and the input is self explained. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4b.&amp;quot; Numerical solution to inverse problem. Calbindin.===== &lt;br /&gt;
This example shows how to extract the density distribution of paramagnetic center from PCS data. The input file for this example is located in Spinach\examples\nmr_paramag\calbindin/dft_density.m together with all supporting files.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1271</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1271"/>
		<updated>2016-08-31T14:20:55Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Corrections to PCS from non-point source */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy-plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy-axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt; (shown on the left). In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics (the case of limiting rhombisity is shown on the right).&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see http://arxiv.org/abs/1607.08869 for details). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbindin PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    props=oparse(&amp;#039;Cu_porph_HFC.out&amp;#039;);&lt;br /&gt;
    for n=26:37 %&lt;br /&gt;
    % Assign isotopes&lt;br /&gt;
    if strcmp(props.symbols{n},&amp;#039;H&amp;#039;)&lt;br /&gt;
        iso=&amp;#039;1H&amp;#039;;&lt;br /&gt;
    end&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    dft_pcs_Cu(n)=hfc2pcs(gauss2mhz(props.hfc.full.matrix{n}),chi_Cu,iso); &lt;br /&gt;
    end&lt;br /&gt;
    disp(&amp;#039;dft_pcs_Cu&amp;#039;)&lt;br /&gt;
    disp(dft_pcs_Cu(26:37)&amp;#039;)&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines give even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;br /&gt;
&lt;br /&gt;
==Distributed model==&lt;br /&gt;
The most general approach that works for any density distribution is described in (http://dx.doi.org/10.1039/C4CP03106G) and implemented in the functions [[kpcs.m]] for the direct problems and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the density distribution defined on three dimensional grid. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4a.&amp;quot; Numerical solution for direct problem. Europium(III) complex=====&lt;br /&gt;
In this example the PCS is computed from the density generated by DFT calculation. The input for this example can be found in Spinach\examples\nmr_paramag/dft_density.m. The supporting files are in the same directory and the input is self explained. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4b.&amp;quot; Numerical solution to inverse problem. Calbindin.===== &lt;br /&gt;
This example shows how to extract the density distribution of paramagnetic center from PCS data. The input file for this example is located in Spinach\examples\nmr_paramag\calbindin/dft_density.m together with all supporting files.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1270</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1270"/>
		<updated>2016-08-31T14:16:24Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Example 1a. Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy-plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy-axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt; (shown on the left). In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics (the case of limiting rhombisity is shown on the right).&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbindin PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    props=oparse(&amp;#039;Cu_porph_HFC.out&amp;#039;);&lt;br /&gt;
    for n=26:37 %&lt;br /&gt;
    % Assign isotopes&lt;br /&gt;
    if strcmp(props.symbols{n},&amp;#039;H&amp;#039;)&lt;br /&gt;
        iso=&amp;#039;1H&amp;#039;;&lt;br /&gt;
    end&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    dft_pcs_Cu(n)=hfc2pcs(gauss2mhz(props.hfc.full.matrix{n}),chi_Cu,iso); &lt;br /&gt;
    end&lt;br /&gt;
    disp(&amp;#039;dft_pcs_Cu&amp;#039;)&lt;br /&gt;
    disp(dft_pcs_Cu(26:37)&amp;#039;)&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines give even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;br /&gt;
&lt;br /&gt;
==Distributed model==&lt;br /&gt;
The most general approach that works for any density distribution is described in (http://dx.doi.org/10.1039/C4CP03106G) and implemented in the functions [[kpcs.m]] for the direct problems and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the density distribution defined on three dimensional grid. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4a.&amp;quot; Numerical solution for direct problem. Europium(III) complex=====&lt;br /&gt;
In this example the PCS is computed from the density generated by DFT calculation. The input for this example can be found in Spinach\examples\nmr_paramag/dft_density.m. The supporting files are in the same directory and the input is self explained. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4b.&amp;quot; Numerical solution to inverse problem. Calbindin.===== &lt;br /&gt;
This example shows how to extract the density distribution of paramagnetic center from PCS data. The input file for this example is located in Spinach\examples\nmr_paramag\calbindin/dft_density.m together with all supporting files.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1269</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1269"/>
		<updated>2016-08-31T13:30:35Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Example 2b. Account for spin tag mobility. Calbidin D9K PCS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbindin PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    props=oparse(&amp;#039;Cu_porph_HFC.out&amp;#039;);&lt;br /&gt;
    for n=26:37 %&lt;br /&gt;
    % Assign isotopes&lt;br /&gt;
    if strcmp(props.symbols{n},&amp;#039;H&amp;#039;)&lt;br /&gt;
        iso=&amp;#039;1H&amp;#039;;&lt;br /&gt;
    end&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    dft_pcs_Cu(n)=hfc2pcs(gauss2mhz(props.hfc.full.matrix{n}),chi_Cu,iso); &lt;br /&gt;
    end&lt;br /&gt;
    disp(&amp;#039;dft_pcs_Cu&amp;#039;)&lt;br /&gt;
    disp(dft_pcs_Cu(26:37)&amp;#039;)&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines give even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;br /&gt;
&lt;br /&gt;
==Distributed model==&lt;br /&gt;
The most general approach that works for any density distribution is described in (http://dx.doi.org/10.1039/C4CP03106G) and implemented in the functions [[kpcs.m]] for the direct problems and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the density distribution defined on three dimensional grid. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4a.&amp;quot; Numerical solution for direct problem. Europium(III) complex=====&lt;br /&gt;
In this example the PCS is computed from the density generated by DFT calculation. The input for this example can be found in Spinach\examples\nmr_paramag/dft_density.m. The supporting files are in the same directory and the input is self explained. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4b.&amp;quot; Numerical solution to inverse problem. Calbindin.===== &lt;br /&gt;
This example shows how to extract the density distribution of paramagnetic center from PCS data. The input file for this example is located in Spinach\examples\nmr_paramag\calbindin/dft_density.m together with all supporting files.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1268</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1268"/>
		<updated>2016-08-30T15:33:39Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Distributed model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    props=oparse(&amp;#039;Cu_porph_HFC.out&amp;#039;);&lt;br /&gt;
    for n=26:37 %&lt;br /&gt;
    % Assign isotopes&lt;br /&gt;
    if strcmp(props.symbols{n},&amp;#039;H&amp;#039;)&lt;br /&gt;
        iso=&amp;#039;1H&amp;#039;;&lt;br /&gt;
    end&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    dft_pcs_Cu(n)=hfc2pcs(gauss2mhz(props.hfc.full.matrix{n}),chi_Cu,iso); &lt;br /&gt;
    end&lt;br /&gt;
    disp(&amp;#039;dft_pcs_Cu&amp;#039;)&lt;br /&gt;
    disp(dft_pcs_Cu(26:37)&amp;#039;)&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines give even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;br /&gt;
&lt;br /&gt;
==Distributed model==&lt;br /&gt;
The most general approach that works for any density distribution is described in (http://dx.doi.org/10.1039/C4CP03106G) and implemented in the functions [[kpcs.m]] for the direct problems and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the density distribution defined on three dimensional grid. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4a.&amp;quot; Numerical solution for direct problem. Europium(III) complex=====&lt;br /&gt;
In this example the PCS is computed from the density generated by DFT calculation. The input for this example can be found in Spinach\examples\nmr_paramag/dft_density.m. The supporting files are in the same directory and the input is self explained. &lt;br /&gt;
&lt;br /&gt;
=====&amp;quot;Example 4b.&amp;quot; Numerical solution to inverse problem. Calbindin.===== &lt;br /&gt;
This example shows how to extract the density distribution of paramagnetic center from PCS data. The input file for this example is located in Spinach\examples\nmr_paramag\calbindin/dft_density.m together with all supporting files.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1267</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1267"/>
		<updated>2016-08-30T14:13:54Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Distributed model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    props=oparse(&amp;#039;Cu_porph_HFC.out&amp;#039;);&lt;br /&gt;
    for n=26:37 %&lt;br /&gt;
    % Assign isotopes&lt;br /&gt;
    if strcmp(props.symbols{n},&amp;#039;H&amp;#039;)&lt;br /&gt;
        iso=&amp;#039;1H&amp;#039;;&lt;br /&gt;
    end&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    dft_pcs_Cu(n)=hfc2pcs(gauss2mhz(props.hfc.full.matrix{n}),chi_Cu,iso); &lt;br /&gt;
    end&lt;br /&gt;
    disp(&amp;#039;dft_pcs_Cu&amp;#039;)&lt;br /&gt;
    disp(dft_pcs_Cu(26:37)&amp;#039;)&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines give even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;br /&gt;
&lt;br /&gt;
==Distributed model==&lt;br /&gt;
The most general approach that works for any density distribution is described in (http://dx.doi.org/10.1039/C4CP03106G) and implemented in the functions [[kpcs.m]] for the direct problems and [[ipcs.m]] for the inverse problems. This approach is fully numeric and operates with the density distribution defined on three dimensional grid. &lt;br /&gt;
Density distribution can be generated analytically as in example &amp;quot;point_vs_distr&amp;quot;:&lt;br /&gt;
   % Generate density distribution from 4 isotropic Gaussians centered withing&lt;br /&gt;
   % the cube of size s (Angstrom) &lt;br /&gt;
   s=3;&lt;br /&gt;
   % Get the 4 postions&lt;br /&gt;
   c=s*(rand(4,3))-s/2;&lt;br /&gt;
   % Define the size of Gaussians (Angstrom)&lt;br /&gt;
   sigma=0.5;&lt;br /&gt;
   % Set problem dimensions&lt;br /&gt;
   dim=128; ext=30;&lt;br /&gt;
   % Get a 3D grid&lt;br /&gt;
   [X,Y,Z]=ndgrid(linspace(-ext,ext,dim),linspace(-ext,ext,dim),linspace(-ext,ext,dim));&lt;br /&gt;
   % Get the normalized density&lt;br /&gt;
   rho=1/(sqrt(2*pi)*sigma)^3*(exp(-((X-c(1,1)).^2+(Y-c(1,2)).^2+(Z-c(1,3)).^2)/(2*sigma^2))+...&lt;br /&gt;
                               exp(-((X-c(2,1)).^2+(Y-c(2,2)).^2+(Z-c(2,3)).^2)/(2*sigma^2))+...&lt;br /&gt;
                               exp(-((X-c(3,1)).^2+(Y-c(3,2)).^2+(Z-c(3,3)).^2)/(2*sigma^2))+...&lt;br /&gt;
                               exp(-((X-c(4,1)).^2+(Y-c(4,2)).^2+(Z-c(4,3)).^2)/(2*sigma^2)))/4;&lt;br /&gt;
 Or one cal load it from DFT calculation.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1266</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1266"/>
		<updated>2016-08-30T14:13:03Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    props=oparse(&amp;#039;Cu_porph_HFC.out&amp;#039;);&lt;br /&gt;
    for n=26:37 %&lt;br /&gt;
    % Assign isotopes&lt;br /&gt;
    if strcmp(props.symbols{n},&amp;#039;H&amp;#039;)&lt;br /&gt;
        iso=&amp;#039;1H&amp;#039;;&lt;br /&gt;
    end&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    dft_pcs_Cu(n)=hfc2pcs(gauss2mhz(props.hfc.full.matrix{n}),chi_Cu,iso); &lt;br /&gt;
    end&lt;br /&gt;
    disp(&amp;#039;dft_pcs_Cu&amp;#039;)&lt;br /&gt;
    disp(dft_pcs_Cu(26:37)&amp;#039;)&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines give even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;br /&gt;
&lt;br /&gt;
==Distributed model==&lt;br /&gt;
The most general approach that works for any density distribution is described in (http://dx.doi.org/10.1039/C4CP03106G) and implemented in the functions [[kpcs.m]] for the direct problems and [[ipcs.m]] for the inverse problems. This approach is fully numeric end operated with the density distribution defined on three dimensional grid. &lt;br /&gt;
Density distribution can be generated analytically as in example &amp;quot;point_vs_distr&amp;quot;:&lt;br /&gt;
   % Generate density distribution from 4 isotropic Gaussians centered withing&lt;br /&gt;
   % the cube of size s (Angstrom) &lt;br /&gt;
   s=3;&lt;br /&gt;
   % Get the 4 postions&lt;br /&gt;
   c=s*(rand(4,3))-s/2;&lt;br /&gt;
   % Define the size of Gaussians (Angstrom)&lt;br /&gt;
   sigma=0.5;&lt;br /&gt;
   % Set problem dimensions&lt;br /&gt;
   dim=128; ext=30;&lt;br /&gt;
   % Get a 3D grid&lt;br /&gt;
   [X,Y,Z]=ndgrid(linspace(-ext,ext,dim),linspace(-ext,ext,dim),linspace(-ext,ext,dim));&lt;br /&gt;
   % Get the normalized density&lt;br /&gt;
   rho=1/(sqrt(2*pi)*sigma)^3*(exp(-((X-c(1,1)).^2+(Y-c(1,2)).^2+(Z-c(1,3)).^2)/(2*sigma^2))+...&lt;br /&gt;
                               exp(-((X-c(2,1)).^2+(Y-c(2,2)).^2+(Z-c(2,3)).^2)/(2*sigma^2))+...&lt;br /&gt;
                               exp(-((X-c(3,1)).^2+(Y-c(3,2)).^2+(Z-c(3,3)).^2)/(2*sigma^2))+...&lt;br /&gt;
                               exp(-((X-c(4,1)).^2+(Y-c(4,2)).^2+(Z-c(4,3)).^2)/(2*sigma^2)))/4;&lt;br /&gt;
 Or one cal load it from DFT calculation.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1265</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1265"/>
		<updated>2016-08-30T12:10:16Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor. The function [[hfc2pcs.m]] computes PCS by multiplying hyperfine tensor with susceptibility tensor and taking its isotropic part. &lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 3a.&amp;#039;&amp;#039; DFT hyperfine. Copper porphyrin=====&lt;br /&gt;
To get the DFT hyperfine for protons one can run a simple ORCA job&lt;br /&gt;
     ! B3LYP def2-SVP&lt;br /&gt;
     *xyzfile 0 2 Cu_porph.xyz&lt;br /&gt;
     %eprnmr&lt;br /&gt;
     Nuclei = all H {adip}&lt;br /&gt;
     end&lt;br /&gt;
An example output file is located in the folder examples/nmr_paramag in Spinach.&lt;br /&gt;
To get the PCS using these hyperfine tensor use the function [[hfc2pcs.m]] &lt;br /&gt;
    props=oparse(&amp;#039;Cu_porph_HFC.out&amp;#039;);&lt;br /&gt;
    for n=26:37 %#ok&amp;lt;*AGROW&amp;gt;&lt;br /&gt;
    % Assign isotopes&lt;br /&gt;
    if strcmp(props.symbols{n},&amp;#039;H&amp;#039;)&lt;br /&gt;
        iso=&amp;#039;1H&amp;#039;;&lt;br /&gt;
    end&lt;br /&gt;
    % Compute DFT PCS&lt;br /&gt;
    dft_pcs_Cu(n)=hfc2pcs(gauss2mhz(props.hfc.full.matrix{n}),chi_Cu,iso); &lt;br /&gt;
    end&lt;br /&gt;
    disp(&amp;#039;dft_pcs_Cu&amp;#039;)&lt;br /&gt;
    disp(dft_pcs_Cu(26:37)&amp;#039;)&lt;br /&gt;
PCS from the simplistic model with spin population on nitrogen Example.2a accounts for delocalization only partially. DFT hyperfines gives even larger absolute shifts: -1.53 and -1.90 ppm (it was -1.21 and -1.81 ppm in Example.2a)&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1263</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1263"/>
		<updated>2016-08-30T11:49:02Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Hyperfine tensor from DFT */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;br /&gt;
Another way to account for spin delocalization is just taking the hyperfine tensors from DFT. Spinach has two parser scripts: [[gparse.m]] - for outputs from Gaussian and [[oparse.m]] - for ORCA outputs, which help to extract the computed hyperfine tensors specified in molecular frame. It should be noted that only anisotropic part of the tensor affects PCS. For light nuclei it is just dipolar hyperfine, for heavy elements the orbital part also contributes to anisotropic part of hyperfine tensor.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1261</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1261"/>
		<updated>2016-08-30T10:31:38Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Example 2a. Correction to point PCS from spin density delocalization. Copper porphyrin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Cu)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Hyperfine_shift_module&amp;diff=1260</id>
		<title>Hyperfine shift module</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Hyperfine_shift_module&amp;diff=1260"/>
		<updated>2016-08-30T09:05:29Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Fitting paramagnetic shifts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Spinach includes a variety of functions that compute hyperfine shifts (including, contact, pseudocontact and dipolar components) and assist in their analysis. The formalism Spinach uses to compute them is described in our recent paper on the subject (http://dx.doi.org/10.1039/C4CP03106G). This section contains an overview of the related functions, located in kernel/utilities and experiments folders.&lt;br /&gt;
&lt;br /&gt;
==Infrastructure functions==&lt;br /&gt;
&lt;br /&gt;
[[cgsppm2ang.m]] – converts magnetic susceptibility from the cgs-ppm (aka cm3/mol) units quoted by quantum chemistry packages into Å3 units required by Spinach pseudocontact shift functionality. Syntax:&lt;br /&gt;
&lt;br /&gt;
     ang=cgsppm2ang(cgsppm)&lt;br /&gt;
Arrays of any dimension are supported.&lt;br /&gt;
&lt;br /&gt;
[[fdhess.m]] – returns the finite-difference Hessian of a 3D array using a finite difference scheme with a user-specified number of stencil points. The dimensions of the 3D array are assumed to be ordered as [X Y Z]. Syntax:&lt;br /&gt;
&lt;br /&gt;
     H=fdhess(A,npoints)&lt;br /&gt;
&lt;br /&gt;
where the second parameter specifies the number of points in the finite difference stencil that should be used. The result is a 3x3 cell array of 3D matrices ordered in the following way:&lt;br /&gt;
     {d2A_dxdx  d2A_dxdy  d2A_dxdz&lt;br /&gt;
      d2A_dydx  d2A_dydy  d2A_dydz&lt;br /&gt;
      d2A_dzdx  d2A_dzdy  d2A_dzdz}&lt;br /&gt;
&lt;br /&gt;
[[fdkup.m]] – returns a finite difference representation of the Kuprov operator: &lt;br /&gt;
&lt;br /&gt;
     K[rho]=-(1/3)*Trace(Hessian[rho]*chi)&lt;br /&gt;
&lt;br /&gt;
with the number of stencil points in the finite difference approximation specified by user. Syntax:&lt;br /&gt;
&lt;br /&gt;
     K=fdkup(dims,chi,npoints)&lt;br /&gt;
&lt;br /&gt;
where dims is a three-element vector specifying the dimensions of the 3D cube of data that the operator will be acting on, chi is the electron magnetic susceptibility tensor and npoints is the number of points in the finite difference stencil. The resulting operator is a sparse matrix designed to act on the vectorization of rho. The dimensions of rho are assumed to be ordered as [X Y Z].&lt;br /&gt;
&lt;br /&gt;
[[fdlap.m]] – returns a finite-difference representation of the Laplacian for a 3D array with a user-specified finite difference stencil size. The resulting operator is a sparse matrix designed to act on the vectorization of the 3D array. The dimensions of the 3D array are assumed to be ordered as [X Y Z]. Syntax:&lt;br /&gt;
&lt;br /&gt;
     L=fdlap(dims,npoints)&lt;br /&gt;
&lt;br /&gt;
where dims is a three-element vector specifying the dimensions of 3D cube of data that the operator will be acting on, and npoints is the number of points in the finite difference stencil. Note: Dirichlet boundary conditions -- the resulting Laplacian should only be used for the inverse Laplacian operation.&lt;br /&gt;
&lt;br /&gt;
[[fdmat.m]] – returns arbitrary-order central finite-difference differentiation matrix with unit spacing and sided finite-difference schemes of the same order at the edges. Syntax:&lt;br /&gt;
&lt;br /&gt;
     D=fdmat(dim,npoints,order)&lt;br /&gt;
&lt;br /&gt;
Parameters: dim - dimension of the column vector to be differentiated; npoints - number of points in the finite difference stencil; order - order of the derivative required.&lt;br /&gt;
&lt;br /&gt;
[[interpmat.m]] – returns a matrix that acts on a stretched pseudocontact shift density cube and projects out the values of the PCS at the Cartesian coordinates given. Tricubic interpolation is used. Syntax:&lt;br /&gt;
&lt;br /&gt;
     P=interpmat(cube_dims,ranges,xyz)&lt;br /&gt;
&lt;br /&gt;
Parameters: cube_dims - PCS dimensions, ordered as [X Y Z]; ranges - Cartesian axis extents for the pseudocontact shift cube as [xmin xmax ymin ymax zmin zmax] in Angstroms; xyz - nuclear coordinates as [x y z] with multiple rows) at which PCS is to be evaluated, in Angstroms. Output: P - matrix projecting out PCS values at the given positions from the stretched PCS cube. Note: this function is a part of the PCS inverse problem solver module and should not normally be called directly by the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[fdvec.m]] – performs arbitrary-order finite-difference differentiation of a user-supplied row or column vector. Uses central finite-difference stencils in the middle and sided stencils of the same order of accuracy on the sides. Syntax:&lt;br /&gt;
&lt;br /&gt;
     dx=fdvec(x,npoints,order)&lt;br /&gt;
&lt;br /&gt;
Parameters: x - column or row vector to be differentiated; npoints - number of points in the finite difference stencil; order - order of the derivative required.&lt;br /&gt;
&lt;br /&gt;
[[fdweights.m]] – calculates finite difference weights for numerical derivatives (including order 0, which amounts to interpolation). Syntax:&lt;br /&gt;
&lt;br /&gt;
     w=fdweights(target_point,grid_points,max_order)&lt;br /&gt;
&lt;br /&gt;
Parameters: target_point - the point at which the derivative is required; grid_points - the points at which the function is given; max_order - maximum derivative order. The function returns finite difference coefficient array with the coefficients for the successive derivatives in rows.&lt;br /&gt;
&lt;br /&gt;
[[points2mult.m]] - computes multipole moments from a set of point charges&lt;br /&gt;
&lt;br /&gt;
    Ilm=points2mult(xyz,mxyz,rho,L,method)&lt;br /&gt;
&lt;br /&gt;
Parameters: xyz  - coordinates as [x y z] at which density rho is evaluated, in Angstroms, mxyz -  coordinates of origin as [x y z], in Angstroms. L    - array of ranks of spherical harmonics of the density L=[0 1 2], rho  - column of the density at the points xyz, method - &amp;#039;points&amp;#039; or &amp;#039;grid&amp;#039;. &amp;#039;Grid&amp;#039; integrates with corresponding d3r and &amp;#039;points&amp;#039; just sum the density at points. Output: Ilm  - predicted multipole moments of the density.&lt;br /&gt;
&lt;br /&gt;
[[qform2sph.m]] - Returns the spherical expansion coefficients of RT*A*R/R^2&lt;br /&gt;
 &lt;br /&gt;
    [r0,r1,r2]=qform2sph(A)&lt;br /&gt;
&lt;br /&gt;
Parameters: A - 3x3 matrix,Output: [r0,r1,r2] - coefficients for zero, first, and second rank spherical harmonics in the order -m:m &lt;br /&gt;
&lt;br /&gt;
==Computing paramagnetic shifts==&lt;br /&gt;
&lt;br /&gt;
[[hfc2pcs.m]] – converts hyperfine coupling tensors and susceptibility tensors into pseudocontact shifts using Equation 10 from the paper by Charnock and Kuprov (http://dx.doi.org/10.1039/C4CP03106G). Syntax:&lt;br /&gt;
&lt;br /&gt;
     sigma=hfc2pcs(A,chi,isotope)&lt;br /&gt;
&lt;br /&gt;
Parameters: A - hyperfine coupling tensor, in MHz; chi - magnetic susceptibility tensor, in Angstrom3. Outputs: sigma - pseudocontact shift, in ppm.&lt;br /&gt;
&lt;br /&gt;
[[hfc2pms.m]] – converts hyperfine coupling tensors and susceptibility tensors into paramagnetic shift tensors using Equation 10 from the paper by Charnock and Kuprov (http://dx.doi.org/10.1039/C4CP03106G). Syntax:&lt;br /&gt;
&lt;br /&gt;
     sigma=hfc2pms(A,chi,isotope)&lt;br /&gt;
&lt;br /&gt;
Parameters: A - hyperfine coupling tensor, in MHz; chi - magnetic susceptibility tensor, in Angstrom3. Outputs: sigma - dipolar shift tensor, in ppm. Note: both the susceptibility tensor and the hyperfine tensor must be submitted to this function with their isotropic parts preserved – do not make them traceless.&lt;br /&gt;
&lt;br /&gt;
[[kpcs.m]] – computes the three-dimensional distribution of pseudocontact shift field by solving Kuprov equation for PCS. Syntax:&lt;br /&gt;
&lt;br /&gt;
     [pcs_cube,pcs_vals]=kpcs(probden,chi,ranges,nxyz)&lt;br /&gt;
&lt;br /&gt;
Parameters: probden - electron probability density cube; chi - electron magnetic susceptibility tensor in cubic Angstroms; ranges - Cartesian axis extents for the electron spin density cube as [xmin xmax ymin ymax zmin zmax] in angstroms; nxyz - nuclear coordinates as [x y z] with multiple rows) at which PCS is to be evaluated, in Angstroms. Output: pcs_vals - pseudocontact shift in ppm at each nucleus;  pcs_cube - pseudocontact shift field on the same grid as the spin density supplied. Note: minimal three-point schemes are used for the finite difference operators. Increase stencil size if you have enough memory. Note: for further information on the equations and algorithms used in this function see http://dx.doi.org/10.1039/C4CP03106G.&lt;br /&gt;
&lt;br /&gt;
[[ppcs.m]] – computes pseudocontact shift from a point electron centre at the nuclear coordinates supplied. Syntax:&lt;br /&gt;
&lt;br /&gt;
     pcs_vals=ppcs(nxyz,mxyz,chi)&lt;br /&gt;
&lt;br /&gt;
Parameters: chi - electron magnetic susceptibility tensor in cubic Angstroms; nxyz - nuclear coordinates as [x y z] with multiple rows, at which PCS is to be evaluated, in Angstroms; mxyz - paramagnetic centre coordinates as [x y z], in Angstroms; Output: pred_pcs - predicted pseudocontact shift (in ppm) at each of the nuclei.&lt;br /&gt;
&lt;br /&gt;
[[lpcs.m]] - computes PCS from paramagnetic density (rho) outside the bounding sphere based on the multipole moments expansion&lt;br /&gt;
&lt;br /&gt;
Parameters: nxyz  - nuclear coordinates as [x y z] with multiple rows, at which PCS is to be evaluated, in Angstroms. mxyz - paramagnetic center coordinates as [x y z], in Angstroms. L - array of ranks of spherical harmonics of the density, Ilm   - {[],[]} array of numbers corresponding to the integral Int(rho(r,theta,phi)Y*lm(theta,phi)r^ld^3r): for L=0 Ilm=N/2/sqrt(pi), for L=1 Ilm=[imag(I11) I10 real(I11)], for L=2 Ilm=[imag(I22) imag(I21) I20 real(I21) real(I22)], chi - 3x3 matrix or 5 values for susceptibility tensor in SI Angstrom^3. Output: theor_pcs - predicted pseudocontact shift (in ppm) at each of the nuclei.&lt;br /&gt;
&lt;br /&gt;
==Visualization==&lt;br /&gt;
&lt;br /&gt;
[[volplot.m]] – volumetric plot function for scalar fields. Syntax:&lt;br /&gt;
&lt;br /&gt;
     volplot(data_cube,axis_ranges)&lt;br /&gt;
&lt;br /&gt;
where data_cube is a 3D cube of real data and axis ranges is a six-element vector giving axis extents as [xmin xmax ymin ymax zmin zmax].&lt;br /&gt;
&lt;br /&gt;
==Fitting paramagnetic shifts==&lt;br /&gt;
&lt;br /&gt;
[[ipcs.m]] – solves the inverse problem for pseudocontact shift by recovering the source term in the Kuprov equation using Tikhonov + maximum entropy regularization procedure. Syntax:&lt;br /&gt;
&lt;br /&gt;
     [source_cube,ranges,pred_pcs,diag_data]=ipcs(nxyz,expt_pcs,chi,npoints,lambda,margins)&lt;br /&gt;
&lt;br /&gt;
Parameters: nxyz - nuclear coordinates as [x y z] with multiple rows at which PCS has been measured, in Angstroms; expt_pcs - pseudocontact shift in ppm at each nucleus; chi - electron magnetic susceptibility tensor, in units of Angstrom^3; npoints  - number of points in each dimension of the source cube, a positive integer greater than 10; lambda - regularization parameters, the first element is the coefficient in front of the maximum entropy term and the second element is the coefficient in front of the Tikhonov term; margins - a six-element vector specifying margins to take around the bounding box of the nuclear coordinates supplied, to account for the possibility that the electron may be located on the periphery. Outputs: source_cube - source term cube with dimensions ordered as [X Y Z]; ranges - Cartesian axis extents for the source cube as [xmin xmax ymin ymax zmin zmax] in Angstroms; pred_pcs - pseudocontact shifts produced by the source cube returned in the first parameter; diag_data - the first element is the least squares error in ppm^2, the second element is the entropy penalty in the error functional, the third element is the tikhonov penalty in the error functional. Note: for further information on the equations and algorithms used in this function see http://dx.doi.org/10.1039/C4CP03106G&lt;br /&gt;
&lt;br /&gt;
[[ippcs.m]] – fits the point electron model PCS to the experimental pseudocontact shift coordinates and values. Syntax:&lt;br /&gt;
&lt;br /&gt;
     [exyz,chi,pred_pcs]=ippcs(nxyz,mguess,expt_pcs)&lt;br /&gt;
&lt;br /&gt;
Parameters: nxyz - nuclear coordinates as [x y z] with multiple rows, at which PCS is measured, in Angstroms; mguess - initial guess for the unpaired electron coordinates as [x y z], in Angstroms; expt_pcs - pseudocontact shift in ppm at each nucleus. Outputs: exyz - optimized unpaired electron coordinates as [x y z], in Angstroms; chi - optimized magnetic susceptibility tensor in cubic, Angstroms; pred_pcs - predicted pseudocontact shift at each nucleus with the optimized mxyz and chi, ppm; Note: a good initial guess for the electron location is essential for a successful fit.&lt;br /&gt;
&lt;br /&gt;
[[ilpcs.m]] - fits experimental PCS using the non-point approximation with multipole expansion of the density.&lt;br /&gt;
&lt;br /&gt;
     mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
&lt;br /&gt;
Parameters: nxyz  - nuclear coordinates as [x y z] with multiple rows, at which PCS is to be evaluated, in Angstroms, expt_pcs  - experimental pseudocontact shift (in ppm), L - row of ranks of spherical harmonics of the density. Output: mxyz - paramagnetic centre coordinates as [x y z], in Angstroms, Ilm - {[],[]} cell array of numbers corresponding to the multipole moments: Int(rho(r,theta,phi)Ylm(theta,phi)r^(l+2)sin(theta)d^3r): for L=0 Ilm=N/2/sqrt(pi), for L=1 Ilm=[real(I11) I10 imag(I11)], for L=2 Ilm=[real(I22) real(I21) I20 imag(I21) imag(I22)], chi   - susceptibility tensor in SI Angstrom^3, pred_pcs  - predicted pseudocontact shift (in ppm) at each of the nuclei.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Hyperfine_shift_module&amp;diff=1259</id>
		<title>Hyperfine shift module</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Hyperfine_shift_module&amp;diff=1259"/>
		<updated>2016-08-30T08:58:54Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Computing paramagnetic shifts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Spinach includes a variety of functions that compute hyperfine shifts (including, contact, pseudocontact and dipolar components) and assist in their analysis. The formalism Spinach uses to compute them is described in our recent paper on the subject (http://dx.doi.org/10.1039/C4CP03106G). This section contains an overview of the related functions, located in kernel/utilities and experiments folders.&lt;br /&gt;
&lt;br /&gt;
==Infrastructure functions==&lt;br /&gt;
&lt;br /&gt;
[[cgsppm2ang.m]] – converts magnetic susceptibility from the cgs-ppm (aka cm3/mol) units quoted by quantum chemistry packages into Å3 units required by Spinach pseudocontact shift functionality. Syntax:&lt;br /&gt;
&lt;br /&gt;
     ang=cgsppm2ang(cgsppm)&lt;br /&gt;
Arrays of any dimension are supported.&lt;br /&gt;
&lt;br /&gt;
[[fdhess.m]] – returns the finite-difference Hessian of a 3D array using a finite difference scheme with a user-specified number of stencil points. The dimensions of the 3D array are assumed to be ordered as [X Y Z]. Syntax:&lt;br /&gt;
&lt;br /&gt;
     H=fdhess(A,npoints)&lt;br /&gt;
&lt;br /&gt;
where the second parameter specifies the number of points in the finite difference stencil that should be used. The result is a 3x3 cell array of 3D matrices ordered in the following way:&lt;br /&gt;
     {d2A_dxdx  d2A_dxdy  d2A_dxdz&lt;br /&gt;
      d2A_dydx  d2A_dydy  d2A_dydz&lt;br /&gt;
      d2A_dzdx  d2A_dzdy  d2A_dzdz}&lt;br /&gt;
&lt;br /&gt;
[[fdkup.m]] – returns a finite difference representation of the Kuprov operator: &lt;br /&gt;
&lt;br /&gt;
     K[rho]=-(1/3)*Trace(Hessian[rho]*chi)&lt;br /&gt;
&lt;br /&gt;
with the number of stencil points in the finite difference approximation specified by user. Syntax:&lt;br /&gt;
&lt;br /&gt;
     K=fdkup(dims,chi,npoints)&lt;br /&gt;
&lt;br /&gt;
where dims is a three-element vector specifying the dimensions of the 3D cube of data that the operator will be acting on, chi is the electron magnetic susceptibility tensor and npoints is the number of points in the finite difference stencil. The resulting operator is a sparse matrix designed to act on the vectorization of rho. The dimensions of rho are assumed to be ordered as [X Y Z].&lt;br /&gt;
&lt;br /&gt;
[[fdlap.m]] – returns a finite-difference representation of the Laplacian for a 3D array with a user-specified finite difference stencil size. The resulting operator is a sparse matrix designed to act on the vectorization of the 3D array. The dimensions of the 3D array are assumed to be ordered as [X Y Z]. Syntax:&lt;br /&gt;
&lt;br /&gt;
     L=fdlap(dims,npoints)&lt;br /&gt;
&lt;br /&gt;
where dims is a three-element vector specifying the dimensions of 3D cube of data that the operator will be acting on, and npoints is the number of points in the finite difference stencil. Note: Dirichlet boundary conditions -- the resulting Laplacian should only be used for the inverse Laplacian operation.&lt;br /&gt;
&lt;br /&gt;
[[fdmat.m]] – returns arbitrary-order central finite-difference differentiation matrix with unit spacing and sided finite-difference schemes of the same order at the edges. Syntax:&lt;br /&gt;
&lt;br /&gt;
     D=fdmat(dim,npoints,order)&lt;br /&gt;
&lt;br /&gt;
Parameters: dim - dimension of the column vector to be differentiated; npoints - number of points in the finite difference stencil; order - order of the derivative required.&lt;br /&gt;
&lt;br /&gt;
[[interpmat.m]] – returns a matrix that acts on a stretched pseudocontact shift density cube and projects out the values of the PCS at the Cartesian coordinates given. Tricubic interpolation is used. Syntax:&lt;br /&gt;
&lt;br /&gt;
     P=interpmat(cube_dims,ranges,xyz)&lt;br /&gt;
&lt;br /&gt;
Parameters: cube_dims - PCS dimensions, ordered as [X Y Z]; ranges - Cartesian axis extents for the pseudocontact shift cube as [xmin xmax ymin ymax zmin zmax] in Angstroms; xyz - nuclear coordinates as [x y z] with multiple rows) at which PCS is to be evaluated, in Angstroms. Output: P - matrix projecting out PCS values at the given positions from the stretched PCS cube. Note: this function is a part of the PCS inverse problem solver module and should not normally be called directly by the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[fdvec.m]] – performs arbitrary-order finite-difference differentiation of a user-supplied row or column vector. Uses central finite-difference stencils in the middle and sided stencils of the same order of accuracy on the sides. Syntax:&lt;br /&gt;
&lt;br /&gt;
     dx=fdvec(x,npoints,order)&lt;br /&gt;
&lt;br /&gt;
Parameters: x - column or row vector to be differentiated; npoints - number of points in the finite difference stencil; order - order of the derivative required.&lt;br /&gt;
&lt;br /&gt;
[[fdweights.m]] – calculates finite difference weights for numerical derivatives (including order 0, which amounts to interpolation). Syntax:&lt;br /&gt;
&lt;br /&gt;
     w=fdweights(target_point,grid_points,max_order)&lt;br /&gt;
&lt;br /&gt;
Parameters: target_point - the point at which the derivative is required; grid_points - the points at which the function is given; max_order - maximum derivative order. The function returns finite difference coefficient array with the coefficients for the successive derivatives in rows.&lt;br /&gt;
&lt;br /&gt;
[[points2mult.m]] - computes multipole moments from a set of point charges&lt;br /&gt;
&lt;br /&gt;
    Ilm=points2mult(xyz,mxyz,rho,L,method)&lt;br /&gt;
&lt;br /&gt;
Parameters: xyz  - coordinates as [x y z] at which density rho is evaluated, in Angstroms, mxyz -  coordinates of origin as [x y z], in Angstroms. L    - array of ranks of spherical harmonics of the density L=[0 1 2], rho  - column of the density at the points xyz, method - &amp;#039;points&amp;#039; or &amp;#039;grid&amp;#039;. &amp;#039;Grid&amp;#039; integrates with corresponding d3r and &amp;#039;points&amp;#039; just sum the density at points. Output: Ilm  - predicted multipole moments of the density.&lt;br /&gt;
&lt;br /&gt;
[[qform2sph.m]] - Returns the spherical expansion coefficients of RT*A*R/R^2&lt;br /&gt;
 &lt;br /&gt;
    [r0,r1,r2]=qform2sph(A)&lt;br /&gt;
&lt;br /&gt;
Parameters: A - 3x3 matrix,Output: [r0,r1,r2] - coefficients for zero, first, and second rank spherical harmonics in the order -m:m &lt;br /&gt;
&lt;br /&gt;
==Computing paramagnetic shifts==&lt;br /&gt;
&lt;br /&gt;
[[hfc2pcs.m]] – converts hyperfine coupling tensors and susceptibility tensors into pseudocontact shifts using Equation 10 from the paper by Charnock and Kuprov (http://dx.doi.org/10.1039/C4CP03106G). Syntax:&lt;br /&gt;
&lt;br /&gt;
     sigma=hfc2pcs(A,chi,isotope)&lt;br /&gt;
&lt;br /&gt;
Parameters: A - hyperfine coupling tensor, in MHz; chi - magnetic susceptibility tensor, in Angstrom3. Outputs: sigma - pseudocontact shift, in ppm.&lt;br /&gt;
&lt;br /&gt;
[[hfc2pms.m]] – converts hyperfine coupling tensors and susceptibility tensors into paramagnetic shift tensors using Equation 10 from the paper by Charnock and Kuprov (http://dx.doi.org/10.1039/C4CP03106G). Syntax:&lt;br /&gt;
&lt;br /&gt;
     sigma=hfc2pms(A,chi,isotope)&lt;br /&gt;
&lt;br /&gt;
Parameters: A - hyperfine coupling tensor, in MHz; chi - magnetic susceptibility tensor, in Angstrom3. Outputs: sigma - dipolar shift tensor, in ppm. Note: both the susceptibility tensor and the hyperfine tensor must be submitted to this function with their isotropic parts preserved – do not make them traceless.&lt;br /&gt;
&lt;br /&gt;
[[kpcs.m]] – computes the three-dimensional distribution of pseudocontact shift field by solving Kuprov equation for PCS. Syntax:&lt;br /&gt;
&lt;br /&gt;
     [pcs_cube,pcs_vals]=kpcs(probden,chi,ranges,nxyz)&lt;br /&gt;
&lt;br /&gt;
Parameters: probden - electron probability density cube; chi - electron magnetic susceptibility tensor in cubic Angstroms; ranges - Cartesian axis extents for the electron spin density cube as [xmin xmax ymin ymax zmin zmax] in angstroms; nxyz - nuclear coordinates as [x y z] with multiple rows) at which PCS is to be evaluated, in Angstroms. Output: pcs_vals - pseudocontact shift in ppm at each nucleus;  pcs_cube - pseudocontact shift field on the same grid as the spin density supplied. Note: minimal three-point schemes are used for the finite difference operators. Increase stencil size if you have enough memory. Note: for further information on the equations and algorithms used in this function see http://dx.doi.org/10.1039/C4CP03106G.&lt;br /&gt;
&lt;br /&gt;
[[ppcs.m]] – computes pseudocontact shift from a point electron centre at the nuclear coordinates supplied. Syntax:&lt;br /&gt;
&lt;br /&gt;
     pcs_vals=ppcs(nxyz,mxyz,chi)&lt;br /&gt;
&lt;br /&gt;
Parameters: chi - electron magnetic susceptibility tensor in cubic Angstroms; nxyz - nuclear coordinates as [x y z] with multiple rows, at which PCS is to be evaluated, in Angstroms; mxyz - paramagnetic centre coordinates as [x y z], in Angstroms; Output: pred_pcs - predicted pseudocontact shift (in ppm) at each of the nuclei.&lt;br /&gt;
&lt;br /&gt;
[[lpcs.m]] - computes PCS from paramagnetic density (rho) outside the bounding sphere based on the multipole moments expansion&lt;br /&gt;
&lt;br /&gt;
Parameters: nxyz  - nuclear coordinates as [x y z] with multiple rows, at which PCS is to be evaluated, in Angstroms. mxyz - paramagnetic center coordinates as [x y z], in Angstroms. L - array of ranks of spherical harmonics of the density, Ilm   - {[],[]} array of numbers corresponding to the integral Int(rho(r,theta,phi)Y*lm(theta,phi)r^ld^3r): for L=0 Ilm=N/2/sqrt(pi), for L=1 Ilm=[imag(I11) I10 real(I11)], for L=2 Ilm=[imag(I22) imag(I21) I20 real(I21) real(I22)], chi - 3x3 matrix or 5 values for susceptibility tensor in SI Angstrom^3. Output: theor_pcs - predicted pseudocontact shift (in ppm) at each of the nuclei.&lt;br /&gt;
&lt;br /&gt;
==Visualization==&lt;br /&gt;
&lt;br /&gt;
[[volplot.m]] – volumetric plot function for scalar fields. Syntax:&lt;br /&gt;
&lt;br /&gt;
     volplot(data_cube,axis_ranges)&lt;br /&gt;
&lt;br /&gt;
where data_cube is a 3D cube of real data and axis ranges is a six-element vector giving axis extents as [xmin xmax ymin ymax zmin zmax].&lt;br /&gt;
&lt;br /&gt;
==Fitting paramagnetic shifts==&lt;br /&gt;
&lt;br /&gt;
[[ipcs.m]] – solves the inverse problem for pseudocontact shift by recovering the source term in the Kuprov equation using Tikhonov + maximum entropy regularization procedure. Syntax:&lt;br /&gt;
&lt;br /&gt;
     [source_cube,ranges,pred_pcs,diag_data]=ipcs(nxyz,expt_pcs,chi,npoints,lambda,margins)&lt;br /&gt;
&lt;br /&gt;
Parameters: nxyz - nuclear coordinates as [x y z] with multiple rows at which PCS has been measured, in Angstroms; expt_pcs - pseudocontact shift in ppm at each nucleus; chi - electron magnetic susceptibility tensor, in units of Angstrom^3; npoints  - number of points in each dimension of the source cube, a positive integer greater than 10; lambda - regularization parameters, the first element is the coefficient in front of the maximum entropy term and the second element is the coefficient in front of the Tikhonov term; margins - a six-element vector specifying margins to take around the bounding box of the nuclear coordinates supplied, to account for the possibility that the electron may be located on the periphery. Outputs: source_cube - source term cube with dimensions ordered as [X Y Z]; ranges - Cartesian axis extents for the source cube as [xmin xmax ymin ymax zmin zmax] in Angstroms; pred_pcs - pseudocontact shifts produced by the source cube returned in the first parameter; diag_data - the first element is the least squares error in ppm^2, the second element is the entropy penalty in the error functional, the third element is the tikhonov penalty in the error functional. Note: for further information on the equations and algorithms used in this function see http://dx.doi.org/10.1039/C4CP03106G&lt;br /&gt;
&lt;br /&gt;
[[ippcs.m]] – fits the point electron model PCS to the experimental pseudocontact shift coordinates and values. Syntax:&lt;br /&gt;
&lt;br /&gt;
     [exyz,chi,pred_pcs]=ippcs(nxyz,mguess,expt_pcs)&lt;br /&gt;
&lt;br /&gt;
Parameters: nxyz - nuclear coordinates as [x y z] with multiple rows, at which PCS is measured, in Angstroms; mguess - initial guess for the unpaired electron coordinates as [x y z], in Angstroms; expt_pcs - pseudocontact shift in ppm at each nucleus. Outputs: exyz - optimized unpaired electron coordinates as [x y z], in Angstroms; chi - optimized magnetic susceptibility tensor in cubic, Angstroms; pred_pcs - predicted pseudocontact shift at each nucleus with the optimized mxyz and chi, ppm; Note: a good initial guess for the electron location is essential for a successful fit.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Qform2sph.m&amp;diff=1258</id>
		<title>Qform2sph.m</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Qform2sph.m&amp;diff=1258"/>
		<updated>2016-08-30T08:51:40Z</updated>

		<summary type="html">&lt;p&gt;Suturina: Created page with &amp;quot;Returns the spherical expansion coefficients of RT*A*R/R^2=Sum(rL(M)YLM). Parameters:    A - 3x3 matrix Output:   [r0,r1,r2] - coefficients for zero, first, and second rank sp...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Returns the spherical expansion coefficients of RT*A*R/R^2=Sum(rL(M)YLM).&lt;br /&gt;
Parameters:&lt;br /&gt;
   A - 3x3 matrix&lt;br /&gt;
Output:&lt;br /&gt;
  [r0,r1,r2] - coefficients for zero, first, and second rank spherical&lt;br /&gt;
               harmonics in the order -m:m &lt;br /&gt;
&lt;br /&gt;
  [r0,r1,r2]=qform2sph(A)&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Hyperfine_shift_module&amp;diff=1257</id>
		<title>Hyperfine shift module</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Hyperfine_shift_module&amp;diff=1257"/>
		<updated>2016-08-30T08:50:41Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Spinach includes a variety of functions that compute hyperfine shifts (including, contact, pseudocontact and dipolar components) and assist in their analysis. The formalism Spinach uses to compute them is described in our recent paper on the subject (http://dx.doi.org/10.1039/C4CP03106G). This section contains an overview of the related functions, located in kernel/utilities and experiments folders.&lt;br /&gt;
&lt;br /&gt;
==Infrastructure functions==&lt;br /&gt;
&lt;br /&gt;
[[cgsppm2ang.m]] – converts magnetic susceptibility from the cgs-ppm (aka cm3/mol) units quoted by quantum chemistry packages into Å3 units required by Spinach pseudocontact shift functionality. Syntax:&lt;br /&gt;
&lt;br /&gt;
     ang=cgsppm2ang(cgsppm)&lt;br /&gt;
Arrays of any dimension are supported.&lt;br /&gt;
&lt;br /&gt;
[[fdhess.m]] – returns the finite-difference Hessian of a 3D array using a finite difference scheme with a user-specified number of stencil points. The dimensions of the 3D array are assumed to be ordered as [X Y Z]. Syntax:&lt;br /&gt;
&lt;br /&gt;
     H=fdhess(A,npoints)&lt;br /&gt;
&lt;br /&gt;
where the second parameter specifies the number of points in the finite difference stencil that should be used. The result is a 3x3 cell array of 3D matrices ordered in the following way:&lt;br /&gt;
     {d2A_dxdx  d2A_dxdy  d2A_dxdz&lt;br /&gt;
      d2A_dydx  d2A_dydy  d2A_dydz&lt;br /&gt;
      d2A_dzdx  d2A_dzdy  d2A_dzdz}&lt;br /&gt;
&lt;br /&gt;
[[fdkup.m]] – returns a finite difference representation of the Kuprov operator: &lt;br /&gt;
&lt;br /&gt;
     K[rho]=-(1/3)*Trace(Hessian[rho]*chi)&lt;br /&gt;
&lt;br /&gt;
with the number of stencil points in the finite difference approximation specified by user. Syntax:&lt;br /&gt;
&lt;br /&gt;
     K=fdkup(dims,chi,npoints)&lt;br /&gt;
&lt;br /&gt;
where dims is a three-element vector specifying the dimensions of the 3D cube of data that the operator will be acting on, chi is the electron magnetic susceptibility tensor and npoints is the number of points in the finite difference stencil. The resulting operator is a sparse matrix designed to act on the vectorization of rho. The dimensions of rho are assumed to be ordered as [X Y Z].&lt;br /&gt;
&lt;br /&gt;
[[fdlap.m]] – returns a finite-difference representation of the Laplacian for a 3D array with a user-specified finite difference stencil size. The resulting operator is a sparse matrix designed to act on the vectorization of the 3D array. The dimensions of the 3D array are assumed to be ordered as [X Y Z]. Syntax:&lt;br /&gt;
&lt;br /&gt;
     L=fdlap(dims,npoints)&lt;br /&gt;
&lt;br /&gt;
where dims is a three-element vector specifying the dimensions of 3D cube of data that the operator will be acting on, and npoints is the number of points in the finite difference stencil. Note: Dirichlet boundary conditions -- the resulting Laplacian should only be used for the inverse Laplacian operation.&lt;br /&gt;
&lt;br /&gt;
[[fdmat.m]] – returns arbitrary-order central finite-difference differentiation matrix with unit spacing and sided finite-difference schemes of the same order at the edges. Syntax:&lt;br /&gt;
&lt;br /&gt;
     D=fdmat(dim,npoints,order)&lt;br /&gt;
&lt;br /&gt;
Parameters: dim - dimension of the column vector to be differentiated; npoints - number of points in the finite difference stencil; order - order of the derivative required.&lt;br /&gt;
&lt;br /&gt;
[[interpmat.m]] – returns a matrix that acts on a stretched pseudocontact shift density cube and projects out the values of the PCS at the Cartesian coordinates given. Tricubic interpolation is used. Syntax:&lt;br /&gt;
&lt;br /&gt;
     P=interpmat(cube_dims,ranges,xyz)&lt;br /&gt;
&lt;br /&gt;
Parameters: cube_dims - PCS dimensions, ordered as [X Y Z]; ranges - Cartesian axis extents for the pseudocontact shift cube as [xmin xmax ymin ymax zmin zmax] in Angstroms; xyz - nuclear coordinates as [x y z] with multiple rows) at which PCS is to be evaluated, in Angstroms. Output: P - matrix projecting out PCS values at the given positions from the stretched PCS cube. Note: this function is a part of the PCS inverse problem solver module and should not normally be called directly by the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[fdvec.m]] – performs arbitrary-order finite-difference differentiation of a user-supplied row or column vector. Uses central finite-difference stencils in the middle and sided stencils of the same order of accuracy on the sides. Syntax:&lt;br /&gt;
&lt;br /&gt;
     dx=fdvec(x,npoints,order)&lt;br /&gt;
&lt;br /&gt;
Parameters: x - column or row vector to be differentiated; npoints - number of points in the finite difference stencil; order - order of the derivative required.&lt;br /&gt;
&lt;br /&gt;
[[fdweights.m]] – calculates finite difference weights for numerical derivatives (including order 0, which amounts to interpolation). Syntax:&lt;br /&gt;
&lt;br /&gt;
     w=fdweights(target_point,grid_points,max_order)&lt;br /&gt;
&lt;br /&gt;
Parameters: target_point - the point at which the derivative is required; grid_points - the points at which the function is given; max_order - maximum derivative order. The function returns finite difference coefficient array with the coefficients for the successive derivatives in rows.&lt;br /&gt;
&lt;br /&gt;
[[points2mult.m]] - computes multipole moments from a set of point charges&lt;br /&gt;
&lt;br /&gt;
    Ilm=points2mult(xyz,mxyz,rho,L,method)&lt;br /&gt;
&lt;br /&gt;
Parameters: xyz  - coordinates as [x y z] at which density rho is evaluated, in Angstroms, mxyz -  coordinates of origin as [x y z], in Angstroms. L    - array of ranks of spherical harmonics of the density L=[0 1 2], rho  - column of the density at the points xyz, method - &amp;#039;points&amp;#039; or &amp;#039;grid&amp;#039;. &amp;#039;Grid&amp;#039; integrates with corresponding d3r and &amp;#039;points&amp;#039; just sum the density at points. Output: Ilm  - predicted multipole moments of the density.&lt;br /&gt;
&lt;br /&gt;
[[qform2sph.m]] - Returns the spherical expansion coefficients of RT*A*R/R^2&lt;br /&gt;
 &lt;br /&gt;
    [r0,r1,r2]=qform2sph(A)&lt;br /&gt;
&lt;br /&gt;
Parameters: A - 3x3 matrix,Output: [r0,r1,r2] - coefficients for zero, first, and second rank spherical harmonics in the order -m:m &lt;br /&gt;
&lt;br /&gt;
==Computing paramagnetic shifts==&lt;br /&gt;
&lt;br /&gt;
[[hfc2pcs.m]] – converts hyperfine coupling tensors and susceptibility tensors into pseudocontact shifts using Equation 10 from the paper by Charnock and Kuprov (http://dx.doi.org/10.1039/C4CP03106G). Syntax:&lt;br /&gt;
&lt;br /&gt;
     sigma=hfc2pcs(A,chi,isotope)&lt;br /&gt;
&lt;br /&gt;
Parameters: A - hyperfine coupling tensor, in MHz; chi - magnetic susceptibility tensor, in Angstrom3. Outputs: sigma - pseudocontact shift, in ppm.&lt;br /&gt;
&lt;br /&gt;
[[hfc2pms.m]] – converts hyperfine coupling tensors and susceptibility tensors into paramagnetic shift tensors using Equation 10 from the paper by Charnock and Kuprov (http://dx.doi.org/10.1039/C4CP03106G). Syntax:&lt;br /&gt;
&lt;br /&gt;
     sigma=hfc2pms(A,chi,isotope)&lt;br /&gt;
&lt;br /&gt;
Parameters: A - hyperfine coupling tensor, in MHz; chi - magnetic susceptibility tensor, in Angstrom3. Outputs: sigma - dipolar shift tensor, in ppm. Note: both the susceptibility tensor and the hyperfine tensor must be submitted to this function with their isotropic parts preserved – do not make them traceless.&lt;br /&gt;
&lt;br /&gt;
[[kpcs.m]] – computes the three-dimensional distribution of pseudocontact shift field by solving Kuprov equation for PCS. Syntax:&lt;br /&gt;
&lt;br /&gt;
     [pcs_cube,pcs_vals]=kpcs(probden,chi,ranges,nxyz)&lt;br /&gt;
&lt;br /&gt;
Parameters: probden - electron probability density cube; chi - electron magnetic susceptibility tensor in cubic Angstroms; ranges - Cartesian axis extents for the electron spin density cube as [xmin xmax ymin ymax zmin zmax] in angstroms; nxyz - nuclear coordinates as [x y z] with multiple rows) at which PCS is to be evaluated, in Angstroms. Output: pcs_vals - pseudocontact shift in ppm at each nucleus;  pcs_cube - pseudocontact shift field on the same grid as the spin density supplied. Note: minimal three-point schemes are used for the finite difference operators. Increase stencil size if you have enough memory. Note: for further information on the equations and algorithms used in this function see http://dx.doi.org/10.1039/C4CP03106G.&lt;br /&gt;
&lt;br /&gt;
[[ppcs.m]] – computes pseudocontact shift from a point electron centre at the nuclear coordinates supplied. Syntax:&lt;br /&gt;
&lt;br /&gt;
     pcs_vals=ppcs(nxyz,mxyz,chi)&lt;br /&gt;
&lt;br /&gt;
Parameters: chi - electron magnetic susceptibility tensor in cubic Angstroms; nxyz - nuclear coordinates as [x y z] with multiple rows, at which PCS is to be evaluated, in Angstroms; mxyz - paramagnetic centre coordinates as [x y z], in Angstroms; Output: pred_pcs - predicted pseudocontact shift (in ppm) at each of the nuclei.&lt;br /&gt;
&lt;br /&gt;
==Visualization==&lt;br /&gt;
&lt;br /&gt;
[[volplot.m]] – volumetric plot function for scalar fields. Syntax:&lt;br /&gt;
&lt;br /&gt;
     volplot(data_cube,axis_ranges)&lt;br /&gt;
&lt;br /&gt;
where data_cube is a 3D cube of real data and axis ranges is a six-element vector giving axis extents as [xmin xmax ymin ymax zmin zmax].&lt;br /&gt;
&lt;br /&gt;
==Fitting paramagnetic shifts==&lt;br /&gt;
&lt;br /&gt;
[[ipcs.m]] – solves the inverse problem for pseudocontact shift by recovering the source term in the Kuprov equation using Tikhonov + maximum entropy regularization procedure. Syntax:&lt;br /&gt;
&lt;br /&gt;
     [source_cube,ranges,pred_pcs,diag_data]=ipcs(nxyz,expt_pcs,chi,npoints,lambda,margins)&lt;br /&gt;
&lt;br /&gt;
Parameters: nxyz - nuclear coordinates as [x y z] with multiple rows at which PCS has been measured, in Angstroms; expt_pcs - pseudocontact shift in ppm at each nucleus; chi - electron magnetic susceptibility tensor, in units of Angstrom^3; npoints  - number of points in each dimension of the source cube, a positive integer greater than 10; lambda - regularization parameters, the first element is the coefficient in front of the maximum entropy term and the second element is the coefficient in front of the Tikhonov term; margins - a six-element vector specifying margins to take around the bounding box of the nuclear coordinates supplied, to account for the possibility that the electron may be located on the periphery. Outputs: source_cube - source term cube with dimensions ordered as [X Y Z]; ranges - Cartesian axis extents for the source cube as [xmin xmax ymin ymax zmin zmax] in Angstroms; pred_pcs - pseudocontact shifts produced by the source cube returned in the first parameter; diag_data - the first element is the least squares error in ppm^2, the second element is the entropy penalty in the error functional, the third element is the tikhonov penalty in the error functional. Note: for further information on the equations and algorithms used in this function see http://dx.doi.org/10.1039/C4CP03106G&lt;br /&gt;
&lt;br /&gt;
[[ippcs.m]] – fits the point electron model PCS to the experimental pseudocontact shift coordinates and values. Syntax:&lt;br /&gt;
&lt;br /&gt;
     [exyz,chi,pred_pcs]=ippcs(nxyz,mguess,expt_pcs)&lt;br /&gt;
&lt;br /&gt;
Parameters: nxyz - nuclear coordinates as [x y z] with multiple rows, at which PCS is measured, in Angstroms; mguess - initial guess for the unpaired electron coordinates as [x y z], in Angstroms; expt_pcs - pseudocontact shift in ppm at each nucleus. Outputs: exyz - optimized unpaired electron coordinates as [x y z], in Angstroms; chi - optimized magnetic susceptibility tensor in cubic, Angstroms; pred_pcs - predicted pseudocontact shift at each nucleus with the optimized mxyz and chi, ppm; Note: a good initial guess for the electron location is essential for a successful fit.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Points2mult.m&amp;diff=1256</id>
		<title>Points2mult.m</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Points2mult.m&amp;diff=1256"/>
		<updated>2016-08-30T08:28:40Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Computes multipole moments from a set of point charges&lt;br /&gt;
Parameters: &lt;br /&gt;
&lt;br /&gt;
    xyz    - coordinates as [x y z] with multiple rows,&lt;br /&gt;
             at which density rho is evaluated, in Angstroms.&lt;br /&gt;
&lt;br /&gt;
    mxyz   - coordinates  of origin as [x y z], in Angstroms.&lt;br /&gt;
&lt;br /&gt;
    L      - array of ranks of spherical harmonics of the density&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    rho    - column of the density at the points xyz&lt;br /&gt;
&lt;br /&gt;
    method - &amp;#039;points&amp;#039; or &amp;#039;grid&amp;#039;. &amp;#039;Grid&amp;#039; integrates with corresponding d3r&lt;br /&gt;
             and &amp;#039;points&amp;#039; just sum the density at points. &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Ilm    - predicted multipole moments of the density&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Hyperfine_shift_module&amp;diff=1255</id>
		<title>Hyperfine shift module</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Hyperfine_shift_module&amp;diff=1255"/>
		<updated>2016-08-30T08:27:42Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Computing paramagnetic shifts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Spinach includes a variety of functions that compute hyperfine shifts (including, contact, pseudocontact and dipolar components) and assist in their analysis. The formalism Spinach uses to compute them is described in our recent paper on the subject (http://dx.doi.org/10.1039/C4CP03106G). This section contains an overview of the related functions, located in kernel/utilities and experiments folders.&lt;br /&gt;
&lt;br /&gt;
==Infrastructure functions==&lt;br /&gt;
&lt;br /&gt;
[[cgsppm2ang.m]] – converts magnetic susceptibility from the cgs-ppm (aka cm3/mol) units quoted by quantum chemistry packages into Å3 units required by Spinach pseudocontact shift functionality. Syntax:&lt;br /&gt;
&lt;br /&gt;
     ang=cgsppm2ang(cgsppm)&lt;br /&gt;
Arrays of any dimension are supported.&lt;br /&gt;
&lt;br /&gt;
[[fdhess.m]] – returns the finite-difference Hessian of a 3D array using a finite difference scheme with a user-specified number of stencil points. The dimensions of the 3D array are assumed to be ordered as [X Y Z]. Syntax:&lt;br /&gt;
&lt;br /&gt;
     H=fdhess(A,npoints)&lt;br /&gt;
&lt;br /&gt;
where the second parameter specifies the number of points in the finite difference stencil that should be used. The result is a 3x3 cell array of 3D matrices ordered in the following way:&lt;br /&gt;
     {d2A_dxdx  d2A_dxdy  d2A_dxdz&lt;br /&gt;
      d2A_dydx  d2A_dydy  d2A_dydz&lt;br /&gt;
      d2A_dzdx  d2A_dzdy  d2A_dzdz}&lt;br /&gt;
&lt;br /&gt;
[[fdkup.m]] – returns a finite difference representation of the Kuprov operator: &lt;br /&gt;
&lt;br /&gt;
     K[rho]=-(1/3)*Trace(Hessian[rho]*chi)&lt;br /&gt;
&lt;br /&gt;
with the number of stencil points in the finite difference approximation specified by user. Syntax:&lt;br /&gt;
&lt;br /&gt;
     K=fdkup(dims,chi,npoints)&lt;br /&gt;
&lt;br /&gt;
where dims is a three-element vector specifying the dimensions of the 3D cube of data that the operator will be acting on, chi is the electron magnetic susceptibility tensor and npoints is the number of points in the finite difference stencil. The resulting operator is a sparse matrix designed to act on the vectorization of rho. The dimensions of rho are assumed to be ordered as [X Y Z].&lt;br /&gt;
&lt;br /&gt;
[[fdlap.m]] – returns a finite-difference representation of the Laplacian for a 3D array with a user-specified finite difference stencil size. The resulting operator is a sparse matrix designed to act on the vectorization of the 3D array. The dimensions of the 3D array are assumed to be ordered as [X Y Z]. Syntax:&lt;br /&gt;
&lt;br /&gt;
     L=fdlap(dims,npoints)&lt;br /&gt;
&lt;br /&gt;
where dims is a three-element vector specifying the dimensions of 3D cube of data that the operator will be acting on, and npoints is the number of points in the finite difference stencil. Note: Dirichlet boundary conditions -- the resulting Laplacian should only be used for the inverse Laplacian operation.&lt;br /&gt;
&lt;br /&gt;
[[fdmat.m]] – returns arbitrary-order central finite-difference differentiation matrix with unit spacing and sided finite-difference schemes of the same order at the edges. Syntax:&lt;br /&gt;
&lt;br /&gt;
     D=fdmat(dim,npoints,order)&lt;br /&gt;
&lt;br /&gt;
Parameters: dim - dimension of the column vector to be differentiated; npoints - number of points in the finite difference stencil; order - order of the derivative required.&lt;br /&gt;
&lt;br /&gt;
[[interpmat.m]] – returns a matrix that acts on a stretched pseudocontact shift density cube and projects out the values of the PCS at the Cartesian coordinates given. Tricubic interpolation is used. Syntax:&lt;br /&gt;
&lt;br /&gt;
     P=interpmat(cube_dims,ranges,xyz)&lt;br /&gt;
&lt;br /&gt;
Parameters: cube_dims - PCS dimensions, ordered as [X Y Z]; ranges - Cartesian axis extents for the pseudocontact shift cube as [xmin xmax ymin ymax zmin zmax] in Angstroms; xyz - nuclear coordinates as [x y z] with multiple rows) at which PCS is to be evaluated, in Angstroms. Output: P - matrix projecting out PCS values at the given positions from the stretched PCS cube. Note: this function is a part of the PCS inverse problem solver module and should not normally be called directly by the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[fdvec.m]] – performs arbitrary-order finite-difference differentiation of a user-supplied row or column vector. Uses central finite-difference stencils in the middle and sided stencils of the same order of accuracy on the sides. Syntax:&lt;br /&gt;
&lt;br /&gt;
     dx=fdvec(x,npoints,order)&lt;br /&gt;
&lt;br /&gt;
Parameters: x - column or row vector to be differentiated; npoints - number of points in the finite difference stencil; order - order of the derivative required.&lt;br /&gt;
&lt;br /&gt;
[[fdweights.m]] – calculates finite difference weights for numerical derivatives (including order 0, which amounts to interpolation). Syntax:&lt;br /&gt;
&lt;br /&gt;
     w=fdweights(target_point,grid_points,max_order)&lt;br /&gt;
&lt;br /&gt;
Parameters: target_point - the point at which the derivative is required; grid_points - the points at which the function is given; max_order - maximum derivative order. The function returns finite difference coefficient array with the coefficients for the successive derivatives in rows.&lt;br /&gt;
&lt;br /&gt;
==Computing paramagnetic shifts==&lt;br /&gt;
&lt;br /&gt;
[[hfc2pcs.m]] – converts hyperfine coupling tensors and susceptibility tensors into pseudocontact shifts using Equation 10 from the paper by Charnock and Kuprov (http://dx.doi.org/10.1039/C4CP03106G). Syntax:&lt;br /&gt;
&lt;br /&gt;
     sigma=hfc2pcs(A,chi,isotope)&lt;br /&gt;
&lt;br /&gt;
Parameters: A - hyperfine coupling tensor, in MHz; chi - magnetic susceptibility tensor, in Angstrom3. Outputs: sigma - pseudocontact shift, in ppm.&lt;br /&gt;
&lt;br /&gt;
[[hfc2pms.m]] – converts hyperfine coupling tensors and susceptibility tensors into paramagnetic shift tensors using Equation 10 from the paper by Charnock and Kuprov (http://dx.doi.org/10.1039/C4CP03106G). Syntax:&lt;br /&gt;
&lt;br /&gt;
     sigma=hfc2pms(A,chi,isotope)&lt;br /&gt;
&lt;br /&gt;
Parameters: A - hyperfine coupling tensor, in MHz; chi - magnetic susceptibility tensor, in Angstrom3. Outputs: sigma - dipolar shift tensor, in ppm. Note: both the susceptibility tensor and the hyperfine tensor must be submitted to this function with their isotropic parts preserved – do not make them traceless.&lt;br /&gt;
&lt;br /&gt;
[[kpcs.m]] – computes the three-dimensional distribution of pseudocontact shift field by solving Kuprov equation for PCS. Syntax:&lt;br /&gt;
&lt;br /&gt;
     [pcs_cube,pcs_vals]=kpcs(probden,chi,ranges,nxyz)&lt;br /&gt;
&lt;br /&gt;
Parameters: probden - electron probability density cube; chi - electron magnetic susceptibility tensor in cubic Angstroms; ranges - Cartesian axis extents for the electron spin density cube as [xmin xmax ymin ymax zmin zmax] in angstroms; nxyz - nuclear coordinates as [x y z] with multiple rows) at which PCS is to be evaluated, in Angstroms. Output: pcs_vals - pseudocontact shift in ppm at each nucleus;  pcs_cube - pseudocontact shift field on the same grid as the spin density supplied. Note: minimal three-point schemes are used for the finite difference operators. Increase stencil size if you have enough memory. Note: for further information on the equations and algorithms used in this function see http://dx.doi.org/10.1039/C4CP03106G.&lt;br /&gt;
&lt;br /&gt;
[[ppcs.m]] – computes pseudocontact shift from a point electron centre at the nuclear coordinates supplied. Syntax:&lt;br /&gt;
&lt;br /&gt;
     pcs_vals=ppcs(nxyz,mxyz,chi)&lt;br /&gt;
&lt;br /&gt;
Parameters: chi - electron magnetic susceptibility tensor in cubic Angstroms; nxyz - nuclear coordinates as [x y z] with multiple rows, at which PCS is to be evaluated, in Angstroms; mxyz - paramagnetic centre coordinates as [x y z], in Angstroms; Output: pred_pcs - predicted pseudocontact shift (in ppm) at each of the nuclei.&lt;br /&gt;
&lt;br /&gt;
[[points2mult.m]] - computes multipole moments from a set of point charges&lt;br /&gt;
&lt;br /&gt;
    Ilm=points2mult(xyz,mxyz,rho,L,method)&lt;br /&gt;
&lt;br /&gt;
Parameters: xyz  - coordinates as [x y z] at which density rho is evaluated, in Angstroms, mxyz -  coordinates of origin as [x y z], in Angstroms. L    - array of ranks of spherical harmonics of the density L=[0 1 2], rho  - column of the density at the points xyz, method - &amp;#039;points&amp;#039; or &amp;#039;grid&amp;#039;. &amp;#039;Grid&amp;#039; integrates with corresponding d3r and &amp;#039;points&amp;#039; just sum the density at points. Output: Ilm  - predicted multipole moments of the density.&lt;br /&gt;
&lt;br /&gt;
==Visualization==&lt;br /&gt;
&lt;br /&gt;
[[volplot.m]] – volumetric plot function for scalar fields. Syntax:&lt;br /&gt;
&lt;br /&gt;
     volplot(data_cube,axis_ranges)&lt;br /&gt;
&lt;br /&gt;
where data_cube is a 3D cube of real data and axis ranges is a six-element vector giving axis extents as [xmin xmax ymin ymax zmin zmax].&lt;br /&gt;
&lt;br /&gt;
==Fitting paramagnetic shifts==&lt;br /&gt;
&lt;br /&gt;
[[ipcs.m]] – solves the inverse problem for pseudocontact shift by recovering the source term in the Kuprov equation using Tikhonov + maximum entropy regularization procedure. Syntax:&lt;br /&gt;
&lt;br /&gt;
     [source_cube,ranges,pred_pcs,diag_data]=ipcs(nxyz,expt_pcs,chi,npoints,lambda,margins)&lt;br /&gt;
&lt;br /&gt;
Parameters: nxyz - nuclear coordinates as [x y z] with multiple rows at which PCS has been measured, in Angstroms; expt_pcs - pseudocontact shift in ppm at each nucleus; chi - electron magnetic susceptibility tensor, in units of Angstrom^3; npoints  - number of points in each dimension of the source cube, a positive integer greater than 10; lambda - regularization parameters, the first element is the coefficient in front of the maximum entropy term and the second element is the coefficient in front of the Tikhonov term; margins - a six-element vector specifying margins to take around the bounding box of the nuclear coordinates supplied, to account for the possibility that the electron may be located on the periphery. Outputs: source_cube - source term cube with dimensions ordered as [X Y Z]; ranges - Cartesian axis extents for the source cube as [xmin xmax ymin ymax zmin zmax] in Angstroms; pred_pcs - pseudocontact shifts produced by the source cube returned in the first parameter; diag_data - the first element is the least squares error in ppm^2, the second element is the entropy penalty in the error functional, the third element is the tikhonov penalty in the error functional. Note: for further information on the equations and algorithms used in this function see http://dx.doi.org/10.1039/C4CP03106G&lt;br /&gt;
&lt;br /&gt;
[[ippcs.m]] – fits the point electron model PCS to the experimental pseudocontact shift coordinates and values. Syntax:&lt;br /&gt;
&lt;br /&gt;
     [exyz,chi,pred_pcs]=ippcs(nxyz,mguess,expt_pcs)&lt;br /&gt;
&lt;br /&gt;
Parameters: nxyz - nuclear coordinates as [x y z] with multiple rows, at which PCS is measured, in Angstroms; mguess - initial guess for the unpaired electron coordinates as [x y z], in Angstroms; expt_pcs - pseudocontact shift in ppm at each nucleus. Outputs: exyz - optimized unpaired electron coordinates as [x y z], in Angstroms; chi - optimized magnetic susceptibility tensor in cubic, Angstroms; pred_pcs - predicted pseudocontact shift at each nucleus with the optimized mxyz and chi, ppm; Note: a good initial guess for the electron location is essential for a successful fit.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Oparse.m&amp;diff=1231</id>
		<title>Oparse.m</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Oparse.m&amp;diff=1231"/>
		<updated>2016-08-25T16:59:40Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Returns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A parser for ORCA calculation logs.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&lt;br /&gt;
     props=oparse(filename)&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
The function extracts all potentially useful information from the ORCA log.&lt;br /&gt;
&lt;br /&gt;
==Arguments==&lt;br /&gt;
&lt;br /&gt;
     filename - the name of the file to be parsed, a character string&lt;br /&gt;
&lt;br /&gt;
==Returns==                &lt;br /&gt;
The following output fields are returned, &amp;#039;&amp;#039;if the corresponding information is present in the log file&amp;#039;&amp;#039;:&lt;br /&gt;
             &lt;br /&gt;
     props.std_geom         - standard geometry, natoms x 3 array, Angstrom&lt;br /&gt;
 &lt;br /&gt;
     props.natoms           - number of atoms, an integer&lt;br /&gt;
 &lt;br /&gt;
     props.hfc.full.eigvals - HFC eigenvalues, natoms x 1 cell array of 3x1 vectors, Gauss&lt;br /&gt;
 &lt;br /&gt;
     props.hfc.full.eigvecs - HFC eigenvectors, natoms x 1 cell array of 3x3 matrices&lt;br /&gt;
 &lt;br /&gt;
     props.hfc.full.matrix  - HFC tensors, natoms x 1 cell array of 3x3 matrices, Gauss&lt;br /&gt;
 &lt;br /&gt;
     props.g_tensor.matrix  - g-tensor, 3x3 matrix, Bohr magneton units&lt;br /&gt;
 &lt;br /&gt;
     props.efg              - electric field gradient tensors, a.u.^-3&lt;br /&gt;
 &lt;br /&gt;
     props.symbols          - atomic symbols, nspins x 1 cell array of character strings&lt;br /&gt;
 &lt;br /&gt;
     props.filename         - log file name, a character string&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
None at the moment.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
# Chemical shielding is &amp;#039;&amp;#039;not&amp;#039;&amp;#039; the same as chemical shift.&lt;br /&gt;
# This function parses ORCA logs. Use [[g2spinach.m]] to convert that information into &amp;#039;&amp;#039;Spinach&amp;#039;&amp;#039; input structures.&lt;br /&gt;
# The parser is a bit old-school. If you are proficient with regular expressoins, we would really appreciate a hand.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[gparse.m]], [[g2spinach.m]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Revision 3284, authors: [[Ilya Kuprov]]&amp;#039;&amp;#039;&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1228</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1228"/>
		<updated>2016-08-25T09:58:07Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Example 2a. Correction to point PCS from spin density delocalization. Cobalt porphyrin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Copper porphyrin=====&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Co)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1227</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1227"/>
		<updated>2016-08-25T09:57:45Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Example 2a. Correction to point PCS from spin density delocalization. Cobalt porphyrin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Cobalt porphyrin=====&lt;br /&gt;
Spin density in copper porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Co)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at -1.00 and -1.57 ppm and non-point model - at -1.21 and -1.81 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1226</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1226"/>
		<updated>2016-08-24T15:15:54Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Example 2a. Correction to point PCS from spin density delocalization. Cobalt porphyrin */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Cobalt porphyrin=====&lt;br /&gt;
Spin density in cobalt porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
         0.000000000000      0.000000000000      0.000000000000&lt;br /&gt;
        -1.452280156504      1.452280156496      0.000000000000&lt;br /&gt;
         1.452280156504     -1.452280156496      0.000000000000&lt;br /&gt;
        -1.452280156496     -1.452280156504      0.000000000000&lt;br /&gt;
         1.452280156496      1.452280156504      0.000000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Co)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at 5.95 and 9.35 ppm and non-point model - at 7.18 and 10.76 ppm.&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1225</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1225"/>
		<updated>2016-08-24T13:12:00Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Cobalt porphyrin=====&lt;br /&gt;
Spin density in cobalt porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with corresponding spin population&lt;br /&gt;
      xyz=[&lt;br /&gt;
       0.000000000      0.000000000      0.000000000   &lt;br /&gt;
       1.452280156      1.452280157      0.000000000&lt;br /&gt;
      -1.452280156     -1.452280157      0.000000000&lt;br /&gt;
      -1.452280157      1.452280156      0.000000000&lt;br /&gt;
       1.452280157     -1.452280156      0.000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Co)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at 5.95 and 9.35 ppm and non-point model - at 7.18 and 10.76 ppm.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Points2mult.m&amp;diff=1224</id>
		<title>Points2mult.m</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Points2mult.m&amp;diff=1224"/>
		<updated>2016-08-24T11:57:40Z</updated>

		<summary type="html">&lt;p&gt;Suturina: Created page with &amp;quot;Computes multipole moments from a set of point charges Parameters:       xyz    - coordinates as [x y z] with multiple rows,              at which density rho is evaluated, in...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Computes multipole moments from a set of point charges&lt;br /&gt;
Parameters: &lt;br /&gt;
&lt;br /&gt;
    xyz    - coordinates as [x y z] with multiple rows,&lt;br /&gt;
             at which density rho is evaluated, in Angstroms.&lt;br /&gt;
&lt;br /&gt;
    mxyz   - paramagnetic centre coordinates as [x y z], in &lt;br /&gt;
             Angstroms.&lt;br /&gt;
&lt;br /&gt;
    L      - array of ranks of spherical harmonics of the density&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    rho    - column of the destity at the points xyz&lt;br /&gt;
&lt;br /&gt;
    method - &amp;#039;points&amp;#039; or &amp;#039;grid&amp;#039;. &amp;#039;Grid&amp;#039; integrates with corresponding d3r&lt;br /&gt;
             and &amp;#039;points&amp;#039; just sum the density at points. &lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    Ilm    - predicted multipole moments of the density&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Lpcs.m&amp;diff=1223</id>
		<title>Lpcs.m</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Lpcs.m&amp;diff=1223"/>
		<updated>2016-08-24T11:55:45Z</updated>

		<summary type="html">&lt;p&gt;Suturina: Created page with &amp;quot;Computes PCS from paramagnetic density (rho) outside the bounding sphere  Parameters:       nxyz       - nuclear coordinates as [x y z] with multiple rows,                  at...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Computes PCS from paramagnetic density (rho) outside the bounding sphere&lt;br /&gt;
&lt;br /&gt;
Parameters: &lt;br /&gt;
&lt;br /&gt;
    nxyz       - nuclear coordinates as [x y z] with multiple rows,&lt;br /&gt;
                 at which PCS is to be evaluated, in Angstroms.&lt;br /&gt;
&lt;br /&gt;
    mxyz       - paramagnetic centre coordinates as [x y z], in &lt;br /&gt;
                 Angstroms.&lt;br /&gt;
&lt;br /&gt;
    L          - array of ranks of spherical harmonics of the density&lt;br /&gt;
&lt;br /&gt;
    Ilm        - {[],[]} array of numbers corresponding to the integral&lt;br /&gt;
                 Int(rho(r,theta,phi)Y*lm(theta,phi)r^ld^3r)&lt;br /&gt;
                 for L=0 Ilm=N/2/sqrt(pi)&lt;br /&gt;
                 for L=1 Ilm=[imag(I11) I10 real(I11)]&lt;br /&gt;
                 for L=2 Ilm=[imag(I22) imag(I21) I20 real(I21) real(I22)]&lt;br /&gt;
&lt;br /&gt;
    chi        - 3x3 matrix or 5 values for susceptibility tensor in SI Angstrom^3&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
    theor_pcs  - predicted pseudocontact shift (in ppm) at each of &lt;br /&gt;
                the nuclei.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Ilpcs.m&amp;diff=1222</id>
		<title>Ilpcs.m</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Ilpcs.m&amp;diff=1222"/>
		<updated>2016-08-24T11:54:05Z</updated>

		<summary type="html">&lt;p&gt;Suturina: Created page with &amp;quot;Fit experimental PCS using the non-point approximation   Parameters:        nxyz      - nuclear coordinates as [x y z] with multiple rows,                  at which PCS is to ...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Fit experimental PCS using the non-point approximation &lt;br /&gt;
&lt;br /&gt;
Parameters: &lt;br /&gt;
&lt;br /&gt;
     nxyz      - nuclear coordinates as [x y z] with multiple rows,&lt;br /&gt;
                 at which PCS is to be evaluated, in Angstroms.&lt;br /&gt;
&lt;br /&gt;
     expt_pcs  - experimental pseudocontact shift (in ppm)  &lt;br /&gt;
&lt;br /&gt;
     L         - row of ranks of spherical harmonics of the density&lt;br /&gt;
                 the nuclei.&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
     mxyz      - paramagnetic centre coordinates as [x y z], in &lt;br /&gt;
                 Angstroms.&lt;br /&gt;
     Ilm       - {[],[]} cell array of numbers corresponding to the multipole&lt;br /&gt;
                 moments:&lt;br /&gt;
                 Int(rho(r,theta,phi)Ylm(theta,phi)r^(l+2)sin(theta)d^3r)&lt;br /&gt;
                 for L=0 Ilm=N/2/sqrt(pi)&lt;br /&gt;
                 for L=1 Ilm=[real(I11) I10 imag(I11)]&lt;br /&gt;
                 for L=2 Ilm=[real(I22) real(I21) I20 imag(I21) imag(I22)]&lt;br /&gt;
&lt;br /&gt;
     chi       - susceptibility tensor in SI Angstrom^3&lt;br /&gt;
&lt;br /&gt;
     pred_pcs  - predicted pseudocontact shift (in ppm) at each of &lt;br /&gt;
                 the nuclei.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1221</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1221"/>
		<updated>2016-08-24T11:48:56Z</updated>

		<summary type="html">&lt;p&gt;Suturina: /* Example 1a. Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|thumb|500px|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity (right).]]&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Cobalt porphyrin=====&lt;br /&gt;
Spin density in cobalt porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with spin density&lt;br /&gt;
      xyz=[&lt;br /&gt;
       0.000000000      0.000000000      0.000000000   &lt;br /&gt;
       1.452280156      1.452280157      0.000000000&lt;br /&gt;
      -1.452280156     -1.452280157      0.000000000&lt;br /&gt;
      -1.452280157      1.452280156      0.000000000&lt;br /&gt;
       1.452280157     -1.452280156      0.000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Co)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at 5.95 and 9.35 ppm and non-point model - at 7.18 and 10.76 ppm.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1220</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1220"/>
		<updated>2016-08-24T11:44:07Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|400px|center|frame|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity.]]&lt;br /&gt;
 &lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Cobalt porphyrin=====&lt;br /&gt;
Spin density in cobalt porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with spin density&lt;br /&gt;
      xyz=[&lt;br /&gt;
       0.000000000      0.000000000      0.000000000   &lt;br /&gt;
       1.452280156      1.452280157      0.000000000&lt;br /&gt;
      -1.452280156     -1.452280157      0.000000000&lt;br /&gt;
      -1.452280157      1.452280156      0.000000000&lt;br /&gt;
       1.452280157     -1.452280156      0.000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Co)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at 5.95 and 9.35 ppm and non-point model - at 7.18 and 10.76 ppm.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1218</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1218"/>
		<updated>2016-08-24T11:41:19Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[File:PCS_axial_rh_chi.png|center|frame|PCS field in the case of axial susceptibility tensor (left) and in the case of limiting rhombisity.]]&lt;br /&gt;
 &lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Cobalt porphyrin=====&lt;br /&gt;
Spin density in cobalt porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with spin density&lt;br /&gt;
      xyz=[&lt;br /&gt;
       0.000000000      0.000000000      0.000000000   &lt;br /&gt;
       1.452280156      1.452280157      0.000000000&lt;br /&gt;
      -1.452280156     -1.452280157      0.000000000&lt;br /&gt;
      -1.452280157      1.452280156      0.000000000&lt;br /&gt;
       1.452280157     -1.452280156      0.000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Co)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at 5.95 and 9.35 ppm and non-point model - at 7.18 and 10.76 ppm.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1217</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1217"/>
		<updated>2016-08-24T11:37:45Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[PCS_axial_rh_chi.png]] &lt;br /&gt;
 &lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.txt]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Cobalt porphyrin=====&lt;br /&gt;
Spin density in cobalt porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with spin density&lt;br /&gt;
      xyz=[&lt;br /&gt;
       0.000000000      0.000000000      0.000000000   &lt;br /&gt;
       1.452280156      1.452280157      0.000000000&lt;br /&gt;
      -1.452280156     -1.452280157      0.000000000&lt;br /&gt;
      -1.452280157      1.452280156      0.000000000&lt;br /&gt;
       1.452280157     -1.452280156      0.000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Co)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at 5.95 and 9.35 ppm and non-point model - at 7.18 and 10.76 ppm.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1213</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1213"/>
		<updated>2016-08-24T10:31:06Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions and basic theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility (χ) tensors. There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[PCS_axial_rh_chi.png]] &lt;br /&gt;
 &lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.png]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Cobalt porphyrin=====&lt;br /&gt;
Spin density in cobalt porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with spin density&lt;br /&gt;
      xyz=[&lt;br /&gt;
       0.000000000      0.000000000      0.000000000   &lt;br /&gt;
       1.452280156      1.452280157      0.000000000&lt;br /&gt;
      -1.452280156     -1.452280157      0.000000000&lt;br /&gt;
      -1.452280157      1.452280156      0.000000000&lt;br /&gt;
       1.452280157     -1.452280156      0.000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Co)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at 5.95 and 9.35 ppm and non-point model - at 7.18 and 10.76 ppm.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1095</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1095"/>
		<updated>2016-08-12T16:03:17Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions as well as the theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility tensors (χ). There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[PCS_axial_rh_chi.png]] &lt;br /&gt;
 &lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin D9K PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.png]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
      mguess=[-5 5 -15];&lt;br /&gt;
      [mxyz,chi,pred_pcs]=ippcs([x y z],mguess,expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Cobalt porphyrin=====&lt;br /&gt;
Spin density in cobalt porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with spin density&lt;br /&gt;
      xyz=[&lt;br /&gt;
       0.000000000      0.000000000      0.000000000   &lt;br /&gt;
       1.452280156      1.452280157      0.000000000&lt;br /&gt;
      -1.452280156     -1.452280157      0.000000000&lt;br /&gt;
      -1.452280157      1.452280156      0.000000000&lt;br /&gt;
       1.452280157     -1.452280156      0.000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 14&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Co)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. Point model predicts shifts at 5.95 and 9.35 ppm and non-point model - at 7.18 and 10.76 ppm.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2b.&amp;#039;&amp;#039; Account for spin tag mobility. Calbidin D9K PCS=====&lt;br /&gt;
To account for possible mobility of thulium ion in the coordination cites we solve the inverse problem with additional non-point contributions using [[ilpcs.m]]. Using the experimental data from example 1b we solve the inverse problem with L=[0 1 2]:&lt;br /&gt;
      [mxyz,Ilm,pred_pcs]=ilpcs(nxyz,expt_pcs,L,mguess)&lt;br /&gt;
Fit of the experimental values improves significantly with account for spin delocalization. Standard deviation drops from 1.26 to 0.67 ppm.&lt;br /&gt;
&lt;br /&gt;
==Hyperfine tensor from DFT==&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1092</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1092"/>
		<updated>2016-08-12T15:06:06Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions as well as the theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility tensors (χ). There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[PCS_axial_rh_chi.png]] &lt;br /&gt;
 &lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.png]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
     [mxyz,chi,pred_pcs]=ippcs([x y z],[-5 5 -15],expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers, which we will talk about later. &lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of a spin distribution. It works for nuclei outside the spin density bounding sphere and accounts for its anisotropy that affect PCS (see [[paper]]). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution.&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from spin density delocalization. Cobalt porphyrin=====&lt;br /&gt;
Spin density in cobalt porphyrin is clearly not a point object. In fact the delocalized spin density over nitrogen leads to the detectable superhyperfine signal in EPR. Let&amp;#039;s assume that 10% of spin density is localized on each nitrogen atom. How that affects proton PCS? A simple way to to account for spin delocalization is to compute multipole moments of the distribution using the function [[points2mult.m]].&lt;br /&gt;
*To compute multipole moments we have to specify nuclear coordinates with spin density&lt;br /&gt;
      xyz=[&lt;br /&gt;
       0.000000000      0.000000000      0.000000000   &lt;br /&gt;
       1.452280156      1.452280157      0.000000000&lt;br /&gt;
      -1.452280156     -1.452280157      0.000000000&lt;br /&gt;
      -1.452280157      1.452280156      0.000000000&lt;br /&gt;
       1.452280157     -1.452280156      0.000000000];&lt;br /&gt;
      % spin population&lt;br /&gt;
      rho=[0.6 0.1 0.1 0.1 0.1]&amp;#039;; &lt;br /&gt;
*Compute multipole moments with ranks from 0 to 4&lt;br /&gt;
      L=[0:14];&lt;br /&gt;
      % multipole moments&lt;br /&gt;
      Ilm=points2mult(xyz,mxyz,rho,L,&amp;#039;points&amp;#039;)&lt;br /&gt;
*Compute PCS with account of spin delocalization&lt;br /&gt;
      theor_pcs=lpcs(nxyz,mxyz,L,Ilm,chi_Co)&lt;br /&gt;
The resulting PCS shows that effect of the spin delocalization on PCS is significant. With point model shifts are 5.95 and 9.35 ppm with account for delocalization they are 7.18 and 10.76 ppm.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1091</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1091"/>
		<updated>2016-08-12T13:44:07Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions as well as the theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility tensors (χ). There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller shift. These correspond to two symmetry unique protons in the D4h symmetric molecule. The shifts (in ppm) are&lt;br /&gt;
      Co     Cu&lt;br /&gt;
     5.95  -1.00&lt;br /&gt;
     9.35  -1.57&lt;br /&gt;
In the case of easy plane anisotropy like in Co the PCS in equatorial plane is positive, and in the case of easy axis anisotropy - negative.&lt;br /&gt;
In both cases g&amp;lt;sub&amp;gt;x&amp;lt;/sub&amp;gt; and g&amp;lt;sub&amp;gt;y&amp;lt;/sub&amp;gt; are the same so the PCS field has a shape of second rank spherical harmonic Y&amp;lt;sub&amp;gt;20&amp;lt;/sub&amp;gt;. In the case of non-zero rhombisity the shape of PCS field is a linear combinations of several second rank spherical harmonics.&lt;br /&gt;
[[PCS_axial_rh_chi.png]] &lt;br /&gt;
 &lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin PCS.=====&lt;br /&gt;
In this example we will process the experimental PCS data for calbindin D9K in which one of the two calcium ions has been replaced by a thulium ion from [Balayssac, S.; Jiménez, B.; Piccioli, M. Journal of Biomolecular NMR 2006, 34, 63]. The matrix of coordinates from PDB file 1IGV atoms with corresponding PCS from the paper is stored in [[calbidin_xyz_pcs.txt]] &lt;br /&gt;
[[File:calb_pcs.png|right|thumb|300px|alt=Alt text|Comparison of the point model PCS with experiment]] &lt;br /&gt;
*Import the data from [[calbidin_xyz_pcs.png]] to x y z and expt_pcs&lt;br /&gt;
*Solve the inverse problem with initial guess of the Tm position [-5 5 -15]. One may need several tries with different initial guesses to converge the solution. &lt;br /&gt;
     [mxyz,chi,pred_pcs]=ippcs([x y z],[-5 5 -15],expt_pcs);&lt;br /&gt;
*Plot experimental vs predicted PCS&lt;br /&gt;
      plot(expt_pcs,pred_pcs,&amp;#039;bo&amp;#039;);&lt;br /&gt;
      xlabel(&amp;#039;Experimental PCS, ppm&amp;#039;);&lt;br /&gt;
      ylabel(&amp;#039;Predicted PCS, ppm&amp;#039;);&lt;br /&gt;
      axis equal; axis square;&lt;br /&gt;
*Print the position of Tm and traceless part of suceptibility tensor in molecular frame&lt;br /&gt;
      disp(&amp;#039;Susceptibility tensor:&amp;#039;); disp(chi);&lt;br /&gt;
      disp(&amp;#039;Point electron location:&amp;#039;); disp(mxyz);&lt;br /&gt;
You can see that the fit with the point model is quite good but there are several outliers. &lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of spin distribution. It works for nuclei outside the bounding sphere of the paramagnetic density and accounts for its anisotropy that affect PCS (see paper). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution. We do not recommend to go beyond L=[0 1 2 3 4].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from the prolate/oblate Gaussian spin density.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=File:Calb_pcs.png&amp;diff=1090</id>
		<title>File:Calb pcs.png</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=File:Calb_pcs.png&amp;diff=1090"/>
		<updated>2016-08-12T13:38:57Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1088</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1088"/>
		<updated>2016-08-12T11:03:42Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions as well as the theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility tensors (χ). There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstrom in SI. To compute susceptibility tensor from g-tensor for S=1/2 at room temperature use the formula &amp;lt;math&amp;gt;{\chi _i} = {\mu _0}\mu _B^2\frac{{g_i^2}}{{4{k_B}T}} \approx 1.9571\frac{{g_i^2}}{{T[K]}}[{{Å}^3}]&amp;lt;/math&amp;gt;. Note that the coordinate system for tensor is defined by molecular frame.&lt;br /&gt;
      % g-tensor&lt;br /&gt;
      g_Co=[3.0 3.0 2.0];&lt;br /&gt;
      g_Cu=[2.0 2.0 2.2];&lt;br /&gt;
      % susceptibility tensor in A^3 in SI&lt;br /&gt;
      T=298; %K&lt;br /&gt;
      chi_Co=1.9571/T*diag(g_Co.^2);&lt;br /&gt;
      chi_Cu=1.9571/T*diag(g_Cu.^2);&lt;br /&gt;
*Define position of paramagnetic center&lt;br /&gt;
      mxyz=[0 0 0];&lt;br /&gt;
*Compute proton PCS with different susceptibility tensors&lt;br /&gt;
      pcs_Co=ppcs(nxyz,mxyz,chi_Co)&lt;br /&gt;
      pcs_Cu=ppcs(nxyz,mxyz,chi_Cu)&lt;br /&gt;
In the output you see that there are two groups of protons: four with larger absolute shift and eight with smaller. different shifts due to high symmetry (D4h) of the molecule. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin PCS.&lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of spin distribution. It works for nuclei outside the bounding sphere of the paramagnetic density and accounts for its anisotropy that affect PCS (see paper). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution. We do not recommend to go beyond L=[0 1 2 3 4].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from the prolate/oblate Gaussian spin density.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1087</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1087"/>
		<updated>2016-08-12T10:33:32Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions as well as the theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility tensors (χ). There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
The structure of the molecule in proper coordinate system is given at [[M_porphyrin.txt]].&lt;br /&gt;
*Enter the coordinates of protons:&lt;br /&gt;
      nxyz=[  &lt;br /&gt;
            4.551635888      2.658552774      0.000000000&lt;br /&gt;
            2.658552774      4.551635889      0.000000000&lt;br /&gt;
           -2.658552774      4.551635888      0.000000000&lt;br /&gt;
           -4.551635889      2.658552774      0.000000000&lt;br /&gt;
           -4.551635888     -2.658552774      0.000000000&lt;br /&gt;
           -2.658552774     -4.551635889      0.000000000&lt;br /&gt;
            2.658552774     -4.551635888      0.000000000&lt;br /&gt;
            4.551635889     -2.658552774      0.000000000&lt;br /&gt;
            4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000     -4.533874147      0.000000000&lt;br /&gt;
           -4.533874147      0.000000000      0.000000000&lt;br /&gt;
            0.000000000      4.533874147      0.000000000];&lt;br /&gt;
*Enter the susceptibility tensor in cubic Angstroems in SI. To compute &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Load the structural parameters.&lt;br /&gt;
Specify susceptibility tensor. How to construct it from g-tensors. Easy axis/ easy plane examples. Non-axial example.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin PCS.&lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of spin distribution. It works for nuclei outside the bounding sphere of the paramagnetic density and accounts for its anisotropy that affect PCS (see paper). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution. We do not recommend to go beyond L=[0 1 2 3 4].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from the prolate/oblate Gaussian spin density.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1086</id>
		<title>Pseudocontact shift analysis</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=Pseudocontact_shift_analysis&amp;diff=1086"/>
		<updated>2016-08-12T10:15:51Z</updated>

		<summary type="html">&lt;p&gt;Suturina: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial shows how to use Spinach for analysis of paramagnetic NMR data. The examples are designed in a way to familiarize users with Spinach functions as well as the theory of paramagnetic shift.&lt;br /&gt;
&lt;br /&gt;
Paramagnetic chemical shift consists of two contributions: Fermi-contact (FC) and pseudocontact shift (PCS). It can be expressed via trace of the product of hyperfine (A) and susceptibility tensors (χ). There are four different approaches for PCS analysis currently presented in Spinach. Difference in the presented methods appears only at the evaluation of the hyperfine tensor while susceptibility is either defined by user or optimized. Note that PCS depends only on the traceless part of χ, whereas Fermi contact part of the paramagnetic shift depends on the Tr(χ).&lt;br /&gt;
&lt;br /&gt;
==Point approximation==&lt;br /&gt;
The simplest approach is based on the point-dipole approximation where dipolar hyperfine tensor depends on the position of a nucleus relative to the paramagnetic center &amp;lt;math&amp;gt;\left(\vec r\right)&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;\frac{1}{{4\pi {r^3}}}\left( {\frac{{\vec r \cdot {{\vec r}^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right)&amp;lt;/math&amp;gt;. Therefore PCS is defined as &amp;lt;math&amp;gt;\sigma  = \frac{1}{{4\pi {r^3}}}{\rm{Tr}}\left( {\left( {\frac{{\vec r \cdot {\vec r^{\rm{T}}}}}{{{r^2}}} - \frac{1}{3}} \right) \cdot {\bf{\chi }}} \right)&amp;lt;/math&amp;gt;. This approach is valid at the distance where paramagnetic center can be viewed as a point. To solve a direct problem use the function [[ppcs.m]]. This function takes structure of a molecule and susceptibility tensor as an input and gives PCS at the nuclei as an output. To solve an inverse problem use [[ippcs.m]]. The function evaluates susceptibility tensor and position of the paramagnetic center for provided PCS data with corresponding nuclear coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=====&amp;#039;&amp;#039;Example 1a.&amp;#039;&amp;#039; Direct problem for PCS using the point-dipole approximation: Metal porphyrin proton PCS.=====&lt;br /&gt;
[[File:Example.jpg|thumb|200px|alt=Alt text|Structure of metal porphyrin. Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey]]&lt;br /&gt;
In this example we will compute PCS on protons of the Co(II)/Cu(II) porphyrin and see how magnetic anisotropy affects PCS.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Load the structural parameters.&lt;br /&gt;
Specify susceptibility tensor. How to construct it from g-tensors. Easy axis/ easy plane examples. Non-axial example.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Example 1b.&amp;#039;&amp;#039; Inverse problem for PCS using point-dipole approximation. Calbidin PCS.&lt;br /&gt;
&lt;br /&gt;
==Corrections to PCS from non-point source==&lt;br /&gt;
The next level of theory that corrects the point approximation is based on the multipole expansion of spin distribution. It works for nuclei outside the bounding sphere of the paramagnetic density and accounts for its anisotropy that affect PCS (see paper). It should be noted that any isotropic distribution of the spin gives the same PCS as the point source. Direct problem is solved using [[lpcs.m]] and inverse problem is solved using [[ilpcs.m]]. This method requires from user list of the ranks of spherical harmonics (L). If L=0 the density is isotropic and result is identical to point approximation. Normally L=[0 1 2] accounts for the major effects of the anisotropy in the spin density distribution. We do not recommend to go beyond L=[0 1 2 3 4].&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Example 2a.&amp;#039;&amp;#039; Correction to point PCS from the prolate/oblate Gaussian spin density.&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
	<entry>
		<id>https://spindynamics.org/wiki/index.php?title=File:Example.jpg&amp;diff=1085</id>
		<title>File:Example.jpg</title>
		<link rel="alternate" type="text/html" href="https://spindynamics.org/wiki/index.php?title=File:Example.jpg&amp;diff=1085"/>
		<updated>2016-08-12T09:56:36Z</updated>

		<summary type="html">&lt;p&gt;Suturina: Structure of metal porphyrin.Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Structure of metal porphyrin.Color code: metal - orange, nitrogen - blue, carbon - grey, hydrogen - light grey&lt;/div&gt;</summary>
		<author><name>Suturina</name></author>
		
	</entry>
</feed>