Safety valve calculation