:py:mod:`neurorosettes.physics` =============================== .. py:module:: neurorosettes.physics .. autoapi-nested-parse:: This module deals with physical interactions between objects. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: neurorosettes.physics.PhysicalProperties neurorosettes.physics.SphereProperties neurorosettes.physics.CylinderProperties neurorosettes.physics.ContactForces neurorosettes.physics.SimpleContact neurorosettes.physics.PotentialsContact neurorosettes.physics.ContactFactory neurorosettes.physics.SimpleFactory neurorosettes.physics.PotentialsFactory Functions ~~~~~~~~~ .. autoapisummary:: neurorosettes.physics.get_distance_components neurorosettes.physics.normalize_vector neurorosettes.physics.get_sphere_overlap neurorosettes.physics.get_sphere_cylinder_intersection neurorosettes.physics.get_cylinder_intersection .. py:function:: get_distance_components(point1, point2) Returns the direction and magnitude components of a vector that connects two points. :param point1: The coordinates of the first point. :type point1: np.ndarray :param point2: The coordinates of the second point. :type point2: np.ndarray :returns: * *np.ndarray* -- The unit vector that defines the direction between the two points. * *float* -- The distance between the two points. .. py:function:: normalize_vector(vector) Returns the input array normalized to a unit vector. :param vector: The array to be normalized. :returns: The normalized vector. :rtype: np.ndarray .. py:function:: get_sphere_overlap(radius1, radius2, distance) Returns the overlap between two objects represented as spheres. :param radius1: The radius of the first object (represented as a sphere). :type radius1: float :param radius2: The radius of the second object (represented as a sphere). :type radius2: float :param distance: The distance between the centres of the two objects. :type distance: float :returns: The overlap between the two objects. :rtype: float .. py:function:: get_sphere_cylinder_intersection(center, base, top) 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. :param center: The coordinates for the center of the sphere object. :type center: np.ndarray :param base: The coordinates for the base of the cylinder object. :type base: np.ndarray :param top: The coordinates for the extremity of the cylinder object. :type top: np.ndarray :returns: The coordinates of the closest point to the sphere on the cylinder axis :rtype: np.ndarray .. py:function:: get_cylinder_intersection(base_1, top_1, base_2, top_2) 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. :param base_1: The coordinates for the base of the first cylinder object. :type base_1: np.ndarray :param top_1: The coordinates for the extremity of the first cylinder object. :type top_1: np.ndarray :param base_2: The coordinates for the base of the second cylinder object. :type base_2: np.ndarray :param top_2: The coordinates for the extremity of the second cylinder object. :type top_2: np.ndarray :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. .. py:class:: PhysicalProperties(radius, interaction_factor) Class with the mechanical properties of a physical object. :param radius: The radius of the physical object. :param interaction_factor: The factor used to calculate the radius of interaction. .. py:property:: radius Returns the radius of the object. Raises an error if a negative or non-numerical value is set. .. py:property:: interaction_factor Returns the interaction factor of the object. Raises an error if a negative or non-numerical value is set. .. py:property:: interaction_radius :type: float Returns the radius of interaction of the physical object. .. py:class:: SphereProperties(radius, interaction_factor) Bases: :py:obj:`PhysicalProperties` Class with the mechanical properties of a sphere. :param radius: The radius of the physical object. :param interaction_factor: The factor used to calculate the radius of interaction. .. py:class:: CylinderProperties(radius, interaction_factor, spring_constant, default_length) Bases: :py:obj:`PhysicalProperties` Class with the mechanical properties of a cylinder with a spring axis. :param radius: The radius of the physical object. :param interaction_factor: The factor used to calculate the radius of interaction. .. py:method:: get_spring_tension(cylinder_length) Returns the tension in the spring for a given spring length. .. py:class:: ContactForces Bases: :py:obj:`abc.ABC` Class to compute the contact forces between two objects, represented as spheres. .. py:attribute:: adhesion_coefficient :type: float .. py:attribute:: repulsion_coefficient :type: float .. py:method:: compute_adhesion(distance, radius1, radius2) :abstractmethod: Returns the magnitude of the adhesion force between two objects :param distance: The distance between two spheres. :type distance: float :param radius1: The radius of the first sphere object. :type radius1: float :param radius2: The radius of the second sphere object. :type radius2: float :returns: The magnitude of the adhesion contact forces. :rtype: float .. py:method:: compute_repulsion(distance, radius1, radius2) :abstractmethod: Returns the magnitude of the repulsion force between two objects :param distance: The distance between two spheres. :type distance: float :param radius1: The radius of the first sphere object. :type radius1: float :param radius2: The radius of the second sphere object. :type radius2: float :returns: The magnitude of the repulsion contact forces. :rtype: float .. py:class:: SimpleContact Bases: :py:obj:`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. .. py:method:: compute_adhesion(distance, radius1, radius2) Returns a force proportional to the adhesion coefficient, cell overlap and cell radii .. py:method:: compute_repulsion(distance, radius1, radius2) Returns a force proportional to the repulsion coefficient and cell overlap .. py:class:: PotentialsContact Bases: :py:obj:`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. .. py:attribute:: smoothness_factor :type: int .. py:method:: compute_adhesion(distance, radius1, radius2) Returns a force based on adhesion potentials .. py:method:: compute_repulsion(distance, radius1, radius2) Returns a force based on repulsion potentials .. py:class:: ContactFactory Bases: :py:obj:`abc.ABC` Helper class that provides a standard way to create an ABC using inheritance. .. py:method:: get_sphere_sphere_interactions() :abstractmethod: .. py:method:: get_sphere_cylinder_interactions() :abstractmethod: .. py:method:: get_cylinder_cylinder_interactions() :abstractmethod: .. py:class:: SimpleFactory Bases: :py:obj:`ContactFactory` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: sphere_sphere_adhesion :type: float .. py:attribute:: sphere_sphere_repulsion :type: float .. py:attribute:: sphere_cylinder_adhesion :type: float .. py:attribute:: sphere_cylinder_repulsion :type: float .. py:attribute:: cylinder_cylinder_adhesion :type: float .. py:attribute:: cylinder_cylinder_repulsion :type: float .. py:method:: get_sphere_sphere_interactions() .. py:method:: get_sphere_cylinder_interactions() .. py:method:: get_cylinder_cylinder_interactions() .. py:class:: PotentialsFactory Bases: :py:obj:`ContactFactory` Helper class that provides a standard way to create an ABC using inheritance. .. py:attribute:: sphere_sphere_adhesion :type: float .. py:attribute:: sphere_sphere_repulsion :type: float .. py:attribute:: sphere_sphere_smoothness :type: int .. py:attribute:: sphere_cylinder_adhesion :type: float .. py:attribute:: sphere_cylinder_repulsion :type: float .. py:attribute:: sphere_cylinder_smoothness :type: int .. py:attribute:: cylinder_cylinder_adhesion :type: float .. py:attribute:: cylinder_cylinder_repulsion :type: float .. py:attribute:: cylinder_cylinder_smoothness :type: int .. py:method:: get_sphere_sphere_interactions() .. py:method:: get_sphere_cylinder_interactions() .. py:method:: get_cylinder_cylinder_interactions()