def test_execute_division():

    sheet = Sheet('emin', *three_faces_sheet())
    geom.update_all(sheet)
    sheet.face_df['vol'] = 1.
    sheet.specs['face']['prefered_vol'] = 1.
    sheet.face_df['prefered_vol'] = 1.

    sheet.face_df['id'] = sheet.face_df.index.values
    manager = EventManager('face')
    face_id = 1
    event = (division, {
        'face_id': face_id,
        'growth_rate': 0.2,
        'critical_vol': 1.5
    })
    manager.current.append(event)
    V0 = sheet.face_df.loc[1, 'prefered_vol']
    manager.execute(sheet)
    manager.update()
    assert sheet.face_df.loc[1, 'prefered_vol'] == V0 * 1.2
    manager.execute(sheet)
    manager.update()
    assert sheet.face_df.loc[1, 'prefered_vol'] == V0 * 1.44
    sheet.face_df.loc[1, 'vol'] *= 1.6
    manager.execute(sheet)
    assert sheet.Nf == 4
def test_compute_gradient():
    h5store = os.path.join(stores_dir, "small_hexagonal.hf5")
    datasets = load_datasets(h5store, data_names=["face", "vert", "edge"])
    specs = config.geometry.cylindrical_sheet()

    sheet = Sheet("emin", datasets, specs)
    nondim_specs = config.dynamics.quasistatic_sheet_spec()
    dim_model_specs = model.dimensionalize(nondim_specs)
    sheet.update_specs(dim_model_specs)

    geom.update_all(sheet)

    sheet.edge_df["is_active"] = sheet.upcast_srce("is_active") * sheet.upcast_face(
        "is_alive"
    )

    nrj_norm_factor = sheet.specs["settings"]["nrj_norm_factor"]
    print("Norm factor: ", nrj_norm_factor)
    ((grad_t, _), (grad_c, _), (grad_v_srce, grad_v_trgt)) = model.compute_gradient(
        sheet, components=True
    )
    grad_t_norm = np.linalg.norm(grad_t, axis=0).sum() / nrj_norm_factor
    assert_almost_equal(grad_t_norm, 0.22486850242320636, decimal=DECIMAL)

    grad_c_norm = np.linalg.norm(grad_c, axis=0).sum() / nrj_norm_factor
    assert_almost_equal(grad_c_norm, 0.49692791, decimal=DECIMAL)

    grad_vs_norm = np.linalg.norm(grad_v_srce.dropna(), axis=0).sum() / nrj_norm_factor
    assert_almost_equal(grad_vs_norm, 0.30281367249952407, decimal=DECIMAL)

    grad_vt_norm = np.linalg.norm(grad_v_trgt.dropna(), axis=0).sum() / nrj_norm_factor
    assert_almost_equal(grad_vt_norm, 0.27732035134768285, decimal=DECIMAL)
def test_execute_constriction():
    h5store = os.path.join(stores_dir, 'small_hexagonal.hf5')
    datasets = load_datasets(h5store, data_names=['face', 'vert', 'edge'])
    specs = config.geometry.cylindrical_sheet()
    sheet = Sheet('emin', datasets, specs)
    geom.update_all(sheet)
    sheet.settings['constriction'] = {
        'contractile_increase': 5,
        'critical_area': 5,
        'max_traction': 10
    }
    sheet.face_df['id'] = sheet.face_df.index.values
    init_nb_cells = len(sheet.face_df)

    sheet.face_df['is_mesoderm'] = 0
    sheet.vert_df['radial_tension'] = 0
    manager = EventManager('face')
    face_id = 17
    sheet.face_df.loc[face_id, 'is_mesoderm'] = 1

    sheet.settings['constriction'].update({'face_id': face_id})
    initial_cell_event = (constriction, sheet.settings['constriction'])
    manager.current.append(initial_cell_event)
    manager.execute(sheet)
    manager.update()
    assert len(manager.current) > 0

    for i in range(20):
        manager.execute(sheet)
        manager.update()
    if len(sheet.face_df) == init_nb_cells:
        assert len(manager.current) > 0
