Exemple #1
0
M = 2  # integer factor that meshsize is refined by at each level
Lmin = 2  # minimum refinement level
Lmax = 8  # maximum refinement level
L = 7

# list of all levels considered
l_element = []
for i in range(Lmin, Lmax + 1):
    l_element.append(i)

bathy = Bathymetry()

bathy.length_x = 1250
bathy.length_y = 1000
bathy.dx = bathy.length_x / M**Lmax
bathy.dy = bathy.length_y / M**Lmax
bathy.mc_slope_test(bathy.dx, bathy.dy, 0.6, 0.15, 0.15)

# interpolation function used to generate bed on new x and y grid
interp_orig_fn = interpolate.interp2d(bathy.x, bathy.y, bathy.z)

# epsilon values - for CDF calculation this should be set to epsilon = [0.001]
epsilon = [0.001, 0.0017, 0.0025, 0.0035, 0.005, 0.006]
N0 = 500  # number of samples used in preliminary run

# set the function which builds XBeach inputs, runs XBeach and records output
build_output = bd_fns.build_xbeach_2d
no_runs = 1
no_parallel_processes = 40  # should be equal to number of cores

# directory where XBeach files will be dumped and code will run - this needs to be changed to reflect name of folder
Exemple #2
0
# directory where XBeach files will be dumped and code will run - this needs to be changed to reflect name of folder
path_stem = '/rds/general/user/mc4117/home/MLMC_Code/slope_2d_mc/1/'

variable_name = 'bed_slope_2d'  # name of uncertain variable
M = 2  # integer factor that meshsize is refined by at each level

t1 = time.time()

L_eps = 9  # fineness of grid

bathy = Bathymetry()

bathy.length_x = 1250
bathy.length_y = 1000
bathy.dx = bathy.length_x / M**L_eps
bathy.dy = bathy.length_y / M**L_eps

bathy.mc_slope_test(bathy.dx, bathy.dy, 0.6, 0.15, 0.15)

# interpolation function used to generate bed on new x and y grid
interp_orig_fn = interpolate.interp2d(bathy.x, bathy.y, bathy.z)

# run monte carlo algorithm
outputf, real_soln, file_name = mc_fn.monte_carlo_main(1000, M**L_eps,
                                                       build_output, path_stem,
                                                       sample, variable_name,
                                                       no_parallel_processes,
                                                       interp_orig_fn)

t2 = time.time()