How to integrate a new term in equation for scalar ?
-
- Posts: 22
- Joined: Wed Dec 11, 2013 6:15 pm
How to integrate a new term in equation for scalar ?
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
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
-
- Posts: 4207
- Joined: Mon Feb 20, 2012 3:25 pm
Re: How to integrate a new term in equation for scalar ?
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
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
-
- Posts: 22
- Joined: Wed Dec 11, 2013 6:15 pm
Re: How to integrate a new term in equation for scalar ?
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) :
= G_i - R_i \pm \nabla\cdot(n_i \frac{e_0 z_i D_i}{kT}\nabla\varphi}))
And, the desired form to improve my module in the Code-saturne 4:
= G_i - R_i })
In this case, the term of migration (
) is solved directly with the diffusion term.
Thank you in advance
Best regards
Paul
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 (
And, the desired form to improve my module in the Code-saturne 4:
In this case, the term of migration (
Thank you in advance
Best regards
Paul
Last edited by pleblanc86 on Thu Jun 30, 2016 7:55 am, edited 1 time in total.
-
- Posts: 4207
- Joined: Mon Feb 20, 2012 3:25 pm
Re: How to integrate a new term in equation for scalar ?
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
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
-
- Posts: 22
- Joined: Wed Dec 11, 2013 6:15 pm
Re: How to integrate a new term in equation for scalar ?
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
Thank again for your reply and to suggest to other colleague to take a look at my problem.
Have a nice day
Regards
Paul
-
- Posts: 22
- Joined: Wed Dec 11, 2013 6:15 pm
Re: How to integrate a new term in equation for scalar ?
Hello,
Did one of your colleague could look at mu problem ?
Thanks again, waiting for your reply
Paul
Did one of your colleague could look at mu problem ?
Thanks again, waiting for your reply
Paul
-
- Posts: 4207
- Joined: Mon Feb 20, 2012 3:25 pm
Re: How to integrate a new term in equation for scalar ?
Hello,
I mentioned your question to the colleague, but I'm not sure he has looked into it yet...
Regards,
Yvan
I mentioned your question to the colleague, but I'm not sure he has looked into it yet...
Regards,
Yvan
-
- Posts: 48
- Joined: Wed Mar 14, 2012 10:06 am
Re: How to integrate a new term in equation for scalar ?
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
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
-
- Posts: 48
- Joined: Wed Mar 14, 2012 10:06 am
Re: How to integrate a new term in equation for scalar ?
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
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
-
- Posts: 22
- Joined: Wed Dec 11, 2013 6:15 pm
Re: How to integrate a new term in equation for scalar ?
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
First of all, thank you for your reply. In response of this question
Thank you,
Best regards
Paul