Exemple #4
0
def test_3faces():
    datasets, specs = three_faces_sheet()
    sheet = Sheet('3faces_2D', datasets, specs)
    sgeom.update_dcoords(sheet)
    sgeom.update_length(sheet)
    np.testing.assert_allclose(sheet.edge_df['length'], 1, rtol=1e-3)

    sgeom.update_centroid(sheet)
    np.testing.assert_array_almost_equal([0.5, -1., 0.5],
                                         sheet.face_df['x'],
                                         decimal=3)

    sgeom.update_normals(sheet)
    norms = np.linalg.norm(sheet.edge_df[['nx', 'ny', 'nz']], axis=1)
    np.testing.assert_allclose(norms, 0.866, rtol=1e-3)

    sgeom.update_areas(sheet)
    np.testing.assert_allclose(sheet.face_df['area'],
                               np.sqrt(3) * 1.5,
                               rtol=1e-3)

    sgeom.update_all(sheet)
    np.testing.assert_allclose(sheet.face_df['area'],
                               np.sqrt(3) * 1.5,
                               rtol=1e-3)
Exemple #5
0
def test_type1_at_shorter():

    sheet = Sheet("emin", *three_faces_sheet())
    sheet.vert_df.loc[0, "x"] += 0.5
    geom.update_all(sheet)
    type1_at_shorter(sheet, 0, geom)
    np.all(sheet.face_df.num_sides.values == [5, 7, 5])
Exemple #6
0
def test_compute_gradient():
    h5store = 'small_hexagonal.hf5'
    datasets = load_datasets(h5store,
                             data_names=['face', 'vert', 'edge'])
    specs = config.geometry.sheet_spec()

    sheet = Sheet('emin', datasets, specs)
    nondim_specs = config.dynamics.quasistatic_sheet_spec()
    dim_model_specs = model.dimentionalize(nondim_specs)
    sheet.update_specs(dim_model_specs)

    geom.update_all(sheet)
    isotropic_relax(sheet, nondim_specs)

    nrj_norm_factor = sheet.specs['settings']['nrj_norm_factor']
    (grad_t, grad_c,
     grad_v_srce, grad_v_trgt) = model.compute_gradient(sheet,
                                                        components=True)
    grad_t_norm = np.linalg.norm(grad_t, axis=0).sum() / nrj_norm_factor
    assert_almost_equal(grad_t_norm, 0.4497370048, decimal=DECIMAL)

    grad_c_norm = np.linalg.norm(grad_c, axis=0).sum() / nrj_norm_factor
    assert_almost_equal(grad_c_norm, 0.49692791, decimal=DECIMAL)

    grad_vs_norm = np.linalg.norm(grad_v_srce.dropna(),
                                  axis=0).sum() / nrj_norm_factor
    assert_almost_equal(grad_vs_norm, 0.3028136725, decimal=DECIMAL)

    grad_vt_norm = np.linalg.norm(grad_v_trgt.dropna(),
                                  axis=0).sum() / nrj_norm_factor
    assert_almost_equal(grad_vt_norm, 0.277320351, decimal=DECIMAL)
Exemple #7
0
def test_execute_division():

    sheet = Sheet("emin", *three_faces_sheet())
    geom.update_all(sheet)
    sheet.face_df["vol"] = 1.0
    sheet.specs["face"]["prefered_vol"] = 1.0
    sheet.face_df["prefered_vol"] = 1.0

    sheet.face_df["id"] = sheet.face_df.index.values
    manager = EventManager("face")
    face_id = 1
    event = (division, {
        "face_id": face_id,
        "growth_rate": 1.2,
        "critical_vol": 1.5
    })
    manager.current.append(event)
    V0 = sheet.face_df.loc[1, "prefered_vol"]
    manager.execute(sheet)
    manager.update()
    assert sheet.face_df.loc[1, "prefered_vol"] == V0 * 1.2
    manager.execute(sheet)
    manager.update()
    assert sheet.face_df.loc[1, "prefered_vol"] == V0 * 1.44
    sheet.face_df.loc[1, "vol"] *= 1.6
    manager.execute(sheet)
    assert sheet.Nf == 4
