00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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),
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);
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
00113 number_of_mutants++;
00114 }
00115
00116 if (p_cell_B->GetMutationState()->IsType<ApcTwoHitCellMutationState>() || p_cell_B->GetMutationState()->IsType<BetaCateninOneHitCellMutationState>())
00117 {
00118
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
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);
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)
00175 {
00176 spring_a_stiffness = mApoptoticSpringTensionStiffness;
00177 }
00178 else
00179 {
00180 spring_a_stiffness = mApoptoticSpringCompressionStiffness;
00181 }
00182 }
00183 if (cell_B_is_apoptotic)
00184 {
00185 if (!isCloserThanRestLength)
00186 {
00187 spring_b_stiffness = mApoptoticSpringTensionStiffness;
00188 }
00189 else
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
00207 if (dynamic_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation) == NULL)
00208 {
00209 EXCEPTION("LinearSpringWithVariableSpringConstantsForce is to be used with a subclass of MeshBasedCellPopulation only");
00210 }
00211
00212 MeshBasedCellPopulation<DIM>* p_static_cast_cell_population = static_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation);
00213
00214 for (typename MeshBasedCellPopulation<DIM>::SpringIterator spring_iterator = p_static_cast_cell_population->SpringsBegin();
00215 spring_iterator != p_static_cast_cell_population->SpringsEnd();
00216 ++spring_iterator)
00217 {
00218 unsigned nodeA_global_index = spring_iterator.GetNodeA()->GetIndex();
00219 unsigned nodeB_global_index = spring_iterator.GetNodeB()->GetIndex();
00220
00221 c_vector<double, DIM> force = CalculateForceBetweenNodes(nodeA_global_index, nodeB_global_index, rCellPopulation);
00222
00223 rForces[nodeB_global_index] -= force;
00224 rForces[nodeA_global_index] += force;
00225 }
00226 }
00227
00228 template<unsigned DIM>
00229 double LinearSpringWithVariableSpringConstantsForce<DIM>::GetBetaCatSpringScaler()
00230 {
00231 return mBetaCatSpringScaler;
00232 }
00233
00234 template<unsigned DIM>
00235 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetBetaCatSpringScaler(double betaCatSpringScaler)
00236 {
00237 assert(betaCatSpringScaler > 0.0);
00238 mBetaCatSpringScaler = betaCatSpringScaler;
00239 }
00240
00241 template<unsigned DIM>
00242 double LinearSpringWithVariableSpringConstantsForce<DIM>::GetApoptoticSpringTensionStiffness()
00243 {
00244 return mApoptoticSpringTensionStiffness;
00245 }
00246
00247 template<unsigned DIM>
00248 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetApoptoticSpringTensionStiffness(double apoptoticSpringTensionStiffness)
00249 {
00250 assert(apoptoticSpringTensionStiffness >= 0.0);
00251 mApoptoticSpringTensionStiffness = apoptoticSpringTensionStiffness;
00252 }
00253
00254 template<unsigned DIM>
00255 double LinearSpringWithVariableSpringConstantsForce<DIM>::GetApoptoticSpringCompressionStiffness()
00256 {
00257 return mApoptoticSpringCompressionStiffness;
00258 }
00259
00260 template<unsigned DIM>
00261 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetApoptoticSpringCompressionStiffness(double apoptoticSpringCompressionStiffness)
00262 {
00263 assert(apoptoticSpringCompressionStiffness >= 0.0);
00264 mApoptoticSpringCompressionStiffness = apoptoticSpringCompressionStiffness;
00265 }
00266
00267 template<unsigned DIM>
00268 void LinearSpringWithVariableSpringConstantsForce<DIM>::OutputForceParameters(out_stream& rParamsFile)
00269 {
00270 *rParamsFile << "\t\t\t<UseEdgeBasedSpringConstant>" << mUseEdgeBasedSpringConstant << "</UseEdgeBasedSpringConstant> \n";
00271 *rParamsFile << "\t\t\t<UseMutantSprings>" << mUseMutantSprings << "</UseMutantSprings> \n";
00272 *rParamsFile << "\t\t\t<MutantMutantMultiplier>" << mMutantMutantMultiplier << "</MutantMutantMultiplier> \n";
00273 *rParamsFile << "\t\t\t<NormalMutantMultiplier>" << mNormalMutantMultiplier << "</NormalMutantMultiplier> \n";
00274 *rParamsFile << "\t\t\t<UseBCatSprings>" << mUseBCatSprings << "</UseBCatSprings> \n";
00275 *rParamsFile << "\t\t\t<UseApoptoticSprings>" << mUseApoptoticSprings << "</UseApoptoticSprings> \n";
00276 *rParamsFile << "\t\t\t<BetaCatSpringScaler>" << mBetaCatSpringScaler << "</BetaCatSpringScaler> \n";
00277 *rParamsFile << "\t\t\t<ApoptoticSpringTensionStiffness>" << mApoptoticSpringTensionStiffness << "</ApoptoticSpringTensionStiffness> \n";
00278 *rParamsFile << "\t\t\t<ApoptoticSpringCompressionStiffness>" << mApoptoticSpringCompressionStiffness << "</ApoptoticSpringCompressionStiffness> \n";
00279
00280
00281 GeneralisedLinearSpringForce<DIM>::OutputForceParameters(rParamsFile);
00282 }
00283
00285
00287
00288 template class LinearSpringWithVariableSpringConstantsForce<1>;
00289 template class LinearSpringWithVariableSpringConstantsForce<2>;
00290 template class LinearSpringWithVariableSpringConstantsForce<3>;
00291
00292
00293
00294 #include "SerializationExportWrapperForCpp.hpp"
00295 EXPORT_TEMPLATE_CLASS_SAME_DIMS(LinearSpringWithVariableSpringConstantsForce)