def charged_nucleation_in_2D(writer,
                             args,
                             R=30,
                             D=25,
                             weights=(0, -10, -8, 8)):
    dx = 2 * R / args.height
    x = (np.arange(args.width) - args.width // 2) * dx
    y = (np.arange(args.height) - args.height // 2) * dx
    x, y = np.meshgrid(x, y, indexing='ij')

    def source_G(t):
        amount = np.exp(-0.5 * (t - 5)**2)
        return (np.exp(-0.5 *
                       ((x - D)**2 + y * y)) * weights[0] + np.exp(-0.5 * (
                           (x + D)**2 + y * y)) * weights[1]) * amount

    def source_X(t):
        amount = np.exp(-0.5 * (t - 5)**2)
        return (np.exp(-0.5 *
                       ((x - D)**2 + y * y)) * weights[2] + np.exp(-0.5 * (
                           (x + D)**2 + y * y)) * weights[3]) * amount

    source_functions = {
        'G': source_G,
        'X': source_X,
    }

    noise_scale = 1e-4
    model_g = ModelG(
        bl_noise(x.shape) * noise_scale,
        bl_noise(x.shape) * noise_scale,
        bl_noise(x.shape) * noise_scale,
        dx,
        dt=args.dt,
        params=args.model_params,
        source_functions=source_functions,
    )

    print("Rendering 'Charged nucleation in 2D'")
    print("Lattice constant dx = {}, time step dt = {}".format(
        model_g.dx, model_g.dt))
    min_G = -4.672736908320116
    max_G = 0.028719261862332906
    min_X = -3.8935243721220334
    max_X = 1.2854028081816122
    min_Y = -0.7454193158963579
    max_Y = 4.20524950766914
    for n in progressbar.progressbar(range(args.num_frames)):
        model_g.step()
        if n % args.oversampling == 0:
            rgb = [
                6 * (-model_g.G + max_G) / (max_G - min_G),
                5 * (model_g.Y - min_Y) / (max_Y - min_Y),
                0.7 * (model_g.X - min_X) / (max_X - min_X),
            ]
            zero_line = 1 - tf.exp(-600 * model_g.Y**2)
            frame = make_video_frame([c * zero_line for c in rgb])
            writer.append_data(frame)
Exemplo n.º 2
0
def soliton_in_g_well_2D(writer, args, R=25, D=15):
    dx = 2 * R / args.height
    x = (np.arange(args.width) - args.width // 2) * dx
    y = (np.arange(args.height) - args.height // 2) * dx
    x, y = np.meshgrid(x, y, indexing='ij')

    def source_G(t):
        nucleator = -np.exp(-0.5 * (t - 5)**2)
        #potential = 0.015 * (np.tanh(t-25) + 1)
        #potential = 0.0003 * (np.tanh(t-25) + 1)   # gradient = (1+np.tanh(t-30)) * 0.0003 # see above

        #u = x / R
        #u = x/10 - 5  # see: "soliton_in_g_well_2D___1_seed__gradient_1__2a.mp4"
        #u = x/15 # see: "soliton_in_g_well_2D___1_seed__gradient_2__2b.mp4"
        #u = x/25
        return (
            #np.exp(-0.5*((x-D)**2+y*y)) * nucleator +
            #(u*u - 1) * potential
            np.exp(-0.5 * ((x)**2 + y * y)) * nucleator  #+ (x+8) * potential
            #(u*u - 1) * potential #+ (x+8) * gradient
        )

    source_functions = {
        'G': source_G,
    }

    noise_scale = 1e-4
    model_g = ModelG(
        bl_noise(x.shape) * noise_scale,
        bl_noise(x.shape) * noise_scale,
        bl_noise(x.shape) * noise_scale,
        dx,
        dt=args.dt,
        params=args.model_params,
        source_functions=source_functions,
    )

    print("Rendering 'Soliton in G-well in 2D'")
    print("Lattice constant dx = {}, time step dt = {}".format(
        model_g.dx, model_g.dt))
    G_scale = 0.02
    X_scale = 0.25
    Y_scale = 0.5
    for n in progressbar.progressbar(range(args.num_frames)):
        model_g.step()
        if n % args.oversampling == 0:
            rgb = [
                (G_scale * 0.5 - model_g.G) / G_scale,
                (model_g.Y - Y_scale * 0.5) / Y_scale,
                (model_g.X - X_scale * 0.5) / X_scale,
            ]
            zero_line = 1 - tf.exp(-600 * model_g.Y**2)
            frame = make_video_frame([c * zero_line for c in rgb])
            writer.append_data(frame)
Exemplo n.º 3
0
def random_1D_fields():
    x = linspace(-20, 20, 512)
    dx = x[1] - x[0]
    noise_scale = 1.0

    fig, axs = subplots(2, 3)
    for ax_ in axs:
        for ax in ax_:
            while True:
                params = {
                    "A": rand() * 20,
                    "B": rand() * 20,
                    "k2": rand() * 2,
                    "k-2": rand() * 2,
                    "k5": rand() * 2,
                    "Dx": rand() * 4,
                    "Dy": rand() * 4,
                }
                model_g = ModelG(bl_noise(x.shape) * noise_scale,
                                 bl_noise(x.shape) * noise_scale,
                                 bl_noise(x.shape) * noise_scale,
                                 dx,
                                 params=params)

                while model_g.t < 20:
                    model_g.step()
                    if rand() < 0.05:
                        G, X, Y = model_g.numpy()
                        if abs(X).max() >= 100:
                            break

                G, X, Y = model_g.numpy()
                if abs(X).max() < 100:
                    break
                print("Rejected", params)

            print("Done", params)

            G /= abs(G).max()
            X /= abs(X).max()
            Y /= abs(Y).max()

            ax.plot(x, G)
            ax.plot(x, X)
            ax.plot(x, Y)
    show()