TysonNovakCellCycleModel.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 #include "TysonNovakCellCycleModel.hpp"
00030 
00031 TysonNovakCellCycleModel::TysonNovakCellCycleModel(boost::shared_ptr<AbstractCellCycleModelOdeSolver> pOdeSolver)
00032     : AbstractOdeBasedCellCycleModel(SimulationTime::Instance()->GetTime(), pOdeSolver)
00033 {
00034     if (!mpOdeSolver)
00035     {
00036 #ifdef CHASTE_CVODE
00037         mpOdeSolver = CellCycleModelOdeSolver<TysonNovakCellCycleModel, CvodeAdaptor>::Instance();
00038         mpOdeSolver->Initialise();
00039         // Chaste solvers always check for stopping events, CVODE needs to be instructed to do so
00040         mpOdeSolver->CheckForStoppingEvents();
00041         mpOdeSolver->SetMaxSteps(10000);
00042         mpOdeSolver->SetTolerances(1e-6, 1e-8);
00043 #else
00044         mpOdeSolver = CellCycleModelOdeSolver<TysonNovakCellCycleModel, BackwardEulerIvpOdeSolver>::Instance();
00045         mpOdeSolver->SetSizeOfOdeSystem(6);
00046         mpOdeSolver->Initialise();
00047         SetDt(0.1/60.0);
00048 #endif //CHASTE_CVODE
00049     }
00050 }
00051 
00052 void TysonNovakCellCycleModel::Initialise()
00053 {
00054     assert(mpOdeSystem == NULL);
00055     mpOdeSystem = new TysonNovak2001OdeSystem;
00056     mpOdeSystem->SetStateVariables(mpOdeSystem->GetInitialConditions());
00057 
00058     AbstractCellCycleModel::Initialise();
00059 }
00060 
00061 void TysonNovakCellCycleModel::ResetForDivision()
00062 {
00063     AbstractOdeBasedCellCycleModel::ResetForDivision();
00064 
00065     assert(mpOdeSystem != NULL);
00066 
00079 #ifdef CHASTE_CVODE
00080     mpOdeSystem->rGetStateVariables()[5] = 0.5*mpOdeSystem->rGetStateVariables()[5];
00081 #else
00082     mpOdeSystem->SetStateVariables(mpOdeSystem->GetInitialConditions());
00083 #endif //CHASTE_CVODE
00084 }
00085 
00086 void TysonNovakCellCycleModel::InitialiseDaughterCell()
00087 {
00088     if (mCellProliferativeType == STEM)
00089     {
00090         mCellProliferativeType = TRANSIT;
00091     }
00092 }
00093 
00094 AbstractCellCycleModel* TysonNovakCellCycleModel::CreateCellCycleModel()
00095 {
00096     // Create a new cell-cycle model
00097     TysonNovakCellCycleModel* p_model = new TysonNovakCellCycleModel(mpOdeSolver);
00098 
00099     /*
00100      * Set each member variable of the new cell-cycle model that inherits
00101      * its value from the parent.
00102      * 
00103      * Note 1: some of the new cell-cycle model's member variables (namely
00104      * mBirthTime, mCurrentCellCyclePhase, mReadyToDivide, mDt, mpOdeSolver)
00105      * will already have been correctly initialized in its constructor.
00106      * 
00107      * Note 2: one or more of the new cell-cycle model's member variables
00108      * may be set/overwritten as soon as InitialiseDaughterCell() is called on
00109      * the new cell-cycle model.
00110      * 
00111      * Note 3: the member variable mDimension remains unset, since this cell-cycle
00112      * model does not need to know the spatial dimension, so if we were to call
00113      * SetDimension() on the new cell-cycle model an exception would be triggered;
00114      * hence we do not set this member variable.
00115      */ 
00116     p_model->SetBirthTime(mBirthTime);
00117     p_model->SetCellProliferativeType(mCellProliferativeType);
00118     p_model->SetMinimumGapDuration(mMinimumGapDuration);
00119     p_model->SetStemCellG1Duration(mStemCellG1Duration);
00120     p_model->SetTransitCellG1Duration(mTransitCellG1Duration);
00121     p_model->SetSDuration(mSDuration);
00122     p_model->SetG2Duration(mG2Duration);
00123     p_model->SetMDuration(mMDuration);
00124     p_model->SetDivideTime(mDivideTime);
00125     p_model->SetFinishedRunningOdes(mFinishedRunningOdes);
00126     p_model->SetG2PhaseStartTime(mG2PhaseStartTime);
00127     p_model->SetLastTime(mLastTime);
00128 
00129     /*
00130      * Create the new cell-cycle model's ODE system and use the current values
00131      * of the state variables in mpOdeSystem as an initial condition.
00132      */
00133     assert(mpOdeSystem);
00134     p_model->SetOdeSystem(new TysonNovak2001OdeSystem);
00135     p_model->SetStateVariables(mpOdeSystem->rGetStateVariables());
00136 
00137     return p_model;
00138 }
00139 
00140 double TysonNovakCellCycleModel::GetSDuration()
00141 {
00147     return 0.0;
00148 }
00149 
00150 double TysonNovakCellCycleModel::GetG2Duration()
00151 {
00157     return 0.0;
00158 }
00159 
00160 double TysonNovakCellCycleModel::GetMDuration()
00161 {
00167     return 0.0;
00168 }
00169 
00170 double TysonNovakCellCycleModel::GetAverageTransitCellCycleTime()
00171 {
00172     return 1.25;
00173 }
00174 
00175 double TysonNovakCellCycleModel::GetAverageStemCellCycleTime()
00176 {
00177     return 1.25;
00178 }
00179 
00180 
00181 bool TysonNovakCellCycleModel::CanCellTerminallyDifferentiate()
00182 {
00183     return false;
00184 }
00185 
00186 void TysonNovakCellCycleModel::OutputCellCycleModelParameters(out_stream& rParamsFile)
00187 {
00188     // No new parameters to output
00189 
00190     // Call method on direct parent class
00191     AbstractOdeBasedCellCycleModel::OutputCellCycleModelParameters(rParamsFile);
00192 }
00193 
00194 // Serialization for Boost >= 1.36
00195 #include "SerializationExportWrapperForCpp.hpp"
00196 CHASTE_CLASS_EXPORT(TysonNovakCellCycleModel)
00197 #include "CellCycleModelOdeSolverExportWrapper.hpp"
00198 EXPORT_CELL_CYCLE_MODEL_ODE_SOLVER(TysonNovakCellCycleModel)

Generated on Tue May 31 14:31:40 2011 for Chaste by  doxygen 1.5.5