def pf_to_n(L, pf, R): """Returns the number of non-intersecting spheres required to achieve as close to a given packing fraction as possible, along with the actual achieved packing fraction. for a number of non-intersecting spheres. Parameters ---------- L: float array, shape (d,) System lengths. pf: float Fraction of space to be occupied by the spheres. R: float Sphere radius. Returns ------- n: integer Number of spheres required to achieve a packing fraction `pf_actual` pf_actual: Fraction of space occupied by `n` spheres. This is the closest possible fraction achievable to `pf`. """ dim = L.shape[0] n = int(round(pf * np.product(L) / sphere_volume(R, dim))) pf_actual = n_to_pf(L, n, R) return n, pf_actual
def n_to_pf(L, n, R): """Returns the packing fraction for a number of non-intersecting spheres. Parameters ---------- L: float array, shape (d,) System lengths. n: integer Number of spheres. R: float Sphere radius. Returns ------- pf: float Fraction of space occupied by the spheres. """ dim = L.shape[0] return (n * sphere_volume(R=R, n=dim)) / np.product(L)
def V_1(self): return sphere_volume(self.R, self.dim)
def vp_to_n(vp, R): return ((vp / 100.0) * geom.sphere_volume(R, 3)) / dataset.Dataset.V_p
def n_to_vp(n, R): return 100.0 * n * dataset.Dataset.V_p / geom.sphere_volume(R, 3)
def volume_sphere(self): return geom.sphere_volume(self.R, self.dim)