When do i have to use yaru instead of suru


They are both "to do" and i know that やる is only used with phsysical actions,
but i cannot say 想像やる because is not a phsysical action. And i also know that
やる is also "to give" like 「プレゼントをやる」but i sometimes see やる being
interchangeable with する is there a rule for that? Can i freely say 「勉強やる」
「運動やる」or 「可愛い女性の写真を見ながらオナニやってる」? How do i know when to use する or やる?

Thanks, greetings from france.

