# Numeric Solution for 1-D ODE with only Neumann conditions

I tried to solve a simple ODE with only Neumann conditions like But obviously this doesn't work. I must add a useless DirichletCondition to make it work I have verified that the solution is correct, but how can I get it without including the useless condition?

The code is

Sol = NDSolveValue[{Piecewise[{{1, x < 0}, {2.25, x > 0}}, 0]*u[x] +
Derivative[u][x] ==
NeumannValue[I*(2*E^(I*x) - u[x]), x == -4*Pi] +
NeumannValue[(0. - 1.5*I)*u[x], x == 4*Pi],
DirichletCondition[1, False]}, u, {x, -4*Pi, 4*Pi}]
ReImPlot[Sol[x], {x, -4*Pi, 4*Pi}]

• With only Neumann conditions, the solution is determined only up to a constant. one way or another, the constant must be specified to obtain a numerical solution. Feb 16 '20 at 4:51
• Maybe not, because if I add some useless condition like DirichletCondition[1, False], the program would find the correct solution. Feb 16 '20 at 11:21
• @ZhuoJiahui I received this message in version 12 NDSolveValue::fembpw: The boundary condition {DirichletCondition[1,False]} cannot be parsed and will be ignored. Feb 16 '20 at 12:21
• Yeee, that condition will be ignored but the solution is correct. Feb 16 '20 at 14:01

You'd need to specify the method in this case, as otherwise NDSolve will first try to solve this as a time ODE:
Sol = NDSolveValue[{Piecewise[{{1, x < 0}, {2.25, x > 0}}, 0]*u[x] +

The fact that you 'only' have NeuamnnValues is not a problem here as they are generalized Neumann conditions (Robin conditions). Using only NeumannValue is only an issue if the NeumannValue is not a generalized NeumannValue (i.e. does not dependend on the dependent variable u in this case)