factorize physic code in a function