Overview of the different functions for obtaining the positions the spheres#

[1]:
import biosspheres.miscella.spherearrangements as pos

Preliminaries#

Geometry#

\(N\) disjoint spheres in \(\mathbb{R}^3\):

  • Position vectors of the sphere centers: \(\mathbf{p_j} \in \mathbb{R}^3\), with \(j \in \{1,...,N\}\).

  • Radii: \(\tilde{r}_j\in \mathbb{R}^+\), with \(j \in \{1,...,N\}\).

  • Interior of sphere \(j\): \(\Omega_j:=\{ \mathbf{x} \in \mathbb{R}^3:||\mathbf{x}-\mathbf{p_j}||_2<\tilde{r}_j \}\).

  • Boundary of sphere \(j\): \(\Gamma_j:=\partial \Omega_j\).

  • Exterior medium, \(\Omega_0\): defined as \(\mathbb{R}^3\) without the spheres and their boundaries.

cube_vertex_positions#

This functions assumes the radii of all spheres are the same, and orders them in the corners of an array of cubes, starting in the origin of the coordinate system and placing them in the first quadrant.

We need three parameters, n, r and d. These are translated to n\(^3\) spheres, with r the radius of each one, and the length of the edge of each cube 2r+d. If d \(=0\) the spheres will touch each other.

Docstring#

[2]:
print(pos.cube_vertex_positions.__doc__)

    To obtain an arrangement of number**3 spheres.

    Notes
    -----
    This functions assumes the radii of all spheres are the same, and
    orders them in the corners of an array of cubes, starting in the
    origin of the coordinate system and placing them in the first
    quadrant.
    We need three parameters, number, r and d. These are translated to
    number**3 spheres, with r the radius of each one, and the length of
    the edge of each cube is 2r + d. If d=0 the spheres will touch each
    other.

    Parameters
    ----------
    number: int
        the total number of spheres is number**3.
    r: float
        radius of each sphere.
    d: float
        distance between two surfaces of spheres. The length of the edge
        of each cube 2r + d. If d=0 the spheres will touch each other.

    Returns
    -------
    ps: list[np.ndarray]
        position of the center of the spheres.


Some examples:#

[3]:
r = 0.75 # float
d = 1.15 # float
n = 2 # int
center_positions = pos.cube_vertex_positions(n, r, d)
n = n**3 # now changed to represent the number of sphers
[4]:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm, colors
import biosspheres.quadratures.sphere as quadratures

big_l_c = 20
quantity_theta_points, quantity_phi_points, weights, pre_vector = quadratures.gauss_legendre_trapezoidal_2d(big_l_c)
vector = pre_vector * r
fig = plt.figure()
ax_1 = fig.add_subplot(111, projection='3d')
for s in np.arange(0,n):
    ax_1.plot_surface(
        vector[0, :, :]+center_positions[s][0],
        vector[1, :, :]+center_positions[s][1],
        vector[2, :, :]+center_positions[s][2],
        rstride=1, cstride=1)
ax_1.set_xlabel('$x$')
ax_1.set_ylabel('$y$')
ax_1.set_zlabel('$z$')
ax_1.set_aspect('equal')
plt.show()
/opt/hostedtoolcache/Python/3.12.15/x64/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
[5]:
import biosspheres.miscella.spherearrangements as pos
r = 1. # float
d = 0.25 # float
n = 10 # int
center_positions = pos.cube_vertex_positions(n, r, d)
n = n**3 # now changed to represent the number of sphers
[6]:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm, colors
import biosspheres.quadratures.sphere as quadratures

big_l_c = 20
quantity_theta_points, quantity_phi_points, weights, pre_vector = quadratures.gauss_legendre_trapezoidal_2d(big_l_c)
vector = pre_vector * r
fig = plt.figure()
ax_1 = fig.add_subplot(111, projection='3d')
for s in np.arange(0,n):
    ax_1.plot_surface(
        vector[0, :, :]+center_positions[s][0],
        vector[1, :, :]+center_positions[s][1],
        vector[2, :, :]+center_positions[s][2],
        rstride=1, cstride=1)
ax_1.set_xlabel('$x$')
ax_1.set_ylabel('$y$')
ax_1.set_zlabel('$z$')
ax_1.set_aspect('equal')
plt.show()
[ ]: