\section{gw\-Numerics  Class Reference}
\label{class_gwNumerics}\index{gwNumerics@{gw\-Numerics}}
{\tt \#include $<$gw\_\-numerics.h$>$}

\subsection*{Public Methods}
\begin{CompactItemize}
\item 
{\bf gw\-Numerics} ()
\item 
{\bf $\sim$gw\-Numerics} ()
\end{CompactItemize}
\subsection*{Static Public Methods}
\begin{CompactItemize}
\item 
void {\bf Solve\-Vector} (const {\bf j\-Vector} \&gradient, const {\bf j\-Vector} \&$\backslash$hessian, {\bf j\-Vector} \&result)
\item 
double {\bf Calculate\-Derivative} (const {\bf j\-Vector} \&direction, const$\backslash${\bf j\-Vector} \&gradient)
\item 
bool {\bf Cubic\-Line\-Search} (const {\bf j\-Vector} \&position, const {\bf j\-Vector} \&$\backslash$direction, const double \&derivative, const$\backslash${\bf Constraint\-Manager} \&CM, int atom\_\-index,$\backslash${\bf j\-Vector} \&New\-Position, double \&qmin)
\item 
{\bf j\-Vector} {\bf Set\-HCPosition2} (const {\bf j\-Vector} \&start\_\-position, const {\bf j\-Vector} \&curr\_\-position,$\backslash$const {\bf j\-Vector} \&direction, {\bf Constraint\-Manager} \&$\backslash$CM, int atom\_\-index, double qmin\_\-dist, double \&max\_\-lpert\_\-r)
\item 
void {\bf add\-VDWSegments} ({\bf Segments} \&Seglist, const {\bf j\-Vector} \&curr\_\-position,$\backslash$const {\bf j\-Vector} \&direction, {\bf Constraint\-Manager} \&$\backslash$CM, int atom\_\-index, double offset=0)
\item 
void {\bf add\-LPERTSegments} ({\bf Segments} \&Seglist, const {\bf j\-Vector} \&curr\_\-position,$\backslash$const {\bf j\-Vector} \&direction, {\bf Constraint\-Manager} \&$\backslash$CM, int atom\_\-index, double qmin\_\-dist,$\backslash$const {\bf j\-Vector} \&start\_\-position, const {\bf j\-Vector} \&new\_\-position, double \&max\_\-r)
\item 
double {\bf Linear\-Threshold} (const double \&stress, double $\ast$Rad\-Array)
\item 
{\bf Segment} {\bf Line\-Intersect\-Sphere} (const {\bf j\-Vector} \&atom\_\-position, const double \&$\backslash$radius, const {\bf j\-Vector} \&vec\_\-position, const$\backslash${\bf j\-Vector} \&atom\_\-direction)
\item 
void {\bf bfgs\_\-step} (const {\bf j\-Vector} \&x, const {\bf j\-Vector} \&xp, const {\bf j\-Vector} \&gf, const {\bf j\-Vector} \&gfp, {\bf j\-Vector} \&H, {\bf j\-Vector} \&direction)
\item 
void {\bf Local\-Pert} (int I, {\bf Constraint\-Manager} \&CM, double min\_\-dist, {\bf j\-Vector} start\_\-position)
\item 
int {\bf Spread\-R} (int I, double radius, {\bf DLList}$<$ int $>$ Moved, int depth, {\bf Constraint\-Manager} \&CM, {\bf j\-Vector} start\_\-position, const {\bf j\-Vector} pref\_\-dir)
\item 
{\bf DLList}$<$int$>$ {\bf Check\-Viol} (int I, {\bf DLList}$<$ int $>$ Neighbor\-List, bool Use\-Previous, const {\bf Constraint\-Manager} \&CM)
\item 
int {\bf Move\-On\-Single\-Viol} (int I, double radius, int other\-Atom, {\bf Constraint\-Manager} \&CM)
\item 
{\bf j\-Vector} {\bf Calc\-Force} (int I, double radius, {\bf DLList}$<$ int $>$ Viol\-List, {\bf DLList}$<$ int $>$ Neighbor\-List, {\bf DLList}$<$ int $>$ Moved, const {\bf Constraint\-Manager} \&CM, const {\bf j\-Vector} \&start\_\-position, double min\_\-dist, const {\bf j\-Vector} pref\_\-dir)
\item 
void {\bf reset\_\-LP\_\-Count} (void)
\end{CompactItemize}
\subsection*{Static Public Attributes}
\begin{CompactItemize}
\item 
int {\bf Num\-LP} = 0
\item 
int {\bf Num\-Not\-LP} = 0
\item 
bool {\bf Use\-Only\-Moved} = true
\begin{CompactList}\small\item\em Flag to set vdw exclusion based on previously moved atoms only.\item\end{CompactList}\item 
double {\bf ls\_\-dist\_\-tolerance} = 0.0001
\item 
double {\bf ls\_\-succ\_\-tolerance} = 0.001
\item 
double {\bf ls\_\-deriv\_\-tolerance} = 0.0000001
\item 
bool {\bf Local\-Perturb} = true
\begin{CompactList}\small\item\em Setting for local perturbation activation.\item\end{CompactList}\item 
int {\bf Max\-NCuts} = 10
\begin{CompactList}\small\item\em Maximum number of cuts used in the cubic line search.\item\end{CompactList}\item 
double {\bf LPert\-Factor}
\begin{CompactList}\small\item\em Multiplication factor for local pert radius.\item\end{CompactList}\item 
double {\bf Max\-Abs\-Dist\-Res} = -1 $\ast$ INF
\begin{CompactList}\small\item\em the max residual over distance constraints.\item\end{CompactList}\item 
double {\bf Ave\-Abs\-Dist\-Res} = 0
\begin{CompactList}\small\item\em the average residual over distance constraints.\item\end{CompactList}\item 
double {\bf Min\-Dist\-Variance} = INF
\begin{CompactList}\small\item\em the minimum variance fron distance constraint data.\item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
//////////////////////////////////////////////////////////

File: {\bf gw\_\-numerics.h}

Created by: Jon Dugan

This class is never instantiated. It containts static, public functions available for use by other classes (in this case GRAPE Jobs). Several of the numerical techniques originally came from Glenn Williams, hence the 'gw\_\-' in the name.

////////////////////////////////////////////////////////// 



Definition at line 33 of file gw\_\-numerics.h.

\subsection{Constructor \& Destructor Documentation}
\index{gwNumerics@{gw\-Numerics}!gwNumerics@{gwNumerics}}
\index{gwNumerics@{gwNumerics}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}gw\-Numerics::gw\-Numerics ()}\label{class_gwNumerics_a0}




