Filament diffusion model for simulating reset and retention processes in RRAM