Variational methods: Applications to nonlinear partial differential equations and Hamiltonian systems