j-fu / VoronoiFVM.jl

Solution of nonlinear multiphysics partial differential equation systems using the Voronoi finite volume method
MIT License
202 stars 34 forks source link

couple two physics in two domains #82

Open xrfe opened 1 year ago

xrfe commented 1 year ago

Hi, I am new to VoronoiFVM.jl. After one week try, I found it is really fantastic at solving diffusion problems, it is faster than similar problem I solved in c++ using FEM. So, I decide to try further. Currently I have the time-dependent mass diffusion equation (c) in 1D domain, and heat conduction equation (T) in a 2D domain. the top boundary of the 2D domain is actually the 1D domain where mass diffusion happens. The equation are coupled (mass diffusion coefficient depends on temperature e.g., D(T), mass diffusion also generate heat, e.g., Q(c)) .

+=============mass diffusion============+ +++++++++++++++++++++++++++++++++++++++
++++++++++++++ heat conduction+++++++++++ +++++++++++++++++++++++++++++++++++++++

I first solve the 2D heat equation and get temperature T, then I solve the mass diffusion equation and get generated heat Q, Can you tell me how can I pass the T, and Q to each other in VoronoiFVM.jl?

j-fu commented 1 year ago

Hi, I would define a joint System for both:

You can add the concentration as boundary species and define a boundary flux function for the mass flux. It would be better to use unknown_storage=:sparse then.

How does the term for mass diffusion generating heat look like? Do you use an EdgeReaction to implement this ? If so I would have to add another callback function for this (which is not much work).

Some of these features have been used in the examples:

https://j-fu.github.io/VoronoiFVM.jl/stable/examples/Example220_NonlinearPoisson2D_BoundarySpecies/

https://j-fu.github.io/VoronoiFVM.jl/stable/examples/Example311_HeatEquation_BoundaryDiffusion/

For coupling two systems as you proposed, you could try to define the 1D mass grid as a subgrid of the 2D heat grid, so you have coupling information between them. You always have node.index and edge.node[1], edge.node[2] in the callbacks to index into respective grid functions.

The advantage of the "one system approach" is that all is solved in one general Newton method.

xrfe commented 1 year ago

Thank you so much for your prompt reply. My equations are like these: ∂c/∂t = ∂ (D(T)∂c/∂x) / ∂x + λT in 1D ​ ∂T/∂t = KΔu, in 2D, with BC: ∂T/∂n = ∂(∂c/∂x) / ∂x

My problem is quite similar to the second example you give. It's really helpful. Curiously, if my heat equation is anisotropic (e.g., K is zero in x direction), then

∂T/∂t = K∂ (∂c/∂y) / ∂y, in 2D with BC: ∂T/∂n = ∂(∂c/∂x) / ∂x.

can I still use VoronoiFVM.jl to discretize them in an "one system approach"?

j-fu commented 1 year ago

Yes, I think this can work. You would need to check the direction of the edge. E.g. you could have a K matrix and multiply this by the normalized edge vector.

Please be aware that this will be only correct if you work with a rectangular simplex grid and the main directions of K are aligned with the x and y directions.