# How to tackle a Stefan problem in ModelingToolkit

**URL:** <https://discourse.julialang.org/t/how-to-tackle-a-stefan-problem-in-modelingtoolkit/59846>\
**Category:** Specific Domains\
**Tags:** pde, modelingtoolkit\
**Created:** [April 23, 2021, 7:46am UTC](https://discourse.julialang.org/t/how-to-tackle-a-stefan-problem-in-modelingtoolkit/59846 "2021-04-23T07:46:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Post date:** [April 23, 2021, 7:46am UTC](https://discourse.julialang.org/t/how-to-tackle-a-stefan-problem-in-modelingtoolkit/59846/1 "2021-04-23T07:46:10Z")

</div>

I have a problem similar to a Stefan problem and I wanted to ask if there is any tooling to make this kind of problem simpler/more efficient to solve.

Especially the moving boundary seems difficult to achieve.

> **[Stefan problem](https://en.wikipedia.org/wiki/Stefan_problem)**
>
> In mathematics and its applications, particularly to phase transitions in matter, a Stefan problem is a particular kind of boundary value problem for a system of partial differential equations (PDE), in which the boundary between the phases can move with time. The classical Stefan problem aims to describe the evolution of the boundary between two phases of a material undergoing a phase change, for example the melting of a solid, such as ice to water. This is accomplished by solving heat equation...

---

<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 23, 2021, 10:20am UTC](https://discourse.julialang.org/t/how-to-tackle-a-stefan-problem-in-modelingtoolkit/59846/2 "2021-04-23T10:20:16Z")

</div>

Using NeuralPDE.jl might be possible here? Though I have to agree that @StefanKarpinski can be quite a problem.

---

<div class="post-metadata">

**Author:** ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Post date:** [April 23, 2021, 8:29pm UTC](https://discourse.julialang.org/t/how-to-tackle-a-stefan-problem-in-modelingtoolkit/59846/3 "2021-04-23T20:29:38Z")

</div>

How would the NeuralPDE be able to handle the free boundary inside the system? Is there a nice way to define the changing domains?

Otherwise a quite manual approach of cell splitting/merging in a finite volume discretization combined with a level set method could be used, I think… but it seems like a lot of work.

---

<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 29, 2021, 3:13pm UTC](https://discourse.julialang.org/t/how-to-tackle-a-stefan-problem-in-modelingtoolkit/59846/4 "2021-04-29T15:13:39Z")

</div>

> [@feanor12](#):
>
> How would the NeuralPDE be able to handle the free boundary inside the system? Is there a nice way to define the changing domains?

You can treat the boundary as larger and use a characteristic function that changes over time. The PINN would be fine with the discontinuity that makes in the untrained version.
