Ternary derivations, stability and physical aspects