This study proposes a unified hard--soft physics--informed neural network (HSPINN) with adaptive loss weighting to address the slow convergence and inaccurate boundary enforcement of conventional PINNs. The framework enforces Dirichlet and periodic boundary conditions exactly through analytical lifting or masking, while treating PDE residuals and initial conditions as soft constraints balanced by an inverse-share softmax strategy.

  • Dirichlet and periodic boundary conditions are enforced exactly by construction via analytical/polynomial lifting, masking functions, and periodic feature mappings.
  • Governing PDE residuals, Neumann fluxes, and initial conditions are treated as soft constraints.
  • An inverse-share softmax strategy dynamically balances loss components, eliminating manual penalty tuning and improving gradient stability.
  • Applications to Poisson, Burgers, and convection problems demonstrate faster convergence, higher accuracy, and greater stability than conventional PINNs.

HSPINN establishes a general and scalable foundation for physics-constrained deep learning by ensuring boundary admissibility throughout optimization and enhancing numerical robustness.