  We present PFNN, a penalty-free neural network method, to efficiently solve a
class of second-order boundary-value problems on complex geometries. To reduce
the smoothness requirement, the original problem is reformulated to a weak form
so that the evaluations of high-order derivatives are avoided. Two neural
networks, rather than just one, are employed to construct the approximate
solution, with one network satisfying the essential boundary conditions and the
other handling the rest part of the domain. In this way, an unconstrained
optimization problem, instead of a constrained one, is solved without adding
any penalty terms. The entanglement of the two networks is eliminated with the
help of a length factor function that is scale invariant and can adapt with
complex geometries. We prove the convergence of the PFNN method and conduct
numerical experiments on a series of linear and nonlinear second-order
boundary-value problems to demonstrate that PFNN is superior to several
existing approaches in terms of accuracy, flexibility and robustness.
