Skip to content

bump in Burger's equation's solution #10

Open
@feiyu-chen96

Description

@feiyu-chen96

When solving Burger's equation, a ' bump' always appear in the residual of the solution. The cause is unknown.

def test_burgers():

    nu = 1
    a = 2  # a parameter for the special case
    T = 0.1

    burgers = lambda u, x, t: diff(u, t) + u * diff(u, x) - nu * diff(u, x, order=2)

    ibvp = IBVP1D(
        x_min=0, x_min_val=lambda t: 0,
        x_max=1, x_max_val=lambda t: 0,
        t_min=0, t_min_val=lambda x: 2 * nu * np.pi * torch.sin(np.pi * x) / (a + torch.cos(np.pi * x))
    )
    net = FCNN(n_input_units=2, n_hidden_units=32, n_hidden_layers=1)

    solution_neural_net_burgers, _ = solve2D(
        pde=burgers, condition=ibvp, xy_min=[0, 0], xy_max=[1, T],
        net=net, max_epochs=300,
        train_generator=ExampleGenerator2D([50, 50], [0, 0], [1, T], method='equally-spaced-noisy'),
        batch_size=64,
        monitor=Monitor2D(check_every=10, xy_min=[0, 0], xy_max=[1, T])
    )

    def solution_analytical_burgers(x, t):
        numer = 2 * nu * np.pi * np.exp(-np.pi ** 2 * nu * t) * np.sin(np.pi * x)
        denom = a + np.exp(-np.pi ** 2 * nu * t) * np.cos(np.pi * x)
        return numer / denom

    xs = np.linspace(0, 1, 101)
    ts = np.linspace(0, T, 101)
    xx, tt = np.meshgrid(xs, ts)
    make_animation(solution_neural_net_burgers, xs, ts) # test animation
    sol_ana = solution_analytical_burgers(xx, tt)
    sol_net = solution_neural_net_burgers(xx, tt, as_type='np')
    assert isclose(sol_net, sol_ana, atol=0.1).all()
    print('Burgers test passed.')

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions