Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Geometry.cpp

Go to the documentation of this file.
00001 // Geometry.cpp: implementation of the CGeometry class.
00002 //
00004 
00005 #include <math.h>
00006 #include "Cell.h"
00007 #include "Display.h"
00008 #include "DNA.h"
00009 #include "Components.h"
00010 #include "Geometry.h"
00011 
00013 // Construction/Destruction
00015 CGeometry::CGeometry(CCell *pCell)
00016 {
00017         m_pCell=pCell;
00018         SL[0]=0;                //Septum length
00019         SL[1]=0;
00020         SL[2]=0;
00021         CW = 0.75E-4;   //Cell Width
00022         CL = 1.52E-4;   //Cell Length
00023         DEN = 0.282;            //Density
00024         S = 3.6E-08;                    //Cellular Surface Area
00025         V = 5.65E-13;                   //Volume
00026         SEPF[0] = 0.0;
00027         SEPF[1] = 0.0;
00028         SEPF[2]=0.0;    //Area of each septum
00029         NSEPF = 0;              //number of septa
00030         CSL[0] = 0.0;
00031         CSL[1]=0.0;
00032         CSL[2]=0.0;//unit change 10000*(septum length)
00033         E2=5.62E-4*V;   //initialize E2
00034         E3[0]=0;
00035         E3[1]=0;
00036         E3[2]=0;
00037         double E3TOT = 0.0;     //declare E3TOT
00038         for(int i=0; i<3; i++)
00039                 E3TOT = E3TOT + E3[i];  //Add total (doesn't really change anything)
00040         E23 = E3TOT + E2;       //total cell envelope enzymes
00041 }
00042 
00043 CGeometry::CGeometry()
00044 {
00045 
00046 }
00047 
00048 CGeometry::~CGeometry()
00049 {
00050 
00051 }
00052 
00053 
00054 CGeometry::CGeometry(const CGeometry &rGeom, CCell *pCell)
00055 {
00056         //*this=*rGeom;
00057         m_pCell=pCell;
00058 }
00059 
00060 double CGeometry::GetVolume()
00061 {
00062         return V;
00063 }
00064 
00065 //This function checks volume to insure that it is consistent with mass and density
00066 void CGeometry::CheckVolume()
00067 {
00068         double VB=V;                                                                    //Initial volume placeholder
00069         ComputeVolume();                                                                        //Calculate total volume based on mass
00070         if(fabs((VB-V)/V) > 0.1)                                                //Volume and mass disagree by > 10%
00071                 m_pCell->GetDisplay()->WarningMessage(1);       //Mismatch warning
00072         return;
00073 }
00074 
00075 void CGeometry::ComputeVolume()
00076 {
00077         double TotalMass=0.0;                                                   //Total cell mass
00078         for(int i=0;i<11;i++)
00079                 TotalMass+=m_pCell->GetComponents()->GetY(i);   //Add up total mass
00080         double MassEnv=m_pCell->GetComponents()->GetY(9);       //Envelope mass
00081         double VE = MassEnv/0.42/0.5526;                                        //Envelope volume
00082         double VC = (TotalMass-MassEnv/0.42)/0.2584;                    //Cytoplasm volume
00083         V=VC+VE;                        
00084 }
00085 
00086 void CGeometry::UpdateShape()
00087 {
00088 
00089         if(m_pCell->GetDNA()->CheckTerm())                                              //if termination occured, add septa
00090                 AddSepta();
00091         E2=m_pCell->GetComponents()->GetY(12);
00092         double E3TOT=0.0;
00093         for(int i=0;i<3;++i)
00094                 E3TOT += E3[i]*(pow(2,i));      //Calculate total cross wall enzyme
00095         E23=E2+E3TOT;                           //total (E2+E3) env. enzymes
00096 
00097         double PRCNT=E2/E23;                            //% of total envelope enzymes
00098         double PRCNTS[3];
00099         for(i=0;i<3;++i)
00100                 PRCNTS[i] = E3[i]/E23;  //% of total envelope enzymes
00101         double DS=(1.2E6/0.42)*m_pCell->GetComponents()->GetDY9()*m_pCell->GetComponents()->DT; //relates change in surface area
00102                                                                         //area to rate of cell envelope synthesis
00103         double SEPFTOT=0.0;
00104         for(i=0;i<3;++i)
00105         {
00106                 SEPF[i] += PRCNTS[i]*DS;        //area of each septa
00107                 SEPFTOT += SEPF[i]*(pow(2,i));  //total septa area
00108         }
00109 
00110         double DCL = (PRCNT*DS)/(3.14*CW);      //change in cell length
00111         CL+=DCL;                                                //adjust cell length accordingly
00112         S+=DS;                                                  //calculate surface area
00113         CW=CalcWidth();                 //call width function
00114         CL=S/(3.14159*CW)-CW-2.0*SL[0]-4.0*SL[1]-8.0*SL[2];     
00115                                                                 //recalculate cell length
00116         double CN=CW*1.0E4;                             //cell width unit change
00117         double CM=(CL+2.0*SL[0]+4.0*SL[1]+8.0*SL[2]+CW)*1.0E4;
00118                                                                         //total cell length
00119         for(i=0;i<3;++i)
00120                 CSL[i]=SL[i]*1.0E4;                     //septum length unit change
00121 }
00122 
00123 void CGeometry::AddSepta()
00124 {
00125         if(NSEPF<3)             //limit number of septa
00126         {
00127                 ++NSEPF;                //add a septa
00128         }
00129         double Y13=m_pCell->GetComponents()->GetY(13);
00130         E3[NSEPF-1]=Y13/pow(2,(NSEPF-1));       //divide enzyme among septa
00131         m_pCell->GetComponents()->ResetY(13);
00132 }
00133 
00134 double CGeometry::GetWidth()
00135 {
00136         return CW;
00137 }
00138 
00139 double CGeometry::CalcWidth()
00140 {
00141         int i=0;
00142         //Newton's method
00143         for(i=0;i<100;++i)
00144         {
00145                 double FS=0.0;
00146                 double DFS=0.0;
00147                 for(int j=0;j<3;++j)
00148                 {
00149                         SL[j]=SEPF[j]/(2*3.14159*CW);
00150                         DFS += (pow(0.25,(j+1))*pow(SEPF[j],3));
00151                         FS += (pow(2,(j+1))*pow(SL[j],3));
00152                 }
00153                 double F = -.262*pow(CW,3)+0.25*S*CW-1.047*FS-V;
00154                 double DF = -0.7854*pow(CW,2)+0.25*S+0.1013*DFS/pow(CW,4);
00155                 double CWN=CW-F/DF;
00156                 if((fabs(F)<=0.001)&&(fabs((CW-CWN)/CWN)<=0.001))
00157                 {
00158                         CW=CWN;
00159                         break;
00160                 }
00161                 CW=CWN;                         //set new guess and continue with iteration
00162         }
00163         for(int j=0;j<3;++j)
00164                 SL[j]=SEPF[j]/(2*3.14159*CW);   //compute septa lengths
00165         
00166         if(i<5)
00167                 return CW;
00168 
00169         m_pCell->GetDisplay()->WarningMessage(2);
00170         return CW;
00171 }
00172 
00173 double CGeometry::GetSurface()
00174 {
00175         return S;
00176 }
00177 
00178 double CGeometry::GetSepf()
00179 {
00180         return SEPF[0];
00181 }
00182 
00183 void CGeometry::Divide()
00184 {
00185         SEPF[0]=SEPF[1];
00186         SEPF[1]=SEPF[2];
00187         SEPF[2]=0.0;            //Shift septa indeces
00188         S=0.5*S;                        //1/2 the surface area
00189         V=0.5*V;                        //1/2 the volume
00190         CL=0.5*CL;                      //half the cell length
00191         E2=0.5*E2;                      //half E2
00192         E3[0]=E3[1];            
00193         E3[1]=E3[2];
00194         E3[2]=0.0;                      //Shift septa enzyme indeces
00195         NSEPF=NSEPF-1;  //1 less septa to worry about
00196 }

Generated on Mon Nov 3 09:37:51 2003 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002