LinearSpringWithVariableSpringConstantsForce.cpp
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
00030
00031
00032
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),
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
00107
00108
00109
00110 if (mUseEdgeBasedSpringConstant)
00111 {
00112 assert(dynamic_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation));
00113 assert(!mUseBCatSprings);
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
00125 number_of_mutants++;
00126 }
00127
00128 if (p_cell_B->GetMutationState()->IsType<ApcTwoHitCellMutationState>() || p_cell_B->GetMutationState()->IsType<BetaCateninOneHitCellMutationState>())
00129 {
00130
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
00151
00152
00153
00154 if (mUseBCatSprings)
00155 {
00156 assert(dynamic_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation));
00157
00158
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);
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)
00193 {
00194 spring_a_stiffness = mApoptoticSpringTensionStiffness;
00195 }
00196 else
00197 {
00198 spring_a_stiffness = mApoptoticSpringCompressionStiffness;
00199 }
00200 }
00201 if (cell_B_is_apoptotic)
00202 {
00203 if (!isCloserThanRestLength)
00204 {
00205 spring_b_stiffness = mApoptoticSpringTensionStiffness;
00206 }
00207 else
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
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
00299 GeneralisedLinearSpringForce<DIM>::OutputForceParameters(rParamsFile);
00300 }
00301
00303
00305
00306 template class LinearSpringWithVariableSpringConstantsForce<1>;
00307 template class LinearSpringWithVariableSpringConstantsForce<2>;
00308 template class LinearSpringWithVariableSpringConstantsForce<3>;
00309
00310
00311
00312 #include "SerializationExportWrapperForCpp.hpp"
00313 EXPORT_TEMPLATE_CLASS_SAME_DIMS(LinearSpringWithVariableSpringConstantsForce)