GLYLIB  0.3.0b
assign_COM.c
Go to the documentation of this file.
00001 // Function written by B. Lachele Foley, 2007
00002 //
00003 // Deprecated.  Use "set_COM" functions instead
00004 //
00005 //#include <mylib.h>
00006 //#include <molecules.h>
00007 //#include "../inc/mylib.h"
00008 //#include "../inc/molecules.h"
00009 /****************** assign_residue_COM() *********************/
00010 /* Finds the center of mass of the molecule and places it in the
00011  * appropriate location.  Similar functions exist for the other
00012  * structures.
00013  */
00014 /*
00015 void assign_residue_COM(residue *r,atype *ATYPE){
00016 int ta=0;
00017 double tmm=0; 
00018 // calculate the molecular weight 
00019 for(ta=0;ta<r[0].na;ta++){
00020         tmm+=ATYPE[r[0].a[ta].t].m;
00021         }
00022 //printf("the molecular weight is %f\n",tmm);
00023 if(tmm==0){mywhine("molecular weight of molecule %s is zero.\n(Have types/masses been assigned?");}
00024 r[0].m=tmm;
00025 
00026 r[0].COM.i=0;
00027 r[0].COM.j=0;
00028 r[0].COM.k=0; 
00029 //printf("center of mass is at: %f %f %f \n",m[0].COM.i,m[0].COM.j,m[0].COM.k);
00030 // calculate the center of mass
00031 for(ta=0;ta<r[0].na;ta++){ // COM = sum(m_i * r_i) / sum(m_i)
00032         r[0].COM.i+=r[0].a[ta].x.i*ATYPE[r[0].a[ta].t].m;
00033         r[0].COM.j+=r[0].a[ta].x.j*ATYPE[r[0].a[ta].t].m;
00034         r[0].COM.k+=r[0].a[ta].x.k*ATYPE[r[0].a[ta].t].m;
00035         }
00036 //printf("center of mass is at: %f %f %f \n",m[0].COM.i,m[0].COM.j,m[0].COM.k);
00037 r[0].COM.i/=tmm;
00038 r[0].COM.j/=tmm;
00039 r[0].COM.k/=tmm; 
00040 //printf("center of mass is at: %20.12e %20.12e %20.12e \n",m[0].COM.i,m[0].COM.j,m[0].COM.k);
00041 return;
00042 }
00043 */
00044 
00045 /****************** assign_molecule_COM() *********************/
00046 /* Finds the center of mass of the molecule and places it in the
00047  * appropriate location.  Similar functions exist for the other
00048  * structures.
00049  */
00050 /* void assign_molecule_COM(molecule *m,atype *ATYPE){
00051 int ta=0,tr=0;
00052 double tmm=0; 
00053 // calculate the molecular weight 
00054 for(tr=0;tr<m[0].nr;tr++){
00055 for(ta=0;ta<m[0].r[tr].na;ta++){
00056         tmm+=ATYPE[m[0].r[tr].a[ta].t].m;
00057         }
00058         }
00059 //printf("the molecular weight is %f\n",tmm);
00060 if(tmm==0){mywhine("molecular weight of molecule %s is zero.\n(Have types/masses been assigned?");}
00061 m[0].m=tmm;
00062 
00063 m[0].COM.i=0;
00064 m[0].COM.j=0;
00065 m[0].COM.k=0; 
00066 //printf("center of mass is at: %f %f %f \n",m[0].COM.i,m[0].COM.j,m[0].COM.k);
00067 // calculate the center of mass
00068 for(tr=0;tr<m[0].nr;tr++){ // COM = sum(m_i * r_i) / sum(m_i)
00069 for(ta=0;ta<m[0].r[tr].na;ta++){ // COM = sum(m_i * r_i) / sum(m_i)
00070         m[0].COM.i+=m[0].r[tr].a[ta].x.i*ATYPE[m[0].r[tr].a[ta].t].m;
00071         m[0].COM.j+=m[0].r[tr].a[ta].x.j*ATYPE[m[0].r[tr].a[ta].t].m;
00072         m[0].COM.k+=m[0].r[tr].a[ta].x.k*ATYPE[m[0].r[tr].a[ta].t].m;
00073         }
00074         }
00075 //printf("center of mass is at: %f %f %f \n",m[0].COM.i,m[0].COM.j,m[0].COM.k);
00076 m[0].COM.i/=tmm;
00077 m[0].COM.j/=tmm;
00078 m[0].COM.k/=tmm; 
00079 //printf("center of mass is at: %20.12e %20.12e %20.12e \n",m[0].COM.i,m[0].COM.j,m[0].COM.k);
00080 return;
00081 }
00082 */
00083 
00084 /****************** assign_assembly_COM() *********************/
00085 /* Finds the center of mass of the molecule and places it in the
00086  * appropriate location.  Similar functions exist for the other
00087  * structures.
00088  */
00089 /*void assign_assembly_COM(assembly *a,atype *ATYPE){
00090 int ta=0,tr=0,tm=0;
00091 double tmm=0; 
00092 // calculate the molecular weight 
00093 for(tm=0;tm<a[0].nm;tm++){
00094 for(tr=0;tr<a[0].m[tm][0].nr;tr++){
00095 for(ta=0;ta<a[0].m[tm][0].r[tr].na;ta++){
00096         tmm+=ATYPE[a[0].m[tm][0].r[tr].a[ta].t].m;
00097         }
00098         }
00099         }
00100 //printf("the molecular weight is %f\n",tmm);
00101 if(tmm==0){mywhine("molecular weight of molecule %s is zero.\n(Have types/masses been assigned?");}
00102 a[0].mass=tmm;
00103 
00104 a[0].COM.i=0;
00105 a[0].COM.j=0;
00106 a[0].COM.k=0; 
00107 //printf("center of mass is at: %f %f %f \n",m[0].COM.i,m[0].COM.j,m[0].COM.k);
00108 // calculate the center of mass
00109 for(tm=0;tm<a[0].nm;tm++){ // COM = sum(m_i * r_i) / sum(m_i)
00110 for(tr=0;tr<a[0].m[tm][0].nr;tr++){ // COM = sum(m_i * r_i) / sum(m_i)
00111 for(ta=0;ta<a[0].m[tm][0].r[tr].na;ta++){ // COM = sum(m_i * r_i) / sum(m_i)
00112         a[0].COM.i+=a[0].m[tm][0].r[tr].a[ta].x.i*ATYPE[a[0].m[tm][0].r[tr].a[ta].t].m;
00113         a[0].COM.j+=a[0].m[tm][0].r[tr].a[ta].x.j*ATYPE[a[0].m[tm][0].r[tr].a[ta].t].m;
00114         a[0].COM.k+=a[0].m[tm][0].r[tr].a[ta].x.k*ATYPE[a[0].m[tm][0].r[tr].a[ta].t].m;
00115         }
00116         }
00117         }
00118 //printf("center of mass is at: %f %f %f \n",m[0].COM.i,m[0].COM.j,m[0].COM.k);
00119 a[0].COM.i/=tmm;
00120 a[0].COM.j/=tmm;
00121 a[0].COM.k/=tmm; 
00122 //printf("center of mass is at: %20.12e %20.12e %20.12e \n",m[0].COM.i,m[0].COM.j,m[0].COM.k);
00123 return;
00124 }
00125 */
00126 /****************** assign_ensemble_COM() *********************/
00127 /* Finds the center of mass of the molecule and places it in the
00128  * appropriate location.  Similar functions exist for the other
00129  * structures.
00130  * NOTE!!  Assemblies within ensembles are assumed to be redundant.
00131  *      That is, the molecules in the ensemble are also represented
00132  *      within the assemblies (copying the molecule pointers keeps 
00133  *      the data from taking extra space).  So, when calculating the
00134  *      center of mass for the ensemble, this function ONLY considers
00135  *      molecules and not assemblies.
00136  */
00137 /* void assign_ensemble_COM(ensemble *e,atype *ATYPE){
00138 int ta=0,tr=0,tm=0;
00139 double tmm=0; 
00140 // calculate the molecular weight 
00141 for(tm=0;tm<e[0].nm;tm++){
00142 for(tr=0;tr<e[0].m[tm].nr;tr++){
00143 for(ta=0;ta<e[0].m[tm].r[tr].na;ta++){
00144         tmm+=ATYPE[e[0].m[tm].r[tr].a[ta].t].m;
00145         }
00146         }
00147         }
00148 //printf("the molecular weight is %f\n",tmm);
00149 if(tmm==0){mywhine("molecular weight of molecule %s is zero.\n(Have types/masses been assigned?");}
00150 e[0].mass=tmm;
00151 
00152 e[0].COM.i=0;
00153 e[0].COM.j=0;
00154 e[0].COM.k=0; 
00155 //printf("center of mass is at: %f %f %f \n",m[0].COM.i,m[0].COM.j,m[0].COM.k);
00156 // calculate the center of mass
00157 for(tm=0;tm<e[0].nm;tm++){ // COM = sum(m_i * r_i) / sum(m_i)
00158 for(tr=0;tr<e[0].m[tm].nr;tr++){ // COM = sum(m_i * r_i) / sum(m_i)
00159 for(ta=0;ta<e[0].m[tm].r[tr].na;ta++){ // COM = sum(m_i * r_i) / sum(m_i)
00160         e[0].COM.i+=e[0].m[tm].r[tr].a[ta].x.i*ATYPE[e[0].m[tm].r[tr].a[ta].t].m;
00161         e[0].COM.j+=e[0].m[tm].r[tr].a[ta].x.j*ATYPE[e[0].m[tm].r[tr].a[ta].t].m;
00162         e[0].COM.k+=e[0].m[tm].r[tr].a[ta].x.k*ATYPE[e[0].m[tm].r[tr].a[ta].t].m;
00163         }
00164         }
00165         }
00166 //printf("center of mass is at: %f %f %f \n",m[0].COM.i,m[0].COM.j,m[0].COM.k);
00167 e[0].COM.i/=tmm;
00168 e[0].COM.j/=tmm;
00169 e[0].COM.k/=tmm; 
00170 //printf("center of mass is at: %20.12e %20.12e %20.12e \n",m[0].COM.i,m[0].COM.j,m[0].COM.k);
00171 return;
00172 } 
00173 */
 All Classes Files Functions Variables Typedefs Defines