Bound-preserving neural network method for linear hyperbolic and parabolic equations