# Coupled PINN

**URL:** https://discourse.julialang.org/t/coupled-pinn/95521
**Category:** General Usage
**Tags:** question
**Created:** [March 4, 2023, 12:58am UTC](https://discourse.julialang.org/t/coupled-pinn/95521 "2023-03-04T00:58:48Z")
**Posts on this page:** 13
**Page:** 2

<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: [March 6, 2023, 1:00pm UTC](https://discourse.julialang.org/t/coupled-pinn/95521/22 "2023-03-06T13:00:36Z")

</div>

> [@Reza\_AO](#):
>
> ```julia
> #newf
> newf(θ,p)=loss_function1(θ,p)+loss_function2(θ,p)
> #Optimization
> f_ = OptimizationFunction(newf, Optimization.AutoZygote())
> u0 = vcat(sym_prob1.flat_init_params,sym_prob2.flat_init_params)
> prob = Optimization.OptimizationProblem(f_, u0)
> 
> ```

```julia
newf(θ,p)=loss_function1(θ.prob1u0,p)+loss_function2(θ.prob2u0,p)
f_ = OptimizationFunction(newf, Optimization.AutoZygote())
u0 = ComponentArrays(prob1u0 = prob1.u0, prob2u0 = prob2.u0)
prob = Optimization.OptimizationProblem(f_, u0)

```

is a nice way to do it.

---

<div class="post-metadata">

### Author: ![Reza\_AO](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/reza_ao/32/51137_2.png) [@Reza\_AO](https://discourse.julialang.org/u/Reza_AO)
#### Post date: [March 6, 2023, 8:54pm UTC](https://discourse.julialang.org/t/coupled-pinn/95521/23 "2023-03-06T20:54:16Z")

</div>

> [@ChrisRackauckas](#):
>
> `u0 = ComponentArrays(prob1u0 = prob1.u0, prob2u0 = prob2.u0)`

What would be the output of this line? Is it the same as Array[prob1u0,prob2u0] which gives a vector with two elements?  
For ComponentArray I get the error “objects of type Module are not callable”.

---

<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: [March 6, 2023, 9:28pm UTC](https://discourse.julialang.org/t/coupled-pinn/95521/24 "2023-03-06T21:28:53Z")

</div>

`u0 = ComponentArray(prob1u0 = prob1.u0, prob2u0 = prob2.u0)`

---

<div class="post-metadata">

### Author: ![Reza\_AO](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/reza_ao/32/51137_2.png) [@Reza\_AO](https://discourse.julialang.org/u/Reza_AO)
#### Post date: [March 7, 2023, 7:35am UTC](https://discourse.julialang.org/t/coupled-pinn/95521/25 "2023-03-07T07:35:29Z")

</div>

Thanks. Do U know what is this error for?

```julia
 Uniform: the condition a < b is not satisfied.

```

I got this at res line run.

---

<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: [March 7, 2023, 8:34am UTC](https://discourse.julialang.org/t/coupled-pinn/95521/26 "2023-03-07T08:34:49Z")

</div>

That means you placed box constraints but the initial condition wasn’t in the box.

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [March 7, 2023, 12:00pm UTC](https://discourse.julialang.org/t/coupled-pinn/95521/28 "2023-03-07T12:00:33Z")

</div>

I think at the point where you are asking about things like `.-` it might be time to learn a bit about how Julia works rather than trying to write a Master’s thesis with line-by-line debugging by Chris on discourse…

(The `.` operator is for broadcasting, see [Functions · The Julia Language](https://docs.julialang.org/en/v1/manual/functions/#man-vectorized))

---

<div class="post-metadata">

### Author: ![Reza\_AO](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/reza_ao/32/51137_2.png) [@Reza\_AO](https://discourse.julialang.org/u/Reza_AO)
#### Post date: [March 7, 2023, 12:23pm UTC](https://discourse.julialang.org/t/coupled-pinn/95521/29 "2023-03-07T12:23:36Z")

</div>

I know. I am sorry. I know the basics but I couldn’t find anything about “.-” and there are some codes which there isn’t any description for them specially PDE problems with PINN; What should I do when I have no clue and there is no guidance after spending 4 months for this problem? BTW I know what `.-` means but I just want to make sure why it is used like this in the loss function which could have been used differently. FYI I don’t think it’s elementwise minus. For example `dx*phi(x, θ) .- 1` is for the normalization constraint (Δtp(x)=1). `.-` is used as an equal somehow and I don’t know why.  
I am going to stop asking him questions from now on.  
Peace

---

<div class="post-metadata">

### Author: ![Reza\_AO](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/reza_ao/32/51137_2.png) [@Reza\_AO](https://discourse.julialang.org/u/Reza_AO)
#### Post date: [March 8, 2023, 10:29pm UTC](https://discourse.julialang.org/t/coupled-pinn/95521/30 "2023-03-08T22:29:43Z")

</div>

Sorry that I have asked U so many questions and I appreciate your help and time. Do U know any course which introduces Deep Learning or PINN with Julia? I have found some videos but those are mostly basic and start from the beginning. I am in need of a more advanced course which will help me understand my problem throughly.  
Peace.

---

<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: [March 8, 2023, 10:35pm UTC](https://discourse.julialang.org/t/coupled-pinn/95521/31 "2023-03-08T22:35:13Z")

</div>

> [@Reza\_AO](#):
>
> Do U know any course which introduces Deep Learning or PINN with Julia?

[https://book.sciml.ai/notes/03-Introduction\_to\_Scientific\_Machine\_Learning\_through\_Physics-Informed\_Neural\_Networks/](https://book.sciml.ai/notes/03-Introduction_to_Scientific_Machine_Learning_through_Physics-Informed_Neural_Networks/)

---

<div class="post-metadata">

### Author: ![Reza\_AO](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/reza_ao/32/51137_2.png) [@Reza\_AO](https://discourse.julialang.org/u/Reza_AO)
#### Post date: [March 13, 2023, 11:53am UTC](https://discourse.julialang.org/t/coupled-pinn/95521/32 "2023-03-13T11:53:25Z")

</div>

```julia
function loss_function1(θ,p)
    sum(map(l->l(θ) ,loss_functions1))
end

```

I have been studying PINN Docs. There are some places where theta is defined as the weight and in other places p is the weight. I am confused. In the definition of loss function, what are theta and p?  
Thanks.

---

<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: [March 15, 2023, 8:44am UTC](https://discourse.julialang.org/t/coupled-pinn/95521/33 "2023-03-15T08:44:20Z")

</div>

It’s a function, you define the argument names.

---

<div class="post-metadata">

### Author: ![Reza\_AO](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/reza_ao/32/51137_2.png) [@Reza\_AO](https://discourse.julialang.org/u/Reza_AO)
#### Post date: [April 16, 2023, 3:36am UTC](https://discourse.julialang.org/t/coupled-pinn/95521/34 "2023-04-16T03:36:46Z")

</div>

In the PhysicsInformedNN documantation there is a saying about phi which is confusing.

- `phi`: a trial solution, specified as `phi(x,p)` where `x` is the coordinates vector for the dependent variable and `p` are the weights of the phi function (generally the weights of the neural network defining `phi`). By default this is generated from the `chain`. This should only be used to more directly impose functional information in the training problem, for example imposing the boundary condition by the test function formulation.

Since the example is solved for only x, if I want to solve multi dimension problem, how can I handle my dimension especially in one point, line or surface for additional loss definition. Here it says it is a vector.  
For example if I want a specific line when my dimensions are t , x , y; should I put them in a vector instead of x or it will be automatically consider x as a vector of [t,x,y]?

---

<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: [April 16, 2023, 6:56am UTC](https://discourse.julialang.org/t/coupled-pinn/95521/35 "2023-04-16T06:56:33Z")

</div>

> [@Reza\_AO](#):
>
> or it will be automatically consider x as a vector of [t,x,y]?

This

[Previous page](https://discourse.julialang.org/t/coupled-pinn/95521.md?page=1)
