How to integrate a new term in equation for scalar ?

Miscellaneous discussion topics about Code_Saturne (development, ...)
Post Reply
pleblanc86
Posts: 22
Joined: Wed Dec 11, 2013 6:15 pm

How to integrate a new term in equation for scalar ?

Post by pleblanc86 »

Hello everybody,

Recently, I wrote a module in Code-Saturn 3 (in the elec folder) to simulate the generation, the development and transport of the electrical charge and does it works !!! But today, I would like rewrite my module in Code-Saturn 4 to improve this simulation. Indeed in the calcul of the different concentration (equation transport of scalar), the term of electrical migration (due to the presence of local electric field) is not implicit term but it is added as a source term in the equation. I would like to implcit this term in the equation with the diffusion term (in the new version of code-saturn).

Is the moddifiation is possible ?

Thank you in advance
Best regards

Paul Leblanc
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: How to integrate a new term in equation for scalar ?

Post by Yvan Fournier »

Hello,

When defining user source terms, you can always add an implicit part (just make sure the implicit + explicit parts amount to the total source term). This has not changed from 3.0 to 4.0.
What has changed, if if you need to add a scalar, this is not done anymore in cs_user_parameters.f90 but in the cs_user_model function in sc_user_parameters.c (check the examples in the same file; those examples are currently missing from the Doxygen documentation, so you need to check the file).

As quite a bit of syntax and access to variables have changed from 3.0 to 4.0, I recommend updating your code to 4.0 first, checking that it works again, and improve it only as a second step (so you test the upgrade and modification separately).

Regards,

Yvan
pleblanc86
Posts: 22
Joined: Wed Dec 11, 2013 6:15 pm

Re: How to integrate a new term in equation for scalar ?

Post by pleblanc86 »

Hello Yvan,

Thank you for your reply.

When I wrote my module, I modified and used the module "Conduction ionique" (ielion). In Code-saturn, there is two terms for the transport of scalar : diffusion and convection. But, I would like to known if it is possible to add a new term in your equation of scalar. The aim is to have a new term which is solved at the same time of diffusion term.

Actually, the form of equation in Code-saturn 3 for my module ( is a scalar) :



And, the desired form to improve my module in the Code-saturne 4:



In this case, the term of migration () is solved directly with the diffusion term.

Thank you in advance

Best regards
Paul
Last edited by pleblanc86 on Thu Jun 30, 2016 7:55 am, edited 1 time in total.
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: How to integrate a new term in equation for scalar ?

Post by Yvan Fournier »

Hello,

I'm not sure about this, and don't have time to look at the details for now, but I'll suggest to other colleagues to take a look within a few days.

At first glance, it would seem feasible (if you solve it at the same time as convection-diffusion, the impact it has on the matrix may or may not require a different linear solver, depending on whether it changes the diagonal dominance of that matrix or not).

Regards,

Yvan
pleblanc86
Posts: 22
Joined: Wed Dec 11, 2013 6:15 pm

Re: How to integrate a new term in equation for scalar ?

Post by pleblanc86 »

Hello,

Thank again for your reply and to suggest to other colleague to take a look at my problem.

Have a nice day
Regards

Paul
pleblanc86
Posts: 22
Joined: Wed Dec 11, 2013 6:15 pm

Re: How to integrate a new term in equation for scalar ?

Post by pleblanc86 »

Hello,

Did one of your colleague could look at mu problem ?

Thanks again, waiting for your reply

Paul
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: How to integrate a new term in equation for scalar ?

Post by Yvan Fournier »

Hello,

I mentioned your question to the colleague, but I'm not sure he has looked into it yet...

Regards,

Yvan
Martin FERRAND
Posts: 44
Joined: Wed Mar 14, 2012 10:06 am

Re: How to integrate a new term in equation for scalar ?

Post by Martin FERRAND »

Hello Paul,
Reading your problem, I think you can do it using DRIFT modelling. Your scalar is nothing else that transported by the velocity u plus a drift (proportional to grad phi). This is possible in version 4.0 to activate drift to a scalar (look at DRIFT in cs_user_parameters.f90) but usually the drift is align with the gravity. In your case you need to adapt that. You can have a look to src/base/driflu.f90 which is adding the drift velocity to the convective velocity.
Best Regards
Martin
Martin FERRAND
Posts: 44
Joined: Wed Mar 14, 2012 10:06 am

Re: How to integrate a new term in equation for scalar ?

Post by Martin FERRAND »

Hello again,
Just a small additional remark: is "ni" a component of a vector? If so, I would suggest you to move to the trunk version because we add the capability to transport vector species (or if not it will be in the coming days).
Best regards
Martin
pleblanc86
Posts: 22
Joined: Wed Dec 11, 2013 6:15 pm

Re: How to integrate a new term in equation for scalar ?

Post by pleblanc86 »

Hello Martin,

First of all, thank you for your reply. In response of this question is the tranport scalar. In migration term, it is a factor of the potential gradient. If I will understanding well, I have to adapt the driflu.f90 for my situation.

Thank you,
Best regards

Paul
Post Reply