CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   fatal error during initialization after udf compilation (https://www.cfd-online.com/Forums/fluent-udf/96571-fatal-error-during-initialization-after-udf-compilation.html)

Pacific February 17, 2020 09:02

Quote:

Originally Posted by vinerm (Post 758380)
Consider the following scenario

There is a flat plate and water is flowing on top of it. Due to this water flow, a convection coefficient is developed between the water and the flat plate. This depends upon the Re number of the flow and Pr of the water apart from the boundary conditions applied on the bottom side of the wall.

1. If you wish to apply an arbitrary heat flux or temperature or convection coefficient on the bottom of the plate (it could be function of space, time, temperature, or any other variable), then you would use DEFINE_PROFILE

2. If you wish to modify the convection coefficient calculated by Fluent between water and plate, this could be due to any reason that is not being simulated, such as rough wall, then you would use DEFINE_HEAT_FLUX

So, your understanding that DEFINE_HEAT_FLUX is to be used if the heat flux is a function of temperature is incorrect. The purpose of DEFINE_HEAT_FLUX is NOT to apply heat flux but modify its relation with the thermal field. To clarify it further, look at the hook point for both. DEFINE_HEAT_FLUX is hooked at a general location and it loops over all the boundaries that exist in your domain. On the other hand, DEFINE_PROFILE is applied on a specific boundary or cell zone.

I am really thankful for your time and effort.


I will read the UDF manual again to find the right function for the problem. I have seen codes in which Define_Profile modifies heat flux or other boundry conditions in terms of time or geometry, but I did not find any example of defining temperature dependent heat flux with this function.
I read somewhere that this function cannot define such a boundry condition.


Thanks a lot,

vinerm February 17, 2020 09:11

Modify
 
You can modify the following as per your requirement. I am writing it assuming heat flux is dependent upon a coefficient and temperature difference from a reference temperature.

#include "udf.h"
#define sCoeff 0.276 /* This and next can also be defined inside the function */
#define sRefTemp 320.0

DEFINE_PROFILE(tBasedHFlux, th, id)
{
face_t f;
begin_f_loop(f,th)
{
F_PROFILE(f, th, id) = sCoeff * (F_T(f, th) - sRefTemp)
}
end_f_loop(f,th)
}

You can apply it on any wall boundary. Actually, the code does not care. You can apply it on inlet, outlet, wherever you want. Do note that the output is not heat flux but a profile of some values. If applied to heat flux boundary, it behaves like heat flux and if applied to temperature, it behaves like temperature.

F_T is the temperature of the boundary where this UDF is applied. Fluent provides this value. All values are in SI.

Pacific February 17, 2020 10:40

Quote:

Originally Posted by vinerm (Post 758392)
You can modify the following as per your requirement. I am writing it assuming heat flux is dependent upon a coefficient and temperature difference from a reference temperature.

#include "udf.h"
#define sCoeff 0.276 /* This and next can also be defined inside the function */
#define sRefTemp 320.0

DEFINE_PROFILE(tBasedHFlux, th, id)
{
face_t f;
begin_f_loop(f,th)
{
F_PROFILE(f, th, id) = sCoeff * (F_T(f, th) - sRefTemp)
}
end_f_loop(f,th)
}

You can apply it on any wall boundary. Actually, the code does not care. You can apply it on inlet, outlet, wherever you want. Do note that the output is not heat flux but a profile of some values. If applied to heat flux boundary, it behaves like heat flux and if applied to temperature, it behaves like temperature.

F_T is the temperature of the boundary where this UDF is applied. Fluent provides this value. All values are in SI.

Dear Vinerm,


I do not know how to thank you for the time taking to respond me.
I hope you good fortune in the projects to come.


Regards,

Pacific February 19, 2020 02:05

Hi Vinerm,


I tried your code and faced the same error.
http://s7.picofile.com/file/83886695..._VIOLATION.JPG


I am trying to find the solution for my errors. I found the below pdf file which I think is very useful.
https://drive.google.com/file/d/1pQn...ew?usp=sharing


Regards,

vinerm February 19, 2020 03:29

Error
 
Where did you hook the code? Was it at a boundary? You seem to be using Fluent 6.3.26. Do note that you need to initialize the case before hooking the UDF.

Pacific February 19, 2020 04:08

Dear Vinerm,


The error was solved.

Yes, I'm using Fluent 6.3 on Windows XP.
Unfortunately, I do not have access to License Manager of Ansys Workbench and, therefore, I should think about mass transfer mechanism for evaporation and condensation phenomenon.
However, now that the Access_Violation error has solved and the case has almost completed, I can go somewhere for running on newer version of Ansys Fluent.


Again, thank you very much for the time and effort.
Regards,

vinerm February 19, 2020 05:08

Good
 
Nice to know that the issue got resolved. But could you also mention how it got resolved so that it could be helpful to others?

Pacific February 19, 2020 06:40

Thanks,

I think the initialization before interpreting the UDF was the solution.

I do not know why this can affect ACCESS_VIOLATION error.

I wonder whether the first code I used to run (Define_heat_Flux) can also work if I interpret it after initialization. It does not matter anymore, thogh.


And finally, can I ask another question?
Is it possible to read the temperature of a wall and insert it into another wall's boundary consition in UDF?


In other words, we want to define a boundary conditioon that connects the temperature of two walls. How can we define a coupled boundary condition in a single UDF code?


By the way, I should thank you again for all your advice.
Hope you good fortunes in the projects to come.

Regards,

vinerm February 19, 2020 14:43

Coupling
 
Yes, you can read temperature from one boundary and use it to apply some condition at another. It could be same or after some modifications.

Pacific February 19, 2020 15:07

That is great.


Thanks,

Pacific February 21, 2020 14:42

Another question about UDF and Thermoelectric:


I need to define Joul heating as a heat sourse as per:


Q = I^2 * R ; I : electriccurrent , R : electric resistance


Based on the Fluent UDF manual, I tried to use Define_Source function and apply it to the thermoelectric zone in my case. Since it is not for a wall or boundary condition, I did not use Define_Profile.

Here is the UDF:
---------------------------------------------------------------------
#include "udf.h"

DEFINE_SOURCE(Joule_heating, cell, thread)
{
real Joule_h,I,R,V;

I=5;
R=2;
V=0.0006; // The volume of TEC per unit depth [m^3/m]

Joule_h = R*I*I/V; // Joule heating [W/m^3/m]
return Joule_h;
}

------------------------------------------------------------------------

I would appreciate it if anyone could let me know whether or not this is true.
It should be noted that the code has been successfully interpreted by Fluent.


Regards,

vinerm February 21, 2020 15:05

UDF and value
 
The UDF as such is correct, but not needed. Since the value is not changing, you can apply a constant value within the cell zone.

For applying source terms, only DEFINE_SOURCE is applicable, DEFINE_PROFILE cannot be used. However, DEFINE_PROFILE can be used for profiles on boundary as well as cell zones.

Pacific February 21, 2020 15:12

Hi Vinerm,


Thank you very much.
The amount of heat source might vary versus temperature in my future studies. So I used Define_Source.

For example, resistivity of the thermoelectric material might change with temperature. I think I should use "C_T(cell,thread)" to apply tempreature into the code.


Regards,

Pacific February 21, 2020 15:21

Quote:

Originally Posted by Pacific (Post 758669)
Dear Vinerm,


The error was solved.

Yes, I'm using Fluent 6.3 on Windows XP.
Unfortunately, I do not have access to License Manager of Ansys Workbench and, therefore, I should think about mass transfer mechanism for evaporation and condensation phenomenon.
However, now that the Access_Violation error has solved and the case has almost completed, I can go somewhere for running on newer version of Ansys Fluent.


Again, thank you very much for the time and effort.
Regards,






Could anybody please inform me whether or not License Manager of Ansys can make problems for another software's License Manager like Amesim?

vinerm February 21, 2020 15:36

Temperature
 
Yes, you can use C_T(cell, thread) to access temperature of a cell.

Newer license managers from Ansys are not based on FlexLM, so, the changes for conflict with others are less. However, if the port required is same, then it could cause trouble. Ansys uses 1055 and 2325. You can modify these in the license file, reread the license file, and then change these at client machine.

Pacific February 21, 2020 15:40

Thanks again,


Amesim uses 5053 as I can recall.

I have tried to define environment variable as 5053@localhost.
But the problem was not solved.


By the way, thank you for the time and effort.

vinerm February 21, 2020 15:42

Hostname
 
Sorry, I have no idea about Amesim, however, localhost may not work with any license manager. License service requires the name of the host machine serving the license.


All times are GMT -4. The time now is 18:13.