|
[Sponsors] |
August 1, 2018, 09:58 |
Problem with DEFINE_SOURCE UDF
|
#1 |
New Member
Caro
Join Date: Jul 2018
Location: Germany
Posts: 14
Rep Power: 8 |
Hey everyone,
I'm trying to write and hook a DEFINE_SOURCE UDF that seems to be a bit complex. For this reason I'm trying to break the problem down just to see what happens. This is the code I'm working with right now: #include "udf.h" DEFINE_SOURCE(massdeposition_source,c,t,dS,eqn) { real source; source = 0.5; dS[eqn] = 0.0; return source; } There is no problem interpreting the code and I'm adding a mass source term in the cell zone condition panel. I thought it would be a good idea to start with a simple code and to add more variables and values to it, so I can see where exactly the problems are. However even the code you can see a few lines above doesn't work. I'd expected the value of 'massdeposition_source' to be 0.5 but it returns 0 Why does that happen and how can I fix it? |
|
August 1, 2018, 20:11 |
|
#2 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
Hi Car,
Building up complexity is an excellent plan. In typical models, a mass source of 0.5 kg/m3/s would be rather disruptive, so I would try a smaller number, but your case might be atypical. Note the units [kg/m3/s] -- I do wonder if the name "massdeposition_source" means that you are incorrectly intending some kind of surface effect. How are you detecting the zero values that you mention? You compile the UDF, and you hook it in as a mass source in a cell zone. What next? I think that source terms have no effect in the density based solver -- sorry, I don't have easy access to manuals right now. This happens silently (which is remarkably unhelpful). Good luck! Ed |
|
August 2, 2018, 16:36 |
|
#3 |
New Member
Caro
Join Date: Jul 2018
Location: Germany
Posts: 14
Rep Power: 8 |
Dear Ed
Thank you for your answer. Referring to your questions: After compiling and hooking the UDF I create a report for the UDF to save the information in a special file. I also use the button ‘print to console’ that one can use in the same panel (sorry if that aren’t exactly the names of the options, I am not at work anymore to have a look in the setup). So, while the simulation is running I can see in the console box values for k, epsilon, energy, my UDF, and some more. That’s where I get the values from. Before I start the calculation, I don’t do much more than that except initializing. Referring to your comments: The value I expect the UDF to be when it is at its end situation (most complex) has the dimension ~ 10^(-6). I ran the code that is shown in my first post for values between 0.000005 and 50000 just to see if it makes any difference which isn’t the case. I have no real reason to set it to 0.5 but I like the number anyway I changed it to a better fitting value now. I know the units and you are right with the assumption: I try to simulate a crystallisation process on a surface. My plan was to set a cell zone condition that lines the walls of the pipe the fluid is flowing through. The distance to the walls should be very small, so that the unit [kg/m^3s] can be converted to [kg/m^2s] (because the cell zone can approximately be seen one-dimensional). I know that this isn’t a proper approach, but I had no better idea to implement the problem of the crystallisation. Car (I just noticed that my nickname has an actual meaning in English language funny I didn't notice that before) |
|
August 2, 2018, 21:09 |
|
#4 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
Hi Car,
I am completely unfamiliar with the "print to console" button that you mention, and this surprises me. If you get the model working and get answers from this button that make sense, please tell me some details. I do not follow your logic about converting [kg/m2/s] to [kg/m3/s]. I think you try to find a way to use the wall-normal dimension (that is, the height) of each cell adjacent to the wall to make the conversion. This would work best for prismatic (including hexahedral) cells -- or, more correctly, this would be a difficult idea for tetrahedral cells. I'm still not sure it's a good idea. I could not see much wrong with the DEFINE_SOURCE UDF that you presented. Ignoring any "print to console" buttons, what happens when you run it? Ed |
|
August 3, 2018, 06:00 |
|
#5 |
New Member
Caro
Join Date: Jul 2018
Location: Germany
Posts: 14
Rep Power: 8 |
Hey Ed,
The geometry I use is 2D and the cells are rectangular. I think the unit of deposition is [kg/(m^2*s)]. Further, I thought the square meters of this unit are referring to the walls surface. The sink term might be in [kg/m^3/s] but in my theory with a very small distance to the wall the whole amount of the sink term can be assumed to crystallize at the wall. In other words, I would just neglect the distance dimension in the unit. Therefore, I would choose the heights of the cell zone depending on the results. The results should be as close to reality as possible. I would check them by comparing the simulation results with experimental results I have. It is an iterative method. Does this description make it clearer what I am trying to do? Cause it’s not easy to write out. However, I think it is what you mentioned in your post earlier this day but not for a 3D geometry. Just for your information if you want to know: to the ‘print to console’ button, you follow the path like Solution -> Report Definitions -> New -> User Defined A new window will open in which one can choose a UDF and a name for it. On the left side of this window under the headline ‘create’, one can find ‘report file’ and ‘report plot’. After activating one of those options, another option is available that is called ‘Print to Console’. That is what I use. Here I should say I’m using Ansys 19, student version. When I just run the code, everything seems to be fine except the missing data… I might have got something terribly wrong by thinking the results of the UDFs calculation would be available. Car |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM | Rizwan | Fluent UDF and Scheme Programming | 40 | March 18, 2018 07:05 |
Problem with DPM simulation with particles injection and EXECUTE_AT_THE_END UDF. | Ari | Fluent UDF and Scheme Programming | 4 | May 31, 2016 09:51 |
udf loading problem | santu | Fluent UDF and Scheme Programming | 1 | May 22, 2015 16:47 |
Vaporization pressure UDF property problem? | lehoanganh07 | Fluent UDF and Scheme Programming | 1 | September 13, 2014 11:59 |
Problem with my udf | july | Fluent UDF and Scheme Programming | 3 | June 20, 2010 07:56 |