|
[Sponsors] |
Boundary condition for multiregion scalar field |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 1, 2020, 17:34 |
Boundary condition for multiregion scalar field
|
#1 | ||||
New Member
Xun Lan
Join Date: Oct 2019
Posts: 21
Rep Power: 7 |
Hey foamers,
I am currently adding some new fields and equations to chtMultiRegionFoam. There's a quite good reference report: http://www.tfd.chalmers.se/~hani/kur...roject0126.pdf in which they used solidWallMixedTemperatureCoupled for boundary condition of the new field added. What they did in this BC was like replacing T with the new field Vel: Quote:
In openfoam 6, the BC used for temperature in the tutorials is: Quote:
Quote:
Quote:
https://www.openfoam.com/documentati...99f556a07d5c9f Any help will be deeply appreciated. Thanks in advance. Lan Last edited by Lann; June 2, 2020 at 16:54. |
|||||
June 5, 2020, 18:30 |
|
#2 |
New Member
Xun Lan
Join Date: Oct 2019
Posts: 21
Rep Power: 7 |
Stuck in here for days, still no clue.
Can someone give some tips? Many thanks! |
|
June 7, 2020, 04:22 |
Check the thermoPhysicalProperties
|
#3 |
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 11 |
Hello Lann,
I've been checking the source code to find what could be going on. The code I've found basically it search for the method to use for calculating the thermal conductivity. If you've chosen fluid it tries find for a turbulence model and use the turbulent effective conductivity, or otherwise look for a fluidThermo object inside the register. In case none of those options are available it raises the "thermo package not available". The file where the error is raised is "temperatureCoupledBase.C", if you want to check it. I've tried to replicate the error myself setting a wrong thermo, but OF will catch it and expose the available solutions. The only way I've managed to raise the "thermo package not available" is swapping the kappaMethod on the regions (this is, setting a fluidThermo to a solid region). You may want to check the constant/region/thermoPhysicalProperties and ensure that all the thermoTypes match what is defined in 0/region/T. If the region is a solid it must have a heRhoThermo, but none of the fluid regions shall have this type. Let's hope that can solve your problem! |
|
June 10, 2020, 18:43 |
|
#4 | |
New Member
Xun Lan
Join Date: Oct 2019
Posts: 21
Rep Power: 7 |
Quote:
Thank you so much for your reply. One thing I found that may cause the error is that the diffusivity I defined is a volScalorField. I did that because it's easier to add to the solver file, even though it's constant. All I need is a BC that fits my situation, that is on both sides of the interface the electric potential (I added in the solver) is equal. So I am not sure if it's a good idea to use solidWallMixedTemperatureCoupled. I used it only because it is used for temperature on the interface. I don't know for the electric potential fH (which I added to the solver) is there any other BCs more suitable? Thanks, Lan |
||
June 11, 2020, 04:17 |
|
#5 |
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 11 |
Ok, I missed the point. If you're not working with a temperature there it has sense that it blows trying to find a thermo object. What you want is just to ensure that fH in the patch regA_to_regB is equal to the one in regB_to_regA, right? In that case you can try a mapped patch.
Code:
regA_to_regB { type mapped; setAverage false; average 0; value 0; } You still have to solve how the regB_to_regA is connected to your problem, otherwise they will get stuck to the initial value of 0 and you will not model the connection among regions. Maybe setting to zeroGradient, or a fixed volume or whatever your problem needs. I think that generally you need to set some kind of balance in the interphase. The phenomena that is occurring in one side has to be connected somehow with the ones happening on the other side. In the case of temperature you have to ensure a energy balance between the heat transmitted along the two sides. Let's hope that helps you to advance with your model. Carlos |
|
June 13, 2020, 17:11 |
|
#6 | |||
New Member
Xun Lan
Join Date: Oct 2019
Posts: 21
Rep Power: 7 |
Quote:
Could you please explain where to solve how the regB_to_regA is connected? (Where should I add some codes?) I left the BC like you did: Quote:
There's also this warning in the log file: Quote:
I understand there's another connection between two sides, which, for my case of the electric field, may be the electric current flow. However, I don't know where to add this connection. Thanks for your patience. Best, Lan |
||||
June 14, 2020, 05:20 |
|
#7 | |
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 11 |
Hello again Lann,
Quote:
In one of them, let's say anode, you set the mapped patch on the anode_to_membrane. What this will do is to copy the values of the patch membrane_to_anode(from the region membrane) into anode_to_membrane(from the region anode). Thus, a link is created among these two regions: anode will be bounded to the region membrane (but not the opposite). Be aware that, in this scenario, the region membrane is not aware of the existence of the region anode as there is no link in the direction anode->membrane, just membrane->anode. Thus you must still set a meaningful boundary to membrane_to_anode, for example zeroGradient. OF will solve membrane region using this boundary condition and, afterwards, impose the values obtained in the surface into anode_to_membrane for solving the region anode. This may be a too simplistic model for many situations, but at least may give you some insight on how to connect regions. For a more complex interaction between these two regions you must define how these two fields are coupled, as is the example of the temperature coupled. In this case the different region temperatures, effective conductivities and maybe surface radiations are used to calculate the surface temperature that adjust a thermal balance, and then each region is solved separately. For doing this you may need to write your own BC. You can use compressible::turbulentTemperatureCoupledBaffleMix ed as a template, for this. P.D: The warning is just telling you that the mapped shall be described as: Code:
regA_to_regB { type mapped; average 0; value uniform 0; } |
||
September 25, 2020, 21:23 |
|
#8 | ||
New Member
Xun Lan
Join Date: Oct 2019
Posts: 21
Rep Power: 7 |
Quote:
Sorry to write to you after 3 months. Unfortunately, I'm still stuck in the problem I mentioned above. Basically, I need to find, or build, a BC on the interface of two regions (anode and membrane) that enures the scalar (electric potential) on each side is equal and the current (sigma*grad.fi) is equal, just like two joint walls having same temperature and heat flux on the interface. As you suggested before, I tried to build a new BC based on compressible::turbulentTemperatureCoupledBaffleMix. However, I cannot change the diffusivity (kappa) inside this BC, because kappa is strongly linked to the thermal model and cannot be replaced. Luckily, I found a similar BC that can be used directly for my case, that is Quote:
However, solidWallMixedTemperatureCoupledFvPatchScalarField only exit in old versions of OF and was removed then. Now for newer version of OF, compressible::turbulentTemperatureCoupledBaffleMix was implemented for replacing solidWallMixedTemperatureCoupledFvPatchScalarField and can adjust to a wider range of situations, like two-phase interface.... However, it can be only used for temperature and kappa. Then I tried to add compressible::turbulentTemperatureCoupledBaffleMix to my OF6, but I failed due to there's several files included that is modified or missing in my OF6. I am wonder if I should continue building a new BC, or try to implement compressible::turbulentTemperatureCoupledBaffleMix (old version BC) to my OF6 until it works implement, or maybe there's just better BC that works for my case. I know what I wrote is too long and you were helping me without return, so it's ok if you cannot help more. Thank you for having helped a lot. Lan Last edited by Lann; September 26, 2020 at 12:50. |
|||
October 7, 2020, 09:50 |
|
#9 |
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 11 |
Hello Lann,
Sorry for being missing so long. I've seen your post but I cannot find any time to think about it and give you an answer untill now. I've been seeing the code on turbulentTemperatureCoupledBaffleMixed and I've seen the relation with kappa that you mention, but I think it would not be so hard to overcome this issue by overwritting the kappa function (defined on temperatureCoupledBase). I'm going to try to write a potentialCoupledBaddleMixed code so you can use it in your model. In mi mind I think that the sigma funcion is not dependent on the electrical potential, right? It may be dependent on the temperature, but let's first try it with a constant sigma, ok? I let you know when I have the time to modify and try the code, but it will be quite usefull if you can share with me some test-case and solver so I can make some trials by my own. |
|
October 7, 2020, 10:01 |
|
#10 | |
New Member
Xun Lan
Join Date: Oct 2019
Posts: 21
Rep Power: 7 |
Quote:
Thank you for your reply! Yes, the sigma funcion is not dependent on the electrical potential nor on the temperature at the moment (may study the temperature dependent issue in the future). Just wanna let you know the sigma is defined as a volume scalar in the solver. I'll send you the solver and test case right away. Thanks again! Lan |
||
October 8, 2020, 04:57 |
First version of potentialCoupledBaffleMixedFvPatch
|
#11 | |
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 11 |
Quote:
I've been working on this condition and I think I already have something you can try. I didn't have the chance to look your solver in detail. I see that you have a couple sigma fields on each domain (sigma_e and sigma_H). I am not familiar with the resolution of electromagnetic equations so I do not fully comprehed these terms. I'm guessing that they are electrical conductivities, but why there are two of them? Anyway if you define as scalarFields is because they have different values along the domain, isn't it? As I cannot identify properly the usage of these fields, I just defined the boundary condition so you can define the value of sigma of the interface in the boundary itself (see the example bellow) Code:
regA_to_regB { type potentialCoupledBaffleMixed; Tnbr T; // or the name of the potential field sigma 1000; // The value of sigma in the regA } For this to work you have to compile the code I attached bellow (I've tried on OF7, but it shall compile on OF6 as well) and add the resultant library on the controlDict: Code:
libs ("libpotentialcoupled.so"); |
||
October 8, 2020, 08:37 |
|
#12 | ||
New Member
Xun Lan
Join Date: Oct 2019
Posts: 21
Rep Power: 7 |
Quote:
thank you for your fast reply! Let me answer a few questions at first. - There are two electrical conductivities(sigma_e and sigma_H) because there are two electrical potential transport equations, one is proton H+ and the other is electron e- - Yes, the electrical conductivities have different values along the domain. However, there's error when I tried to wmake the code. Quote:
Lan |
|||
October 8, 2020, 09:16 |
|
#13 | |
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 11 |
Quote:
Check this file adapted to OF6. |
||
November 30, 2020, 14:31 |
|
#14 | |
New Member
Artem
Join Date: Apr 2014
Posts: 29
Rep Power: 12 |
Quote:
Firstly, thank you for sharing your work here. I also would like to use the interface condition for electrical potential and I find your BC very helpful. May I ask a question about how your BC treats sigma (electrical conductivity)? In my case, sigma is constant in the first domain and constant in the second domain but these constants are different from each other. 1. If I specify sigma as a scalar field in each domain, your BC changes sigma value at the interface, doesn't it? What in that case should I specify in the sigma field file for the interface BC: zeroGradient or calculated or something else? 2. Or your BC treats sigma as a constant from the transport properties file (each constant to each domain)? Regards, Artem Last edited by Kombinator; November 30, 2020 at 16:07. |
||
December 3, 2020, 03:12 |
|
#15 | |
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 11 |
Hi Artem,
Glad to know my work can be useful for someone else, thank you for letting me know . Concerning your question: Quote:
The approach 1 you're suggesting is interesting if sigma is changing along the domain and it is magnitudes are required for other calculation inside the region. The second approach you mention is the "correct" way to do it if sigma is a material property, just to be consistent with the structure of OF cases. As I do not know the precise nature of your calculation, I don't know if the approach 1 should be more interesting for you, so I went to the simpler solution I can imagine, although it may not be the most elegant solution. Let me know if you got any further problems and I will see if I can find some time to improve the code. Good luck! |
||
December 5, 2020, 09:50 |
|
#16 | |
New Member
Artem
Join Date: Apr 2014
Posts: 29
Rep Power: 12 |
Quote:
|
||
Tags |
boundary condition, cht coupling, chtmulitregionfoam, multi region |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
sliding mesh problem in CFX | Saima | CFX | 46 | September 11, 2021 08:38 |
Division by zero exception - loop over scalarField | Pat84 | OpenFOAM Programming & Development | 6 | February 18, 2017 06:57 |
[mesh manipulation] Importing Multiple Meshes | thomasnwalshiii | OpenFOAM Meshing & Mesh Conversion | 18 | December 19, 2015 19:57 |
An error has occurred in cfx5solve: | volo87 | CFX | 5 | June 14, 2013 18:44 |
Error finding variable "THERMX" | sunilpatil | CFX | 8 | April 26, 2013 08:00 |