Alarcon2004OxygenBasedCellCycleModel.cpp

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 "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 }
00044 
00045 void Alarcon2004OxygenBasedCellCycleModel::ResetForDivision()
00046 {
00047     AbstractOdeBasedCellCycleModel::ResetForDivision();
00048     assert(mpOdeSystem != NULL);
00049 
00050     // This model needs the protein concentrations and phase resetting to G0/G1.
00051     // Keep the oxygen concentration the same but reset everything else
00052     std::vector<double> init_conds = mpOdeSystem->GetInitialConditions();
00053     for (unsigned i=0; i<5; i++)
00054     {
00055         mpOdeSystem->rGetStateVariables()[i] = init_conds[i];
00056     }
00057 }
00058 
00059 AbstractCellCycleModel* Alarcon2004OxygenBasedCellCycleModel::CreateCellCycleModel()
00060 {
00061     // Create a new cell cycle model
00062     Alarcon2004OxygenBasedCellCycleModel* p_model = new Alarcon2004OxygenBasedCellCycleModel(mpOdeSolver);
00063 
00064     // Create the new cell cycle model's ODE system
00065     bool is_labelled = mpCell->HasCellProperty<CellLabel>();
00066     switch (mDimension)
00067     {
00068         case 1:
00069         {
00070             const unsigned DIM = 1;
00071             p_model->SetOdeSystem(new Alarcon2004OxygenBasedCellCycleOdeSystem(CellwiseData<DIM>::Instance()->GetValue(mpCell,0), is_labelled));
00072             break;
00073         }
00074         case 2:
00075         {
00076             const unsigned DIM = 2;
00077             p_model->SetOdeSystem(new Alarcon2004OxygenBasedCellCycleOdeSystem(CellwiseData<DIM>::Instance()->GetValue(mpCell,0), is_labelled));
00078             break;
00079         }
00080         case 3:
00081         {
00082             const unsigned DIM = 3;
00083             p_model->SetOdeSystem(new Alarcon2004OxygenBasedCellCycleOdeSystem(CellwiseData<DIM>::Instance()->GetValue(mpCell,0), is_labelled));
00084             break;
00085         }
00086         default:
00087             NEVER_REACHED;
00088     }
00089 
00090     // Use the current values of the state variables in mpOdeSystem as an initial condition for the new cell cycle model's ODE system
00091     assert(mpOdeSystem);
00092     p_model->SetStateVariables(mpOdeSystem->rGetStateVariables());
00093 
00094     // Set the values of the new cell cycle model's member variables
00095     p_model->SetLastTime(mLastTime);
00096     p_model->SetDivideTime(mDivideTime);
00097     p_model->SetFinishedRunningOdes(mFinishedRunningOdes);
00098     p_model->SetG2PhaseStartTime(mG2PhaseStartTime);
00099     p_model->SetDimension(mDimension);
00100     p_model->SetCellProliferativeType(mCellProliferativeType);
00101 
00102     return p_model;
00103 }
00104 
00105 void Alarcon2004OxygenBasedCellCycleModel::Initialise()
00106 {
00107     assert(mpOdeSystem == NULL);
00108     assert(mpCell != NULL);
00109 
00110     bool is_labelled = mpCell->HasCellProperty<CellLabel>();
00111 
00112     switch (mDimension)
00113     {
00114         case 1:
00115         {
00116             const unsigned DIM = 1;
00117             mpOdeSystem = new Alarcon2004OxygenBasedCellCycleOdeSystem(CellwiseData<DIM>::Instance()->GetValue(mpCell,0), is_labelled);
00118             break;
00119         }
00120         case 2:
00121         {
00122             const unsigned DIM = 2;
00123             mpOdeSystem = new Alarcon2004OxygenBasedCellCycleOdeSystem(CellwiseData<DIM>::Instance()->GetValue(mpCell,0), is_labelled);
00124             break;
00125         }
00126         case 3:
00127         {
00128             const unsigned DIM = 3;
00129             mpOdeSystem = new Alarcon2004OxygenBasedCellCycleOdeSystem(CellwiseData<DIM>::Instance()->GetValue(mpCell,0), is_labelled);
00130             break;
00131         }
00132         default:
00133             NEVER_REACHED;
00134     }
00135 
00136     mpOdeSystem->SetStateVariables(mpOdeSystem->GetInitialConditions());
00137 }
00138 
00139 void Alarcon2004OxygenBasedCellCycleModel::AdjustOdeParameters(double currentTime)
00140 {
00141     SetDt(0.0001);
00142 
00143     // Pass this time step's oxygen concentration into the solver as a constant over this timestep
00144     switch (mDimension)
00145     {
00146         case 1:
00147         {
00148             const unsigned DIM = 1;
00149             mpOdeSystem->rGetStateVariables()[5] = CellwiseData<DIM>::Instance()->GetValue(mpCell, 0);
00150             break;
00151         }
00152         case 2:
00153         {
00154             const unsigned DIM = 2;
00155             mpOdeSystem->rGetStateVariables()[5] = CellwiseData<DIM>::Instance()->GetValue(mpCell, 0);
00156             break;
00157         }
00158         case 3:
00159         {
00160             const unsigned DIM = 3;
00161             mpOdeSystem->rGetStateVariables()[5] = CellwiseData<DIM>::Instance()->GetValue(mpCell, 0);
00162             break;
00163         }
00164         default:
00165             NEVER_REACHED;
00166     }
00167 
00168     // Use whether the cell is currently labelled as another input
00169     bool is_labelled = mpCell->HasCellProperty<CellLabel>();
00170     static_cast<Alarcon2004OxygenBasedCellCycleOdeSystem*>(mpOdeSystem)->SetIsLabelled(is_labelled);
00171 }
00172 
00173 // Serialization for Boost >= 1.36
00174 #include "SerializationExportWrapperForCpp.hpp"
00175 CHASTE_CLASS_EXPORT(Alarcon2004OxygenBasedCellCycleModel)
00176 #include "CellCycleModelOdeSolverExportWrapper.hpp"
00177 EXPORT_CELL_CYCLE_MODEL_ODE_SOLVER(Alarcon2004OxygenBasedCellCycleModel)

Generated on Mon Nov 1 12:35:16 2010 for Chaste by  doxygen 1.5.5