Multiple convection fields
Multiple convection fields
It is sometimes useful to have different convection fields for different species and heat. For example, my problem involving liquid flow driven by small bubbles needs a convection velocity field including the upward drift of bubbles. And one could do Nernst-Planck electromigration modeling by adding a grad(potential) term to the convection velocity in the advection-diffusion equation.
Unfortunately, right now there's just one "Convection" keyword for heat and all solutes. What would it take to separate this into multiple such keywords, e.g. "Heat Convection" for thermal and, say, "Oxygen Convection" for diffusion (following the example in the Models Manual)?
The one hitch is backward compatibility, it would need to understand plain "Convection" as applying to all of them.
-Adam
Unfortunately, right now there's just one "Convection" keyword for heat and all solutes. What would it take to separate this into multiple such keywords, e.g. "Heat Convection" for thermal and, say, "Oxygen Convection" for diffusion (following the example in the Models Manual)?
The one hitch is backward compatibility, it would need to understand plain "Convection" as applying to all of them.
-Adam
-
- Site Admin
- Posts: 4832
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: Multiple convection fields
Hi
Of course one can introduce new keywords using the GetReal command for the same same purpose and use the original if the newer option is not found. However, for this case there might be a partial remedy already. The HeatSolver knows the keyword "Temperature Convection Field" (in Solver section) and the AdvectionDiffusion solver the "Convection Field Variable". Maybe not most coherent keywords but this means that you can anyways choose different fields for the different solvers (the default field is the "Flow Solution" as computed by the N-S solver).
Unfortunately, this relates to the option that convection field is "computed". If you have a field that is composed of several parts, it is currently not simple to get the derived field to be a proper Variable. Maybe the "Exported Variable i", i=1,2,... could also have a value defining part so that derived field could be computed after the solution of a specific solver. This might help in some other cases as well. Currently there is only SaveMaterials auxiliary solver that supports the making of additional variables from material properties that can have a free expression form.
Well, this probably didn't solve any of your problems. We'll have to think a little bit for a generic solution. You can always change the keywords for your own purposes. For example, setting the "Convection = constant" and renaming the keywords "Convection Velocity i", i=1,2,3 differently in the two Solvers in questions might be the easiest quick remedy.
-Peter
PS. The Nernts-Planck idea might be more conveniently implemented using the potential field directly rather than computing a velocity field of it in between. So this might be similar addition as the Soret diffusion where the velocity is proportional to the gradient of the temperature field.
Of course one can introduce new keywords using the GetReal command for the same same purpose and use the original if the newer option is not found. However, for this case there might be a partial remedy already. The HeatSolver knows the keyword "Temperature Convection Field" (in Solver section) and the AdvectionDiffusion solver the "Convection Field Variable". Maybe not most coherent keywords but this means that you can anyways choose different fields for the different solvers (the default field is the "Flow Solution" as computed by the N-S solver).
Unfortunately, this relates to the option that convection field is "computed". If you have a field that is composed of several parts, it is currently not simple to get the derived field to be a proper Variable. Maybe the "Exported Variable i", i=1,2,... could also have a value defining part so that derived field could be computed after the solution of a specific solver. This might help in some other cases as well. Currently there is only SaveMaterials auxiliary solver that supports the making of additional variables from material properties that can have a free expression form.
Well, this probably didn't solve any of your problems. We'll have to think a little bit for a generic solution. You can always change the keywords for your own purposes. For example, setting the "Convection = constant" and renaming the keywords "Convection Velocity i", i=1,2,3 differently in the two Solvers in questions might be the easiest quick remedy.
-Peter
PS. The Nernts-Planck idea might be more conveniently implemented using the potential field directly rather than computing a velocity field of it in between. So this might be similar addition as the Soret diffusion where the velocity is proportional to the gradient of the temperature field.
Re: Multiple convection fields
Hi Peter,
Ah, neither of these is documented in the Models Manual, but I can see them in the source code. So I'd need to set up a couple of vector variables then...raback wrote:The HeatSolver knows the keyword "Temperature Convection Field" (in Solver section) and the AdvectionDiffusion solver the "Convection Field Variable". Maybe not most coherent keywords but this means that you can anyways choose different fields for the different solvers (the default field is the "Flow Solution" as computed by the N-S solver).
Okay, this is good to know in terms of setting up variables. Looks like this could take some work, but thanks.Unfortunately, this relates to the option that convection field is "computed". If you have a field that is composed of several parts, it is currently not simple to get the derived field to be a proper Variable. Maybe the "Exported Variable i", i=1,2,... could also have a value defining part so that derived field could be computed after the solution of a specific solver. This might help in some other cases as well. Currently there is only SaveMaterials auxiliary solver that supports the making of additional variables from material properties that can have a free expression form.
That doesn't work, it leads to a section like:Well, this probably didn't solve any of your problems. We'll have to think a little bit for a generic solution. You can always change the keywords for your own purposes. For example, setting the "Convection = constant" and renaming the keywords "Convection Velocity i", i=1,2,3 differently in the two Solvers in questions might be the easiest quick remedy.
Code: Select all
Equation 1
Name = "Bubble flow"
Concentration Units = Absolute Mass
Convection velocity 1 = Equals Velocity 1
Convection = Constant
Convection velocity 2 = Equals Velocity 2
Convection = Constant
Convection velocity 3 = 0
Convection velocity 1 = Equals Velocity 1
Convection velocity 2 = Variable Velocity 2; Real MATC "tx+0.01"
Active Solvers(4) = 3 1 2 4
End
Good idea, I hadn't considered the similarity to Soret. And the default mobility would just be D/RT. I'll see if I can get some time to work up a patch.PS. The Nernts-Planck idea might be more conveniently implemented using the potential field directly rather than computing a velocity field of it in between. So this might be similar addition as the Soret diffusion where the velocity is proportional to the gradient of the temperature field.
Re: Multiple convection fields
Hi, I'm going to need a bit more help to use SaveMaterials to create the convection velocity variable, for heat or advection/diffusion. There is little documentation, and there are no examples, for SaveMaterials. I think I can see how to create scalar variables, but how do I create a vector variable?
-
- Site Admin
- Posts: 4832
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: Multiple convection fields
Perhaps the "SaveMaterials" is not the best way to create the secondary flow field. I guess what you need is a field u=v+w, where v is the computed flow field and w is defined analytically, and u should be available as a proper vector field. This would not be many lines of in a tailored solver.
A generic solution might be to include an optional expression field in every Exported Variable. This would be evaluated at the end of each solver run. The outcome in sif could look like:
This would offer possibilities also for ElmerGUI implementation where as
would be perhaps prettier but the dynamic naming is not easily compatible with the GUI. Still even this idea looses some of its attraction for vector fields. Below is how a constant contribution would be added to the z-component:
Any better ideas? Implementation would not be that difficult once a good syntax is found.
-Peter
A generic solution might be to include an optional expression field in every Exported Variable. This would be evaluated at the end of each solver run. The outcome in sif could look like:
Code: Select all
Variable = Temperature ! the true variable
...
Exported Variable 1 = CTemperature ! derived variable
Exported Variable 1 Value = Variable Temperature
Real MATC "tx-273.15"
Code: Select all
CTemperature = Variable Temperature
Real MATC "tx-273.15"
Code: Select all
Exported Variable 1 = -dofs 3 AnotherFlow
Exported Variable 1 Value 1 = Equals Flow 1
Exported Variable 1 Value 2 = Equals Flow 2
Exported Variable 1 Value 3 = Variable Flow 3
Real MATC "tx+1.23" !
-Peter
Re: Multiple convection fields
Thank you for all of your help. I have tried this, but am having trouble: whenever I use "Convection Field Variable = AnotherFlow" the Advection Diffusion Equation norm is NaN. When I try "Convection Field Variable = Velocity" it says: "ERROR:: AdvectionDiffusion: No convection variable velocity available", same if I use "Convection Field Variable = Flow", which is odd. Shouldn't either Velocity or Flow be available?
I will dig through AdvectionDiffusion.src to see if I can find something to make this work. Thanks again.
I will dig through AdvectionDiffusion.src to see if I can find something to make this work. Thanks again.
-
- Site Admin
- Posts: 4832
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: Multiple convection fields
Sorry, in my previous mail I was merely suggesting different scenarios on how this could be implemented in to the code. So the syntax was sort of open for comments and I'll hopefully add these new features in near future.hazelsct wrote:Thank you for all of your help. I have tried this, but am having trouble: whenever I use "Convection Field Variable = AnotherFlow" the Advection Diffusion Equation norm is NaN. When I try "Convection Field Variable = Velocity" it says: "ERROR:: AdvectionDiffusion: No convection variable velocity available", same if I use "Convection Field Variable = Flow", which is odd.
-Peter
Re: Multiple convection fields
Hi, I've been using the attached patch as a solution, which prepends "Concentration" or the species variable to the convection parameters. The cost is backward compatibility, which of course is broken.
But the present situation is not compatible with ElmerGUI, as it leads to multiple "Convection" keywords if coupled with the heat equation. Even if the convection velocity fields the same, which is usually the case, two or more repetitions would be confusing, so this clarifies that situation.
There is also a corresponding patch to advection-diffusion.xml which changes a couple of other things as well. With this patch, one can run the solver in the GUI without editing the SIF file first.
-Adam
But the present situation is not compatible with ElmerGUI, as it leads to multiple "Convection" keywords if coupled with the heat equation. Even if the convection velocity fields the same, which is usually the case, two or more repetitions would be confusing, so this clarifies that situation.
There is also a corresponding patch to advection-diffusion.xml which changes a couple of other things as well. With this patch, one can run the solver in the GUI without editing the SIF file first.
-Adam
- Attachments
-
- advection-diffusion.diff.txt
- Patch to change "Advection Diffusion Equation" to "Advection Diffusion Concentration" so species variable name is in the PDE name; prepend Concentration to convection commands; and expose Convection Field Variable in the GUI
- (4.29 KiB) Downloaded 280 times
-
- AdvectionDiffusion.diff.txt
- Patch to add species variable e.g. Concentration to all convection commands, and move Convection Velocity and Convection Field Variable from Material to Equation section
- (2.12 KiB) Downloaded 282 times
Re: Multiple convection fields
Sorry, I left out one patch fragment needed for this to work, which is the second part of the attached.
- Attachments
-
- AdvectionDiffusion.diff.txt
- Diff to AdvectionDiffusion.src and SOLVER.KEYWORDS
- (2.9 KiB) Downloaded 279 times
Re: Multiple convection fields
Adam,
thanks for your effort, this really seems messy. The "freesurface.xml" adds to
the confusion by setting the value of the (one and the same) "Convection"
field to "Computed" by default, and you don't even notice it in the other solvers...
I'll have a look at your patches something about this next week, hopefully we can
sort it out....
Regads, Juha
thanks for your effort, this really seems messy. The "freesurface.xml" adds to
the confusion by setting the value of the (one and the same) "Convection"
field to "Computed" by default, and you don't even notice it in the other solvers...
I'll have a look at your patches something about this next week, hopefully we can
sort it out....
Regads, Juha