CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Solving a system of equations to calculate boundary conditions (https://www.cfd-online.com/Forums/openfoam-programming-development/127552-solving-system-equations-calculate-boundary-conditions.html)

elujan December 13, 2013 17:46

Solving a system of equations to calculate boundary conditions
 
Hi,
I have a simulation where the boundary conditions are calculated solving, each time step, a non-linear, inhomogeneous, partial differential system of equations. Is there an easy way to do that? How do you solve this problem?
Thanks!
Emmanuel

Bernhard December 15, 2013 04:24

Is it a differential equation that you can solve on a "per face" basis, or do you need to calculate it based on integrated quantities? You might want to check how it is implemented in the "advective" boundary condition.

elujan December 16, 2013 13:41

Dear Bernhard,
thanks for your time. Currently the domain of my problem is a box. One of the faces of this box represents an anode. I need to calculate some scalar fields (C_1, C_2, C_3, C_4 y V) on this face, solving this equation system:

- D_1 * grad(C_1) - s_1 * u_1 * C_1 * grad(V) = I_1 / F
- D_2 * grad(C_2) - s_2 * u_2 * C_2 * grad(V) = 0
- D_3 * grad(C_3) - s_3 * u_3 * C_3 * grad(V) = I_2 / F
- D_4 * grad(C_4) - s_4 * u_4 * C_4 * grad(V) = 0
C_4 = (s_1 * C_1 + s_2 * C_2 + s_3 * C_3)/s4
I_1_exp = (F/(2*R*T)) * (V + E0eq_I );
I_2_exp = (F/(2*R*T)) * (V + E0eq_II );
I_1 = I_0I * ( exp (-I_1_exp) - (C_1 / C_1_0) * exp (I_1_exp)) ;
I_2 = I_0II * ( (C_2 / C_2_0) * exp (-I_2_exp) - exp (I_2_exp)) ;

Where C_1, C_2, C_3, C_4 and V are the fields I want to calculate, and the others are known constants.

Thanks again.

Emmanuel

ngj December 16, 2013 14:39

Hi Emmanuel,

As I see it, you can approach this in a couple of ways:

1. You can linearise the system and solve it on an faMesh (available in OF1.6-ext), and then loop around the linearised, segregated system of equations until you have reach an given tolerance.

2. You can simply write your own non-segregated approach for this. If the equation only come in this form, it should be relatively easy, however, you need to be very careful in terms of correct coupling across potential processor boundaries in the case of parallel computing.

3. More recent versions of OF from ESI also support the solution of equations on boundary patches. I do not know, how these works, but it could be an option, if you work in one of those releases. Again, this will most probably lead to a linearised, segregated system, which requires a number of outer loops for convergence.

The outer loops obviously comes into play via the coupling between the C_i fields and V (their products) and also because V is inside the exponential. I am thinking whether a simple Taylor expansion with only 2 or 3 terms around the old value of V would be a good way of approaching this? It would mean that you could have part of the source term implicitly represented in your linear system of equations.

Good luck,

Niels

Minisasi November 18, 2015 11:01

Hello,
I know this is an old post, but I was wondering if you managed to solve the problem.
I am facing the same BC problem, where everything is coupling!:(

ancolli July 19, 2017 06:24

did u try groovyBC?

em17 September 24, 2018 12:15

Hi all,

Has anyone managed to implement a system of equations for a boundary condition?
I am trying to implement a system nonlinear inhomogeneous partial DE's too and would appreciate any guidance.

Thank you,
E

Diro7 January 28, 2021 08:46

Quote:

Originally Posted by em17 (Post 707284)
Hi all,

Has anyone managed to implement a system of equations for a boundary condition?
I am trying to implement a system nonlinear inhomogeneous partial DE's too and would appreciate any guidance.

Thank you,
E

Hi Emily,

may I ask you if you managed to implement the solution of a differential equation on a boundary?
I'd need something similar (indeed simpler than your problems, i.e. I have a single linear equation in time, at least for now). I thought of "manual" time integration, as it is seemingly also done in the "advective" BC mentioned in previous replies.

If you have any advice it would be much appreciated :)
Thanks,

Andrea


All times are GMT -4. The time now is 00:42.