seapipy.lattice_class.Lattice

class seapipy.lattice_class.Lattice(number_cells_x: int, number_cells_y: int, tessellation: object | None = None)

Bases: object

Lattice class with all lattice properties

Parameters:
  • number_cells_x (int) – Number of cells in the x-axis to create

  • number_cells_y – Number of cells in the x-axis to create

create_example_lattice(voronoi_seeds_std: float = 0.15, voronoi_seeds_step: int = 20) tuple[dict, dict, dict]

Create a lattice with the initial Voronoi tessellation

Parameters:
  • voronoi_seeds_std (float) – Noise taken from a normal of mean zero and this value as standard deviation

  • voronoi_seeds_step (float) – SSpatial step to deposition of seeds in the tessellation

Returns:

The vertices, edges and cells generated

Return type:

tuple

create_lattice_elements() tuple

Create the vertices, edges and cells from the scipy.spatial.Voronoi() objects

Returns:

Vertices, edges and cell’s list

Return type:

tuple

generate_square_seeds(standard_deviation: float = 0, spatial_step: int = 1) list

Generate seeds for tessellation as a rectangular grid

Parameters:
  • standard_deviation (float) – Move seeds with a normal with this standard deviation

  • spatial_step (int)

Returns:

List of [x,y] coordinates for the seeds

Return type:

list

generate_voronoi_tessellation(seed_values: list) object

Generates the voronoi tessellation from the seed values provided

Parameters:

seed_values (list) – [x, y] list of positions to use as seeds for the voronoi tessellation

Returns:

Voronoi tessellation object generated from the seed values

Return type:

scipy.spatial.Voronoi()

static get_cell_area(cell_vertices: list, vertices: dict) float

Area of a polygon using the shoelace formula

Parameters:
  • cell_vertices – List of vertex’s id of the polygon

  • vertices – Dictionary of vertices in the system

Returns:

Area of the polygon. Positive number indicates clockwise orientation, negative number counterclockwise.

get_cell_area_sign(cell: list, all_vertices: dict) int

Get the orientation of the polygon for a cell_vertices using the sign of the area through gauss formula

Parameters:
  • cell (list) – Vertices of the cell_vertices to determine orientation

  • all_vertices (dict) – Dictionary with all the vertices in the lattice

Returns:

Sign of the cell_vertices area to determine orientation of the polygon

Return type:

int

static get_coordinates(vertices: dict) tuple

Get the coordinates for all vertices in the system

Parameters:

vertices (dict) – List of vertices

Returns:

X and Y coordinates

Return type:

tuple

static get_edge_centroid(edge_id: int, vertices: list, edges: list) tuple

Get the center of the requested edge

Parameters:
  • edge_id (int) – id of edge

  • vertices (list) – List of vertices

  • edges (list) – list of edges

Returns:

x and y coordinates of the edge’s centroid

static get_enum(edge: list, edges: dict) int

Get id of the edge from the vertex position or new possible ID if the vertex is already known

Parameters:
  • edge (list) – id of the vertices that create the edge

  • edges (dict) – Dictionary of the edges currently identified

Returns:

edge id if the edge exists, if not the next possible id to assign

Return type:

int

static get_normally_distributed_densities(edges: dict, center: float = 1, standard_deviation: float = 0.01) dict

Get a dictionary of tensions that is normally distributed around the center with a certain standard deviation

Parameters:
  • edges (dict) – List of edges in the lattice

  • center (float) – Center of the distribution of tensions

  • standard_deviation (float) – Standard deviation for the distribution of tensions

Returns:

Dictionary with the keys as edge ids and the tensions as values

Return type:

dict

static get_vertex_number(vertex: list, vertices: dict) int

Get id of the vertex from the vertex position or new possible ID if the vertex is already known

Parameters:
  • vertex (list) – Vertex position

  • vertices (dict) – Dictionary of the vertices currently identified

Returns:

Vertex id if the vertex exists, if not the next possible id to assign

Return type:

int

static line_eq(p0: float, p1: float, x: numpy.ndarray) list

Get the value of linear function that goes through p0 and p1 at x

Parameters:
  • p0 (list) – First point to join

  • p1 – Second point to join

  • x – Independent variable of the equation

Returns:

Value of y(x) for a line that goes through p0 and p1

remove_infinite_regions(regions: list, max_distance: float = 50) list

Remove regions that have a vertex too far away to be part of the tissue. This solves vertices placed in ‘infinity’ by the tessellation

Parameters:
  • regions (list) – List of the voronoi regions

  • max_distance (float, optional) – Maximum distance of a vertex in a polygon

Returns:

List of regions without the offending ones

Return type:

list