Chaste Release::3.1
Alarcon2004OxygenBasedCellCycleModel.cpp
00001 /*
00002 
00003 Copyright (c) 2005-2012, University of Oxford.
00004 All rights reserved.
00005 
00006 University of Oxford means the Chancellor, Masters and Scholars of the
00007 University of Oxford, having an administrative office at Wellington
00008 Square, Oxford OX1 2JD, UK.
00009 
00010 This file is part of Chaste.
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided that the following conditions are met:
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019  * Neither the name of the University of Oxford nor the names of its
00020    contributors may be used to endorse or promote products derived from this
00021    software without specific prior written permission.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 
00036 #include "Alarcon2004OxygenBasedCellCycleModel.hpp"
00037 
00038 #include "CellLabel.hpp"
00039 #include "Exception.hpp"
00040 
00041 Alarcon2004OxygenBasedCellCycleModel::Alarcon2004OxygenBasedCellCycleModel(boost::shared_ptr<AbstractCellCycleModelOdeSolver> pOdeSolver)
00042     : AbstractOdeBasedCellCycleModel(SimulationTime::Instance()->GetTime(), pOdeSolver)
00043 {
00044     if (!mpOdeSolver)
00045     {
00046         mpOdeSolver = CellCycleModelOdeSolver<Alarcon2004OxygenBasedCellCycleModel, RungeKutta4IvpOdeSolver>::Instance();
00047         mpOdeSolver->Initialise();
00048     }
00049     SetDt(0.0001);
00050 }
00051 
00052 void Alarcon2004OxygenBasedCellCycleModel::ResetForDivision()
00053 {
00054     AbstractOdeBasedCellCycleModel::ResetForDivision();
00055     assert(mpOdeSystem != NULL);
00056 
00057     // This model needs the protein concentrations and phase resetting to G0/G1.
00058     // Keep the oxygen concentration the same but reset everything else
00059     std::vector<double> init_conds = mpOdeSystem->GetInitialConditions();
00060     for (unsigned i=0; i<5; i++)
00061     {
00062         mpOdeSystem->rGetStateVariables()[i] = init_conds[i];
00063     }
00064 }
00065 
00066 AbstractCellCycleModel* Alarcon2004OxygenBasedCellCycleModel::CreateCellCycleModel()
00067 {
00068     // Create a new cell-cycle model
00069     Alarcon2004OxygenBasedCellCycleModel* p_model = new Alarcon2004OxygenBasedCellCycleModel(mpOdeSolver);
00070 
00071     /*
00072      * Set each member variable of the new cell-cycle model that inherits
00073      * its value from the parent.
00074      *
00075      * Note 1: some of the new cell-cycle model's member variables (namely
00076      * mBirthTime, mCurrentCellCyclePhase, mReadyToDivide, mDt, mpOdeSolver)
00077      * will already have been correctly initialized in its constructor.
00078      *
00079      * Note 2: one or more of the new cell-cycle model's member variables
00080      * may be set/overwritten as soon as InitialiseDaughterCell() is called on
00081      * the new cell-cycle model.
00082      */
00083     p_model->SetBirthTime(mBirthTime);
00084     p_model->SetDimension(mDimension);
00085     p_model->SetMinimumGapDuration(mMinimumGapDuration);
00086     p_model->SetStemCellG1Duration(mStemCellG1Duration);
00087     p_model->SetTransitCellG1Duration(mTransitCellG1Duration);
00088     p_model->SetSDuration(mSDuration);
00089     p_model->SetG2Duration(mG2Duration);
00090     p_model->SetMDuration(mMDuration);
00091     p_model->SetDivideTime(mDivideTime);
00092     p_model->SetFinishedRunningOdes(mFinishedRunningOdes);
00093     p_model->SetG2PhaseStartTime(mG2PhaseStartTime);
00094     p_model->SetLastTime(mLastTime);
00095 
00096     /*
00097      * Create the new cell-cycle model's ODE system and use the current values
00098      * of the state variables in mpOdeSystem as an initial condition.
00099      */
00100     assert(mpOdeSystem);
00101     bool is_labelled = mpCell->HasCellProperty<CellLabel>();
00102     p_model->SetOdeSystem(new Alarcon2004OxygenBasedCellCycleOdeSystem(mpCell->GetCellData()->GetItem("oxygen"), is_labelled));
00103     p_model->SetStateVariables(mpOdeSystem->rGetStateVariables());
00104 
00105     return p_model;
00106 }
00107 
00108 void Alarcon2004OxygenBasedCellCycleModel::Initialise()
00109 {
00110     assert(mpOdeSystem == NULL);
00111     assert(mpCell != NULL);
00112 
00113     bool is_labelled = mpCell->HasCellProperty<CellLabel>();
00114 
00115     mpOdeSystem = new Alarcon2004OxygenBasedCellCycleOdeSystem(mpCell->GetCellData()->GetItem("oxygen"), is_labelled);
00116 
00117     mpOdeSystem->SetStateVariables(mpOdeSystem->GetInitialConditions());
00118 }
00119 
00120 void Alarcon2004OxygenBasedCellCycleModel::AdjustOdeParameters(double currentTime)
00121 {
00122     // Pass this time step's oxygen concentration into the solver as a constant over this timestep
00123 
00124     mpOdeSystem->rGetStateVariables()[5] = mpCell->GetCellData()->GetItem("oxygen");
00125 
00126     // Use whether the cell is currently labelled as another input
00127     bool is_labelled = mpCell->HasCellProperty<CellLabel>();
00128     static_cast<Alarcon2004OxygenBasedCellCycleOdeSystem*>(mpOdeSystem)->SetIsLabelled(is_labelled);
00129 }
00130 
00131 void Alarcon2004OxygenBasedCellCycleModel::OutputCellCycleModelParameters(out_stream& rParamsFile)
00132 {
00133     // No new parameters to output
00134 
00135     // Call method on direct parent class
00136     AbstractOdeBasedCellCycleModel::OutputCellCycleModelParameters(rParamsFile);
00137 }
00138 
00139 // Serialization for Boost >= 1.36
00140 #include "SerializationExportWrapperForCpp.hpp"
00141 CHASTE_CLASS_EXPORT(Alarcon2004OxygenBasedCellCycleModel)
00142 #include "CellCycleModelOdeSolverExportWrapper.hpp"
00143 EXPORT_CELL_CYCLE_MODEL_ODE_SOLVER(Alarcon2004OxygenBasedCellCycleModel)