예제 #1
0
def u_0_function(x, jump=True):
    if jump:
        return 1. * (x <= 0.25)
    return 0.5 * (1.0 +
                  np.cos(2.0 * np.pi * x)) * (0.0 <= x <= 0.5) + 0. * (x > 0.5)


grid = create_uniform_grid(GLOBAL_SPACE_GRID_SIZE)

space_time_grid = perform_tent_pitching(grid,
                                        T_MAX,
                                        characteristic_speed,
                                        n_max=1000)

lambda_ = LOCAL_TIME_GRID_SIZE / LOCAL_SPACE_GRID_SIZE
numerical_flux = LaxFriedrichsFlux(linear_transport_flux,
                                   linear_transport_flux_derivative, lambda_)

discretization = DiscontinuousGalerkin(numerical_flux, inverse_transformation,
                                       LOCAL_SPACE_GRID_SIZE)

grid_operator = GridOperator(space_time_grid,
                             discretization,
                             DGFunction,
                             u_0_function,
                             TimeStepperType=RungeKutta4,
                             local_space_grid_size=LOCAL_SPACE_GRID_SIZE,
                             local_time_grid_size=LOCAL_TIME_GRID_SIZE)

fom = SpacetimeModel(grid_operator, inverse_transformation, n_x=N_X, n_t=N_T)

parameters = []
예제 #2
0
def inverse_transformation(u, phi_2, phi_2_dt, phi_2_dx, mu=1.):
    return 2 * u / (1 + np.sqrt(1 - 2 * u * phi_2_dx * mu))


def u_0_function(x, jump=False):
    if jump:
        return 1. * (x <= 0.25)
    return 0.5 * (1.0 + np.cos(2.0 * np.pi * x)) * (0.0 <= x <= 0.5) + 0. * (x > 0.5)


grid = create_uniform_grid(GLOBAL_SPACE_GRID_SIZE)

space_time_grid = perform_tent_pitching(grid, T_MAX, characteristic_speed, n_max=1000)

lambda_ = LOCAL_TIME_GRID_SIZE / LOCAL_SPACE_GRID_SIZE
numerical_flux = LaxFriedrichsFlux(burgers_flux, burgers_flux_derivative, lambda_)

discretization = DiscontinuousGalerkin(numerical_flux, inverse_transformation,
                                       LOCAL_SPACE_GRID_SIZE)

grid_operator = GridOperator(space_time_grid, discretization, DGFunction, u_0_function,
                             TimeStepperType=RungeKutta4,
                             local_space_grid_size=LOCAL_SPACE_GRID_SIZE,
                             local_time_grid_size=LOCAL_TIME_GRID_SIZE)

fom = SpacetimeModel(grid_operator, inverse_transformation, n_x=N_X, n_t=N_T)

parameters = []
reference_parameter = 1.

gs_smoothing_params = {'alpha': 100., 'exponent': 3}