\section{Position\-Constraint  Class Reference}
\label{class_PositionConstraint}\index{PositionConstraint@{Position\-Constraint}}
{\tt \#include $<$position\_\-constraint.h$>$}

Inheritance diagram for Position\-Constraint\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=60pt]{class_PositionConstraint_inherit_graph}
\end{center}
\end{figure}
Collaboration diagram for Position\-Constraint:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=363pt]{class_PositionConstraint_coll_graph}
\end{center}
\end{figure}
\subsection*{Public Methods}
\begin{CompactItemize}
\item 
{\bf Position\-Constraint} ({\bf Constraint\-Manager} \&cm)
\item 
{\bf Position\-Constraint} ({\bf Constraint\-Manager} \&cm, int atom\_\-i, double x, double y, double {\bf z}, double variance\_\-in)
\item 
{\bf $\sim$Position\-Constraint} ()
\item 
{\bf j\-Vector} {\bf d\-Stress} (int k, const {\bf j\-Vector} \&pos) const
\item 
int {\bf Compare} (const Position\-Constraint \&dc) const
\item 
{\bf MAKECOMPARISONS\_\-WITH\_\-COMPARE} (Position\-Constraint)
\item 
int {\bf Output} (ostream \&os) const
\item 
int {\bf Output\-Binary} (ostream \&os) const
\end{CompactItemize}
\subsection*{Static Public Attributes}
\begin{CompactItemize}
\item 
{\bf Dyn\-String} {\bf Identifier} = "atompos:"
\end{CompactItemize}
\subsection*{Protected Methods}
\begin{CompactItemize}
\item 
double {\bf compute\-Stress} () const
\item 
double {\bf compute\-Stress} (int k, const {\bf j\-Vector} \&pos) const
\begin{CompactList}\small\item\em Mimics moving the atom to a new position.\item\end{CompactList}\item 
int {\bf Read} (istream \&is)
\item 
int {\bf Read\-Binary} (istream \&is)
\begin{CompactList}\small\item\em Same scenerio as {\bf Read}() {\rm (p.\,\pageref{class_PositionConstraint_b2})} only binary version.\item\end{CompactList}\item 
void {\bf Pre\-Setup} ()
\end{CompactItemize}
\subsection*{Protected Attributes}
\begin{CompactItemize}
\item 
{\bf j\-Vector} {\bf measured}
\begin{CompactList}\small\item\em input, measured position (the correct position).\item\end{CompactList}\item 
double {\bf variance}
\item 
double {\bf stdev}
\end{CompactItemize}


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

{\bf position\_\-constraint.h}

This is a constraint type for GRAPE. It constrains the position of a single atom to set coordinates, each with a specified variance.

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



Definition at line 20 of file position\_\-constraint.h.

\subsection{Constructor \& Destructor Documentation}
\index{PositionConstraint@{Position\-Constraint}!PositionConstraint@{PositionConstraint}}
\index{PositionConstraint@{PositionConstraint}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Position\-Constraint::Position\-Constraint ({\bf Constraint\-Manager} \& {\em cm})}\label{class_PositionConstraint_a0}