Exemple #8
0
def test_execute_constriction():
    h5store = os.path.join(stores_dir, "small_hexagonal.hf5")
    datasets = load_datasets(h5store, data_names=["face", "vert", "edge"])
    specs = config.geometry.cylindrical_sheet()
    sheet = Sheet("emin", datasets, specs)
    geom.update_all(sheet)
    sheet.settings["constriction"] = {
        "contractile_increase": 5,
        "critical_area": 5,
        "max_traction": 10,
    }
    sheet.face_df["id"] = sheet.face_df.index.values
    init_nb_cells = len(sheet.face_df)

    sheet.face_df["is_mesoderm"] = 0
    sheet.vert_df["radial_tension"] = 0
    manager = EventManager("face")
    face_id = 17
    sheet.face_df.loc[face_id, "is_mesoderm"] = 1

    sheet.settings["constriction"].update({"face_id": face_id})
    initial_cell_event = (constriction, sheet.settings["constriction"])
    manager.current.append(initial_cell_event)
    manager.execute(sheet)
    manager.update()
    assert len(manager.current) > 0

    for i in range(20):
        manager.execute(sheet)
        manager.update()
    if len(sheet.face_df) == init_nb_cells:
        assert len(manager.current) > 0
Exemple #9
0
def test_3faces():

    datasets, specs = three_faces_sheet()
    sheet = Sheet("3faces_2D", datasets, specs)
    sgeom.update_dcoords(sheet)
    sgeom.update_length(sheet)
    np.testing.assert_allclose(sheet.edge_df["length"], 1, rtol=1e-3)

    sgeom.update_centroid(sheet)
    np.testing.assert_array_almost_equal([0.5, -1.0, 0.5],
                                         sheet.face_df["x"],
                                         decimal=3)

    sgeom.update_normals(sheet)
    norms = np.linalg.norm(sheet.edge_df[["nx", "ny", "nz"]], axis=1)
    np.testing.assert_allclose(norms, 0.866, rtol=1e-3)

    sgeom.update_areas(sheet)
    np.testing.assert_allclose(sheet.face_df["area"],
                               np.sqrt(3) * 1.5,
                               rtol=1e-3)

    sgeom.update_all(sheet)
    np.testing.assert_allclose(sheet.face_df["area"],
                               np.sqrt(3) * 1.5,
                               rtol=1e-3)
Exemple #10
0
def test_vertex_mesh():
    datasets = {}
    tri_verts = [[0, 0, 0], [1, 0, 0], [-0.5, 0.86, 1.0], [-0.5, -0.86, 1.0]]

    tri_edges = [
        [0, 1, 0, 0],
        [1, 2, 0, 0],
        [2, 0, 0, 0],
        [0, 3, 1, 0],
        [3, 1, 1, 0],
        [1, 0, 1, 0],
        [0, 2, 2, 0],
        [2, 3, 2, 0],
        [3, 0, 2, 0],
    ]

    datasets["edge"] = pd.DataFrame(data=np.array(tri_edges),
                                    columns=["srce", "trgt", "face", "cell"])
    datasets["edge"].index.name = "edge"

    datasets["face"] = pd.DataFrame(data=np.zeros((3, 3)),
                                    columns=["x", "y", "z"])
    datasets["face"].index.name = "face"

    datasets["vert"] = pd.DataFrame(data=np.array(tri_verts),
                                    columns=["x", "y", "z"])
    datasets["vert"].index.name = "vert"

    specs = config.geometry.flat_sheet()

    eptm = Epithelium("vertex_mesh", datasets, specs, coords=["x", "y", "z"])
    SheetGeometry.update_all(eptm)

    # tested method
    res_verts, res_faces, res_normals = eptm.vertex_mesh(["x", "y", "z"])
    res_xy_verts, res_xy_faces = eptm.vertex_mesh(["x", "y", "z"],
                                                  vertex_normals=False)
    res_faces = list(res_faces)

    expected_faces = [[0, 1, 2], [0, 3, 1], [0, 2, 3]]

    # floating point precision might causes issues here
    # when comparing arrays ... there seems to be
    # a built-in 1e-10 tolerance in
    # the assert_array_equal function.

    expected_normals = np.array([
        [1.911111111e-01, 9.25185854e-18, 2.866666667e-01],
        [-4.16333634e-17, 0.0, 2.866666667e-01],
        [2.866666667e-01, -1.666666667e-01, 2.866666667e-01],
        [2.866666667e-01, 1.666666667e-01, 2.866666667e-01],
    ])

    assert_array_equal(res_verts, np.array(tri_verts))
    assert all([
        res_faces[i] == expected_faces[i] for i in range(len(expected_faces))
    ])
    assert_array_equal(np.round(res_normals, decimals=6),
                       np.round(expected_normals, decimals=6))
