# allow for thermal advection in the atmosphere, and heat diffusion in the atmosphere and the ground atmosp_addition = dt * top_level.thermal_advection( temperature_atmos, air_pressure, u, v, w, dx, dy, dz) temperature_atmos[advection_boundary: -advection_boundary, :, :] -= atmosp_addition[ advection_boundary:-advection_boundary, :, :] temperature_atmos[ advection_boundary - 1, :, :] -= 0.5 * atmosp_addition[advection_boundary - 1, :, :] temperature_atmos[ -advection_boundary, :, :] -= 0.5 * atmosp_addition[ -advection_boundary, :, :] # as density is now variable, allow for mass advection density_addition = dt * top_level.divergence_with_scalar( air_density, u, v, w, dx, dy, dz) air_density[advection_boundary: -advection_boundary, :, :] -= density_addition[ advection_boundary:-advection_boundary, :, :] air_density[( advection_boundary - 1 ), :, :] -= 0.5 * density_addition[advection_boundary - 1, :, :] air_density[-advection_boundary, :, :] -= 0.5 * density_addition[ -advection_boundary, :, :] # temperature_world -= dt*(thermal_diffusivity_roc*top_level.laplacian_2D(temperature_world,dx,dy)) # time_taken = float(round(time.time() - before_advection,3)) # print('Advection: ',str(time_taken),'s') # before_plot = time.time()
w[:,:,18:] *= 0 # w[:1,:,:] *= 0 # w[-1:,:,:] *= 0 # plt.semilogy(w[5,25,:sponge_index],pressure_levels[:sponge_index]) # plt.gca().invert_yaxis() # plt.show() if verbose: time_taken = float(round(time.time() - before_w,3)) print('Calculate w: ',str(time_taken),'s') ################################# atmosp_addition = top_level.divergence_with_scalar(potential_temperature,u,v,w,dx,dy,lat,lon,pressure_levels,polar_grid_resolution,indices,coords,grids,grid_velocities) if smoothing: atmosp_addition = top_level.smoothing_3D(atmosp_addition,smoothing_parameter_add) atmosp_addition[:,:,sponge_index-1] *= 0.5 atmosp_addition[:,:,sponge_index:] *= 0 potential_temperature -= dt*atmosp_addition ################################################################### tracer_addition = top_level.divergence_with_scalar(tracer,u,v,w,dx,dy,lat,lon,pressure_levels,polar_grid_resolution,indices,coords,grids,grid_velocities) tracer -= dt*tracer_addition diffusion = top_level.laplacian_3d(potential_temperature,dx,dy,pressure_levels) diffusion[0,:,:] = np.mean(diffusion[1,:,:],axis=0)
w[:, :, 0] = -w[:, :, 1] # w[:,:,2] *= 0.1 # w[:,:,3] *= 0.5 # u *= 0 # v *= 0 # w *= 0 time_taken = float(round(time.time() - before_velocity, 3)) print('Velocity: ', str(time_taken), 's') if advection: before_advection = time.time() # allow for thermal advection in the atmosphere atmosp_addition = dt * top_level.divergence_with_scalar( potential_temperature, u, v, w, dx, dy, pressure_levels) time_taken = float(round(time.time() - before_advection, 3)) print('Advection: ', str(time_taken), 's') before_projection = time.time() ################################################################### ### north pole ### north_temperature_data = potential_temperature[ pole_low_index_N:, :, :] north_polar_plane_temperature = beam_me_up( lat[pole_low_index_N:], lon, north_temperature_data, pole_low_index_N, grid_xx_N.shape[0], grid_lat_coords_N, grid_lon_coords_N)
v[:advection_boundary, :, :] = 0 w[:advection_boundary, :, :] = 0 u[-advection_boundary:, :, :] = 0 v[-advection_boundary:, :, :] = 0 w[-advection_boundary:, :, :] = 0 # time_taken = float(round(time.time() - before_velocity,3)) # print('Velocity: ',str(time_taken),'s') # before_advection = time.time() if advection: # allow for thermal advection in the atmosphere, and heat diffusion in the atmosphere and the ground # atmosp_addition = dt*(thermal_diffusivity_air*laplacian(temperature_atmos)) atmosp_addition = dt * top_level.divergence_with_scalar( temperature_atmos, u, v, w, dx, dy, dz) temperature_atmos[advection_boundary: -advection_boundary, :, :] -= atmosp_addition[ advection_boundary:-advection_boundary, :, :] temperature_atmos[ advection_boundary - 1, :, :] -= 0.5 * atmosp_addition[advection_boundary - 1, :, :] temperature_atmos[ -advection_boundary, :, :] -= 0.5 * atmosp_addition[ -advection_boundary, :, :] # as density is now variable, allow for mass advection density_addition = dt * top_level.divergence_with_scalar( air_density, u, v, w, dx, dy, dz) air_density[advection_boundary: -advection_boundary, :, :] -= density_addition[