PDE solution does not satisfy Neumann boundary conditions using NDSolve

I am trying to solve the free particle Schrodinger equation in 1D (hbar =1, Energy = 1, mass = 1), But specifying conditions only on x==0:

k = Sqrt[2];
sol = NDSolveValue[{op == NeumannValue[0, x == 0],
DirichletCondition[u[x] == Cos[k x], x == 0]}, u, {x, 0, 1}]

Plot[{sol[x] , Cos[k x]}, {x, 0, 1}]


The blue line is the numeric solution, and it is obviously not the expected solution (in orange), since the derivative in x==0 is not zero. I understand that specifying the Neumann value is not needed since its default is zero, but it isn't zero here!

What is going on?

-
Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! –  Lou Feb 26 at 13:35

Both NeumannValue and DirichletCondition are set to apply at x==0. In such cases the DirichletCondition will trump the NeumannValue. Besides the NeumannValue is set to zero which means that the natural boundary condition is 0, the boundary integral vanishes. I think you want the DirichletCondition at x==1:

k = Sqrt[2];
sol = NDSolveValue[{op == NeumannValue[0, x == 0],
DirichletCondition[u[x] == Cos[k x], x == 1]}, u, {x, 0, 1}];


But NeumannValue[0,...] is equivalent to not specifying anything at all:

k = Sqrt[2];

I am actually interested in solving using conditions only at x == 0. I want to use DiriclehtCondition and NeumannValue to get the equivalent solution to this: NDSolveValue[{-1/2 u''[x] - u[x] == 0, u[0] == Cos[k 0] , u'[0] == -k Sin [k 0]}, u, {x, 0, 1}] Is it not possible? –  Amit Abir Feb 26 at 16:24
@AmitAbir, note that the above NDSolve does a time integration, while the FEM is a spatial discretization method. –  user21 Feb 26 at 18:17