Definition at line 3 of file gw\_\-numerics.C.\footnotesize\begin{verbatim}00004 {
00005 \end{verbatim}\normalsize 
\index{gwNumerics@{gw\-Numerics}!~gwNumerics@{$\sim$gwNumerics}}
\index{~gwNumerics@{$\sim$gwNumerics}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}gw\-Numerics::$\sim$gw\-Numerics ()}\label{class_gwNumerics_a1}




Definition at line 7 of file gw\_\-numerics.C.\footnotesize\begin{verbatim}00008 {
00009 \end{verbatim}\normalsize 


\subsection{Member Function Documentation}
\index{gwNumerics@{gw\-Numerics}!CalcForce@{CalcForce}}
\index{CalcForce@{CalcForce}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf j\-Vector} gw\-Numerics::Calc\-Force (int {\em I}, double {\em radius}, {\bf DLList}$<$ int $>$ {\em Viol\-List}, {\bf DLList}$<$ int $>$ {\em Neighbor\-List}, {\bf DLList}$<$ int $>$ {\em Moved}, const {\bf Constraint\-Manager} \& {\em CM}, const {\bf j\-Vector} \& {\em start\_\-position}, double {\em min\_\-dist}, const {\bf j\-Vector} {\em pref\_\-dir})\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_d13}


\index{gwNumerics@{gw\-Numerics}!CalculateDerivative@{CalculateDerivative}}
\index{CalculateDerivative@{CalculateDerivative}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double gw\-Numerics::Calculate\-Derivative (const {\bf j\-Vector} \& {\em direction}, const$\backslash${\bf j\-Vector} \& {\em gradient})\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_d1}


Returns the derivative of the evaluation function at a position. GGG This return variable is used to check for convergence in the iterations GGG \index{gwNumerics@{gw\-Numerics}!CheckViol@{CheckViol}}
\index{CheckViol@{CheckViol}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf DLList}$<$int$>$ gw\-Numerics::Check\-Viol (int {\em I}, {\bf DLList}$<$ int $>$ {\em Neighbor\-List}, bool {\em Use\-Previous}, const {\bf Constraint\-Manager} \& {\em CM})\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_d11}


\index{gwNumerics@{gw\-Numerics}!CubicLineSearch@{CubicLineSearch}}
\index{CubicLineSearch@{CubicLineSearch}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool gw\-Numerics::Cubic\-Line\-Search (const {\bf j\-Vector} \& {\em position}, const {\bf j\-Vector} \&$\backslash$ {\em direction}, const double \& {\em derivative}, const$\backslash${\bf Constraint\-Manager} \& {\em CM}, int {\em atom\_\-index}, $\backslash${\bf j\-Vector} \& {\em New\-Position}, double \& {\em qmin})\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_d2}


