00001 /* 00002 00003 Copyright (C) University of Oxford, 2005-2010 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 00055 double standard_deviation = 0.9; 00056 00057 mStochasticG2Duration = p_gen->NormalRandomDeviate(mean, standard_deviation); 00058 00059 // Check that the normal random deviate has not returned a small or negative G2 duration 00060 if (mStochasticG2Duration < mMinimumGapDuration) 00061 { 00062 mStochasticG2Duration = mMinimumGapDuration; 00063 } 00064 } 00065 00066 void StochasticWntCellCycleModel::InitialiseDaughterCell() 00067 { 00068 GenerateStochasticG2Duration(); 00069 } 00070 00071 void StochasticWntCellCycleModel::Initialise() 00072 { 00073 WntCellCycleModel::Initialise(); 00074 GenerateStochasticG2Duration(); 00075 } 00076 00077 void StochasticWntCellCycleModel::ResetForDivision() 00078 { 00079 AbstractWntOdeBasedCellCycleModel::ResetForDivision(); 00080 GenerateStochasticG2Duration(); 00081 } 00082 00083 double StochasticWntCellCycleModel::GetG2Duration() 00084 { 00085 return mStochasticG2Duration; 00086 } 00087 00088 AbstractCellCycleModel* StochasticWntCellCycleModel::CreateCellCycleModel() 00089 { 00090 // Create a new cell cycle model 00091 StochasticWntCellCycleModel* p_model = new StochasticWntCellCycleModel(mpOdeSolver); 00092 00093 // Create the new cell cycle model's ODE system 00094 double wnt_level = GetWntLevel(); 00095 p_model->SetOdeSystem(new WntCellCycleOdeSystem(wnt_level, mpCell->GetMutationState())); 00096 00097 // Use the current values of the state variables in mpOdeSystem as an initial condition for the new cell cycle model's ODE system 00098 assert(mpOdeSystem); 00099 p_model->SetStateVariables(mpOdeSystem->rGetStateVariables()); 00100 00101 // Set the values of the new cell cycle model's member variables 00102 p_model->SetBirthTime(mBirthTime); 00103 p_model->SetLastTime(mLastTime); 00104 p_model->SetDivideTime(mDivideTime); 00105 p_model->SetFinishedRunningOdes(mFinishedRunningOdes); 00106 p_model->SetG2PhaseStartTime(mG2PhaseStartTime); 00107 p_model->SetDimension(mDimension); 00108 p_model->SetCellProliferativeType(mCellProliferativeType); 00109 00110 return p_model; 00111 } 00112 00113 // Serialization for Boost >= 1.36 00114 #include "SerializationExportWrapperForCpp.hpp" 00115 CHASTE_CLASS_EXPORT(StochasticWntCellCycleModel) 00116 #include "CellCycleModelOdeSolverExportWrapper.hpp" 00117 EXPORT_CELL_CYCLE_MODEL_ODE_SOLVER(StochasticWntCellCycleModel)