neurorosettes.physics#

This module deals with physical interactions between objects.

Module Contents#

Classes#

PhysicalProperties

Class with the mechanical properties of a physical object.

SphereProperties

Class with the mechanical properties of a sphere.

CylinderProperties

Class with the mechanical properties of a cylinder with a spring axis.

ContactForces

Class to compute the contact forces between two objects, represented as spheres.

SimpleContact

Class to compute simple contact forces between two spheres. The force components

PotentialsContact

Class to compute contact forces between two spheres based on potentials. The force components

ContactFactory

Helper class that provides a standard way to create an ABC using

SimpleFactory

Helper class that provides a standard way to create an ABC using

PotentialsFactory

Helper class that provides a standard way to create an ABC using

Functions#

get_distance_components(point1, point2)

Returns the direction and magnitude components of a vector that connects two points.

normalize_vector(vector)

Returns the input array normalized to a unit vector.

get_sphere_overlap(radius1, radius2, distance)

Returns the overlap between two objects represented as spheres.

get_sphere_cylinder_intersection(center, base, top)

Returns the closest point on the cylinder axis to the sphere.

get_cylinder_intersection(base_1, top_1, base_2, top_2)

Returns the closest point between two cylinders.

neurorosettes.physics.get_distance_components(point1, point2)[source]#

Returns the direction and magnitude components of a vector that connects two points.

Parameters
  • point1 (np.ndarray) – The coordinates of the first point.

  • point2 (np.ndarray) – The coordinates of the second point.

Returns

  • np.ndarray – The unit vector that defines the direction between the two points.

  • float – The distance between the two points.

Return type

Tuple[numpy.ndarray, float]

neurorosettes.physics.normalize_vector(vector)[source]#

Returns the input array normalized to a unit vector.

Parameters

vector (numpy.ndarray) – The array to be normalized.

Returns

The normalized vector.

Return type

np.ndarray

neurorosettes.physics.get_sphere_overlap(radius1, radius2, distance)[source]#

Returns the overlap between two objects represented as spheres.

Parameters
  • radius1 (float) – The radius of the first object (represented as a sphere).

  • radius2 (float) – The radius of the second object (represented as a sphere).

  • distance (float) – The distance between the centres of the two objects.

Returns

The overlap between the two objects.

Return type

float

neurorosettes.physics.get_sphere_cylinder_intersection(center, base, top)[source]#

Returns the closest point on the cylinder axis to the sphere.

The intersection is given by the dot product. Taking the dot product between the cylinder axis and the axis that connects the cylinder base to the sphere, the dot product gives us the projection of the cylinder-sphere axis on the cylinder axis. For dot products between 0 and 1, the closest point is on the cylinder axis. For dot products below 0 or above 1, the closest points are the base and the extremity of the cylinder, respectively.

Parameters
  • center (np.ndarray) – The coordinates for the center of the sphere object.

  • base (np.ndarray) – The coordinates for the base of the cylinder object.

  • top (np.ndarray) – The coordinates for the extremity of the cylinder object.

Returns

The coordinates of the closest point to the sphere on the cylinder axis

Return type

np.ndarray

neurorosettes.physics.get_cylinder_intersection(base_1, top_1, base_2, top_2)[source]#

Returns the closest point between two cylinders.

The cross product is used to evaluate if the cylinder axes are parallel. If they are, the closest points between the two objects are considered to be their middle points. If not, the projection of each axis on the other axis is computed to find the closest point on each axis.

Parameters
  • base_1 (np.ndarray) – The coordinates for the base of the first cylinder object.

  • top_1 (np.ndarray) – The coordinates for the extremity of the first cylinder object.

  • base_2 (np.ndarray) – The coordinates for the base of the second cylinder object.

  • top_2 (np.ndarray) – The coordinates for the extremity of the second cylinder object.

Returns

  • np.ndarray – The closest point on the axis of the first cylinder.

  • np.ndarray – The closest point on the axis of the second cylinder.

Return type

Tuple[numpy.ndarray, numpy.ndarray]

class neurorosettes.physics.PhysicalProperties(radius, interaction_factor)[source]#

Class with the mechanical properties of a physical object.

Parameters
  • radius (float) – The radius of the physical object.

  • interaction_factor (float) – The factor used to calculate the radius of interaction.

property radius#

Returns the radius of the object. Raises an error if a negative or non-numerical value is set.

property interaction_factor#

Returns the interaction factor of the object. Raises an error if a negative or non-numerical value is set.

property interaction_radius: float#

Returns the radius of interaction of the physical object.

Return type

float

class neurorosettes.physics.SphereProperties(radius, interaction_factor)[source]#

Bases: PhysicalProperties

Class with the mechanical properties of a sphere.

