123 assert(nodeAGlobalIndex != nodeBGlobalIndex);
126 c_vector<double,2> node_a_location_2d = rCellPopulation.
GetNode(nodeAGlobalIndex)->rGetLocation();
127 c_vector<double,2> node_b_location_2d = rCellPopulation.
GetNode(nodeBGlobalIndex)->rGetLocation();
135 double distance_between_nodes = norm_2(unit_difference);
136 assert(distance_between_nodes > 0);
137 assert(!std::isnan(distance_between_nodes));
139 unit_difference /= distance_between_nodes;
148 return zero_vector<double>(2);
154 double rest_length = 1.0;
159 double ageA = p_cell_A->GetAge();
160 double ageB = p_cell_B->GetAge();
162 assert(!std::isnan(ageA));
163 assert(!std::isnan(ageB));
175 std::pair<CellPtr,CellPtr> cell_pair = p_static_cast_cell_population->
CreateCellPair(p_cell_A, p_cell_B);
188 double a_rest_length = rest_length*0.5;
189 double b_rest_length = a_rest_length;
195 if (p_cell_A->HasApoptosisBegun())
197 double time_until_death_a = p_cell_A->GetTimeUntilDeath();
198 a_rest_length = a_rest_length * time_until_death_a / p_cell_A->GetApoptosisTime();
200 if (p_cell_B->HasApoptosisBegun())
202 double time_until_death_b = p_cell_B->GetTimeUntilDeath();
203 b_rest_length = b_rest_length * time_until_death_b / p_cell_B->GetApoptosisTime();
206 rest_length = a_rest_length + b_rest_length;
209 assert(rest_length <= 1.0+1e-12);
211 bool is_closer_than_rest_length =
true;
213 if (distance_between_nodes - rest_length > 0)
215 is_closer_than_rest_length =
false;
222 double multiplication_factor = 1.0;
226 c_vector<double,3> force_between_nodes = multiplication_factor * this->
GetMeinekeSpringStiffness() * unit_difference * (distance_between_nodes - rest_length);
229 c_vector<double,3> outward_normal_unit_vector;
232 double theta_B = atan2(node_b_location_2d[1], node_b_location_2d[0]);
233 double normalization_factor = sqrt(1 + dfdr*dfdr);
235 outward_normal_unit_vector[0] = dfdr*cos(theta_B)/normalization_factor;
236 outward_normal_unit_vector[1] = dfdr*sin(theta_B)/normalization_factor;
237 outward_normal_unit_vector[2] = -1.0/normalization_factor;
240 c_vector<double,2> projected_force_between_nodes_2d;
241 double force_dot_normal = inner_prod(force_between_nodes, outward_normal_unit_vector);
243 for (
unsigned i=0; i<2; i++)
245 projected_force_between_nodes_2d[i] = force_between_nodes[i]
246 - force_dot_normal*outward_normal_unit_vector[i]
247 + force_dot_normal*outward_normal_unit_vector[2];
250 return projected_force_between_nodes_2d;
261 EXCEPTION(
"CryptProjectionForce is to be used with a subclass of MeshBasedCellPopulation only");
267 spring_iterator != p_static_cast_cell_population->
SpringsEnd();
270 unsigned nodeA_global_index = spring_iterator.GetNodeA()->GetIndex();
271 unsigned nodeB_global_index = spring_iterator.GetNodeB()->GetIndex();
274 c_vector<double, 2> negative_force = -1.0 * force;
275 spring_iterator.GetNodeB()->AddAppliedForceContribution(negative_force);
276 spring_iterator.GetNodeA()->AddAppliedForceContribution(force);
284 cell_iter != rCellPopulation.
End();
292 rCellPopulation.
GetNode(index)->AddAppliedForceContribution(wnt_chemotactic_force);