# How to make Z bus matrix

I've been working on code to calculate a balanced three-phase fault without using PSS/E. The issue I'm facing is with the fault impedance at a specific bus.

I used the diagonal element of the Z-bus, which I obtained by inverting the Y-bus matrix. However, when I compared my results with the fault impedance from PSS/E's 'ASCC' calculation on IEEE-9 bus system, the values were significantly different.

So I have a few questions:

- How does PSS/E calculate the fault impedance?
- If PSS/E uses the Z-bus to determine the fault impedance, how does it construct the Z-bus matrix?
- Is there another way to accurately construct the Z-bus matrix?

I'd greatly appreciate any insight into these questions.