def main(): number_of_grid_points = 64 name_of_the_code = 'athena' model = CalculateLinearWave1D( number_of_grid_points = number_of_grid_points, number_of_workers = 1, name_of_the_code = name_of_the_code, amplitude = 0.1 | speed, vflow_factor = 1.0, grid_length = 1.0 | length, number_of_steps = 5 ) if not IS_PLOT_AVAILABLE: return grids = model.get_solution_at_time(1.0 | time) rho0 = model.start_grids[0].rho[...,...,0].value_in(density) rho = grids[0].rho[...,...,0].value_in(density) drho = rho - rho0 print drho.sum(), rho[0][0], rho0[0][0], drho[0][0] x = grids[0].x[...,...,0].value_in(length) y = grids[0].y[...,...,0].value_in(length) figure = pyplot.figure(figsize=(10,10)) plot = figure.add_subplot(1,1,1, projection='3d') plot.plot_surface(x, y, drho) plot.plot_surface(x, y, rho) figure.savefig('kelvin_helmholtz_{0}_{1}.png'.format(name_of_the_code, number_of_grid_points)) pyplot.show()
def main(): number_of_grid_points = 64 name_of_the_code = 'athena' model = CalculateLinearWave1D(number_of_grid_points=number_of_grid_points, number_of_workers=1, name_of_the_code=name_of_the_code, amplitude=0.1 | speed, vflow_factor=1.0, grid_length=1.0 | length, number_of_steps=5) if not IS_PLOT_AVAILABLE: return grids = model.get_solution_at_time(1.0 | time) rho0 = model.start_grids[0].rho[..., ..., 0].value_in(density) rho = grids[0].rho[..., ..., 0].value_in(density) drho = rho - rho0 print drho.sum(), rho[0][0], rho0[0][0], drho[0][0] x = grids[0].x[..., ..., 0].value_in(length) y = grids[0].y[..., ..., 0].value_in(length) figure = pyplot.figure(figsize=(10, 10)) plot = figure.add_subplot(1, 1, 1, projection='3d') plot.plot_surface(x, y, drho) plot.plot_surface(x, y, rho) figure.savefig('kelvin_helmholtz_{0}_{1}.png'.format( name_of_the_code, number_of_grid_points)) pyplot.show()
def main(): number_of_grid_points = 64 name_of_the_code = 'athena' model1 = CalculateLinearWave1D( number_of_grid_points = number_of_grid_points, number_of_workers = 1, name_of_the_code = name_of_the_code, amplitude = 1e-1 | speed, vflow_factor = 1.0, grid_length = 1.0 | length, number_of_steps = 5, use_boundaries = True ) model2 = CalculateLinearWave1D( number_of_grid_points = number_of_grid_points, number_of_workers = 1, name_of_the_code = name_of_the_code, amplitude = 1e-1 | speed, vflow_factor = 1.0, grid_length = 1.0 | length, number_of_steps = 5, use_boundaries = False ) if not IS_PLOT_AVAILABLE: return print "Evolve model with amuse implementing the periodic boundaries" grids1 = model1.get_solution_at_time(1.0 | time) print "Evolve model with the code implementing the periodic boundaries" grids2 = model2.get_solution_at_time(1.0 | time) rho1 = grids1[0].rho[...,...,0].value_in(density) rho2 = grids2[0].rho[...,...,0].value_in(density) drho = rho2 - rho1 print drho.sum(), rho1[0][0], rho2[0][0], drho[0][0] x = grids1[0].x[...,...,0].value_in(length) y = grids1[0].y[...,...,0].value_in(length) figure = pyplot.figure(figsize=(10,5)) plot = figure.add_subplot(1,2,1, projection='3d') plot.plot_surface(x, y, drho) plot = figure.add_subplot(1,2,2, projection='3d') plot.plot_surface(x, y, rho1, color='r') figure.savefig('kelvin_helmholtz_{0}_{1}.png'.format(name_of_the_code, number_of_grid_points)) pyplot.show()
def main(): number_of_grid_points = 64 name_of_the_code = 'athena' model1 = CalculateLinearWave1D(number_of_grid_points=number_of_grid_points, number_of_workers=1, name_of_the_code=name_of_the_code, amplitude=1e-1 | speed, vflow_factor=1.0, grid_length=1.0 | length, number_of_steps=5, use_boundaries=True) model2 = CalculateLinearWave1D(number_of_grid_points=number_of_grid_points, number_of_workers=1, name_of_the_code=name_of_the_code, amplitude=1e-1 | speed, vflow_factor=1.0, grid_length=1.0 | length, number_of_steps=5, use_boundaries=False) if not IS_PLOT_AVAILABLE: return print "Evolve model with amuse implementing the periodic boundaries" grids1 = model1.get_solution_at_time(1.0 | time) print "Evolve model with the code implementing the periodic boundaries" grids2 = model2.get_solution_at_time(1.0 | time) rho1 = grids1[0].rho[..., ..., 0].value_in(density) rho2 = grids2[0].rho[..., ..., 0].value_in(density) drho = rho2 - rho1 print drho.sum(), rho1[0][0], rho2[0][0], drho[0][0] x = grids1[0].x[..., ..., 0].value_in(length) y = grids1[0].y[..., ..., 0].value_in(length) figure = pyplot.figure(figsize=(10, 5)) plot = figure.add_subplot(1, 2, 1, projection='3d') plot.plot_surface(x, y, drho) plot = figure.add_subplot(1, 2, 2, projection='3d') plot.plot_surface(x, y, rho1, color='r') figure.savefig('kelvin_helmholtz_{0}_{1}.png'.format( name_of_the_code, number_of_grid_points)) pyplot.show()