This code is heavily based on the Julia QuantEcon lecture ``Default Risk and Income Fluctuations'' by John Stachurski, Jesse Perla and Thomas J. Sargent. Thanks to them for providing a highly optimised scaffold.
I extend that code to solve an economy with long term debt, similar to Chatterjee and Eyigungor (2012).
In the other code file I also allow for some inflation. You can see how default sets move even when there is (anticipated) inflation.
I also have code which solves this economy via the projection method, which I am happy to provide upon request.