def test_solver(): 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) isotropic_relax(sheet, nondim_specs) # sheet.vert_df.is_active = 1 # grad_err = solver.check_grad(sheet, geom, model) # grad_err /= sheet.vert_df.size # assert_almost_equal(grad_err, 0.0, DECIMAL) settings = { 'minimize': { 'options': { 'disp': False, 'ftol': 1e-4, 'gtol': 1e-4 }, } } res = solver.find_energy_min(sheet, geom, model, **settings) assert res['success']
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)
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
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)
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
def test_compute_energy(): h5store = '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.dimentionalize(nondim_specs) sheet.update_specs(dim_model_specs) geom.update_all(sheet) isotropic_relax(sheet, nondim_specs) Et, Ec, Ev = model.compute_energy(sheet, full_output=True) assert_almost_equal(Et.mean(), 0.02301937, decimal=DECIMAL) assert_almost_equal(Ec.mean(), 0.15260879, decimal=DECIMAL) assert_almost_equal(Ev.mean(), 0.03189850, decimal=DECIMAL) energy = model.compute_energy(sheet, full_output=False) assert_almost_equal(energy, 12.9049416411, decimal=DECIMAL) assert_almost_equal(energy/sheet.face_df.is_alive.sum(), 0.3226, decimal=2)