def test_annular(): sheet = generate_ring(10, 1, 2, R_vit=None, apical="in") PlanarGeometry.update_all(sheet) apical_length = sheet.edge_df.loc[sheet.apical_edges, "length"] basal_length = sheet.edge_df.loc[sheet.basal_edges, "length"] lateral_length = sheet.edge_df.loc[sheet.lateral_edges, "length"] assert sheet.Nf == 10 assert sheet.Ne == 40 assert sheet.Nv == 20 assert_almost_equal(apical_length.mean(), 2 * sin(np.pi / 10)) assert_almost_equal(basal_length.mean(), 4 * sin(np.pi / 10)) assert_almost_equal(lateral_length.mean(), 1) assert (np.linalg.norm(sheet.vert_df.loc[sheet.apical_verts, ["x", "y"]], axis=1).mean() == 1) assert (np.linalg.norm(sheet.vert_df.loc[sheet.basal_verts, ["x", "y"]], axis=1).mean() == 2) sheet = generate_ring(10, 1, 2, R_vit=None, apical="out") PlanarGeometry.update_all(sheet) apical_length = sheet.edge_df.loc[sheet.apical_edges, "length"] basal_length = sheet.edge_df.loc[sheet.basal_edges, "length"] lateral_length = sheet.edge_df.loc[sheet.lateral_edges, "length"] assert_almost_equal(apical_length.mean(), 4 * sin(np.pi / 10)) assert_almost_equal(basal_length.mean(), 2 * sin(np.pi / 10)) assert (np.linalg.norm(sheet.vert_df.loc[sheet.apical_verts, ["x", "y"]], axis=1).mean() == 2) assert (np.linalg.norm(sheet.vert_df.loc[sheet.basal_verts, ["x", "y"]], axis=1).mean() == 1)
def test_x_and_y_boundary_celldiv(): dsets = hdf5.load_datasets( Path(stores.stores_dir) / "planar_periodic8x8.hf5") specs = config.geometry.planar_sheet() specs["settings"]["boundaries"] = {"x": [-0.1, 8.1], "y": [-0.1, 8.1]} sheet = Sheet("periodic", dsets, specs) coords = ["x", "y"] draw_specs = config.draw.sheet_spec() PlanarGeometry.update_all(sheet) Nf = sheet.Nf # arbitrarily choose a cells on x_boundary and y_boundary to divide div_cell = sheet.face_df.index[(sheet.face_df["at_x_boundary"] == True) & (sheet.face_df["at_y_boundary"] == True)][0] daughter = cell_division(sheet, div_cell, PlanarGeometry, angle=0.6) assert sheet.validate() assert sheet.Nf == Nf + 1
def test_relaxation_convergance(): # Here we relax a pre-counstructed periodic tissue object to its "periodic equilibrium" configuration # this tissue object that is loaded is far away from equilibrium 6x6 is the "periodic" equilibrium dsets = hdf5.load_datasets(Path(stores.stores_dir) / "planar_periodic8x8.hf5") specs = config.geometry.planar_sheet() specs["settings"]["boundaries"] = {"x": [-0.1, 8.1], "y": [-0.1, 8.1]} initial_box_size = 8.2 sheet = Sheet("periodic", dsets, specs) coords = ["x", "y"] draw_specs = config.draw.sheet_spec() PlanarGeometry.update_all(sheet) solver = QSSolver(with_collisions=False, with_t1=True, with_t3=False) nondim_specs = config.dynamics.quasistatic_plane_spec() dim_model_specs = model.dimensionalize(nondim_specs) sheet.update_specs(dim_model_specs, reset=True) # epsilon is deviation of boundary between iterations epsilon = 1.0 # max_dev is the max epsilon allowed for configuration to be in equilibrium max_dev = 0.001 # i counts the number of solver iterations i = 0 # loop ends if box size variation between iterations drops 10^-3 # loaded tissue is far away from periodic equilibrium L=8 and equilibrium is reached around 6.06 while np.abs(epsilon) > max_dev: i += 1 if i == 1: previous_box_size = 0 else: previous_box_size = solution_result["x"][-1] solution_result = solver.find_energy_min( sheet, PlanarGeometry, model, periodic=True ) epsilon = solution_result["x"][-1] - previous_box_size # print(epsilon) final_box_size = ( sheet.settings["boundaries"]["x"][1] - sheet.settings["boundaries"]["x"][0] ) print("number of iterations " + str(i)) print("final box size " + str(final_box_size)) assert 6.06 - 0.1 < final_box_size < 6.06 + 0.1
def test_periodic_planar(): hdf_path = hdf5.load_datasets( os.path.join(stores_dir, "planar_periodic8x8.hf5")) specs = config.stores.planar_periodic8x8() sheet = Sheet("periodic", hdf_path, specs) PlanarGeometry.update_all(sheet) assert sheet.edge_df.length.max() < 1.0 fsx = sheet.edge_df["fx"] - sheet.edge_df["sx"] fsy = sheet.edge_df["fy"] - sheet.edge_df["sy"] lai = (fsx**2 + fsy**2)**0.5 assert lai.max() < 0.7 assert sheet.face_df.area.max() < 1.2 assert sheet.face_df.area.min() > 0.8 sheet.update_specs(config.geometry.sheet_spec()) sheet = Sheet("2.5D", sheet.datasets, sheet.specs) SheetGeometry.update_all(sheet) assert sheet.edge_df.length.max() < 1.0 fsx = sheet.edge_df["fx"] - sheet.edge_df["sx"] fsy = sheet.edge_df["fy"] - sheet.edge_df["sy"] lai = (fsx**2 + fsy**2)**0.5 assert lai.max() < 0.7 assert sheet.face_df.area.max() < 1.2 assert sheet.face_df.area.min() > 0.8
def update_all(cls, eptm): PlanarGeometry.update_all(eptm) cls.update_lumen_volume(eptm)