Returns bool flag indication success(true) or failure (false). The function also resets the value in 'New\-Position' to the best position on the line if the search was successful. 

Referenced by gw\-Relax\-Atom::run().\index{gwNumerics@{gw\-Numerics}!LineIntersectSphere@{LineIntersectSphere}}
\index{LineIntersectSphere@{LineIntersectSphere}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Segment} gw\-Numerics::Line\-Intersect\-Sphere (const {\bf j\-Vector} \& {\em atom\_\-position}, const double \&$\backslash$ {\em radius}, const {\bf j\-Vector} \& {\em vec\_\-position}, const$\backslash${\bf j\-Vector} \& {\em atom\_\-direction})\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_d7}


using the vec\_\-position and vec\_\-direction, a line in three space is tested if an atom at atom\_\-position with radius specified by radius intersects that  line. {\bf Segment} {\rm (p.\,\pageref{class_Segment})} returned has units of direction.mag() 

Referenced by add\-LPERTSegments().\index{gwNumerics@{gw\-Numerics}!LinearThreshold@{LinearThreshold}}
\index{LinearThreshold@{LinearThreshold}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double gw\-Numerics::Linear\-Threshold (const double \& {\em X}, double $\ast$ {\em Array})\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_d6}


Determines the 'radius' of an atom for hard constraint purposes using  the linear interpolation method between the max and min settings in Rad\-Array. 

Definition at line 466 of file gw\_\-numerics.C.\footnotesize\begin{verbatim}00467 {
00468   // The Array specifies the linear function that maps one space
00469   // into another, like from X to Y.  Array[0] = Xmin,
00470   // Array[1] = Yval for X < Xmin.  Array[2]= Xmax-Xmin, and Array[3]=
00471   // Yval for X > Xmax.  Linear interpolation is done if X is between
00472   // Xmin and Xmax.
00473   
00474   if (X <= Array[0]) return Array[1];
00475   if (X >= Array[0]+Array[2]) return Array[3]; // Array[2]==0 => step fntn
00476   if (Array[2]!=0){ //just in case
00477     return Array[1]+(Array[3]-Array[1])*((X-Array[0])/Array[2]);
00478   }
00479 \end{verbatim}\normalsize 
\index{gwNumerics@{gw\-Numerics}!LocalPert@{LocalPert}}
\index{LocalPert@{LocalPert}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void gw\-Numerics::Local\-Pert (int {\em I}, {\bf Constraint\-Manager} \& {\em CM}, double {\em min\_\-dist}, {\bf j\-Vector} {\em start\_\-position})\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_d9}


\index{gwNumerics@{gw\-Numerics}!MoveOnSingleViol@{MoveOnSingleViol}}
\index{MoveOnSingleViol@{MoveOnSingleViol}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int gw\-Numerics::Move\-On\-Single\-Viol (int {\em I}, double {\em radius}, int {\em other\-Atom}, {\bf Constraint\-Manager} \& {\em CM})\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_d12}


\index{gwNumerics@{gw\-Numerics}!SetHCPosition2@{SetHCPosition2}}
\index{SetHCPosition2@{SetHCPosition2}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf j\-Vector} gw\-Numerics::Set\-HCPosition2 (const {\bf j\-Vector} \& {\em start\_\-position}, const {\bf j\-Vector} \& {\em curr\_\-position}, $\backslash$const {\bf j\-Vector} \& {\em direction}, {\bf Constraint\-Manager} \&$\backslash$ {\em CM}, int {\em atom\_\-index}, double {\em qmin\_\-dist}, double \& {\em max\_\-lpert\_\-r})\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_d3}


This returns a [3x1] vector used to move an atom in its final iteration, conforming to the Van Der Waal constraints. 

Definition at line 88 of file gw\_\-numerics.C.