Exemple #11
0
def test_center():

    sheet = Sheet.planar_sheet_3d('sheet', 5, 5, 1, 1)
    sheet.sanitize()
    sgeom.update_all(sheet)
    sgeom.center(sheet)
    np.testing.assert_allclose(sheet.vert_df[sheet.coords].mean(axis=0),
                               [0, 0, 0],
                               atol=1e-7)
Exemple #12
0
def test_t1_transition():

    h5store = os.path.join(stores_dir, "small_hexagonal.hf5")
    datasets = load_datasets(h5store, data_names=["face", "vert", "edge"])
    specs = cylindrical_sheet()
    sheet = Sheet("emin", datasets, specs)
    geom.update_all(sheet)
    face = sheet.edge_df.loc[84, "face"]
    type1_transition(sheet, 84)
    assert sheet.edge_df.loc[84, "face"] != face
Exemple #13
0
def test_split_vert():

    datasets, specs = three_faces_sheet()
    sheet = Sheet("3cells_2D", datasets, specs)
    geom.update_all(sheet)

    split_vert(sheet, 0, multiplier=10)
    geom.update_all(sheet)
    assert sheet.Nv == 14
    assert sheet.Ne == 20
Exemple #14
0
def test_t1_transition():

    h5store = 'small_hexagonal.hf5'
    datasets = load_datasets(h5store, data_names=['face', 'vert', 'edge'])
    specs = sheet_spec()
    sheet = Sheet('emin', datasets, specs)
    geom.update_all(sheet)
    face = sheet.edge_df.loc[84, 'face']
    type1_transition(sheet, 84)
    assert sheet.edge_df.loc[84, 'face'] != face
Exemple #15
0
def test_execute_apoptosis():
    h5store = os.path.join(stores_dir, "small_hexagonal.hf5")
    datasets = load_datasets(h5store, data_names=["face", "vert", "edge"])
    specs = config.geometry.cylindrical_sheet()
    sheet = Sheet("emin", datasets, specs)
    geom.update_all(sheet)
    sheet.settings["apoptosis"] = {
        "contractile_increase": 2.0,
        "critical_area": 0.1
    }
    sheet.face_df["id"] = sheet.face_df.index.values
    init_nb_faces = len(sheet.face_df)
    manager = EventManager("face")
    face_id = 17
    face_area = sheet.face_df.loc[face_id, "area"]
    initial_nbsides = sheet.face_df.loc[face_id, "num_sides"]

    sheet.settings["apoptosis"].update({"face_id": face_id})
    initial_cell_event = (apoptosis, sheet.settings["apoptosis"])

    manager.current.append(initial_cell_event)
    manager.execute(sheet)
    manager.update()
    assert len(manager.current) > 0
    manager.execute(sheet)
    manager.update()

    sheet.settings["apoptosis"] = {
        "contractile_increase": 2.0,
        "critical_area": 2 * face_area,
    }
    manager.current.clear()
    sheet.settings["apoptosis"].update({"face_id": face_id})
    modified_cell_event = (apoptosis, sheet.settings["apoptosis"])

    manager.current.append(modified_cell_event)
    manager.execute(sheet)
    manager.update()
    next_nbsides = sheet.face_df.loc[sheet.idx_lookup(face_id, "face"),
                                     "num_sides"]
    i = 1
    while next_nbsides > 4:
        assert next_nbsides == initial_nbsides - i
        assert len(manager.current) > 0
        i = i + 1
        manager.execute(sheet)
        manager.update()
        next_nbsides = sheet.face_df.loc[sheet.idx_lookup(face_id, "face"),
                                         "num_sides"]
        if i > 20:
            raise RecursionError
    manager.execute(sheet)
    manager.update()
    assert len(sheet.face_df) < init_nb_faces
