DeltaNotchCellCycleModel.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 "UblasIncludes.hpp"
00030 #include "DeltaNotchCellCycleModel.hpp"
00031 #include "CellwiseData.hpp"
00032 #include "CellCycleModelOdeSolver.hpp"
00033 #include "CvodeAdaptor.hpp"
00034 #include "Exception.hpp"
00035 
00036 DeltaNotchCellCycleModel::DeltaNotchCellCycleModel(boost::shared_ptr<AbstractCellCycleModelOdeSolver> pOdeSolver)
00037     : CellCycleModelOdeHandler(DOUBLE_UNSET, pOdeSolver)
00038 {
00039     if (mpOdeSolver == boost::shared_ptr<AbstractCellCycleModelOdeSolver>())
00040     {
00041 #ifdef CHASTE_CVODE
00042         mpOdeSolver = CellCycleModelOdeSolver<DeltaNotchCellCycleModel, CvodeAdaptor>::Instance();
00043         mpOdeSolver->Initialise();
00044         mpOdeSolver->SetMaxSteps(10000);
00045 #else
00046         mpOdeSolver = CellCycleModelOdeSolver<DeltaNotchCellCycleModel, RungeKutta4IvpOdeSolver>::Instance();
00047         mpOdeSolver->Initialise();
00048         SetDt(0.001);
00049 #endif //CHASTE_CVODE
00050     }
00051     assert(mpOdeSolver->IsSetUp());
00052 }
00053 
00054 AbstractCellCycleModel* DeltaNotchCellCycleModel::CreateCellCycleModel()
00055 {
00056     // Create a new cell-cycle model
00057     DeltaNotchCellCycleModel* p_model = new DeltaNotchCellCycleModel(this->mpOdeSolver);
00058 
00059     // Create the new cell-cycle model's ODE system
00060     double mean_neighbouring_delta = GetMeanNeighbouringDelta();
00061     p_model->SetOdeSystem(new DeltaNotchOdeSystem(mean_neighbouring_delta));
00062 
00063     // Use the current values of the state variables in mpOdeSystem as an initial condition for the new cell-cycle model's ODE system
00064     assert(mpOdeSystem);
00065     p_model->SetStateVariables(mpOdeSystem->rGetStateVariables());
00066 
00067     // Set the values of the new cell-cycle model's member variables
00068     p_model->SetCellProliferativeType(mCellProliferativeType);
00069     p_model->SetBirthTime(mBirthTime);
00070     p_model->SetLastTime(mLastTime);
00071     p_model->SetDimension(mDimension);
00072     p_model->SetGeneration(mGeneration);
00073     p_model->SetMaxTransitGenerations(mMaxTransitGenerations);
00074     p_model->SetCellProliferativeType(mCellProliferativeType);
00075 
00076     return p_model;
00077 }
00078 
00079 void DeltaNotchCellCycleModel::UpdateCellCyclePhase()
00080 {
00081     assert(SimulationTime::Instance()->IsStartTimeSetUp());
00082     UpdateDeltaNotch();
00083     AbstractSimpleCellCycleModel::UpdateCellCyclePhase();
00084 }
00085 
00086 void DeltaNotchCellCycleModel::Initialise()
00087 {
00088     assert(mpOdeSystem == NULL);
00089     assert(mpCell != NULL);
00090 
00091     mpOdeSystem = new DeltaNotchOdeSystem;
00092     mpOdeSystem->SetStateVariables(mpOdeSystem->GetInitialConditions());
00093 
00094     StochasticDurationGenerationBasedCellCycleModel::Initialise();
00095 
00096     SetLastTime(mBirthTime);
00097 }
00098 
00099 void DeltaNotchCellCycleModel::UpdateDeltaNotch()
00100 {
00101     assert(mpOdeSystem != NULL);
00102     assert(mpCell != NULL);
00103 
00104     double mean_delta;
00105     switch (mDimension)
00106     {
00107         case 1:
00108         {
00109             const unsigned DIM = 1;
00110             mean_delta = CellwiseData<DIM>::Instance()->GetValue(mpCell, 0);
00111             break;
00112         }
00113         case 2:
00114         {
00115             const unsigned DIM = 2;
00116             mean_delta = CellwiseData<DIM>::Instance()->GetValue(mpCell, 0);
00117             break;
00118         }
00119         case 3:
00120         {
00121             const unsigned DIM = 3;
00122             mean_delta = CellwiseData<DIM>::Instance()->GetValue(mpCell, 0);
00123             break;
00124         }
00125         default:
00126             NEVER_REACHED;
00127     }
00128 
00129     mpOdeSystem->rGetStateVariables()[2] = mean_delta;
00130 
00131     SolveOdeToTime(SimulationTime::Instance()->GetTime());
00132 }
00133 
00134 double DeltaNotchCellCycleModel::GetNotch()
00135 {
00136     assert(mpOdeSystem != NULL);
00137     double notch = mpOdeSystem->rGetStateVariables()[0];
00138     return notch;
00139 }
00140 
00141 double DeltaNotchCellCycleModel::GetDelta()
00142 {
00143     assert(mpOdeSystem != NULL);
00144     double delta = mpOdeSystem->rGetStateVariables()[1];
00145     return delta;
00146 }
00147 
00148 double DeltaNotchCellCycleModel::GetMeanNeighbouringDelta()
00149 {
00150     assert(mpOdeSystem != NULL);
00151     double mean_neighbouring_delta = mpOdeSystem->rGetStateVariables()[2];
00152     return mean_neighbouring_delta;
00153 }
00154 
00155 void DeltaNotchCellCycleModel::OutputCellCycleModelParameters(out_stream& rParamsFile)
00156 {
00157     // No new parameters to output.
00158 
00159     // Call direct parent class
00160     StochasticDurationGenerationBasedCellCycleModel::OutputCellCycleModelParameters(rParamsFile);
00161 }
00162 
00163 // Declare identifier for the serializer
00164 #include "SerializationExportWrapperForCpp.hpp"
00165 CHASTE_CLASS_EXPORT(DeltaNotchCellCycleModel)
00166 #include "CellCycleModelOdeSolverExportWrapper.hpp"
00167 EXPORT_CELL_CYCLE_MODEL_ODE_SOLVER(DeltaNotchCellCycleModel)
Generated on Thu Dec 22 13:00:04 2011 for Chaste by  doxygen 1.6.3