Alarcon2004OxygenBasedCellCycleModel.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 "Alarcon2004OxygenBasedCellCycleModel.hpp"
00030 
00031 #include "CellwiseData.hpp"
00032 #include "CellLabel.hpp"
00033 #include "PetscTools.hpp" // For NEVER_REACHED
00034 
00035 Alarcon2004OxygenBasedCellCycleModel::Alarcon2004OxygenBasedCellCycleModel(boost::shared_ptr<AbstractCellCycleModelOdeSolver> pOdeSolver)
00036     : AbstractOdeBasedCellCycleModel(SimulationTime::Instance()->GetTime(), pOdeSolver)
00037 {
00038     if (!mpOdeSolver)
00039     {
00040         mpOdeSolver = CellCycleModelOdeSolver<Alarcon2004OxygenBasedCellCycleModel, RungeKutta4IvpOdeSolver>::Instance();
00041         mpOdeSolver->Initialise();
00042     }
00043     SetDt(0.0001);
00044 }
00045 
00046 void Alarcon2004OxygenBasedCellCycleModel::ResetForDivision()
00047 {
00048     AbstractOdeBasedCellCycleModel::ResetForDivision();
00049     assert(mpOdeSystem != NULL);
00050 
00051     // This model needs the protein concentrations and phase resetting to G0/G1.
00052     // Keep the oxygen concentration the same but reset everything else
00053     std::vector<double> init_conds = mpOdeSystem->GetInitialConditions();
00054     for (unsigned i=0; i<5; i++)
00055     {
00056         mpOdeSystem->rGetStateVariables()[i] = init_conds[i];
00057     }
00058 }
00059 
00060 AbstractCellCycleModel* Alarcon2004OxygenBasedCellCycleModel::CreateCellCycleModel()
00061 {
00062     // Create a new cell-cycle model
00063     Alarcon2004OxygenBasedCellCycleModel* p_model = new Alarcon2004OxygenBasedCellCycleModel(mpOdeSolver);
00064 
00065     /*
00066      * Set each member variable of the new cell-cycle model that inherits
00067      * its value from the parent.
00068      * 
00069      * Note 1: some of the new cell-cycle model's member variables (namely
00070      * mBirthTime, mCurrentCellCyclePhase, mReadyToDivide, mDt, mpOdeSolver)
00071      * will already have been correctly initialized in its constructor.
00072      * 
00073      * Note 2: one or more of the new cell-cycle model's member variables
00074      * may be set/overwritten as soon as InitialiseDaughterCell() is called on
00075      * the new cell-cycle model.
00076      */ 
00077     p_model->SetBirthTime(mBirthTime);
00078     p_model->SetDimension(mDimension);
00079     p_model->SetCellProliferativeType(mCellProliferativeType);
00080     p_model->SetMinimumGapDuration(mMinimumGapDuration);
00081     p_model->SetStemCellG1Duration(mStemCellG1Duration);
00082     p_model->SetTransitCellG1Duration(mTransitCellG1Duration);
00083     p_model->SetSDuration(mSDuration);
00084     p_model->SetG2Duration(mG2Duration);
00085     p_model->SetMDuration(mMDuration);
00086     p_model->SetDivideTime(mDivideTime);
00087     p_model->SetFinishedRunningOdes(mFinishedRunningOdes);
00088     p_model->SetG2PhaseStartTime(mG2PhaseStartTime);
00089     p_model->SetLastTime(mLastTime);
00090 
00091     /*
00092      * Create the new cell-cycle model's ODE system and use the current values
00093      * of the state variables in mpOdeSystem as an initial condition.
00094      */
00095     assert(mpOdeSystem);
00096     bool is_labelled = mpCell->HasCellProperty<CellLabel>();
00097     switch (mDimension)
00098     {
00099         case 1:
00100         {
00101             const unsigned DIM = 1;
00102             p_model->SetOdeSystem(new Alarcon2004OxygenBasedCellCycleOdeSystem(CellwiseData<DIM>::Instance()->GetValue(mpCell,0), is_labelled));
00103             break;
00104         }
00105         case 2:
00106         {
00107             const unsigned DIM = 2;
00108             p_model->SetOdeSystem(new Alarcon2004OxygenBasedCellCycleOdeSystem(CellwiseData<DIM>::Instance()->GetValue(mpCell,0), is_labelled));
00109             break;
00110         }
00111         case 3:
00112         {
00113             const unsigned DIM = 3;
00114             p_model->SetOdeSystem(new Alarcon2004OxygenBasedCellCycleOdeSystem(CellwiseData<DIM>::Instance()->GetValue(mpCell,0), is_labelled));
00115             break;
00116         }
00117         default:
00118             NEVER_REACHED;
00119     }
00120     p_model->SetStateVariables(mpOdeSystem->rGetStateVariables());
00121 
00122     return p_model;
00123 }
00124 
00125 void Alarcon2004OxygenBasedCellCycleModel::Initialise()
00126 {
00127     assert(mpOdeSystem == NULL);
00128     assert(mpCell != NULL);
00129 
00130     bool is_labelled = mpCell->HasCellProperty<CellLabel>();
00131 
00132     switch (mDimension)
00133     {
00134         case 1:
00135         {
00136             const unsigned DIM = 1;
00137             mpOdeSystem = new Alarcon2004OxygenBasedCellCycleOdeSystem(CellwiseData<DIM>::Instance()->GetValue(mpCell,0), is_labelled);
00138             break;
00139         }
00140         case 2:
00141         {
00142             const unsigned DIM = 2;
00143             mpOdeSystem = new Alarcon2004OxygenBasedCellCycleOdeSystem(CellwiseData<DIM>::Instance()->GetValue(mpCell,0), is_labelled);
00144             break;
00145         }
00146         case 3:
00147         {
00148             const unsigned DIM = 3;
00149             mpOdeSystem = new Alarcon2004OxygenBasedCellCycleOdeSystem(CellwiseData<DIM>::Instance()->GetValue(mpCell,0), is_labelled);
00150             break;
00151         }
00152         default:
00153             NEVER_REACHED;
00154     }
00155 
00156     mpOdeSystem->SetStateVariables(mpOdeSystem->GetInitialConditions());
00157 }
00158 
00159 void Alarcon2004OxygenBasedCellCycleModel::AdjustOdeParameters(double currentTime)
00160 {
00161     // Pass this time step's oxygen concentration into the solver as a constant over this timestep
00162     switch (mDimension)
00163     {
00164         case 1:
00165         {
00166             const unsigned DIM = 1;
00167             mpOdeSystem->rGetStateVariables()[5] = CellwiseData<DIM>::Instance()->GetValue(mpCell, 0);
00168             break;
00169         }
00170         case 2:
00171         {
00172             const unsigned DIM = 2;
00173             mpOdeSystem->rGetStateVariables()[5] = CellwiseData<DIM>::Instance()->GetValue(mpCell, 0);
00174             break;
00175         }
00176         case 3:
00177         {
00178             const unsigned DIM = 3;
00179             mpOdeSystem->rGetStateVariables()[5] = CellwiseData<DIM>::Instance()->GetValue(mpCell, 0);
00180             break;
00181         }
00182         default:
00183             NEVER_REACHED;
00184     }
00185 
00186     // Use whether the cell is currently labelled as another input
00187     bool is_labelled = mpCell->HasCellProperty<CellLabel>();
00188     static_cast<Alarcon2004OxygenBasedCellCycleOdeSystem*>(mpOdeSystem)->SetIsLabelled(is_labelled);
00189 }
00190 
00191 void Alarcon2004OxygenBasedCellCycleModel::OutputCellCycleModelParameters(out_stream& rParamsFile)
00192 {
00193     // No new parameters to output
00194 
00195     // Call method on direct parent class
00196     AbstractOdeBasedCellCycleModel::OutputCellCycleModelParameters(rParamsFile);
00197 }
00198 
00199 // Serialization for Boost >= 1.36
00200 #include "SerializationExportWrapperForCpp.hpp"
00201 CHASTE_CLASS_EXPORT(Alarcon2004OxygenBasedCellCycleModel)
00202 #include "CellCycleModelOdeSolverExportWrapper.hpp"
00203 EXPORT_CELL_CYCLE_MODEL_ODE_SOLVER(Alarcon2004OxygenBasedCellCycleModel)

Generated on Mon Apr 18 11:35:27 2011 for Chaste by  doxygen 1.5.5