  Neural networks can emulate nonlinear physical systems with high accuracy,
yet they may produce physically-inconsistent results when violating fundamental
constraints. Here, we introduce a systematic way of enforcing nonlinear
analytic constraints in neural networks via constraints in the architecture or
the loss function. Applied to convective processes for climate modeling,
architectural constraints enforce conservation laws to within machine precision
without degrading performance. Enforcing constraints also reduces errors in the
subsets of the outputs most impacted by the constraints.