Definition at line 3 of file position\_\-constraint.C.\footnotesize\begin{verbatim}00004   : Constraint(cm,IntVec(1,-1))
00005   {
00006     // this is an unititialized constraint.  The atom position
00007     // and the variance values must be added.
00008     measured[0]=0;
00009     measured[1]=0;
00010     measured[2]=0;
00011     //    variance[0] = INF;
00012     //    variance[1] = INF;
00013     //    variance[2] = INF;
00014     variance = INF;
00015 \end{verbatim}\normalsize 
\index{PositionConstraint@{Position\-Constraint}!PositionConstraint@{PositionConstraint}}
\index{PositionConstraint@{PositionConstraint}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Position\-Constraint::Position\-Constraint ({\bf Constraint\-Manager} \& {\em cm}, int {\em atom\_\-i}, double {\em x}, double {\em y}, double {\em z}, double {\em variance\_\-in})}\label{class_PositionConstraint_a1}




Definition at line 20 of file position\_\-constraint.C.\footnotesize\begin{verbatim}00023   : Constraint(cm, IntVec(1,atom_i))
00024 
00025 {
00026   measured[0]=x;
00027   measured[1]=y;
00028   measured[2]=z;
00029   //  variance[0] = x_var;
00030   //variance[1] = y_var;
00031   //variance[2] = z_var;
00032   variance = variance_in;
00033   //  stdev[0] = sqrt(x_var);
00034   //  stdev[1] = sqrt(y_var);
00035   //  stdev[2] = sqrt(z_var);
00036   stdev = sqrt(variance);
00037 \end{verbatim}\normalsize 
\index{PositionConstraint@{Position\-Constraint}!~PositionConstraint@{$\sim$PositionConstraint}}
\index{~PositionConstraint@{$\sim$PositionConstraint}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Position\-Constraint::$\sim$Position\-Constraint ()\hspace{0.3cm}{\tt  [inline]}}\label{class_PositionConstraint_a2}




Definition at line 34 of file position\_\-constraint.h.\footnotesize\begin{verbatim}00034                         {}
00035 \end{verbatim}\normalsize 


\subsection{Member Function Documentation}
\index{PositionConstraint@{Position\-Constraint}!Compare@{Compare}}
\index{Compare@{Compare}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Position\-Constraint::Compare (const Position\-Constraint \& {\em pc}) const\hspace{0.3cm}{\tt  [inline]}}\label{class_PositionConstraint_a4}




Definition at line 72 of file position\_\-constraint.h.\footnotesize\begin{verbatim}00073 {
00074   if(supportA[0] == pc.supportA[0])
00075     return 0;
00076   if(supportA[0]<pc.supportA[0])
00077     return -1;
00078   return 1;  
00079 \end{verbatim}\normalsize 
\index{PositionConstraint@{Position\-Constraint}!MAKECOMPARISONS_WITH_COMPARE@{MAKECOMPARISONS\_\-WITH\_\-COMPARE}}
\index{MAKECOMPARISONS_WITH_COMPARE@{MAKECOMPARISONS\_\-WITH\_\-COMPARE}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Position\-Constraint::MAKECOMPARISONS\_\-WITH\_\-COMPARE (Position\-Constraint)}\label{class_PositionConstraint_a5}


\index{PositionConstraint@{Position\-Constraint}!Output@{Output}}
\index{Output@{Output}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Position\-Constraint::Output (ostream \& {\em os}) const\hspace{0.3cm}{\tt  [virtual]}}\label{class_PositionConstraint_a6}




Reimplemented from {\bf Constraint} {\rm (p.\,\pageref{class_Constraint_a11})}.

Definition at line 137 of file position\_\-constraint.C.\footnotesize\begin{verbatim}00138 {
00139   os << supportA[0] << ' ' << measured[0] << ' '<< measured[1] << ' '
00140      << measured[2] << ' ' << variance;
00141   return 2;
00142 \end{verbatim}\normalsize 
\index{PositionConstraint@{Position\-Constraint}!OutputBinary@{OutputBinary}}
\index{OutputBinary@{OutputBinary}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Position\-Constraint::Output\-Binary (ostream \& {\em os}) const\hspace{0.3cm}{\tt  [virtual]}}\label{class_PositionConstraint_a7}




Reimplemented from {\bf Constraint} {\rm (p.\,\pageref{class_Constraint_a13})}.

Definition at line 151 of file position\_\-constraint.C.\footnotesize\begin{verbatim}00152 {
00153   os <= supportA <= measured <= variance;
00154   return 2;
00155 \end{verbatim}\normalsize 
\index{PositionConstraint@{Position\-Constraint}!PreSetup@{PreSetup}}
\index{PreSetup@{PreSetup}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Position\-Constraint::Pre\-Setup (void)\hspace{0.3cm}{\tt  [protected, virtual]}}\label{class_PositionConstraint_b4}


The setup function is called if the uninialized constraint method is used to create the constraint to allow different data representations within the constraint. Without this, only data read in from the input file will be available to the member functions. For simple constraints, this is really not very useful. However for multi-atom constraints that need to be a little 'smarter' about data representations, the Setup function will be helpful. 

Reimplemented from {\bf Constraint} {\rm (p.\,\pageref{class_Constraint_b6})}.

Definition at line 39 of file position\_\-constraint.C.\footnotesize\begin{verbatim}00040 {
00041   //  stdev[0] = sqrt(variance[0]);
00042   //  stdev[1] = sqrt(variance[1]);
00043   //  stdev[2] = sqrt(variance[2]);
00044   stdev = sqrt(variance);
00045 \end{verbatim}\normalsize 
\index{PositionConstraint@{Position\-Constraint}!Read@{Read}}
\index{Read@{Read}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Position\-Constraint::Read (istream \& {\em is})\hspace{0.3cm}{\tt  [protected, virtual]}}\label{class_PositionConstraint_b2}


Derived classes need to define here how to read  themselves in. Notice that the base class defines {\bf Input}() {\rm (p.\,\pageref{class_Constraint_a12})} as a wrapper around this virtual function. Subclasses should typically overwrite just the {\bf Read}() {\rm (p.\,\pageref{class_PositionConstraint_b2})} function (and not the {\bf Input}() {\rm (p.\,\pageref{class_Constraint_a12})} function).

In the {\bf Read}() {\rm (p.\,\pageref{class_PositionConstraint_b2})} function, the derived class should $\ast$not$\ast$ log itself with the constraint manager since this is taken care of in the base classes {\bf Input}() {\rm (p.\,\pageref{class_Constraint_a12})} function. 

Reimplemented from {\bf Constraint} {\rm (p.\,\pageref{class_Constraint_b4})}.

Definition at line 144 of file position\_\-constraint.C.\footnotesize\begin{verbatim}00145 {
00146   is >> supportA[0] >> measured[0] >>  measured[1]
00147      >> measured[2] >> variance;
00148   return 2;
00149 \end{verbatim}\normalsize 
\index{PositionConstraint@{Position\-Constraint}!ReadBinary@{ReadBinary}}
\index{ReadBinary@{ReadBinary}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int Position\-Constraint::Read\-Binary (istream \& {\em is})\hspace{0.3cm}{\tt  [protected, virtual]}}\label{class_PositionConstraint_b3}


Same scenerio as {\bf Read}() {\rm (p.\,\pageref{class_PositionConstraint_b2})} only binary version.



Reimplemented from {\bf Constraint} {\rm (p.\,\pageref{class_Constraint_b5})}.

Definition at line 157 of file position\_\-constraint.C.\footnotesize\begin{verbatim}00158 {
00159   is >= supportA[0] >= measured >= variance;
00160   return 2;
00161 \end{verbatim}\normalsize 
\index{PositionConstraint@{Position\-Constraint}!computeStress@{computeStress}}
\index{computeStress@{computeStress}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Position\-Constraint::compute\-Stress (int {\em k}, const {\bf j\-Vector} \& {\em pos\_\-k}) const\hspace{0.3cm}{\tt  [protected, virtual]}}\label{class_PositionConstraint_b1}


Mimics moving the atom to a new position.



Reimplemented from {\bf Constraint} {\rm (p.\,\pageref{class_Constraint_a27})}.

Definition at line 70 of file position\_\-constraint.C.\footnotesize\begin{verbatim}00071 {
00072   
00073   if(k != supportA[0])
00074     {
00075       cerr << "Fatal error: position_constraint.C, computeStress("<< k \
00076            <<", pos) not legal on position constraint for atom " \
00077            << supportA[0] << endl;
00078       DIE("");
00079     }
00080 \end{verbatim}\normalsize 
\index{PositionConstraint@{Position\-Constraint}!computeStress@{computeStress}}
\index{computeStress@{computeStress}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Position\-Constraint::compute\-Stress () const\hspace{0.3cm}{\tt  [protected, virtual]}}\label{class_PositionConstraint_b0}


Returns how similar the distance between atoms i and j in molecule, mol, are compared to the measured distance represented in this constraint. 

Reimplemented from {\bf Constraint} {\rm (p.\,\pageref{class_Constraint_a26})}.

Definition at line 52 of file position\_\-constraint.C.\footnotesize\begin{verbatim}00053 {
00054   
00055 
00056   // Find the current position in the predicted molecule:
00057   jVector diff = getMolecule()(supportA[0])-measured;
00058   
00059   // Return the squared difference between this and our model position:
00060   // double calc = (diff[0]*diff[0]/variance[0])+
00061   // (diff[1]*diff[1]/variance[1])+
00062   // (diff[2]*diff[2]/variance[2]);
00063   double calc = (diff[0]*diff[0]+ \
00064                  (diff[1]*diff[1])+\
00065                  (diff[2]*diff[2]));
00066   
00067   return calc/(2.0*variance);
00068 \end{verbatim}\normalsize 
\index{PositionConstraint@{Position\-Constraint}!dStress@{dStress}}
\index{dStress@{dStress}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf j\-Vector} Position\-Constraint::d\-Stress (int {\em k}, const {\bf j\-Vector} \& {\em pos\_\-k}) const\hspace{0.3cm}{\tt  [virtual]}}\label{class_PositionConstraint_a3}


asking constraint number k for its 12 element d\-Stress vector we pass in pos\_\-a vector -- corresponding to the atom position if the constraint is an atom, and corresponding to the position of the atom k in question if the call is to a non-atom constraint. EG for a distance constraint atom 12 needs the d\-Stress from the d-constraint, so it will call d\-Stress on the d-constraint(12, atom\_\-pos) so the d\_\-constr can answer the question if atom 12 were in atom\_\-pos, I would say my d\-Stress is blah. 

Reimplemented from {\bf Constraint} {\rm (p.\,\pageref{class_Constraint_a6})}.

Definition at line 95 of file position\_\-constraint.C.\footnotesize\begin{verbatim}00096 {
00097   // A HACK and a TEMPORARY FIX to an inherent logic problems in this
00098   // set of functions.  come see me w/ questions -jd
00099   
00100 
00101   if(k != supportA[0])
00102     {
00103       cerr << "Fatal error: position_constraint.C, dStress("<< k \
00104            <<", pos) not legal on position constraint for atom " <<
00105         supportA[0] << endl;
00106       DIE("");
00107     }
00108 \end{verbatim}\normalsize 


\subsection{Member Data Documentation}
\index{PositionConstraint@{Position\-Constraint}!Identifier@{Identifier}}
\index{Identifier@{Identifier}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Dyn\-String} Position\-Constraint::Identifier = "atompos:"\hspace{0.3cm}{\tt  [static]}}\label{class_PositionConstraint_p0}




Reimplemented from {\bf Constraint} {\rm (p.\,\pageref{class_Constraint_p0})}.

Definition at line 118 of file globals.C.\index{PositionConstraint@{Position\-Constraint}!measured@{measured}}
\index{measured@{measured}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf j\-Vector} Position\-Constraint::measured\hspace{0.3cm}{\tt  [protected]}}\label{class_PositionConstraint_n0}


input, measured position (the correct position).



Definition at line 59 of file position\_\-constraint.h.\index{PositionConstraint@{Position\-Constraint}!stdev@{stdev}}
\index{stdev@{stdev}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Position\-Constraint::stdev\hspace{0.3cm}{\tt  [protected]}}\label{class_PositionConstraint_n2}




Definition at line 62 of file position\_\-constraint.h.\index{PositionConstraint@{Position\-Constraint}!variance@{variance}}
\index{variance@{variance}!PositionConstraint@{Position\-Constraint}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double Position\-Constraint::variance\hspace{0.3cm}{\tt  [protected]}}\label{class_PositionConstraint_n1}




Definition at line 61 of file position\_\-constraint.h.

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