Referenced by gw\-Relax\-Atom::run().\footnotesize\begin{verbatim}00090                                                              {
00091 
00092     
00094   //    overview
00095   //
00096   // add vdw to seglist
00097   // add lpert to seglist
00098   // copy seglist
00099   // check viol  
00100   // if viol -- loop:
00101   //   // get neighbors at best
00102   //   // add vdw
00103   //   // check viol
00104   // until !viol
00105   //
00107 
00108   Segments SegList;
00109   Segment TempSegment;
00110   double func_eval1, func_eval2;
00111 
00112   jVector new_position = curr_position +direction*qmin_dist;
00113 
00114 //   cerr << "*1 new_position =>" << new_position << endl;
00115 //   cerr << "*1 curr_position =>" << curr_position << endl;
00116   
00117 //   cerr << "new_position" << new_position << endl;
00118 //   cerr << "curr_position" << curr_position << endl;
00119 //   cerr << "qmin_dist"  << qmin_dist << endl;
00120   
00121 #ifdef GNOMAD_OUTPUT
00122       printf("  Initial qmin:\n");
00123       printf("    initial qmin = %lf\n", qmin_dist);
00124 #endif
00125 
00126 
00127   // add vdw to seglist
00128       addVDWSegments(SegList, curr_position,  \
00129                        direction, CM, atom_index, 0);
00130 
00131         //  cerr << "*2 new_position =>" << new_position << endl;
00132 
00133   // add lpert to seglist
00134   if (LocalPerturb) 
00135     addLPERTSegments (SegList, curr_position,  \
00136                       direction, CM, atom_index, qmin_dist, \
00137                       start_position, new_position, max_lpert_r);
00138 
00139   //  cerr << "*3 new_position =>" << new_position << endl;
00140   
00141   // check viol  -- write seglist.qsortviol
00142   TempSegment = SegList.QSortReduceViol(qmin_dist);
00143 
00144   if ((TempSegment.start == 0) && (TempSegment.end == 0)){
00145     // no violation
00146 
00147 #ifdef GNOMAD_OUTPUT
00148     printf("  After vdw_segs\n");
00149     //    printf("    lbound, ubound = %lf %lf\n", *lbound, *ubound);
00150     //    printf("    num_segments = %d\n", *num_segments);
00151     printf ("Segment List:\n");
00152     for(int ixx=0; ixx < SegList.GetNum(); ixx++)
00153       printf("      start_ineq, end_ineq = %lf %lf\n", SegList.GetSeg(ixx).start, SegList.GetSeg(ixx).end );
00154     printf("\n");
00155 
00156     printf("  After viol_check\n");
00157     printf("    qmin = %lf\n\n", qmin_dist);
00158 #endif
00159 
00160     //    cerr << "*4 new_position =>" << new_position << endl;    
00161     return new_position;
00162     
00163   } else {     // BEGIN Violation else
00164 
00165 
00166     while ((TempSegment.start != 0) && (TempSegment.end != 0)){
00167       // BEGIN location loop:    
00168       
00169       //find current best
00170       func_eval1 = CM.stress(atom_index, curr_position+direction*TempSegment.start);
00171       func_eval2 = CM.stress(atom_index, curr_position+direction*TempSegment.end);
00172       qmin_dist = (func_eval1 < func_eval2)? TempSegment.start : TempSegment.end;      
00173       
00174       //change qmin_dist to be there
00175       new_position = curr_position + (direction*qmin_dist);
00176       
00177       //      cerr << "*5 new_position =>" << new_position << endl;
00178 //       cerr << "*5 direction =>" << direction << endl;
00179 //       cerr << "*5 direction.mag() =>" << direction.mag() << endl;
00180 //       cerr << "*5 qmin =>" << qmin_dist << endl;
00181       
00182       // add new vdw
00183       addVDWSegments(SegList, new_position,  \
00184                      direction, CM, atom_index, qmin_dist);
00185       
00186       //      cerr << "*6 new_position =>" << new_position << endl;      
00187 
00188       //  check viol
00189       TempSegment = SegList.QSortReduceViol(qmin_dist);
00190       
00191       // if no violation at current qmin_dist, then TempSegment will be 0,0 -- break out of loop.
00192 
00193     }   // END location loop
00194 
00195 
00196 #ifdef GNOMAD_OUTPUT
00197     printf("  After vdw_segs\n");
00198     //    printf("    lbound, ubound = %lf %lf\n", *lbound, *ubound);
00199     //    printf("    num_segments = %d\n", *num_segments);
00200     printf ("Segment List:\n");
00201     for(int ixx=0; ixx < SegList.GetNum(); ixx++)
00202       printf("      start_ineq, end_ineq = %lf %lf\n", SegList.GetSeg(ixx).start, SegList.GetSeg(ixx).end );
00203     printf("\n");
00204 
00205     printf("  After viol_check\n");
00206     printf("    qmin = %lf\n\n", qmin_dist);
00207 #endif
00208     
00209     //    cerr << "*7 new_position =>" << new_position << endl;      
00210     return new_position;
00211     
00212   }
00213 \end{verbatim}\normalsize 
\index{gwNumerics@{gw\-Numerics}!SolveVector@{SolveVector}}
\index{SolveVector@{SolveVector}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void gw\-Numerics::Solve\-Vector (const {\bf j\-Vector} \& {\em gradient}, const {\bf j\-Vector} \&$\backslash$ {\em hessian}, {\bf j\-Vector} \& {\em result})\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_d0}


Result pointer is a [3x1] array of doubles that represent  are the solution to Hessian (x1,y1,z1) = Gradient. GGG in Gnomad, x1,y1,z1 (result$\ast$) is variable p GGG 

Referenced by bfgs\_\-step().\index{gwNumerics@{gw\-Numerics}!SpreadR@{SpreadR}}
\index{SpreadR@{SpreadR}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int gw\-Numerics::Spread\-R (int {\em I}, double {\em radius}, {\bf DLList}$<$ int $>$ {\em Moved}, int {\em depth}, {\bf Constraint\-Manager} \& {\em CM}, {\bf j\-Vector} {\em start\_\-position}, const {\bf j\-Vector} {\em pref\_\-dir})\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_d10}


\index{gwNumerics@{gw\-Numerics}!addLPERTSegments@{addLPERTSegments}}
\index{addLPERTSegments@{addLPERTSegments}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void gw\-Numerics::add\-LPERTSegments ({\bf Segments} \& {\em Seg\-List}, const {\bf j\-Vector} \& {\em curr\_\-position}, $\backslash$const {\bf j\-Vector} \& {\em direction}, {\bf Constraint\-Manager} \&$\backslash$ {\em CM}, int {\em atom\_\-index}, double {\em qmin\_\-dist}, $\backslash$const {\bf j\-Vector} \& {\em start\_\-position}, const {\bf j\-Vector} \& {\em new\_\-position}, double \& {\em max\_\-r})\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_d5}




Definition at line 308 of file gw\_\-numerics.C.\footnotesize\begin{verbatim}00312                                                                              {
00313 
00314 
00315 #ifdef GNOMAD_OUTPUT
00316   printf("  In pert_seg\n");
00317   printf("    initial x0, y0, z0 = %lf  %lf  %lf\n", start_position[0], start_position[1], start_position[2]);
00318   printf("    initial x, y, z = %lf  %lf  %lf\n", curr_position[0], curr_position[1], curr_position[2]);
00319   printf("    initial direction vector = %lf  %lf  %lf\n", direction[0], direction[1], direction[2]);
00320   //  printf("    initial lbound, ubound = %lf %lf\n", *lbound, *ubound);
00321   //  printf("    num_segments = %d\n\n", *num_segments);
00322 #endif
00323 
00324 #ifdef JOB_VERBOSE
00325   cerr << "addLPERTSegments: starting " << endl; 
00326 #endif
00327   
00328   Segment TempSegment;
00329   //  double radius = LinearThreshold(sqrt(CM.stress(atom_index, curr_position)), LPertRadius);
00330   //double radius = sqrt(0.5*CM.stress(atom_index, curr_position));
00331   double radius = sqrt(0.5*MinDistVariance*CM.stress(atom_index, new_position));
00332 
00333   if (radius > max_r){
00334 #ifdef JOB_VERBOSE2
00335     cerr << "addLPERTSegments: pert radius =    " << radius << endl; 
00336     cerr << "RESETTING PERT RADIUS ARBITRARILY to " << radius << endl ;
00337 #endif
00338     radius = max_r;
00339   }
00340   
00341 #ifdef JOB_VERBOSE2
00342   cerr << "addLPERTSegments: pert stress =    " << CM.stress(atom_index, new_position)  << endl; 
00343   cerr << "addLPERTSegments: pert dif vector =" << curr_position-start_position << endl; 
00344   cerr << "addLPERTSegments: pert radius =    " << radius << endl; 
00345   cerr << "addLPERTSegments: pert max_radius cutoff =    " << max_r << endl;
00346   cerr << "addLPERTSegments: pert mindistvar =    " << MinDistVariance << endl;   
00347 #endif
00348   //cerr << "r " << radius << endl;
00349   //radius = LinearThreshold(log10(CM.stress(atom_index, curr_position)+1), LPertRadius);
00350   //radius = LinearThreshold(LPertRadius[2]-(1/(CM.stress(atom_index, curr_position)+LPertRadius[0])), LPertRadius);
00351   // radius = radius * LPertFactor;    
00352   if (radius>0) {
00353     TempSegment = LineIntersectSphere(start_position, radius, curr_position, direction);
00354 
00355 #ifdef JOB_VERBOSE2
00356     cerr << "addLPERTSegments: pert segement =" << TempSegment << endl; 
00357 #endif
00358 
00359     if (TempSegment.start < -1e8 && TempSegment.end > 1e8) { // two number from Glenn's ass
00360       return;
00361     }
00362   
00363     if ((qmin_dist > TempSegment.start) && (qmin_dist < TempSegment.end)) {
00364 #ifdef JOB_VERBOSE2
00365       cerr << "addLPERTSegments: segment caused perturbation" << endl;
00366 #endif
00367       NumLP++;
00368       SegList.Add(TempSegment);      
00369       // here is where Local Pert has bumped atom number atom_index'
00370     } else {
00371 #ifdef JOB_VERBOSE2
00372       cerr << "addLPERTSegments: pert segment irrelevant" << endl;
00373 #endif
00374       NumNotLP++;
00375     }
00376     
00377   }
00378 \end{verbatim}\normalsize 
\index{gwNumerics@{gw\-Numerics}!addVDWSegments@{addVDWSegments}}
\index{addVDWSegments@{addVDWSegments}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void gw\-Numerics::add\-VDWSegments ({\bf Segments} \& {\em Seg\-List}, const {\bf j\-Vector} \& {\em curr\_\-position}, $\backslash$const {\bf j\-Vector} \& {\em direction}, {\bf Constraint\-Manager} \&$\backslash$ {\em CM}, int {\em atom\_\-index}, double {\em offset} = 0)\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_d4}




Definition at line 217 of file gw\_\-numerics.C.\footnotesize\begin{verbatim}00219                                    {
00220   
00221 #ifdef JOB_VERBOSE
00222   cerr << "addVDWSegments: starting " << endl;
00223   cerr << "addVDWSegments: offset = "<<offset << endl; 
00224   if (direction.nrm() == 0)
00225     cerr << "addVDWSegments: Zero dir! (abort)" << endl;
00226 #endif
00227   
00228   if (direction.nrm() == 0)
00229     return ;
00230 
00231   
00232   DLList<int> NeighborList = CM.approx_neighbor_i(curr_position, 3.7);
00233   DLList<int>::ConstIterator Nei_Iter;
00234   int other_index;
00235   double msd;  // Minimum Separation Distance (center to center)
00236   Segment TempSegment;
00237   
00238   for(Nei_Iter = NeighborList.GetConstIterator(); Nei_Iter; ++Nei_Iter){
00239     // BEGIN iterate over local neighbors
00240     other_index = *Nei_Iter;
00241 
00242 #ifdef JOB_VERBOSE2
00243     cerr << "addVDWSegments: checking atom " << other_index << endl; 
00244 #endif
00245 
00246     //    msd = LinearThreshold((CM.stress(other_index)),VDWRadius);
00247     //msd = 3;
00248     //msd    moved into loop to prevent msd on atom = atom
00249     
00250     //    cerr << "Bonds for atom " << atom_index << ": " << CM.getMolecule().GetBonds(atom_index) << endl;
00251     
00252     // DEBUG
00253     //cerr << "vdw atom:     "<< other_index;
00254     //cerr << "vdw msd:   "<< msd;
00255     //cerr << "vdw position: "<< (CM.getMolecule())(other_index) << endl;
00256 
00257     // here use the Moved() atom info to only check VDW against moved atoms    
00258     if ((other_index != atom_index) && (CM.constraintON(other_index))) {    
00259       if ((UseOnlyMoved == false)
00260           || ((UseOnlyMoved == true)
00261               && (CM.getAtom(other_index).Moved() == true)
00262               ))
00263         {
00264           msd = (CM.getMolecule()).MSD(atom_index, other_index);
00265 
00266 #ifdef JOB_VERBOSE2
00267           cerr << "addVDWSegments: atom " << other_index <<
00268             " passed move and self-atom criteria. msd = " << msd << endl; 
00269 
00270           cerr << "x            " << curr_position << endl;
00271           cerr << "other atom x " << (CM.getMolecule())(other_index) << endl;
00272           cerr << "dir          " << direction << endl;
00273 #endif
00274 
00275           TempSegment = LineIntersectSphere((CM.getMolecule())(other_index), 
00276                                             msd, curr_position ,direction);       
00277           // returns segment on 0,0 if not intersect
00278           //cerr << "vdw segment: " << TempSegment << endl;
00279 
00280 #ifdef JOB_VERBOSE2
00281           cerr << "addVDWSegments: segment returned " << TempSegment
00282                << " for atom " << other_index << "; d = "
00283                << euclid ((CM.getMolecule())(other_index), curr_position)
00284                << endl; 
00285 #endif
00286 
00287           if (offset){
00288             TempSegment.start += offset;
00289             TempSegment.end += offset;    
00290 #ifdef JOB_VERBOSE2
00291           cerr << "addVDWSegments: segment offset to " << TempSegment
00292                << " for atom " << other_index << endl;
00293 #endif
00294             
00295           }
00296           if (TempSegment.start != TempSegment.end) SegList.Add(TempSegment);
00297         }
00298     }
00299   }
00300 \end{verbatim}\normalsize 
\index{gwNumerics@{gw\-Numerics}!bfgs_step@{bfgs\_\-step}}
\index{bfgs_step@{bfgs\_\-step}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void gw\-Numerics::bfgs\_\-step (const {\bf j\-Vector} \& {\em x}, const {\bf j\-Vector} \& {\em xp}, const {\bf j\-Vector} \& {\em gf}, const {\bf j\-Vector} \& {\em gfp}, {\bf j\-Vector} \& {\em H}, {\bf j\-Vector} \& {\em direction})\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_d8}




Definition at line 921 of file gw\_\-numerics.C.

Referenced by gw\-Relax\-Atom::run().\footnotesize\begin{verbatim}00923                                                       {
00924 
00925 //      cerr << "D: -  H-row0= " << H[0] << " " << H[1] << " " << H[2] << endl;
00926 //      cerr << "D: -  H-row1= " << H[1] << " " << H[3] << " " << H[4] << endl;
00927 //      cerr << "D: -  H-row2= " << H[2] << " " << H[4] << " " << H[5] << endl;
00928 //      cerr << "D:  -  x= " << x << endl;
00929 //      cerr << "D:  -  xp= " << xp << endl;
00930 //      cerr << "D:  -  gf= " << gf << endl;
00931 //      cerr << "D:  -  gfp= " << gfp << endl;
00932 //      cerr << "D:  -  p= " << direction << endl;
00933   // solves for p, the direction vector
00934 
00935   register int i;
00936   // double Acopy[9], bcopy[3], d1, d2, hs[3], h1[6], h2[6], s[3], st, temp, v[3];
00937   double st, d1, d2, temp, h1[6], h2[6], hs[3];
00938   jVector Acopy(9,0);
00939   jVector s;
00940   jVector v;
00941   
00942   st = 0.0;
00943   
00944   s = x - xp;
00945 //   cerr << "D:  -  s= " << s << endl;
00946   v = gf - gfp;
00947 //   cerr << "D:  -  v= " << v << endl;
00948   
00949   d1 = 1/(v*s);
00950 //   cerr << "D:  -  d1= " << d1 << endl;
00951   
00952   h1[0] = d1*v[0]*v[0];
00953   h1[1] = d1*v[0]*v[1];
00954   h1[2] = d1*v[0]*v[2];
00955   h1[3] = d1*v[1]*v[1];
00956   h1[4] = d1*v[1]*v[2];
00957   h1[5] = d1*v[2]*v[2];
00958 
00959   temp = H[1]*s[0]*s[1] + H[2]*s[0]*s[2] + H[4]*s[1]*s[2];
00960   temp *= 2.0;
00961   d2 = H[0]*s[0]*s[0] + H[3]*s[1]*s[1] + H[5]*s[2]*s[2];
00962   d2 += temp;
00963   d2 = 1.0/d2;
00964 
00965 //   cerr << "D:  -  d2= " << d2 << endl;
00966   
00967   hs[0] = H[0]*s[0] + H[1]*s[1] + H[2]*s[2];
00968   hs[1] = H[1]*s[0] + H[3]*s[1] + H[4]*s[2];
00969   hs[2] = H[2]*s[0] + H[4]*s[1] + H[5]*s[2];
00970 
00971   h2[0] = d2*hs[0]*hs[0];
00972   h2[1] = d2*hs[0]*hs[1];
00973   h2[2] = d2*hs[0]*hs[2];
00974   h2[3] = d2*hs[1]*hs[1];
00975   h2[4] = d2*hs[1]*hs[2];
00976   h2[5] = d2*hs[2]*hs[2];
00977 
00978   for(i=0; i<6; i++) H[i] = H[i] + h1[i] - h2[i];
00979 
00980   Acopy[0] = H[0];
00981   Acopy[1] = H[1];
00982   Acopy[2] = H[2];
00983   Acopy[3] = H[1];
00984   Acopy[4] = H[3];
00985   Acopy[5] = H[4];
00986   Acopy[6] = H[2];
00987   Acopy[7] = H[4];
00988   Acopy[8] = H[5];
00989   
00990   
00991   gwNumerics::SolveVector((-1)*gf, Acopy, direction);
00992 
00993 \end{verbatim}\normalsize 
\index{gwNumerics@{gw\-Numerics}!reset_LP_Count@{reset\_\-LP\_\-Count}}
\index{reset_LP_Count@{reset\_\-LP\_\-Count}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void gw\-Numerics::reset\_\-LP\_\-Count (void)\hspace{0.3cm}{\tt  [inline, static]}}\label{class_gwNumerics_d14}




Definition at line 191 of file gw\_\-numerics.h.\footnotesize\begin{verbatim}00191                                             {
00192     NumLP = NumNotLP = 0;
00193 \end{verbatim}\normalsize 


\subsection{Member Data Documentation}
\index{gwNumerics@{gw\-Numerics}!AveAbsDistRes@{AveAbsDistRes}}
\index{AveAbsDistRes@{AveAbsDistRes}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double gw\-Numerics::Ave\-Abs\-Dist\-Res = 0\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_p10}


the average residual over distance constraints.



Definition at line 11 of file globals.C.\index{gwNumerics@{gw\-Numerics}!LPertFactor@{LPertFactor}}
\index{LPertFactor@{LPertFactor}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double gw\-Numerics::LPert\-Factor\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_p8}


Multiplication factor for local pert radius.



Definition at line 223 of file gw\_\-numerics.h.\index{gwNumerics@{gw\-Numerics}!LocalPerturb@{LocalPerturb}}
\index{LocalPerturb@{LocalPerturb}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool gw\-Numerics::Local\-Perturb = true\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_p6}


Setting for local perturbation activation.



Definition at line 20 of file globals.C.\index{gwNumerics@{gw\-Numerics}!MaxAbsDistRes@{MaxAbsDistRes}}
\index{MaxAbsDistRes@{MaxAbsDistRes}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double gw\-Numerics::Max\-Abs\-Dist\-Res = -1 $\ast$ INF\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_p9}


the max residual over distance constraints.



Definition at line 10 of file globals.C.\index{gwNumerics@{gw\-Numerics}!MaxNCuts@{MaxNCuts}}
\index{MaxNCuts@{MaxNCuts}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int gw\-Numerics::Max\-NCuts = 10\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_p7}


Maximum number of cuts used in the cubic line search.



Definition at line 21 of file globals.C.\index{gwNumerics@{gw\-Numerics}!MinDistVariance@{MinDistVariance}}
\index{MinDistVariance@{MinDistVariance}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double gw\-Numerics::Min\-Dist\-Variance = INF\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_p11}


the minimum variance fron distance constraint data.



Definition at line 12 of file globals.C.\index{gwNumerics@{gw\-Numerics}!NumLP@{NumLP}}
\index{NumLP@{NumLP}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int gw\-Numerics::Num\-LP = 0\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_p0}




Definition at line 22 of file globals.C.\index{gwNumerics@{gw\-Numerics}!NumNotLP@{NumNotLP}}
\index{NumNotLP@{NumNotLP}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int gw\-Numerics::Num\-Not\-LP = 0\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_p1}




Definition at line 23 of file globals.C.\index{gwNumerics@{gw\-Numerics}!UseOnlyMoved@{UseOnlyMoved}}
\index{UseOnlyMoved@{UseOnlyMoved}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool gw\-Numerics::Use\-Only\-Moved = true\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_p2}


Flag to set vdw exclusion based on previously moved atoms only.



Definition at line 19 of file globals.C.\index{gwNumerics@{gw\-Numerics}!ls_deriv_tolerance@{ls\_\-deriv\_\-tolerance}}
\index{ls_deriv_tolerance@{ls\_\-deriv\_\-tolerance}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double gw\-Numerics::ls\_\-deriv\_\-tolerance = 0.0000001\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_p5}


Tolerance of convergence. This value is used to test the derivative of the evaluation function duringthe line search. (tau) 

Definition at line 8 of file globals.C.\index{gwNumerics@{gw\-Numerics}!ls_dist_tolerance@{ls\_\-dist\_\-tolerance}}
\index{ls_dist_tolerance@{ls\_\-dist\_\-tolerance}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double gw\-Numerics::ls\_\-dist\_\-tolerance = 0.0001\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_p3}


Epsilon of useless movement. If an atom is moved less than this amount, it is assumed to be a trivial movement. (1e-4) 

Definition at line 7 of file globals.C.\index{gwNumerics@{gw\-Numerics}!ls_succ_tolerance@{ls\_\-succ\_\-tolerance}}
\index{ls_succ_tolerance@{ls\_\-succ\_\-tolerance}!gwNumerics@{gw\-Numerics}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double gw\-Numerics::ls\_\-succ\_\-tolerance = 0.001\hspace{0.3cm}{\tt  [static]}}\label{class_gwNumerics_p4}


Tolerance value used to test if the line search function was successful. (alph in glenn wiliams code) 

Definition at line 6 of file globals.C.

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
{\bf gw\_\-numerics.h}\item 
{\bf globals.C}\item 
{\bf gw\_\-numerics.C}\end{CompactItemize}
