Esempio n. 1
0
        dE = E_after - E_before
        if not initial_step and dE > 0.0:
            dt.chop()
            converged = False

    initial_step = False

    # Update time with final dt value
    t += dt.get()

    if tstep % 1 == 0:
        ts.dump(t)

        # Assigning timestep size according to grad_mu_max:
        grad_mu = ts.get_function("abs_grad_mu")
        grad_mu_max = mpi_max(grad_mu.vector().get_local())
        dt_prev = dt.get()
        dt.set(min(0.25/grad_mu_max, T-t))
        info_blue("dt = {}".format(dt.get()))

        ts.dump_stats(t,
                      [grad_mu_max, dt_prev, dt.get(),
                       float(h.values()),
                       Eout_0, Eout_2,
                       Eout_0 + Eout_2, float(tau.values()),
                       dE],
                      "data")

    if tstep % parameters["checkpoint_intv"] == 0 or t >= T:
        save_checkpoint(tstep, t, geo_map.ref_mesh,
                        u_, u_1, ts.folder, parameters)
Esempio n. 2
0
              (tau / 2) * K * psi_**2 + (1 / 4) * K * psi_**4)
ts.add_field(E_0, "E_0")
ts.add_field(E_2, "E_2")
ts.add_field(df.sqrt(geo_map.gab[i, j] * mu_.dx(i) * mu_.dx(j)), "abs_grad_mu")

# Step in time
ts.dump(tstep)

initial_step = bool(parameters["restart_folder"] is None)
t_prev = t
while t < T:
    tstep += 1
    info_cyan("tstep = {}, time = {}".format(tstep, t))

    # Print max difference since last timestep:
    dumax = mpi_max(abs(u_.vector().get_local() - u_1.vector().get_local()))
    info_blue("max(u_ - u_1) = {}".format(dumax))

    u_1.assign(u_)

    converged = False
    while not converged:
        if parameters["anneal"]:
            tau.assign(
                anneal_func(t + dt.get(), parameters["tau"],
                            parameters["tau_ramp"], parameters["t_ramp"]))

        u_.assign(u_1)
        Eout_0 = df.assemble(geo_map.form(E_0))
        Eout_2 = df.assemble(geo_map.form(E_2))
        E_before = Eout_0 + Eout_2