# Advanced Tutorials: PINNs

**URL:** <https://discourse.julialang.org/t/advanced-tutorials-pinns/80595>\
**Category:** New to Julia\
**Tags:** modelingtoolkit, neural-network\
**Created:** [May 6, 2022, 9:25am UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595 "2022-05-06T09:25:13Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeoCott](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@LeoCott](https://discourse.julialang.org/u/LeoCott)\
**Post date:** [May 6, 2022, 9:25am UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595/1 "2022-05-06T09:25:13Z")

</div>

Dear all,

I am quite new to Julia so I maybe missed the proper documentation.

May anyone suggest advanced Julia tutorials for Physics-Informed NN (a GitHub repository or something else) ? For instance, problems with complex geometry (i.e. no-rectangular domain) etc ? I have already explored the examples in the NeuralPDE doc.

Thanks in advance 🙂

---

<div class="post-metadata">

**Author:** ![RosalRicardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rosalricardo/32/30041_2.png) [@RosalRicardo](https://discourse.julialang.org/u/RosalRicardo)\
**Post date:** [May 6, 2022, 9:43am UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595/3 "2022-05-06T09:43:25Z")

</div>

Hi Leo,

take a look at the SciML book, especially in lecture 3, there’s a great explanation about PINNs there.

[https://book.sciml.ai/notes/03/](https://book.sciml.ai/notes/03/)

---

<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:** [May 6, 2022, 12:29pm UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595/4 "2022-05-06T12:29:28Z")

</div>

The tutorials in [NeuralPDE.jl: Automatic Physics-Informed Neural Networks (PINNs) · NeuralPDE.jl](https://neuralpde.sciml.ai/dev/) cover what is currently supported. The library does not do complex geometries at this time, but it’s something that’s being worked towards.

---

<div class="post-metadata">

**Author:** ![LeoCott](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@LeoCott](https://discourse.julialang.org/u/LeoCott)\
**Post date:** [May 7, 2022, 4:02pm UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595/5 "2022-05-07T16:02:52Z")

</div>

Thanks @RosalRicardo, I’ll have a look!

@ChrisRackauckas super cool thanks! Keep on the good work, NeuralPDE is so nice!

---

<div class="post-metadata">

**Author:** ![Craig\_Hamel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/craig_hamel/32/202434_2.png) [@Craig\_Hamel](https://discourse.julialang.org/u/Craig_Hamel)\
**Post date:** [May 17, 2022, 11:04pm UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595/6 "2022-05-17T23:04:57Z")

</div>

@ChrisRackauckas if you’re in need of support for moving to comolex geometries I’m open to help contribute. Ive been working on non linear solid mechanics pinns the last year or so where our goal is always complex geoemtry.

Ive been wanting to move some stuff over to julia from python but i have the feeling the ecosystem is not quite mature enough for my needs unfortunately, but would love to help push it there.

---

<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:** [May 20, 2022, 4:38am UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595/7 "2022-05-20T04:38:12Z")

</div>

Indeed we’d be very happy to have someone help out here. We’d need to pick a mesh representation to use in the ModelingToolkit format. It would probably be good for that to be compatible with Gridap.jl as well, so that in the future the same symbolic code works for NeuralPDE.jl and Gridap.jl. We’d need some way to describe the weak form as well.

Which Python PINN package does arbitrary geometries? I know DeepXDE is a bit limited as well on the geometry choices.

---

<div class="post-metadata">

**Author:** ![LeoCott](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@LeoCott](https://discourse.julialang.org/u/LeoCott)\
**Post date:** [May 21, 2022, 7:49am UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595/8 "2022-05-21T07:49:02Z")

</div>

Hi @ChrisRackauckas

There is also IDRLnet ([GitHub - idrl-lab/idrlnet: IDRLnet, a Python toolbox for modeling and solving problems through Physics-Informed Neural Network (PINN) systematically.](https://github.com/idrl-lab/idrlnet)), that is mainly based on NVIDIA’s Modulus ([Modulus | NVIDIA Developer](https://developer.nvidia.com/modulus)). Both made their codes available.  
Good point is that Modulus enables to import .stl files for a complicated geometry!

---

<div class="post-metadata">

**Author:** ![Craig\_Hamel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/craig_hamel/32/202434_2.png) [@Craig\_Hamel](https://discourse.julialang.org/u/Craig_Hamel)\
**Post date:** [May 22, 2022, 12:01am UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595/9 "2022-05-22T00:01:53Z")

</div>

@ChrisRackauckas great points about compatability with other packages in the ecosystem.

For arbitrary mesh geometries for my work, i made a home baked jax pinn solver using the weak form that was built on top of exodusII python interfaces for reading a mesh as well as postprocessing. I moved some of those tools over to Julia in Exodus.jl to directly call the C library. That format scales to obscene amounts of cores so there should never be any limitations there. It’s old, but held to very high standards and just works.

---

<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:** [May 22, 2022, 10:40am UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595/10 "2022-05-22T10:40:46Z")

</div>

Oh interesting, that’s good to know. Yeah, getting something together usually isn’t too hard, it’s fitting it to the symbolics that may be difficult, but that’s the step that’s essential for getting it to non-mathematical folks!

---

<div class="post-metadata">

**Author:** ![Craig\_Hamel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/craig_hamel/32/202434_2.png) [@Craig\_Hamel](https://discourse.julialang.org/u/Craig_Hamel)\
**Post date:** [May 22, 2022, 6:27pm UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595/11 "2022-05-22T18:27:09Z")

</div>

Great points on the symbolics.

I think fundamentally that may have to be handled differently depending upon strong form vs. weak form. For the strong form I think it’s maybe a little bit easier as long as you have a sufficiently sampled set of collocation points for your irregular geometry (that’s probably the challenging part).

For the weak form I think at the end of the day we would need some interface from symbolics down to say an “element level residual (or energy etc.)” that will map a given operator or set of operators to how that element should be calculated and then a general assembly interface or AD tricks could be used. For general operators that’s easier said then done though. Perhaps a kernel system like that in INL’s MOOSE library might be something to consider so that we have building blocks of PDE operators.

---

<div class="post-metadata">

**Author:** ![jav](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jav/32/46548_2.png) [@jav](https://discourse.julialang.org/u/jav)\
**Post date:** [February 3, 2023, 5:58pm UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595/12 "2023-02-03T17:58:58Z")

</div>

It would be very nice to have support for complex geometries. In my project, regular FEM is used to perform some calculations for a 3d aircraft model. Getting the complex geometry of the aircraft into NeuralPDE.jl is probably the main obstacle for using NeuralPDE.jl for some required optimizations and other tasks as well, e.g., having a function for the impact of the pressure of the hydrogen filled tanks, impact of the aerodynamic forces and so on. For now, for each modification, a FEM calculation must be performed.

So I am looking forward to the feature of integrating complex geometries. By the way, the open-source community which performs FEM calculations, often makes heavy use of [GMSH](https://gmsh.info/) as their meshing tool. Ideally, one could use gmsh for meshing and insert it directly to NeuralPDE. Gridap and Fenics allow reading the gmsh mesh.

---

<div class="post-metadata">

**Author:** ![jav](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jav/32/46548_2.png) [@jav](https://discourse.julialang.org/u/jav)\
**Post date:** [February 4, 2023, 12:24pm UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595/13 "2023-02-04T12:24:04Z")

</div>

Hi, can idrlnet also be used for complex 3d geometries with defined subdomains? They state:

> complex domain geometries without mesh generation. Provided geometries include interval, triangle, rectangle, polygon, circle, sphere… Other geometries can be constructed using three boolean operations: union, difference, and intersection" [idrlnet](https://github.com/idrl-lab/idrlnet)

However, their [documentation](https://idrlnet.readthedocs.io/en/latest/modules/idrlnet.geo_utils.html?highlight=polygon#idrlnet.geo_utils.geo_obj.Polygon) only shows a Polygon function in 2D. In order to generate complex geometries in 3D, I assume to require the same Polygon function in 3D. Spheres, boxes and similar shapes, might not suffice. Reading loading any 3d .stl file might be an alternative, but I would also require some tags for physical domains, like gmsh and gridap provide. So, the concrete question is: can idrlnet be used in order to generate complex 3d geometries with specified physical subdomains?

---

<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:** [February 22, 2023, 12:37pm UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595/14 "2023-02-22T12:37:21Z")

</div>

> [@jav](#):
>
> can idrlnet be used in order to generate complex 3d geometries with specified physical subdomains?

I’m not sure it can.

---

<div class="post-metadata">

**Author:** ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)\
**Post date:** [February 22, 2023, 2:10pm UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595/15 "2023-02-22T14:10:03Z")

</div>

As at best a casual FEM user I have migrated to [Salome-Meca](https://www.salome-platform.org/?page_id=117) for my FEA needs as it is all open source. It uses [Salome](https://docs.salome-platform.org/latest/main/index.html) as its solid modeling and meshing tool and [Code Aster](https://code-aster.org/spip.php?rubrique2) for its FEM engine. It is highly developed and should not be overlooked.

---

<div class="post-metadata">

**Author:** ![xtalax](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xtalax/32/35293_2.png) [@xtalax](https://discourse.julialang.org/u/xtalax)\
**Post date:** [March 30, 2023, 4:34pm UTC](https://discourse.julialang.org/t/advanced-tutorials-pinns/80595/16 "2023-03-30T16:34:26Z")

</div>

We are actively talking about implementing this both in the symbolic frontend, and in NeuralPDE; We have a GSoC interested in pursuing this in NeuralPDE. See the issue [here](https://github.com/SciML/PDEBase.jl/issues/5), really welcoming any comments.
