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

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