LinearSpringWithVariableSpringConstantsForce.cpp

00001 /*
00002 
00003 Copyright (c) 2005-2015, 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 "LinearSpringWithVariableSpringConstantsForce.hpp"
00037 #include "MeshBasedCellPopulation.hpp"
00038 #include "VanLeeuwen2009WntSwatCellCycleModelHypothesisOne.hpp"
00039 #include "VanLeeuwen2009WntSwatCellCycleModelHypothesisTwo.hpp"
00040 #include "ApoptoticCellProperty.hpp"
00041 
00042 template<unsigned DIM>
00043 LinearSpringWithVariableSpringConstantsForce<DIM>::LinearSpringWithVariableSpringConstantsForce()
00044     : GeneralisedLinearSpringForce<DIM>(),
00045       mUseEdgeBasedSpringConstant(false),
00046       mUseMutantSprings(false),
00047       mMutantMutantMultiplier(DOUBLE_UNSET),
00048       mNormalMutantMultiplier(DOUBLE_UNSET),
00049       mUseBCatSprings(false),
00050       mUseApoptoticSprings(false),
00051       mBetaCatSpringScaler(18.14/6.0), // scale spring constant with beta-catenin level (divided by 6 for heaxagonal cells)
00052       mApoptoticSpringTensionStiffness(15.0*0.25),
00053       mApoptoticSpringCompressionStiffness(15.0*0.75)
00054 {
00055 }
00056 
00057 template<unsigned DIM>
00058 LinearSpringWithVariableSpringConstantsForce<DIM>::~LinearSpringWithVariableSpringConstantsForce()
00059 {
00060 }
00061 
00062 template<unsigned DIM>
00063 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetEdgeBasedSpringConstant(bool useEdgeBasedSpringConstant)
00064 {
00065     assert(DIM == 2);
00066     mUseEdgeBasedSpringConstant = useEdgeBasedSpringConstant;
00067 }
00068 
00069 template<unsigned DIM>
00070 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetMutantSprings(bool useMutantSprings, double mutantMutantMultiplier, double normalMutantMultiplier)
00071 {
00072     mUseMutantSprings = useMutantSprings;
00073     mMutantMutantMultiplier = mutantMutantMultiplier;
00074     mNormalMutantMultiplier = normalMutantMultiplier;
00075 }
00076 
00077 template<unsigned DIM>
00078 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetBetaCateninSprings(bool useBCatSprings)
00079 {
00080     mUseBCatSprings = useBCatSprings;
00081 }
00082 
00083 template<unsigned DIM>
00084 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetApoptoticSprings(bool useApoptoticSprings)
00085 {
00086     mUseApoptoticSprings = useApoptoticSprings;
00087 }
00088 
00089 template<unsigned DIM>
00090 double LinearSpringWithVariableSpringConstantsForce<DIM>::VariableSpringConstantMultiplicationFactor(
00091     unsigned nodeAGlobalIndex,
00092     unsigned nodeBGlobalIndex,
00093     AbstractCellPopulation<DIM>& rCellPopulation,
00094     bool isCloserThanRestLength)
00095 {
00096 
00097     double multiplication_factor = GeneralisedLinearSpringForce<DIM>::VariableSpringConstantMultiplicationFactor(nodeAGlobalIndex,
00098                                                                                                             nodeBGlobalIndex,
00099                                                                                                             rCellPopulation,
00100                                                                                                             isCloserThanRestLength);
00101 
00102     CellPtr p_cell_A = rCellPopulation.GetCellUsingLocationIndex(nodeAGlobalIndex);
00103     CellPtr p_cell_B = rCellPopulation.GetCellUsingLocationIndex(nodeBGlobalIndex);
00104 
00105     /*
00106      * The next code block computes the edge-dependent spring constant as given by equation
00107      * (3) in the following reference: van Leeuwen et al. 2009. An integrative computational model
00108      * for intestinal tissue renewal. Cell Prolif. 42(5):617-636. doi:10.1111/j.1365-2184.2009.00627.x
00109      */
00110     if (mUseEdgeBasedSpringConstant)
00111     {
00112         assert(dynamic_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation));
00113         assert(!mUseBCatSprings);   // don't want to do both (both account for edge length)
00114 
00115         multiplication_factor = (static_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation))->GetVoronoiEdgeLength(nodeAGlobalIndex, nodeBGlobalIndex)*sqrt(3.0);
00116     }
00117 
00118     if (mUseMutantSprings)
00119     {
00120         unsigned number_of_mutants = 0;
00121 
00122         if (p_cell_A->GetMutationState()->IsType<ApcTwoHitCellMutationState>() || p_cell_A->GetMutationState()->IsType<BetaCateninOneHitCellMutationState>())
00123         {
00124             // If cell A is mutant
00125             number_of_mutants++;
00126         }
00127 
00128         if (p_cell_B->GetMutationState()->IsType<ApcTwoHitCellMutationState>() || p_cell_B->GetMutationState()->IsType<BetaCateninOneHitCellMutationState>())
00129         {
00130             // If cell B is mutant
00131             number_of_mutants++;
00132         }
00133 
00134         switch (number_of_mutants)
00135         {
00136             case 1u:
00137             {
00138                 multiplication_factor *= mNormalMutantMultiplier;
00139                 break;
00140             }
00141             case 2u:
00142             {
00143                 multiplication_factor *= mMutantMutantMultiplier;
00144                 break;
00145             }
00146         }
00147     }
00148 
00149     /*
00150      * The next code block computes the beta-catenin dependent spring constant as given by equation
00151      * (4) in the following reference: van Leeuwen et al. 2009. An integrative computational model
00152      * for intestinal tissue renewal. Cell Prolif. 42(5):617-636. doi:10.1111/j.1365-2184.2009.00627.x
00153      */
00154     if (mUseBCatSprings)
00155     {
00156         assert(dynamic_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation));
00157 
00158         // If using beta-cat dependent springs, both cell-cycle models had better be VanLeeuwen2009WntSwatCellCycleModel
00159         AbstractVanLeeuwen2009WntSwatCellCycleModel* p_model_A = dynamic_cast<AbstractVanLeeuwen2009WntSwatCellCycleModel*>(p_cell_A->GetCellCycleModel());
00160         AbstractVanLeeuwen2009WntSwatCellCycleModel* p_model_B = dynamic_cast<AbstractVanLeeuwen2009WntSwatCellCycleModel*>(p_cell_B->GetCellCycleModel());
00161 
00162         assert(!mUseEdgeBasedSpringConstant);   // This already adapts for edge lengths - don't want to do it twice.
00163         double beta_cat_cell_1 = p_model_A->GetMembraneBoundBetaCateninLevel();
00164         double beta_cat_cell_2 = p_model_B->GetMembraneBoundBetaCateninLevel();
00165 
00166         MeshBasedCellPopulation<DIM>* p_static_cast_cell_population = (static_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation));
00167 
00168         double perim_cell_1 = p_static_cast_cell_population->GetSurfaceAreaOfVoronoiElement(nodeAGlobalIndex);
00169         double perim_cell_2 = p_static_cast_cell_population->GetSurfaceAreaOfVoronoiElement(nodeBGlobalIndex);
00170         double edge_length_between_1_and_2 = p_static_cast_cell_population->GetVoronoiEdgeLength(nodeAGlobalIndex, nodeBGlobalIndex);
00171 
00172         double beta_cat_on_cell_1_edge = beta_cat_cell_1 *  edge_length_between_1_and_2 / perim_cell_1;
00173         double beta_cat_on_cell_2_edge = beta_cat_cell_2 *  edge_length_between_1_and_2 / perim_cell_2;
00174 
00175         double min_beta_Cat_of_two_cells = std::min(beta_cat_on_cell_1_edge, beta_cat_on_cell_2_edge);
00176 
00177         multiplication_factor *= min_beta_Cat_of_two_cells / mBetaCatSpringScaler;
00178     }
00179 
00180     if (mUseApoptoticSprings)
00181     {
00182         bool cell_A_is_apoptotic = p_cell_A->HasCellProperty<ApoptoticCellProperty>();
00183         bool cell_B_is_apoptotic = p_cell_B->HasCellProperty<ApoptoticCellProperty>();
00184 
00185         if (cell_A_is_apoptotic || cell_B_is_apoptotic)
00186         {
00187             double spring_a_stiffness = 2.0 * this->GetMeinekeSpringStiffness();
00188             double spring_b_stiffness = 2.0 * this->GetMeinekeSpringStiffness();
00189 
00190             if (cell_A_is_apoptotic)
00191             {
00192                 if (!isCloserThanRestLength) // if under tension
00193                 {
00194                     spring_a_stiffness = mApoptoticSpringTensionStiffness;
00195                 }
00196                 else // if under compression
00197                 {
00198                     spring_a_stiffness = mApoptoticSpringCompressionStiffness;
00199                 }
00200             }
00201             if (cell_B_is_apoptotic)
00202             {
00203                 if (!isCloserThanRestLength) // if under tension
00204                 {
00205                     spring_b_stiffness = mApoptoticSpringTensionStiffness;
00206                 }
00207                 else // if under compression
00208                 {
00209                     spring_b_stiffness = mApoptoticSpringCompressionStiffness;
00210                 }
00211             }
00212 
00213             multiplication_factor /= (1.0/spring_a_stiffness + 1.0/spring_b_stiffness)*this->GetMeinekeSpringStiffness();
00214         }
00215     }
00216 
00217     return multiplication_factor;
00218 }
00219 
00220 template<unsigned DIM>
00221 void LinearSpringWithVariableSpringConstantsForce<DIM>::AddForceContribution(AbstractCellPopulation<DIM>& rCellPopulation)
00222 {
00223     // Throw an exception message if not using a MeshBasedCellPopulation
00224     if (dynamic_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation) == NULL)
00225     {
00226         EXCEPTION("LinearSpringWithVariableSpringConstantsForce is to be used with a subclass of MeshBasedCellPopulation only");
00227     }
00228 
00229     MeshBasedCellPopulation<DIM>* p_static_cast_cell_population = static_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation);
00230 
00231     for (typename MeshBasedCellPopulation<DIM>::SpringIterator spring_iterator = p_static_cast_cell_population->SpringsBegin();
00232         spring_iterator != p_static_cast_cell_population->SpringsEnd();
00233         ++spring_iterator)
00234     {
00235         unsigned nodeA_global_index = spring_iterator.GetNodeA()->GetIndex();
00236         unsigned nodeB_global_index = spring_iterator.GetNodeB()->GetIndex();
00237 
00238         c_vector<double, DIM> force = this->CalculateForceBetweenNodes(nodeA_global_index, nodeB_global_index, rCellPopulation);
00239         c_vector<double, DIM> negative_force = -1.0*force;
00240 
00241         spring_iterator.GetNodeB()->AddAppliedForceContribution(negative_force);
00242         spring_iterator.GetNodeA()->AddAppliedForceContribution(force);
00243     }
00244 }
00245 
00246 template<unsigned DIM>
00247 double LinearSpringWithVariableSpringConstantsForce<DIM>::GetBetaCatSpringScaler()
00248 {
00249     return mBetaCatSpringScaler;
00250 }
00251 
00252 template<unsigned DIM>
00253 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetBetaCatSpringScaler(double betaCatSpringScaler)
00254 {
00255     assert(betaCatSpringScaler > 0.0);
00256     mBetaCatSpringScaler = betaCatSpringScaler;
00257 }
00258 
00259 template<unsigned DIM>
00260 double LinearSpringWithVariableSpringConstantsForce<DIM>::GetApoptoticSpringTensionStiffness()
00261 {
00262     return mApoptoticSpringTensionStiffness;
00263 }
00264 
00265 template<unsigned DIM>
00266 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetApoptoticSpringTensionStiffness(double apoptoticSpringTensionStiffness)
00267 {
00268     assert(apoptoticSpringTensionStiffness >= 0.0);
00269     mApoptoticSpringTensionStiffness = apoptoticSpringTensionStiffness;
00270 }
00271 
00272 template<unsigned DIM>
00273 double LinearSpringWithVariableSpringConstantsForce<DIM>::GetApoptoticSpringCompressionStiffness()
00274 {
00275     return mApoptoticSpringCompressionStiffness;
00276 }
00277 
00278 template<unsigned DIM>
00279 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetApoptoticSpringCompressionStiffness(double apoptoticSpringCompressionStiffness)
00280 {
00281     assert(apoptoticSpringCompressionStiffness >= 0.0);
00282     mApoptoticSpringCompressionStiffness = apoptoticSpringCompressionStiffness;
00283 }
00284 
00285 template<unsigned DIM>
00286 void LinearSpringWithVariableSpringConstantsForce<DIM>::OutputForceParameters(out_stream& rParamsFile)
00287 {
00288     *rParamsFile << "\t\t\t<UseEdgeBasedSpringConstant>" << mUseEdgeBasedSpringConstant << "</UseEdgeBasedSpringConstant>\n";
00289     *rParamsFile << "\t\t\t<UseMutantSprings>" << mUseMutantSprings << "</UseMutantSprings>\n";
00290     *rParamsFile << "\t\t\t<MutantMutantMultiplier>" << mMutantMutantMultiplier << "</MutantMutantMultiplier>\n";
00291     *rParamsFile << "\t\t\t<NormalMutantMultiplier>" << mNormalMutantMultiplier << "</NormalMutantMultiplier>\n";
00292     *rParamsFile << "\t\t\t<UseBCatSprings>" << mUseBCatSprings << "</UseBCatSprings>\n";
00293     *rParamsFile << "\t\t\t<UseApoptoticSprings>" << mUseApoptoticSprings << "</UseApoptoticSprings>\n";
00294     *rParamsFile << "\t\t\t<BetaCatSpringScaler>" << mBetaCatSpringScaler << "</BetaCatSpringScaler>\n";
00295     *rParamsFile << "\t\t\t<ApoptoticSpringTensionStiffness>" << mApoptoticSpringTensionStiffness << "</ApoptoticSpringTensionStiffness>\n";
00296     *rParamsFile << "\t\t\t<ApoptoticSpringCompressionStiffness>" << mApoptoticSpringCompressionStiffness << "</ApoptoticSpringCompressionStiffness>\n";
00297 
00298     // Call method on direct parent class
00299     GeneralisedLinearSpringForce<DIM>::OutputForceParameters(rParamsFile);
00300 }
00301 
00303 // Explicit instantiation
00305 
00306 template class LinearSpringWithVariableSpringConstantsForce<1>;
00307 template class LinearSpringWithVariableSpringConstantsForce<2>;
00308 template class LinearSpringWithVariableSpringConstantsForce<3>;
00309 
00310 
00311 // Serialization for Boost >= 1.36
00312 #include "SerializationExportWrapperForCpp.hpp"
00313 EXPORT_TEMPLATE_CLASS_SAME_DIMS(LinearSpringWithVariableSpringConstantsForce)

Generated by  doxygen 1.6.2