def test_execute_apoptosis():
    h5store = os.path.join(stores_dir, 'small_hexagonal.hf5')
    datasets = load_datasets(h5store, data_names=['face', 'vert', 'edge'])
    specs = config.geometry.cylindrical_sheet()
    sheet = Sheet('emin', datasets, specs)
    geom.update_all(sheet)
    sheet.settings['apoptosis'] = {
        'contractile_increase': 2.0,
        'critical_area': 0.1
    }
    sheet.face_df['id'] = sheet.face_df.index.values
    init_nb_faces = len(sheet.face_df)
    manager = EventManager('face')
    face_id = 17
    face_area = sheet.face_df.loc[face_id, 'area']
    initial_nbsides = sheet.face_df.loc[face_id, 'num_sides']

    sheet.settings['apoptosis'].update({'face_id': face_id})
    initial_cell_event = (apoptosis, sheet.settings['apoptosis'])

    manager.current.append(initial_cell_event)
    manager.execute(sheet)
    manager.update()
    assert len(manager.current) > 0
    manager.execute(sheet)
    manager.update()

    sheet.settings['apoptosis'] = {
        'contractile_increase': 2.0,
        'critical_area': 2 * face_area
    }
    manager.current.clear()
    sheet.settings['apoptosis'].update({'face_id': face_id})
    modified_cell_event = (apoptosis, sheet.settings['apoptosis'])

    manager.current.append(modified_cell_event)
    manager.execute(sheet)
    manager.update()
    next_nbsides = sheet.face_df.loc[sheet.idx_lookup(face_id, 'face'),
                                     'num_sides']
    i = 1
    while next_nbsides > 4:
        assert next_nbsides == initial_nbsides - i
        assert len(manager.current) > 0
        i = i + 1
        manager.execute(sheet)
        manager.update()
        next_nbsides = sheet.face_df.loc[sheet.idx_lookup(face_id, 'face'),
                                         'num_sides']
    manager.execute(sheet)
    manager.update()
    assert len(sheet.face_df) < init_nb_faces
Exemple #17
0
def test_face_rotation():

    h5store = os.path.join(stores_dir, "small_hexagonal.hf5")
    datasets = load_datasets(h5store, data_names=["face", "vert", "edge"])
    specs = config.geometry.cylindrical_sheet()

    sheet = Sheet("emin", datasets, specs)
    sgeom.update_all(sheet)
    face = 17
    normal = sheet.edge_df[sheet.edge_df["face"] == face][sheet.ncoords].mean()
    rot = sgeom.face_rotation(sheet, face, 0)
    rotated = np.dot(rot, normal)
    np.testing.assert_allclose(rotated[:2], np.zeros(2), atol=1e-7)
Exemple #18
0
def test_face_rotation():

    h5store = 'small_hexagonal.hf5'
    datasets = load_datasets(h5store, data_names=['face', 'vert', 'edge'])
    specs = config.geometry.sheet_spec()

    sheet = Sheet('emin', datasets, specs)
    sgeom.update_all(sheet)
    face = 17
    normal = sheet.edge_df[sheet.edge_df['face'] == face][sheet.ncoords].mean()
    rot = sgeom.face_rotation(sheet, face, 0)
    rotated = np.dot(rot, normal)
    np.testing.assert_allclose(rotated[:2], np.zeros(2), atol=1e-7)
Exemple #19
0
def test_division():

    h5store = 'small_hexagonal.hf5'
    datasets = load_datasets(h5store, data_names=['face', 'vert', 'edge'])
    specs = sheet_spec()
    sheet = Sheet('emin', datasets, specs)
    geom.update_all(sheet)

    Nf, Ne, Nv = sheet.Nf, sheet.Ne, sheet.Nv

    cell_division(sheet, 17, geom)

    assert sheet.Nf - Nf == 1
    assert sheet.Nv - Nv == 2
    assert sheet.Ne - Ne == 6
Exemple #20
0
def test_division():

    h5store = os.path.join(stores_dir, "small_hexagonal.hf5")

    datasets = load_datasets(h5store, data_names=["face", "vert", "edge"])
    specs = cylindrical_sheet()
    sheet = Sheet("emin", datasets, specs)
    geom.update_all(sheet)

    Nf, Ne, Nv = sheet.Nf, sheet.Ne, sheet.Nv

    cell_division(sheet, 17, geom)

    assert sheet.Nf - Nf == 1
    assert sheet.Nv - Nv == 2
    assert sheet.Ne - Ne == 6
