Calculation of heavy ion ranges in complex media