Simple Impedance/Admittance based Transmission/Reflection Simulation
func s11(f) = ZR(f)/Z0


This is not correct. You should be using something that computes
$$S_{11}(f) = \frac{Z_L - Z_0}{Z_L + Z_0}$$
where \$Z_L\$ is the cascade of the filter and the load connected on its port 2.

What the error is in your \$S_{21}\$ calculation, I didn't notice with a quick look.

Edit: the error in your \$S_{21}\$ calculation is that you calculate \$S_{11}\$ and call it s21.