Exemple #21
0
def test_check_tri_faces():
    h5store = os.path.join(stores_dir, "small_hexagonal.hf5")
    datasets = load_datasets(h5store, data_names=["face", "vert", "edge"])
    specs = config.geometry.cylindrical_sheet()
    sheet = Sheet("emin", datasets, specs)
    initial_nb_cells = len(sheet.face_df)
    nb_tri_cells = len(sheet.face_df[(sheet.face_df["num_sides"] < 4)])
    geom.update_all(sheet)
    sheet.face_df["id"] = sheet.face_df.index.values
    manager = EventManager("face")
    manager.current.append((check_tri_faces, {}))
    manager.execute(sheet)
    manager.update()

    manager.execute(sheet)
    manager.update()
    assert len(sheet.face_df) == initial_nb_cells - nb_tri_cells
def test_execute_contraction():
    sheet = Sheet('emin', *three_faces_sheet())
    geom.update_all(sheet)
    sheet.face_df['contractility'] = 1.12

    sheet.face_df['id'] = sheet.face_df.index.values
    manager = EventManager('face')
    face_id = 1
    event = (contraction, {
        'face_id': face_id,
        'contractile_increase': 0.2,
        'critical_area': 1e-2
    })
    manager.current.append(event)
    manager.execute(sheet)
    manager.update()
    assert sheet.face_df.loc[face_id, 'contractility'] == 1.32
Exemple #23
0
def test_type1_transition():
    sheet = Sheet("emin", *three_faces_sheet())
    geom.update_all(sheet)

    sheet.face_df["id"] = sheet.face_df.index.values
    manager = EventManager("face")
    face_id = 1
    nb_neighbors_start = len(sheet.edge_df[sheet.edge_df["face"] == face_id])
    edge_to_modify = sheet.edge_df[sheet.edge_df["face"] == face_id].index[0]
    sheet.edge_df.loc[edge_to_modify, "length"] = 0.2
    event = (type1_transition, {"face_id": face_id, "critical_length": 0.3})
    manager.current.append(event)
    manager.execute(sheet)
    manager.update()

    nb_neighbors_end = len(sheet.edge_df[sheet.edge_df["face"] == face_id])

    assert nb_neighbors_end == nb_neighbors_start - 1
Exemple #24
0
def test_rotations():
    h5store = os.path.join(stores_dir, "small_hexagonal.hf5")
    datasets = load_datasets(h5store, data_names=["face", "vert", "edge"])
    specs = config.geometry.cylindrical_sheet()

    sheet = Sheet("emin", datasets, specs)
    sgeom.update_all(sheet)
    sheet.sanitize()
    sgeom.update_all(sheet)
    sgeom.center(sheet)
    assert sgeom.face_rotations(sheet, method='normal',
                                output_as='edge').shape[0] == sheet.Ne
    assert sgeom.face_rotations(sheet, method='normal',
                                output_as='face').shape[0] == sheet.Nf
    assert sgeom.face_rotations(sheet, method='svd',
                                output_as='edge').shape[0] == sheet.Ne
    assert sgeom.face_rotations(sheet, method='svd',
                                output_as='face').shape[0] == sheet.Nf
def test_type1_transition():
    sheet = Sheet('emin', *three_faces_sheet())
    geom.update_all(sheet)

    sheet.face_df['id'] = sheet.face_df.index.values
    manager = EventManager('face')
    face_id = 1
    nb_neighbors_start = len(sheet.edge_df[sheet.edge_df['face'] == face_id])
    edge_to_modify = sheet.edge_df[sheet.edge_df['face'] == face_id].index[0]
    sheet.edge_df.loc[edge_to_modify, 'length'] = 0.2
    event = (type1_transition, {'face_id': face_id, 'critical_length': 0.3})
    manager.current.append(event)
    manager.execute(sheet)
    manager.update()

    nb_neighbors_end = len(sheet.edge_df[sheet.edge_df['face'] == face_id])

    assert nb_neighbors_end == nb_neighbors_start - 1
