1%% LyX 1.5.6 created this file. For more info, see http://www.lyx.org/. 2%% Do not edit unless you really know what you are doing. 3\documentclass[english,preprint]{revtex4} 4\usepackage[T1]{fontenc} 5\usepackage[latin9]{inputenc} 6\usepackage{graphicx} 7\usepackage{babel} 8 9\begin{document} 10 11\title{MATLAB version number 5 of the APBS} 12 13 14\date{\today} 15 16\begin{abstract} 17This solver uses the biconjugate gradient stabilized method and the 18inexact LU decomposition to numerically solve the linearized PB equation 19on a cartesian 3D-grid. This version requires the shifted dielectric 20and the ion accessibility coefficient (kappa function) maps as generated 21by the APBS code as well as the corresponding pqr file generated by 22the pdb2pqr code. It uses standard three-linear splines (spl0) to 23spread the charge density along the nearest grid points if needed. 24It is able to solve the linear PB eq with either Dirichlet or focus 25boundary conditions. In the later case, this code solves the PB equation 26in a large (low resolution) domain and the resulting electrostatic 27potential solution is subsequently used to evaluate the Dirichlet 28boundary condition to solve the PB equation in a (higher resolution) 29sub-domain region. The resulting electrostatic potential and charge 30maps for both the coarse and target grids are saved in dx format in 31different folders. For visualization purpose, this code also generates 32two files (.fig and .tiff) corresponding to the graphical representation 33of the electrostatic potential surface. This version was used to solve 34the pka example provided by the apbs package. If the Dirichlet Boundary 35Condition is required, then this version basically provides the same 36results than the previous one. The main difference is that the user 37doesn't have to edit the source files in this version but only have 38to provide the target input-file name and the corresponding full path 39as the only argument of the (new) matlab function MAPBS (x). See the 40pka example and the MATLAB\_PB\_SOLVER\_5 package for more details. 41\end{abstract} 42\maketitle 43 44\subsection*{Description} 45 46This code is based on Michel Holst's thesis and Nathan Baker's APBS 47approach. The box-method is used to discretize the following (linearized) 48PB equation 49 50\begin{equation} 51-\nabla.\left(\epsilon\left(\mathbf{r}\right)\nabla u\left(\mathbf{r}\right)\right)+\bar{\kappa}\left(\mathbf{r}\right)^{2}u\left(\mathbf{r}\right)=magic\sum_{i=1}^{N}z_{i}\delta\left(\mathbf{r}-\mathbf{r}_{i}\right)\label{eq:one}\end{equation} 52 53 54where $u\left(\mathbf{r}\right)=e_{c}\Phi\left(\mathbf{r}\right)/K_{B}T$ 55and $magic=4\pi e_{c}^{2}/K_{B}T.$ For a diagonal dielectric tensor, 56the resulting discretized linear PB equations at the nodes $u_{ijk}=u\left(x_{i},y_{j},z_{k}\right)$ 57for $1\leq i\leq N_{x}$, $1\leq j\leq N_{y}$ and $1\leq k\leq N_{z}$ 58reads 59 60\[ 61\left[\epsilon_{i-1/2,j,k}^{x}\frac{\left(h_{j-1}+h_{j}\right)\left(h_{k-1}+h_{k}\right)}{4h_{i-1}}+\epsilon_{i+1/2,j,k}^{x}\frac{\left(h_{j-1}+h_{j}\right)\left(h_{k-1}+h_{k}\right)}{4h_{i}}+\right.\] 62 63 64\[ 65\epsilon_{i,j-1/2,k}^{y}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{k-1}+h_{k}\right)}{4h_{j-1}}+\epsilon_{i,j+1/2,k}^{y}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{k-1}+h_{k}\right)}{4h_{j}}+\] 66 67 68\[ 69\epsilon_{i,j,k-1/2}^{k}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{j-1}+h_{j}\right)}{4h_{k-1}}+\epsilon_{i,j,k+1/2}^{k}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{j-1}+h_{j}\right)}{4h_{k}}+\] 70 71 72\[ 73\left.\kappa_{ijk}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{j-1}+h_{j}\right)\left(h_{k-1}+h_{k}\right)}{8}\right]u_{ijk}+\] 74 75 76\[ 77\left[-\epsilon_{i-1/2,j,k}^{x}\frac{\left(h_{j-1}+h_{j}\right)\left(h_{k-1}+h_{k}\right)}{4h_{i-1}}\right]u_{i-1jk}+\left[-\epsilon_{i+1/2,j,k}^{x}\frac{\left(h_{j-1}+h_{j}\right)\left(h_{k-1}+h_{k}\right)}{4h_{i}}\right]u_{i+1jk}+\] 78 79 80\[ 81\left[-\epsilon_{i,j-1/2,k}^{y}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{k-1}+h_{k}\right)}{4h_{j-1}}\right]u_{ij-1k}+\left[-\epsilon_{i,j+1/2,k}^{y}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{k-1}+h_{k}\right)}{4h_{j}}\right]u_{ij+1k}+\] 82 83 84\[ 85\left[-\epsilon_{i,j,k-1/2}^{k}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{j-1}+h_{j}\right)}{4h_{k-1}}\right]u_{ijk-1}+\left[-\epsilon_{i,j,k+1/2}^{k}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{j-1}+h_{j}\right)}{4h_{k}}\right]u_{ijk+1}=\] 86 87 88\begin{equation} 89magic\frac{\left(h_{i-1}+h_{i}\right)\left(h_{j-1}+h_{j}\right)\left(h_{k-1}+h_{k}\right)}{8}f_{ijk}\label{eq:two}\end{equation} 90 91 92in which 93 94\[ 95h_{i}=x_{i+1}-x_{i},\: h_{j}=y_{j+1}-y_{j}\: h_{k}=z_{k+1}-z_{k}\] 96 97 98The delta functions appearing in the right hand side of the starting 99equations are approximated with linear B-splines (spl0) which spread 100the point like charge along the nearest neighborhood. The resulting 101$f_{ijk}$ represent the smearing of the point charges along the grid 102points. 103 104For more details, including used unit system, please refer to the 105Michel Holst's thesis and the APBS user guide online. To visualize 106more clearly the problem, let's explicitly write the first equations 107for a cubic grid of 5x5x5 containing general coefficients 108 109\[ 110a_{222}u_{222}+a_{122}u_{122}+a_{322}u_{322}+a_{212}u_{212}+a_{232}u_{232}+a_{221}u_{221}+a_{223}u_{223}=f_{222}\] 111 112 113\[ 114a_{322}u_{322}+a_{222}u_{222}+a_{422}u_{422}+a_{312}u_{312}+a_{332}u_{332}+a_{321}u_{321}+a_{323}u_{323}=f_{322}\] 115 116 117\[ 118a_{422}u_{422}+a_{122}u_{122}+a_{322}u_{322}+a_{212}u_{212}+a_{232}u_{232}+a_{221}u_{221}+a_{223}u_{223}=f_{422}\] 119 120 121\[ 122a_{232}u_{232}+a_{132}u_{132}+a_{332}u_{332}+a_{222}u_{222}+a_{242}u_{242}+a_{231}u_{231}+a_{233}u_{233}=f_{232}\] 123 124 125\[ 126\ldots\] 127 128 129in which the nodes are arranged using the natural ordering 130 131\[ 132U=[u_{111},u_{211},..,u_{N_{x}11,}u_{121},..,u_{221},u_{321},..,u_{N_{x}21}...,u_{N_{x}N_{y}N_{z}}]^{T}\] 133 134 135Note that the prescribed values of nodes $u_{1jk},u_{N_{x},j,k},u_{i,1,k},u_{i,N_{y},k},u_{ij1}$ 136and $u_{ijN_{z}}$ along the faces of the box coming from the Dirichlet 137boundary conditions will have their corresponding elements removed 138in such a way that only equations for the interior nodes remain. In 139other words, we will only consider the following set of unknown nodes 140 141\[ 142U=[u_{222},u_{322},..,u_{N_{x}-1,22,}u_{232},..,u_{332},u_{432},..,u_{N_{x}-2,32}...,u_{N_{x}-1,N_{y}-1,N_{z}-1}]^{T}\] 143 144 145in such a way that the previous equations become 146 147\[ 148a_{222}u_{222}+a_{322}u_{322}+a_{232}u_{232}+a_{223}u_{223}=f_{222}-a_{122}u_{122}-a_{212}u_{212}-a_{221}u_{221}\equiv b_{222}\] 149 150 151\[ 152a_{322}u_{322}+a_{222}u_{222}+a_{422}u_{422}+a_{332}u_{332}+a_{323}u_{323}=f_{322}-a_{312}u_{312}-a_{321}u_{321}\equiv b_{322}\] 153 154 155\[ 156a_{422}u_{422}+a_{322}u_{322}+a_{232}u_{232}+a_{223}u_{223}=f_{422}-a_{122}u_{122}-a_{212}u_{212}-a_{221}u_{221}\equiv b_{422}\] 157 158 159\[ 160a_{232}u_{232}+a_{332}u_{332}+a_{222}u_{222}+a_{242}u_{242}+a_{233}u_{233}=f_{232}-a_{132}u_{132}-a_{231}u_{231}\equiv b_{232}\] 161 162 163in which the boundary $u's$ are conveniently brought to the right-hand-side 164of the equations. The resulting left-hand side equations can be written 165in compact form in term of matrix vector product as follows 166 167\[ 168Au=b\] 169 170 171in which 172 173\[ 174u\left(p\right)=u_{ijk},\qquad b\left(p\right)=b_{ijk},\qquad p=(k-2)(N_{x}-2)(N_{y}-2)+(j-2)(N_{x}-2)+i-1\] 175 176 177\[ 178i=2,..,N_{x}-2,\quad j=2,..,N_{y}-2,\quad k=2,..,N_{z}-2\] 179 180 181% 182\begin{figure} 183\includegraphics[scale=0.75]{Amatrix} 184 185\caption{A Matrix representation} 186 187\end{figure} 188 189 190and $A$ is a (seven banded block tri-diagonal form) $(N_{x}-2)(N_{y}-2)(N_{z}-2)$ 191by $(N_{x}-2)(N_{y}-2)(N_{z}-2)$ squared symmetric positive definite 192matrix containing the following nonzero elements (see figure 1): 193 194\begin{itemize} 195\item The main diagonal elements 196\end{itemize} 197\[ 198d_{0}(p)=\left[\epsilon_{i-1/2,j,k}^{x}\frac{\left(h_{j-1}+h_{j}\right)\left(h_{k-1}+h_{k}\right)}{4h_{i-1}}+\epsilon_{i+1/2,j,k}^{x}\frac{\left(h_{j-1}+h_{j}\right)\left(h_{k-1}+h_{k}\right)}{4h_{i}}+\right.\] 199 200 201\[ 202\epsilon_{i,j-1/2,k}^{y}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{k-1}+h_{k}\right)}{4h_{j-1}}+\epsilon_{i,j+1/2,k}^{y}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{k-1}+h_{k}\right)}{4h_{j}}+\] 203 204 205\[ 206\epsilon_{i,j,k-1/2}^{k}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{j-1}+h_{j}\right)}{4h_{k-1}}+\epsilon_{i,j,k+1/2}^{k}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{j-1}+h_{j}\right)}{4h_{k}}+\] 207 208 209\begin{equation} 210\left.\kappa_{ijk}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{j-1}+h_{j}\right)\left(h_{k-1}+h_{k}\right)}{8}\right]\label{eq:three}\end{equation} 211 212 213\begin{itemize} 214\item The Next upper band diagonal, which is shifted in one column to the 215left from the first column, contains the following elements 216\end{itemize} 217\begin{equation} 218\left[d_{1}(p)=-\epsilon_{i+1/2,j,k}^{x}\frac{\left(h_{j-1}+h_{j}\right)\left(h_{k-1}+h_{k}\right)}{4h_{i}}\right]\label{eq:four}\end{equation} 219 220 221\begin{itemize} 222\item The second upper band diagonal which is shifted $N_{x}-2$ columns 223from the first column 224\end{itemize} 225\begin{equation} 226d_{2}(p)=\left[-\epsilon_{i,j+1/2,k}^{y}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{k-1}+h_{k}\right)}{4h_{j}}\right]\label{eq:five}\end{equation} 227 228 229\begin{itemize} 230\item The third upper band diagonal which is shifted $(N_{x}-2)(N_{y}-2)$ 231columns from the first column 232\end{itemize} 233\begin{equation} 234d_{3}(p)=\left[-\epsilon_{i,j,k+1/2}^{k}\frac{\left(h_{i-1}+h_{i}\right)\left(h_{j-1}+h_{j}\right)}{4h_{k}}\right]\label{eq:six}\end{equation} 235 236 237The remaining elements of the upper triangular squared matrix A are 238set equal to zero. By symmetry we obtain the lower triagonal elements 239of the matrix A. Because the matrix A is sparse and large, we can 240implement efficient methods that optimally solve the linear system 241for U. Specifically, we use the biconjugate gradient stabilized method 242combined with the inexact LU decomposition of the matrix A. Having 243the numerical values for the nodes in the interior of the box, we 244finally add the previously removed prescribed values along the six 245faces to get the solution over the complete set of grid points. 246 247 248\subsection*{Dirichlet Boundary Condition} 249 250The values of nodes $u_{1jk},u_{N_{x},j,k},u_{i,1,k},u_{i,N_{y},k},u_{ij1}$ 251and $u_{ijN_{z}}$ along the six faces of the box is set to the values 252prescribed by a Debye-H�ckel model for a multiple, non-interacting 253spheres with a point charges. The sphere radii are set to the atomic 254radii of the biomolecule and the sphere charges are set to the total 255charge of the protein. 256 257 258\subsection*{Focus Boundary Condition} 259 260Our code uses linear interpolation to obtain the value of the potential 261at the six faces of the target box from the value of the potential 262obtained at larger domain. 263 264 265\subsection*{Computational algorithm for Dirichlet boundary conditions} 266 267\begin{enumerate} 268\item The code reads the (target) input file .inm to get the APBS input 269files (shifted dielectric coefficients, kappa function and pqr data 270file) as well as the number of (target) grid points, the box Lengths, 271temperature, and bulk properties (ionic strength and solvent dielectric 272coefficient) among other parameters. 273\item The center of the grid is evaluated from the corresponding pqr file. 274\item By using linear B-splines, the charge density is discretized to get 275$f_{ijk}$ for $i=1,..,N_{x},\quad j=1,..,N_{y},\quad k=1,..,N_{z}$. 276The Dirichlet boundary condition along the six faces of the box $u_{1jk},u_{N_{x},j,k},u_{i,1,k},u_{i,N_{y},k},u_{ij1}$ 277and $u_{ijN_{z}}$ are calculated by using the temperature, the value 278of the bulk dielectric coefficient (usually water) and ionic strength. 279\item The nonzero components of the matrix $A$, e.g., the diagonal elements 280$d_{0}(p),d_{1}(p),d_{2}(p),$ and $d_{3}(p),$ for $p=(k-2)(N_{x}-2)(N_{y}-2)+(j-2)(N_{x}-2)+i-1$ 281and $i=2,..,N_{x}-1,\quad j=2,..,N_{y}-1,\quad k=2,..,N_{z}-1$ are 282evaluated by using the expressions (\ref{eq:three}), (\ref{eq:four}),(\ref{eq:five}), 283and (\ref{eq:six}). The values for the shifted dielectric coefficients 284and kappa function elements are obtained from the APBS input files. 285The values of the mesh size $h_{i},h_{j}$ and $h_{k}$ are obtained 286from the number of grid points and the Length of the box. Next, the 287sparse upper triangular matrix A is constructed by filling with zeros 288the remaining elements of the matrix A. Next, the lower triangular 289elements of the matrix A are obtained by using the following symmetry 290property $A_{pq}=A_{qp}$ for $q=1,..,(N_{x}-2)(N_{y}-2)(N_{z}-2)$ 291and $p=q,..,(N_{x}-2)(N_{y}-2)(N_{z}-2)$. 292\item The elements of $b_{ijk}$ are evaluated by using the values obtained 293for the discretized charge density $f_{ijk}$ and the values of the 294Dirichlet boundary elements multiplied by the appropriate shifted 295dielectric coefficient values. The natural ordering $p=(k-2)(N_{x}-2)(N_{y}-2)+(j-2)(N_{x}-2)+i-1$ 296and $i=2,..,N_{x}-1,\quad j=2,..,N_{y}-1,\quad k=2,..,N_{z}-1$ is 297used to construct the corresponding vector $b(p)$ (one index) from 298the data array structure (three indices) $b_{ijk}$. 299\item The inexact $LU$ decomposition of the matrix $A$ is performed. The 300default tolerance value is set equal to 0.25 which provides a fast 301evaluation of the matrices $L$ and $U$. 302\item The resulting $L$ and $U$ matrices, the matrix $A$ and the vector 303$b$ are used to approximately solve $Au=b$ for the vector $u$ using 304the biconjugate gradient stabilized method. The default accuracy is 305set equal to 10\textasciicircum{}-9 and the maximum number of iteration 306equal to 800. 307\item The natural ordering relationship is used to convert the resulting 308vector $u(p)$ to data array structure to get the numerical solution 309for $u_{ijk}$ for $i=2,..,N_{x}-1,\quad j=2,..,N_{y}-1,\quad k=2,..,N_{z}-1$. 310\item Finally the previously removed values of the nodes at the faces of 311the box are used to obtain the solution for the nodes $u_{ijk}$ over 312the complete set of grid points, namely for $i=1,..,N_{x},\quad j=1,..,N_{y},\quad k=1,..,N_{z}$. 313\item The electrostatic potential $u_{ijk}$ and the charge $f_{ijk}$ maps 314are saved in dx format files. 315\item The electrostatic potential surface $u_{ij(N_{z}+1)/2}$ is saved 316in tiff and fig format files for visualization purpose. 317\end{enumerate} 318 319\subsection*{Computational algorithm for Focus boundary conditions} 320 321The algorithm reads the target input file finding that the boundary 322condition line says {}``focusname.inm'' instead of {}``sdh''. 323Then the matlab code automatically first reads that input file {}``focusname.inm'' 324to solve the PB equation in the specified coarse grid using Dirichlet 325boundary condition as explained previously. It saves the resulting 326electrostatic potential solution in a temporary dx formatted file 327and then perform the following steps; 328 329\begin{enumerate} 330\item The code reads the (target) input file .inm to get the APBS input 331files (shifted dielectric coefficients, kappa function and pqr data 332file) as well as the number of (target) grid points, the box Lengths, 333temperature, and bulk properties (ionic strength and solvent dielectric 334coefficient) among other parameters. 335\item The center of the grid is evaluated from the corresponding pqr file. 336\item By using linear B-splines, the charge density is discretized to get 337$f_{ijk}$ for $i=1,..,N_{x},\quad j=1,..,N_{y},\quad k=1,..,N_{z}$. 338The Dirichlet boundary condition along the six faces of the target 339(smaller) box $u_{1jk},u_{N_{x},j,k},u_{i,1,k},u_{i,N_{y},k},u_{ij1}$ 340and $u_{ijN_{z}}$ are calculated by using a three-linear interpolation 341for the electrostatic potential solution obtained previously at larger 342boxsides (Focus boundary Condition). 343\item The nonzero components of the matrix $A$, e.g., the diagonal elements 344$d_{0}(p),d_{1}(p),d_{2}(p),$ and $d_{3}(p),$ for $p=(k-2)(N_{x}-2)(N_{y}-2)+(j-2)(N_{x}-2)+i-1$ 345and $i=2,..,N_{x}-1,\quad j=2,..,N_{y}-1,\quad k=2,..,N_{z}-1$ are 346evaluated by using the expressions (\ref{eq:three}), (\ref{eq:four}),(\ref{eq:five}), 347and (\ref{eq:six}). The values for the shifted dielectric coefficients 348and kappa function elements are obtained from the APBS input files. 349The values of the mesh size $h_{i},h_{j}$ and $h_{k}$ are obtained 350from the number of grid points and the Length of the box. Next, the 351sparse upper triangular matrix A is constructed by filling with zeros 352the remaining elements of the matrix A. Next, the lower triangular 353elements of the matrix A are obtained by using the following symmetry 354property $A_{pq}=A_{qp}$ for $q=1,..,(N_{x}-2)(N_{y}-2)(N_{z}-2)$ 355and $p=q,..,(N_{x}-2)(N_{y}-2)(N_{z}-2)$. 356\item The elements of $b_{ijk}$ are evaluated by using the values obtained 357for the discretized charge density $f_{ijk}$ and the values of the 358Dirichlet boundary elements multiplied by the appropriate shifted 359dielectric coefficient values. The natural ordering $p=(k-2)(N_{x}-2)(N_{y}-2)+(j-2)(N_{x}-2)+i-1$ 360and $i=2,..,N_{x}-1,\quad j=2,..,N_{y}-1,\quad k=2,..,N_{z}-1$ is 361used to construct the corresponding vector $b(p)$ (one index) from 362the data array structure (three indices) $b_{ijk}$. 363\item The inexact $LU$ decomposition of the matrix $A$ is performed. The 364default tolerance value is set equal to 0.25 which provides a fast 365evaluation of the matrices $L$ and $U$. 366\item The resulting $L$ and $U$ matrices, the matrix $A$ and the vector 367$b$ are used to approximately solve $Au=b$ for the vector $u$ using 368the biconjugate gradient stabilized method. The default accuracy is 369set equal to 10\textasciicircum{}-9 and the maximum number of iteration 370equal to 800. 371\item The natural ordering relationship is used to convert the resulting 372vector $u(p)$ to data array structure to get the numerical solution 373for $u_{ijk}$ for $i=2,..,N_{x}-1,\quad j=2,..,N_{y}-1,\quad k=2,..,N_{z}-1$. 374\item Finally the previously removed values of the nodes at the faces of 375the box are used to obtain the solution for the nodes $u_{ijk}$ over 376the complete set of grid points, namely for $i=1,..,N_{x},\quad j=1,..,N_{y},\quad k=1,..,N_{z}$. 377\item The electrostatic potential $u_{ijk}$ and the charge $f_{ijk}$ maps 378are saved in dx format files. 379\item The electrostatic potential surface $u_{ij(N_{z}+1)/2}$ is saved 380in tiff and fig format files for visualization purpose. 381\end{enumerate} 382\emph{Comment1:} Note that in this case the user have to provide two 383inm.files and the corresponding dx and pqr files for both the coarse 384and target grids. 385 386\emph{Comments2:} In this version the user have to provide two pqr 387files, one representing the molecule by which the PB eq is solved 388and, the second one to define the center of the grid. It may be the 389same than the first one, but in general, for complex systems they 390are not. 391 392\emph{Comments3:} Fianlly, the user have to provide both directories 393for the input and output files respectively. In this way the user 394doesn't have to edit the source files at all. Just need to provide 395the name of the input file and the full path as the only argument 396in the Matlab function MPABS (x). 397\end{document} 398