def METHOD_NAME(id, session=None):
    if session is None:
        session = get_default_session()
    if isinstance(id, str) or isinstance(id, str):
        assert "/" not in id, "Replace '/' with '_' in input string."
        if "%" in id or "_" in id:
            match_clause = Simulation.basename.like(id)
        else:
            match_clause = Simulation.basename == id
        res = session.query(Simulation).filter(match_clause)
        num = res.count()
        if num == 0:
            raise RuntimeError("No simulation matches %r" % id)
        elif num > 1:
            raise RuntimeError("Multiple (%d) matches for %r" % (num, id))
        else:
            return res.first()
    else:
        return session.query(Simulation).filter_by(id=int(id)).first()