Exemple #26
0
def test_t1_at_border():
    datasets, specs = three_faces_sheet()
    sheet = Sheet("3cells_2D", datasets, specs)
    geom.update_all(sheet)
    # double half edge with no right cell (aka cell c)
    type1_transition(sheet, 0, epsilon=0.4)
    sheet.reset_index()
    assert sheet.validate()
    # single half edge with no bottom cell (aka cell d)
    geom.update_all(sheet)
    type1_transition(sheet, 16, epsilon=0.5)
    geom.update_all(sheet)
    assert sheet.validate()
    # single half edge with no left cell (aka cell a)
    geom.update_all(sheet)
    type1_transition(sheet, 17, epsilon=0.5)
    geom.update_all(sheet)
    assert sheet.validate()
def test_compute_energy():
    h5store = os.path.join(stores_dir, "small_hexagonal.hf5")
    datasets = load_datasets(h5store, data_names=["face", "vert", "edge"])
    specs = config.geometry.cylindrical_sheet()

    sheet = Sheet("emin", datasets, specs)
    nondim_specs = config.dynamics.quasistatic_sheet_spec()
    dim_model_specs = model.dimensionalize(nondim_specs)
    sheet.update_specs(dim_model_specs, reset=True)

    geom.update_all(sheet)

    Et, Ec, Ev = model.compute_energy(sheet, full_output=True)
    assert_almost_equal(Et.mean(), 0.02458566846202479, decimal=DECIMAL)
    assert_almost_equal(Ec.mean(), 0.12093674686179141, decimal=DECIMAL)
    assert_almost_equal(Ev.mean(), 0.08788417666060594, decimal=DECIMAL)

    energy = model.compute_energy(sheet, full_output=False)
    assert_almost_equal(energy, 14.254513236339077, decimal=DECIMAL)
Exemple #28
0
def test_compute_energy():
    h5store = os.path.join(stores_dir, "small_hexagonal.hf5")
    datasets = load_datasets(h5store, data_names=["face", "vert", "edge"])
    specs = config.geometry.cylindrical_sheet()

    sheet = Sheet("emin", datasets, specs)
    nondim_specs = config.dynamics.quasistatic_sheet_spec()
    dim_model_specs = model.dimensionalize(nondim_specs)
    sheet.update_specs(dim_model_specs, reset=True)

    geom.update_all(sheet)

    Et, Ec, Ev = model.compute_energy(sheet, full_output=True)
    assert_almost_equal(Et.mean(), 0.02458566846202479, decimal=DECIMAL)
    assert_almost_equal(Ec.mean(), 0.08638339061549484, decimal=DECIMAL)
    assert_almost_equal(Ev.mean(), 0.06277441190064434, decimal=DECIMAL)

    energy = model.compute_energy(sheet, full_output=False)
    assert_almost_equal(energy, 15.040138762574534, decimal=DECIMAL)
Exemple #29
0
def test_execute_contraction():
    sheet = Sheet("emin", *three_faces_sheet())
    geom.update_all(sheet)
    sheet.face_df["contractility"] = 1.12

    sheet.face_df["id"] = sheet.face_df.index.values
    manager = EventManager("face")
    face_id = 1
    event = (
        contraction,
        {
            "face_id": face_id,
            "contractile_increase": 0.2,
            "critical_area": 1e-2
        },
    )
    manager.current.append(event)
    manager.execute(sheet)
    manager.update()
    assert sheet.face_df.loc[face_id, "contractility"] == 1.32
Exemple #30
0
def test_extra_indices_hexabug():
    # GH #192

    with pytest.raises(AssertionError):
        h5store = os.path.join(stores_dir, "small_hexagonal_snaped.hf5")

        datasets = load_datasets(h5store)
        specs = config.geometry.cylindrical_sheet()
        sheet = Sheet("emin", datasets, specs)

        SheetGeometry.update_all(sheet)
        sheet.sanitize()
        sheet.get_extra_indices()

    h5store = os.path.join(stores_dir, "small_hexagonal.hf5")

    datasets = load_datasets(h5store)
    specs = config.geometry.cylindrical_sheet()
    sheet = Sheet("emin", datasets, specs)

    SheetGeometry.update_all(sheet)
    sheet.sanitize()
    sheet.get_extra_indices()