That particular subject may require a review of 2 fluid mechanics courses. Too much for this site.
Regarding the question title: you can get sonic flow in a pipe ,and also in its discharge nozzle, if the discharge pressure is less than 50% of the pipe inlet pressure ( assuming a Cp/Cv of about 1.4)and you are flowing a compressible gas. If the flow chokes in the pipe, that is normally treated as "Fanno Flow" and solved using the fanno curves or fanno relationships,if the pipe has a constant cross sectional area..