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