How can I modify the equation for electric potential?

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
rodion
Posts: 98
Joined: Wed Jan 11, 2017 4:13 pm

Re: How can I modify the equation for electric potential?

Post by rodion »

Hello Yvan,

Sorry, I meant cs_gradient_scalar or _gradient_scalar. I guess I have to use cs_gradient_scalar, right?

Also if I assume the homogeneous Neumann boundary condition, does it mean that I have to assign bc_coeff_a=0 and bc_coeff_b=1?

Furthermore, is there any way to call cs_gradient_scalar from Fortran?

Best regards,
Rodion
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: How can I modify the equation for electric potential?

Post by Yvan Fournier »

Hello Rodion,

Yes, _gradient_scalar is a low-level "private" function, simply used inside cs_gradient_scalar so to split the function in several pieces. Only cs_gradient_scalar is actually callable from outside the cs_gradient.c file.

To call it from Fortran, use cgdcel.

Best regards,

Yvan
rodion
Posts: 98
Joined: Wed Jan 11, 2017 4:13 pm

Re: How can I modify the equation for electric potential?

Post by rodion »

Dear Yvan,

Thanks a lot for the answer. It is surprising how much I did not know about the gradient computation in Code_Saturne, even though I looked into it for a while.

In the source code I can see that cgdcel is called by gradient_s in case without potential-type values and without weighting. Also specifically gradient_s is widely used in the source code of Code_Saturne, while cgdcel is only called by gradient_s. Does it mean that it is safer to use gradient_s for my purposes?
I can see that gradient_s has some extra treatment of periodicity, but I do not even know what is that.

In addition, if I assume the homogeneous Neumann boundary condition, does it mean that I have to assign bc_coeff_a=0 and bc_coeff_b=1?

Best regards,
Rodion
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: How can I modify the equation for electric potential?

Post by Yvan Fournier »

Hello Rodion,

I had forgotten about the gradient_s binding. If you have no periodicity, there is no major difference, but you are right, it is cleaner to use gradient_s.

An yes, if you assume homogeneous Neuman BC's, you have to provide bc_coeff_a and bc_coeff_b arrays (in version 6.0, in C functions, the code will automatically create temporary arrys with those values, but in version 5.0 or oldern if you do not provide these arrays, you will get a crash...).

If your value is a variable (i.e. solved, with boundary conditions) field, you can also use the high-level field_gradients_scalar. Otherwise, gradient_s with your bound boundary coefficient arrays is the way to go.

Best regards,

Yvan
rodion
Posts: 98
Joined: Wed Jan 11, 2017 4:13 pm

Re: How can I modify the equation for electric potential?

Post by rodion »

Hello Yvan,

Thanks a lot for your explanations. It is clear now. I will try to implement all these new things and get back to this thread to tell what I got.

Best regards,
Rodion

Update:
Okay, I implemented the equation for effective field in the model. In fact it didn't work as intended. It resulted in significant violation of conservation of electric current density. Taking into account the diffusion of electrons created parasitic electric current in all the areas with non-zero gradient of electron temperature. Due to the induced parasitic electric current and hence Joule power, the standard voltage scaling algorithm failed, so I had to switch to the current control over a cross section. In addition at the arc attachment to the electrodes the total electric current increased twofold. Perhaps I was doing something wrong and further checks and development are needed.

Rodion
Post Reply