Fixed derivative calculation for locations at model boundaries