def advect_timestep_donorcell(x,q,vi,dt): """ Simple donor-cell advection scheme. First and last cell are ghost cells and are not affected. ARGUMENTS: x The cell center locations (array of nx elements) q The cell center q values (array of nx elements) vi The velocities at the cell walls (array of nx-1 elements) dt The time step RETURNS: qnew The updated values of q at the next time step """ xi = 0.5*(x[1:]+x[:-1]) # Location of cell walls dx = xi[1:]-xi[:-1] # Array of cell widths dx = np.hstack((0,dx,0)) # Get dx indices in line with cell indices fi = np.zeros_like(vi) # Prepare array of interface fluxes ipos = np.where(vi>=0.)[0] # Indices of interfaces with positive vi ineg = np.where(vi<0.)[0] # Indices of interfaces with negative vi <<< COMPLETE THE ALGORITHM HERE >>>