def _adjust_step_size_pid(dt, rel_change, rel_change_step, vsimex_tol, k_P,
    k_I, k_D, dt_bounds, s_bounds):
    """
    Adjust the step size using the PID controller.
    """
    mult = (rel_change[1] / rel_change_step) ** k_P * (vsimex_tol /
        rel_change_step) ** k_I * (rel_change[0] ** 2 / rel_change[1] /
        rel_change_step) ** k_D
    if mult > s_bounds[1]:
        mult = s_bounds[1]
    elif mult < s_bounds[0]:
        mult = s_bounds[0]
    new_dt = mult * dt[2]
    if new_dt > dt_bounds[1]:
        new_dt = dt_bounds[1]
    elif new_dt < dt_bounds[0]:
        new_dt = dt_bounds[0]
    dt = dt[1], dt[2], new_dt
    rel_change = rel_change[1], rel_change_step
    return dt, rel_change
