Refactored function check_system_collapse in b_sim.py