How to compute a series of deterministic shocks that keep a variable constant

Hi all!

I am trying to simulate an augmented NK model with credit frictions and fiscal policy in a deterministic setting through the perfect foresight solver.

In particular, I would like to simulate a demand shock hitting the economy at time = 1, but I would like government debt to stay constant at a certain level during the simulation.

To do so, I would have to (I guess iteratively) compute a series of exogenous shocks to the government budget constraint that are such that (i) government debt is constant, (ii) equilibrium holds given that agents anticipate such shocks (indeed we are in perfect foresight).

Any clue on how to compute such a series of exogenous shocks?

Many thanks!

You should be able to follow the approach of