# PINN with two boundary conditions

**URL:** https://discourse.julialang.org/t/pinn-with-two-boundary-conditions/53813
**Category:** Numerics
**Created:** [January 23, 2021, 12:17am UTC](https://discourse.julialang.org/t/pinn-with-two-boundary-conditions/53813 "2021-01-23T00:17:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Honza9723](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/honza9723/32/7807_2.png) [@Honza9723](https://discourse.julialang.org/u/Honza9723)
#### Post date: [January 23, 2021, 12:17am UTC](https://discourse.julialang.org/t/pinn-with-two-boundary-conditions/53813/1 "2021-01-23T00:17:32Z")

</div>

Hi,

I am working on a physically informed neural network solution of ODE with two boundary conditions. In a standard initial value problem, let’s say y(x) - y’(x) = 0 with y(0) = 1, I would use approximation in a form

y(x) = 1.0 + x\*NN(x)

where NN(x) is a neural network. However, I need to solve a differential equation on the X \in [x\_low,x\_high] interval with one boundary condition on x\_low and second x\_high. Any idea, how to “hard-code” the boundary condition into the approximator, or do I had to enforce these boundary conditions through the loss function term?

Best,  
Honza

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [January 23, 2021, 2:33am UTC](https://discourse.julialang.org/t/pinn-with-two-boundary-conditions/53813/2 "2021-01-23T02:33:04Z")

</div>

```julia
y(x) = y(x_low)*(x-x_high) + y(x_high)*(x-x_low) + (x-x_low)*(x-x_high)*NN(x)

```

or just use NeuralPDE.jl and add two terms to the loss for `y(x_low) - known value` and `y(x_high) - konwn value`.

---

<div class="post-metadata">

### Author: ![Honza9723](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/honza9723/32/7807_2.png) [@Honza9723](https://discourse.julialang.org/u/Honza9723)
#### Post date: [January 23, 2021, 10:54am UTC](https://discourse.julialang.org/t/pinn-with-two-boundary-conditions/53813/3 "2021-01-23T10:54:12Z")

</div>

@ChrisRackauckas Thank you!
