valve calculation