StochasticWntCellCycleModel.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 "StochasticWntCellCycleModel.hpp"
00030 
00031 StochasticWntCellCycleModel::StochasticWntCellCycleModel(boost::shared_ptr<AbstractCellCycleModelOdeSolver> pOdeSolver)
00032     : WntCellCycleModel(pOdeSolver)
00033 {
00034     if (!pOdeSolver)
00035     {
00036 #ifdef CHASTE_CVODE
00037         mpOdeSolver = CellCycleModelOdeSolver<StochasticWntCellCycleModel, 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 #else
00043         mpOdeSolver = CellCycleModelOdeSolver<StochasticWntCellCycleModel, RungeKutta4IvpOdeSolver>::Instance();
00044         mpOdeSolver->Initialise();
00045 #endif //CHASTE_CVODE
00046     }
00047 }
00048 
00049 void StochasticWntCellCycleModel::GenerateStochasticG2Duration()
00050 {
00051     RandomNumberGenerator* p_gen = RandomNumberGenerator::Instance();
00052 
00053     double mean = AbstractCellCycleModel::GetG2Duration();
00054     double standard_deviation = 0.9;
00055     mStochasticG2Duration = p_gen->NormalRandomDeviate(mean, standard_deviation);
00056 
00057     // Check that the normal random deviate has not returned a small or negative G2 duration
00058     if (mStochasticG2Duration < mMinimumGapDuration)
00059     {
00060         mStochasticG2Duration = mMinimumGapDuration;
00061     }
00062 }
00063 
00064 void StochasticWntCellCycleModel::InitialiseDaughterCell()
00065 {
00066     WntCellCycleModel::InitialiseDaughterCell();
00067     GenerateStochasticG2Duration();
00068 }
00069 
00070 void StochasticWntCellCycleModel::Initialise()
00071 {
00072     WntCellCycleModel::Initialise();
00073     GenerateStochasticG2Duration();
00074 }
00075 
00076 void StochasticWntCellCycleModel::ResetForDivision()
00077 {
00078     AbstractWntOdeBasedCellCycleModel::ResetForDivision();
00079     GenerateStochasticG2Duration();
00080 }
00081 
00082 double StochasticWntCellCycleModel::GetG2Duration()
00083 {
00084     return mStochasticG2Duration;
00085 }
00086 
00087 AbstractCellCycleModel* StochasticWntCellCycleModel::CreateCellCycleModel()
00088 {
00089     // Create a new cell-cycle model
00090     StochasticWntCellCycleModel* p_model = new StochasticWntCellCycleModel(mpOdeSolver);
00091 
00092     /*
00093      * Set each member variable of the new cell-cycle model that inherits
00094      * its value from the parent.
00095      *
00096      * Note 1: some of the new cell-cycle model's member variables (namely
00097      * mBirthTime, mCurrentCellCyclePhase, mReadyToDivide, mDt, mpOdeSolver)
00098      * will already have been correctly initialized in its constructor.
00099      *
00100      * Note 2: one or more of the new cell-cycle model's member variables
00101      * may be set/overwritten as soon as InitialiseDaughterCell() is called on
00102      * the new cell-cycle model.
00103      */
00104     p_model->SetBirthTime(mBirthTime);
00105     p_model->SetDimension(mDimension);
00106     p_model->SetCellProliferativeType(mCellProliferativeType);
00107     p_model->SetMinimumGapDuration(mMinimumGapDuration);
00108     p_model->SetStemCellG1Duration(mStemCellG1Duration);
00109     p_model->SetTransitCellG1Duration(mTransitCellG1Duration);
00110     p_model->SetSDuration(mSDuration);
00111     p_model->SetG2Duration(mG2Duration);
00112     p_model->SetMDuration(mMDuration);
00113     p_model->SetDivideTime(mDivideTime);
00114     p_model->SetFinishedRunningOdes(mFinishedRunningOdes);
00115     p_model->SetG2PhaseStartTime(mG2PhaseStartTime);
00116     p_model->SetLastTime(mLastTime);
00117 
00118     /*
00119      * Create the new cell-cycle model's ODE system and use the current values
00120      * of the state variables in mpOdeSystem as an initial condition.
00121      */
00122     assert(mpOdeSystem);
00123     double wnt_level = GetWntLevel();
00124     p_model->SetOdeSystem(new WntCellCycleOdeSystem(wnt_level, mpCell->GetMutationState()));
00125     p_model->SetStateVariables(mpOdeSystem->rGetStateVariables());
00126 
00127     return p_model;
00128 }
00129 
00130 void StochasticWntCellCycleModel::OutputCellCycleModelParameters(out_stream& rParamsFile)
00131 {
00132     // No new parameters to output
00133 
00134     // Call method on direct parent class
00135     WntCellCycleModel::OutputCellCycleModelParameters(rParamsFile);
00136 }
00137 
00138 // Serialization for Boost >= 1.36
00139 #include "SerializationExportWrapperForCpp.hpp"
00140 CHASTE_CLASS_EXPORT(StochasticWntCellCycleModel)
00141 #include "CellCycleModelOdeSolverExportWrapper.hpp"
00142 EXPORT_CELL_CYCLE_MODEL_ODE_SOLVER(StochasticWntCellCycleModel)
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3