Pressure swing adsorption (PSA) has attracted significant recent interest for chemical process intensification due to its potential for high energy efficiency and amenability to small, modular designs. However, the lack of simulation tools that are readily available, transparent, and trusted, has been identified as a serious impediment to widespread adoption of PSA, as well as to further research on PSA modeling, numerical solution, optimization, and control. This paper presents a complete framework for dynamic modeling and simulation of PSA processes and its implementation in an open-source simulator called toPSAil. The presentation is tutorial and includes many modeling and implementation details often overlooked in existing literature. Novel methods are presented for handling flow reversals and implementing various pressure-flow relationships, along with controlled boundary conditions. Finally, the code contains several innovations designed to improve efficiency and reduce the extensive trial-and-error tuning often required to produce a working PSA cycle.