# Boundary value is not what I defined

**URL:** <https://discourse.julialang.org/t/boundary-value-is-not-what-i-defined/50290>\
**Category:** General Usage\
**Tags:** diffeq\
**Created:** [November 17, 2020, 11:12am UTC](https://discourse.julialang.org/t/boundary-value-is-not-what-i-defined/50290 "2020-11-17T11:12:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fred\_He](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fred_he/32/14298_2.png) [@Fred\_He](https://discourse.julialang.org/u/Fred_He)\
**Post date:** [November 17, 2020, 11:12am UTC](https://discourse.julialang.org/t/boundary-value-is-not-what-i-defined/50290/1 "2020-11-17T11:12:49Z")

</div>

Hello all, I started using DifferentialEquations package to solve a transit convection-diffusion equation with reaction, but the result looks strange.  
Firstly, I define a  
du/dt = -usg du/dx + Deg d^2u/dx  
the boundary condition is  
u(0) = Deg/usg \* du/dx + u\_in  
u\_in = 2  
du/dx(end) = 0  
the code is as follow, modified from the [heat equation example](https://github.com/SciML/DiffEqOperators.jl/blob/master/examples/heat_equation.jl) in DiffEqOperators.jl

```julia
using DiffEqOperators, DifferentialEquations, Plots
    plotly()
    nknots = 100
    h = 0.1/(nknots+1)
    knots = collect(range(h, step=h, length=nknots))
    ord_deriv = 2
    ord_approx = 2
    usg = 0.1
    Deg = 2.2E-4
    Δ1 = UpwindDifference(1, 2, h, nknots, -usg)
    Δ2 = CenteredDifference(ord_deriv, ord_approx, h, nknots)
    bc = RobinBC((1.0, -Deg/usg, 2.), (0.0, 1.0, 0.0),knots, 2)
    #bc = Dirichlet0BC(Float64)

    t0 = 0.0
    t1 = 8
    u0 = 0.3*exp.(1 .- knots) #u_analytic.(knots, t0)

    step(u,p,t) = Δ1*bc*u + Deg*Δ2*bc*u #- 1.2E-1*u
    prob = ODEProblem(step, u0, (t0, 2.))

sol = solve(prob, alg_hints = [:stiff])

surface(sol.t, knots, Array(sol), xlabel="t [s]", ylabel="L ")

```

The first interesting thing is that, without rteaction, u at the inlet is less than 2.  
and secondly, u at the outlet increased. as can be seen in the figure below  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/2/02bd72c56a8b01863fb3d501b3306783cd8300f9.png)

when i replace the boundary condition by:

```julia
bc = RobinBC((1.0, 0., 2.), (0.0, 1.0, 0.0),knots, 2)

```

the first problem is solved, but the second problem is not. Is there anyone can give me some guidance? Thanks a lot!

![image](https://global.discourse-cdn.com/julialang/original/3X/f/e/fe57991713bf7ed7438e10a5fdd573790c46ba53.png)
