dom, dom1, dom2, boundary_neumann, boundary_dirichlet = des.setup_domain()
 # ----------------------------------------------------------------------
 #                   STEP 2: SETUP MODEL
 # ----------------------------------------------------------------------
 mat = md.EnergyModel('neohookean', 3, cf.E, cf.nu)
 dem = DeepEnergyMethod([cf.D_in, cf.H, cf.D_out], 'simpson', mat, 3)
 # ----------------------------------------------------------------------
 #                   STEP 3: TRAINING MODEL
 # ----------------------------------------------------------------------
 start_time = time.time()
 cf.iteration = 25
 cf.filename_out = "./output/dem/NeoHook_3Layer_lr0p5_mesh10x10x60-30x10x10_iter25_simp"
 dem.train_model(dom1, dom2, boundary_neumann, boundary_dirichlet,
                 cf.iteration, cf.lr, cf.dxdydz1, cf.shape1, cf.dxdydz2,
                 cf.shape2, cf.dxdy, cf.shape3)
 end_time = time.time() - start_time
 print("End time: %.5f" % end_time)
 # Plot the vertical structure
 x, y, z, datatest = des.get_datatest()
 U, S11, S12, S13, S22, S23, S33, E11, E12, E13, E22, E23, E33, SVonMises, F11, F12, F13, F21, F22, F23, F31, F32, F33 = dem.evaluate_model(
     x, y, z)
 util.write_vtk_v2(cf.filename_out + "_part%d" % 1, x, y, z, U, S11, S12,
                   S13, S22, S23, S33, E11, E12, E13, E22, E23, E33,
                   SVonMises)
 # Plot the horizontal structure
 x, y, z, datatest = des.get_datatest2()
 U, S11, S12, S13, S22, S23, S33, E11, E12, E13, E22, E23, E33, SVonMises, F11, F12, F13, F21, F22, F23, F31, F32, F33 = dem.evaluate_model(
     x, y, z)
 util.write_vtk_v2(cf.filename_out + "_part%d" % 2, x, y, z, U, S11, S12,
                   S13, S22, S23, S33, E11, E12, E13, E22, E23, E33,
                   SVonMises)
    x, y, z, datatest = des.get_datatest()
    # ----------------------------------------------------------------------
    #                   STEP 2: SETUP MODEL
    # ----------------------------------------------------------------------
    mat = md.EnergyModel('neohookean', 3, cf.E, cf.nu)
    dem = DeepEnergyMethod([cf.D_in, cf.H, cf.D_out], 'simpson', mat, 3)
    # ----------------------------------------------------------------------
    #                   STEP 3: TRAINING MODEL
    # ----------------------------------------------------------------------
    start_time = time.time()
    cf.iteration = 25
    cf.filename_out = "./output/dem/NeoHook_3Layer_lr0p5_mesh41x41x41_iter25_simp"
    body_force = cf.np.ones(dom.shape) * cf.np.array(
        [cf.body_force_x, cf.body_force_y, cf.body_force_z])
    dem.train_model(cf.shape, cf.dxdydz, dom, body_force, boundary_neumann,
                    boundary_dirichlet, cf.iteration, cf.lr)
    end_time = time.time() - start_time
    print("End time: %.5f" % end_time)
    U, S11, S12, S13, S22, S23, S33, E11, E12, E13, E22, E23, E33, SVonMises, F11, F12, F13, F21, F22, F23, F31, F32, F33 = dem.evaluate_model(
        x, y, z)
    util.write_vtk_v2(cf.filename_out, x, y, z, U, S11, S12, S13, S22, S23,
                      S33, E11, E12, E13, E22, E23, E33, SVonMises)
    surUx, surUy, surUz = U
    L2norm = util.getL2norm(surUx, surUy, surUz, len(x), len(y), len(z),
                            x[1] - x[0], y[1] - y[0], z[1] - z[0])
    H10norm = util.getH10norm(F11, F12, F13, F21, F22, F23, F31, F32, F33,
                              len(x), len(y), len(z), x[1] - x[0], y[1] - y[0],
                              z[1] - z[0])
    print("L2 norm = %.10f" % L2norm)
    print("H10 norm = %.10f" % H10norm)
Ejemplo n.º 3
0
    # ----------------------------------------------------------------------
    dom, boundary_neumann, boundary_dirichlet = des.setup_domain()
    x, y, datatest = des.get_datatest()
    # ----------------------------------------------------------------------
    #                   STEP 2: SETUP MODEL
    # ----------------------------------------------------------------------
    mat = md.EnergyModel('neohookean', 2, cf.E, cf.nu)
    dem = DeepEnergyMethod([cf.D_in, cf.H, cf.D_out], 'trapezoidal', mat, 2)
    # ----------------------------------------------------------------------
    #                   STEP 3: TRAINING MODEL
    # ----------------------------------------------------------------------
    start_time = time.time()
    shape = [cf.Nx, cf.Ny]
    dxdy = [cf.hx, cf.hy]
    cf.iteration = 30
    cf.filename_out = "./output/dem/NeoHook_3Layer_mesh40x10_iter30_trap"
    dem.train_model(shape, dxdy, dom, boundary_neumann, boundary_dirichlet,
                    cf.iteration, cf.lr)
    end_time = time.time() - start_time
    print("End time: %.5f" % end_time)
    z = np.array([0])
    U, S11, S12, S13, S22, S23, S33, E11, E12, E13, E22, E23, E33, SVonMises, F11, F12, F21, F22 = dem.evaluate_model(
        x, y, z)
    util.write_vtk_v2(cf.filename_out, x, y, z, U, S11, S12, S13, S22, S23,
                      S33, E11, E12, E13, E22, E23, E33, SVonMises)
    surUx, surUy, surUz = U
    L2norm = util.getL2norm2D(surUx, surUy, cf.Nx, cf.Ny, cf.hx, cf.hy)
    H10norm = util.getH10norm2D(F11, F12, F21, F22, cf.Nx, cf.Ny, cf.hx, cf.hy)
    print("L2 norm = %.10f" % L2norm)
    print("H10 norm = %.10f" % H10norm)