Parameters
  • radius (float) – The radius of the physical object.

  • interaction_factor (float) – The factor used to calculate the radius of interaction.

class neurorosettes.physics.CylinderProperties(radius, interaction_factor, spring_constant, default_length)[source]#

Bases: PhysicalProperties

Class with the mechanical properties of a cylinder with a spring axis.

Parameters
  • radius (float) – The radius of the physical object.

  • interaction_factor (float) – The factor used to calculate the radius of interaction.

  • spring_constant (float) –

  • default_length (float) –

get_spring_tension(cylinder_length)[source]#

Returns the tension in the spring for a given spring length.

Parameters

cylinder_length (float) –

Return type

float

class neurorosettes.physics.ContactForces[source]#

Bases: abc.ABC

Class to compute the contact forces between two objects, represented as spheres.

adhesion_coefficient :float#
repulsion_coefficient :float#
abstract compute_adhesion(distance, radius1, radius2)[source]#

Returns the magnitude of the adhesion force between two objects

Parameters
  • distance (float) – The distance between two spheres.

  • radius1 (float) – The radius of the first sphere object.

  • radius2 (float) – The radius of the second sphere object.

Returns

The magnitude of the adhesion contact forces.

Return type

float

abstract compute_repulsion(distance, radius1, radius2)[source]#

Returns the magnitude of the repulsion force between two objects

Parameters
  • distance (float) – The distance between two spheres.

  • radius1 (float) – The radius of the first sphere object.

  • radius2 (float) – The radius of the second sphere object.

Returns

The magnitude of the repulsion contact forces.

Return type

float

class neurorosettes.physics.SimpleContact[source]#

Bases: ContactForces

Class to compute simple contact forces between two spheres. The force components are proportional to the adhesion/repulsion coefficients, the overlap between the spheres and, in the case of adhesion forces, the equivalent radius of the spheres. Same approach as done in Cx3D.

compute_adhesion(distance, radius1, radius2)[source]#

Returns a force proportional to the adhesion coefficient, cell overlap and cell radii

Parameters
  • distance (float) –

  • radius1 (float) –

  • radius2 (float) –

Return type

float

compute_repulsion(distance, radius1, radius2)[source]#

Returns a force proportional to the repulsion coefficient and cell overlap

Parameters
  • distance (float) –

  • radius1 (float) –

  • radius2 (float) –

Return type

float

class neurorosettes.physics.PotentialsContact[source]#

Bases: ContactForces

Class to compute contact forces between two spheres based on potentials. The force components take into account the adhesion/coefficient coefficients, a smoothness factor and the distance between two objects. Same approach as done in PhysiCell.

smoothness_factor :int#
compute_adhesion(distance, radius1, radius2)[source]#

Returns a force based on adhesion potentials

Parameters
  • distance (float) –

  • radius1 (float) –

  • radius2 (float) –

Return type

float

compute_repulsion(distance, radius1, radius2)[source]#

Returns a force based on repulsion potentials

Parameters
  • distance (float) –

  • radius1 (float) –

  • radius2 (float) –

Return type

float

class neurorosettes.physics.ContactFactory[source]#

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract get_sphere_sphere_interactions()[source]#
Return type

ContactForces

abstract get_sphere_cylinder_interactions()[source]#
Return type

ContactForces

abstract get_cylinder_cylinder_interactions()[source]#
Return type

ContactForces

class neurorosettes.physics.SimpleFactory[source]#

Bases: ContactFactory

Helper class that provides a standard way to create an ABC using inheritance.

sphere_sphere_adhesion :float#
sphere_sphere_repulsion :float#
sphere_cylinder_adhesion :float#
sphere_cylinder_repulsion :float#
cylinder_cylinder_adhesion :float#
cylinder_cylinder_repulsion :float#
get_sphere_sphere_interactions()[source]#
Return type

ContactForces

get_sphere_cylinder_interactions()[source]#
Return type

ContactForces

get_cylinder_cylinder_interactions()[source]#
Return type

ContactForces

class neurorosettes.physics.PotentialsFactory[source]#

Bases: ContactFactory

Helper class that provides a standard way to create an ABC using inheritance.

sphere_sphere_adhesion :float#
sphere_sphere_repulsion :float#
sphere_sphere_smoothness :int#
sphere_cylinder_adhesion :float#
sphere_cylinder_repulsion :float#
sphere_cylinder_smoothness :int#
cylinder_cylinder_adhesion :float#
cylinder_cylinder_repulsion :float#
cylinder_cylinder_smoothness :int#
get_sphere_sphere_interactions()[source]#
Return type

PotentialsContact

get_sphere_cylinder_interactions()[source]#
Return type

PotentialsContact

get_cylinder_cylinder_interactions()[source]#
Return type

PotentialsContact