CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

fatal error during initialization after udf compilation

Register Blogs Community New Posts Updated Threads Search

Like Tree12Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 17, 2020, 10:02
Default
  #21
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 12
Pacific is on a distinguished road
Quote:
Originally Posted by vinerm View Post
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,
Pacific is offline   Reply With Quote

Old   February 17, 2020, 10:11
Default Modify
  #22
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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 likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.

Last edited by vinerm; February 17, 2020 at 10:38. Reason: Additional Information
vinerm is offline   Reply With Quote

Old   February 17, 2020, 11:40
Default
  #23
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 12
Pacific is on a distinguished road
Quote:
Originally Posted by vinerm View Post
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,

Last edited by Pacific; February 19, 2020 at 03:06.
Pacific is offline   Reply With Quote

Old   February 19, 2020, 03:05
Default
  #24
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 12
Pacific is on a distinguished road
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,

Last edited by Pacific; February 19, 2020 at 05:09.
Pacific is offline   Reply With Quote

Old   February 19, 2020, 04:29
Default Error
  #25
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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 likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 19, 2020, 05:08
Default
  #26
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 12
Pacific is on a distinguished road
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,
Pacific is offline   Reply With Quote

Old   February 19, 2020, 06:08
Default Good
  #27
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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 likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 19, 2020, 07:40
Default
  #28
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 12
Pacific is on a distinguished road
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,
Pacific is offline   Reply With Quote

Old   February 19, 2020, 15:43
Default Coupling
  #29
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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 likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 19, 2020, 16:07
Default
  #30
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 12
Pacific is on a distinguished road
That is great.


Thanks,
Pacific is offline   Reply With Quote

Old   February 21, 2020, 15:42
Default
  #31
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 12
Pacific is on a distinguished road
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,
Pacific is offline   Reply With Quote

Old   February 21, 2020, 16:05
Default UDF and value
  #32
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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 likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 21, 2020, 16:12
Default
  #33
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 12
Pacific is on a distinguished road
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 is offline   Reply With Quote

Old   February 21, 2020, 16:21
Default
  #34
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 12
Pacific is on a distinguished road
Quote:
Originally Posted by Pacific View Post
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?
Pacific is offline   Reply With Quote

Old   February 21, 2020, 16:36
Default Temperature
  #35
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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 likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 21, 2020, 16:40
Default
  #36
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 12
Pacific is on a distinguished road
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.
Pacific is offline   Reply With Quote

Old   February 21, 2020, 16:42
Default Hostname
  #37
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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.
Pacific likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF compilation error Szabolcs Varga Fluent UDF and Scheme Programming 4 September 14, 2015 06:27
UDF compilation problem -- "undeclared variable" Henrik Ström FLUENT 1 September 21, 2005 06:25
error while compiling the USER Sub routine CFD user CFX 3 November 25, 2002 16:16
UDF initialization Sam FLUENT 1 May 21, 2002 09:23
Compiled UDF / Compilation problem mikhail FLUENT 1 October 13, 2000 07:12


All times are GMT -4. The time now is 20:58.