I'm reading David Hutton's Finite Element Analysis, and recently programmed the truss analysis from scratch (in java). The figure shows the screenshot of a regular truss, with two ends fixed and a load at center. The hue and the stroke width indicate the axial stress, while the red-blue figure distinguish tension from compression. I find the zero stress (marked with red circles) in the case of N=5, 9 (and 13, 17, etc.) interesting but confusing. Is there explanation for such pattern? or has my program mistakes?
Without a better understanding of your program I can't be sure, but this looks like a modelling mistake I've already done countless times (so I recognize it from experience).
I believe you defined both supports as vertical and horizontal constraints. This is not the expected behavior for trusses. Instead, only one support should be RX and RY, while the other is only RY.
Trusses can be broadly conceptualized as beams, with the top and lower chord representing the respective fiber of a beam and the diagonals represent the shear force. In your case, the truss should therefore behave like a simply supported beam, with compression at the top and tension at the bottom.
The reason you're getting zero stress on those spans is because they are the transition from tension to compression in your lower chord. Notice that the neighboring bars closer to the support are actually in compression. This is because a truss is meant to respond to load by deforming, which includes an outward horizontal expansion (due to the tension applied to the lower chord). By restraining horizontal displacements in both supports, you forbid this expansion and therefore generate a strong compression force.
Releasing horizontal displacements in one of the supports should solve your problem.