|
[Sponsors] |
September 26, 2014, 03:50 |
help udf error
|
#1 |
Member
ad
Join Date: Apr 2014
Posts: 75
Rep Power: 12 |
hi guys, i have a problem compiling a udf ,i want to simulate a pulse tube refrigerator,in order to model the piston i used this udf :
#include "udf.h" #include "dynamesh_tools.h" DEFINE_CG_MOTION(oscillate,dt,vel,omega,time,dtime ) { Thread *t; face_t f; /* define the variables */ t = DT_THREAD(dt); /* get the thread pointer for which the motion is defined */ /* if (!Data_Valid_P()) /* return; /* check if the values of the variables are accessible before you compute the function */ begin_f_loop(f,t) /* loop over each face in the zone to create an array of data */ { if (time <= 1) vel[0] = -2* 3.14159 * 2 * 0.025 * cos (2 * 3.14159 * 2 * time); /* define the velocity of the moving zone---*/ else vel[0] = 0; } end_f_loop(f,t) } i successfully compiled it,but when i tried to compile this udf for time dependent viscosity : #include "udf.h" DEFINE_PROPERTY(helium_viscosity,c,t) { real T = C_T(c,t); return (0.412e-6)*(T**0.68014); } it wont compile,i even tried a udf from fluent udf manual: #include "udf.h" DEFINE_PROPERTY(cell_viscosity, cell, thread) { real mu_lam; real T = C_T(cell, thread); if (T > 288.) mu_lam = 5.5e-3; else if (T > 286.) mu_lam = 143.2135 - 0.49725 * T; else mu_lam = 1.; return mu_lam; } but it wont compile either,does anyone know what might be the problem? please help |
|
September 26, 2014, 04:26 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Code:
T**0.68014 I guess you want Code:
pow(T,0.68014) |
|
September 26, 2014, 05:15 |
|
#3 |
Member
ad
Join Date: Apr 2014
Posts: 75
Rep Power: 12 |
thanks for your reply
i used your advice #include "udf.h" DEFINE_PROPERTY(helium_viscosity,c,t) { real T = C_T(c,t); return (0.412e-6)*pow(T,0.68014); } but it gave me this error: line 5: function returning float returns double. |
|
September 26, 2014, 05:45 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
That is not an error, but a warning (small difference).
What it means: you are calculating in double precision, but the function that you defined now returns a result in single precision. The compiler can change a number in single precision into a number in double precision, but it gives a warning because it might not have been what you intended. In your case, this is no problem. (The number 0.412e-6 is probably not exactly 0.4120000000000e-6, so single precision for the viscosity is accurate enough.) If you want to get rid of this warning, cast the result into a double yourself: Code:
return (real)((0.412e-6)*pow(T,0.68014)); |
|
September 26, 2014, 06:55 |
|
#5 |
Member
ad
Join Date: Apr 2014
Posts: 75
Rep Power: 12 |
thanks a lot man, you are so right, now i have one more problem im able to interpret but it wont compile,what do you think about this?whats the problem?
this is a first udf that i compiled:Copied C:\Users\edi\Desktop\kos/C:\Users\edi\Desktop\kos\piston.c to libudf\src Creating user_nt.udf file for 2ddp ... (system "copy "C:\PROGRA~1\ANSYSI~1\v150\fluent"\fluent15.0.0\sr c\makefile_nt.udf "libudf\win64\2ddp\makefile" ") 1 file(s) copied. (chdir "libudf")(chdir "win64\2ddp")# Generating ud_io1.h piston.c # Generating udf_names.c because of makefile piston.obj udf_names.c udf_names.c(8) : warning C4113: 'void (*)()' differs in parameter lists from 'void (*)(void)' # Linking libudf.dll because of makefile user_nt.udf udf_names.obj piston.obj Microsoft (R) Incremental Linker Version 10.00.30319.01 Copyright (C) Microsoft Corporation. All rights reserved. Creating library libudf.lib and object libudf.exp Done. but when i compile the second one nothing happend, Copied C:\Users\edi\Desktop\kos/C:\Users\edi\Desktop\kos\New Text Document (2).c to libudf2\src Copied C:\Users\edi\Desktop\kos/C:\Users\edi\Desktop\kos\piston.c to libudf2\src Creating user_nt.udf file for 2ddp ... (system "copy "C:\PROGRA~1\ANSYSI~1\v150\fluent"\fluent15.0.0\sr c\makefile_nt.udf "libudf2\win64\2ddp\makefile" ") 1 file(s) copied. (chdir "libudf2")(chdir "win64\2ddp") Done. |
|
September 26, 2014, 07:39 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
It could be because you have spaces in your filename.
|
|
September 26, 2014, 07:54 |
|
#7 |
Member
ad
Join Date: Apr 2014
Posts: 75
Rep Power: 12 |
you are right again,thank you so much man,thanks for your time
|
|
October 3, 2014, 09:02 |
|
#8 |
Member
ad
Join Date: Apr 2014
Posts: 75
Rep Power: 12 |
hi,i'v got another problem :
#include "udf.h" #define permeability 1.06e-10 #define resistance 76090 DEFINE_SOURCE(xmom_source,c,t,dS,eqn) { real x[ND_ND]; real source,a,b; C_CENTROID(x,c,t); a=(C_MU_L(c,t))/permeability; b=0.5*resistance*C_R(c,t); source=-((a*C_U(c,t))+(b*C_U(c,t)*fabs(C_U(c,t)))); dS=-(a+(2*b*fabs(C_U(c,t)))); return source; } when i try to interpret this udf it gives me line 12: invalid type conversion: double -> pointer to float. ,im new in c language,i cant undrestand the relation between float,double help please |
|
October 3, 2014, 09:18 |
|
#9 |
Member
ad
Join Date: Apr 2014
Posts: 75
Rep Power: 12 |
I missed a dS[eqn],problem solved
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[OpenFOAM] an error in Calculator's equation | immortality | ParaView | 12 | June 29, 2021 01:10 |
Undeclared Identifier Errof UDF | SteveGoat | Fluent UDF and Scheme Programming | 7 | October 15, 2014 08:11 |
ParaView for OF-1.6-ext | Chrisi1984 | OpenFOAM Installation | 0 | December 31, 2010 07:42 |
Installation OF1.5-dev | ttdtud | OpenFOAM Installation | 46 | May 5, 2009 03:32 |
Problem with compile the setParabolicInlet | ivanyao | OpenFOAM Running, Solving & CFD | 6 | September 5, 2008 21:50 |