In an RDWC system, you will want the entire volume of water to change once every 1 to 2 hours. The simple formula is the ( total number of gallons of water) divided by 2 (hours) = necessary GPH pump. I personally divide by 1.5 because I want a little more volume exchanged.
In your case 40...