Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions addons/PhysiMeSS/PhysiMeSS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ void physimess_update_cell_velocity( Cell* pCell, Phenotype& phenotype, double d
}

// std::cout << " AGENT " << pCell->type_name << " " << pCell->ID << " has " ;
if (!isFibre(pCell)) {
static_cast<PhysiMeSS_Cell*>(pCell)->fibre_contact_damping = 0.0;
static_cast<PhysiMeSS_Cell*>(pCell)->fibre_contact_orientation.assign(3, 0.0);
}

//add potentials between pCell and its neighbors
for (auto* neighbor : static_cast<PhysiMeSS_Agent*>(pCell)->physimess_neighbors)
{
Expand Down Expand Up @@ -102,6 +107,7 @@ void physimess_update_cell_velocity( Cell* pCell, Phenotype& phenotype, double d
if (!isFibre(pCell)) {

PhysiMeSS_Cell* ppCell = static_cast<PhysiMeSS_Cell*>(pCell);

int stuck_threshold = 10;
int unstuck_threshold = 1;

Expand All @@ -117,13 +123,28 @@ void physimess_update_cell_velocity( Cell* pCell, Phenotype& phenotype, double d
<< PhysiCell_globals.current_time << std::endl;*/
ppCell->unstuck_counter++;
ppCell->force_update_motility_vector(dt);
ppCell->velocity += phenotype.motility.motility_vector;
}
else {
pCell->update_motility_vector(dt);
pCell->velocity += phenotype.motility.motility_vector;
}

// Fibre contact damping: scale the motility component perpendicular to the
// most strongly contacting fibre by (1 - c), c = vel_contact*(1 - xi^2) in [0,1].
// This acts on the active velocity only (not on v_prev or the repulsion),
// so it cannot feed velocity back into itself.
std::vector<double> motility = phenotype.motility.motility_vector;
double c = std::min(1.0, std::max(0.0, ppCell->fibre_contact_damping));
if (c > 0.0) {
const std::vector<double>& o = ppCell->fibre_contact_orientation;
double m_par = 0.0;
for (int j = 0; j < 3; j++) { m_par += motility[j] * o[j]; }
for (int j = 0; j < 3; j++) {
double par = m_par * o[j];
motility[j] = par + (1.0 - c) * (motility[j] - par);
}
}
pCell->velocity += motility;

if(ppCell->unstuck_counter == unstuck_threshold+1){
ppCell->unstuck_counter = 0;
}
Expand Down
15 changes: 13 additions & 2 deletions addons/PhysiMeSS/PhysiMeSS_cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ PhysiMeSS_Cell::PhysiMeSS_Cell()
{
stuck_counter = 0;
unstuck_counter = 0;
fibre_contact_damping = 0.0;
fibre_contact_orientation.assign(3, 0.0);
}


Expand Down Expand Up @@ -95,13 +97,22 @@ void PhysiMeSS_Cell::add_potentials_from_fibre(PhysiMeSS_Fibre* pFibre)
double xip = pow(xi, p_exponent);
double xiq = pow((1 - xi * xi), q_exponent);

// Clamp at 0: once |v| > cell_velocity_max the factor would go negative
// and grow with speed, feeding the velocity back into itself.
fibre_adhesion = this->custom_data["vel_adhesion"] * xip *
(1 - cell_velocity / this->custom_data["cell_velocity_max"]);
std::max(0.0, 1 - cell_velocity / this->custom_data["cell_velocity_max"]);

fibre_repulsion = this->custom_data["vel_contact"] * xiq;

axpy(&(velocity), fibre_adhesion, pFibre->state.orientation);
naxpy(&(velocity), fibre_repulsion, previous_velocity);
// Don't subtract previous_velocity here. Feeding v_prev back (once per fibre)
// gives a gain >= ~1 on v_prev, which is unstable with the Adams-Bashforth
// position update. Keep the strongest contact and its fibre orientation; in
// physimess_update_cell_velocity it damps only the motility perpendicular to that fibre.
if (fibre_repulsion > fibre_contact_damping) {
fibre_contact_damping = fibre_repulsion;
fibre_contact_orientation = pFibre->state.orientation;
}

degrade_fibre(pFibre);
}
Expand Down
9 changes: 8 additions & 1 deletion addons/PhysiMeSS/PhysiMeSS_cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ class PhysiMeSS_Cell : public PhysiMeSS_Agent

int stuck_counter;
int unstuck_counter;


// Strongest fibre contact damping coefficient seen this mechanics step, and the
// orientation of that fibre. Applied once (not once per fibre) in
// physimess_update_cell_velocity, to the part of the motility vector that is
// perpendicular to the fibre.
double fibre_contact_damping;
std::vector<double> fibre_contact_orientation;

PhysiMeSS_Cell();
~PhysiMeSS_Cell() {};

Expand Down
4 changes: 4 additions & 0 deletions config/Cell_Fibre_Mechanics/test_close_fibers.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-8,0,0,1
8,0,0,1
0,0,0,0
0,-300,0,2
Loading
Loading