General simulations of open and closed quantum systems