


{"id":379237,"date":"2024-08-16T01:47:42","date_gmt":"2024-08-16T01:47:42","guid":{"rendered":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/error-udf-2\/"},"modified":"2024-08-16T12:16:11","modified_gmt":"2024-08-16T12:16:11","slug":"error-udf-2","status":"publish","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/error-udf-2\/","title":{"rendered":"error udf"},"content":{"rendered":"<p>I get this error when I use run simulation with this UDF:<br \/><a class=\"wp-colorbox-image cboxElement\" href=\"https:\/\/innovationspace.ansys.com\/forum\/wp-content\/uploads\/sites\/2\/2024\/08\/16-08-2024-1723810440-mceclip0.png\" data-wpel-link=\"internal\"><img decoding=\"async\" src=\"https:\/\/innovationspace.ansys.com\/forum\/wp-content\/uploads\/sites\/2\/2024\/08\/16-08-2024-1723810440-mceclip0.png\"><\/a><\/p>\n<div>\n<div>#include &#8220;udf.h&#8221;<\/div>\n<div>#include &#8220;dpm.h&#8221;<\/div>\n<div>#include<\/div>\n<p><\/p>\n<div>#define Rho_air 1.225<\/div>\n<div>#define mu 0.5<\/div>\n<div>#define PI 3.14<\/div>\n<div>#define VISC 1.7894e-05 \/\/ dynamic viscosity of air<\/div>\n<div>#define Rho_p 1550<\/div>\n<p><\/p>\n<div>FILE *fp1;<\/div>\n<p><\/p>\n<div>DEFINE_DPM_DRAG(particle_drag_force, Re, p)<\/div>\n<div>{ &nbsp; &nbsp;<\/div>\n<div>&nbsp; &nbsp; real b1, b2, b3, b4, Cd, drag_force, A, radius, df;<\/div>\n<div>&nbsp; &nbsp; real shf = 1;<\/div>\n<div>&nbsp; &nbsp; real nf, ff;<\/div>\n<p><\/p>\n<div>&nbsp; &nbsp; Thread* tcell = P_CELL_THREAD(p);<\/div>\n<div>&nbsp; &nbsp; cell_t c = P_CELL(p);<\/div>\n<div>&nbsp; &nbsp; real relVel[ND_3], dvtdn, fluidVel[ND_3];<\/div>\n<p><\/p>\n<div>&nbsp; &nbsp; \/\/ Fluid velocity<\/div>\n<div>&nbsp; &nbsp; NV_D(fluidVel, =, C_U(c, tcell), C_V(c, tcell), C_W(c, tcell)); &nbsp;\/\/ Assign fluid velocity components to vector<\/div>\n<div>&nbsp; &nbsp; \/\/ Relative velocity<\/div>\n<div>&nbsp; &nbsp; NV_VV(relVel, =, fluidVel, -, P_VEL(p)); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ Calculate relative velocity of flow on particle by subtracting absolute particle velocity from fluid velocity<\/div>\n<div>&nbsp; &nbsp; dvtdn = NV_MAG(relVel); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ Calculate relative velocity magnitude<\/div>\n<p><\/p>\n<div>&nbsp; &nbsp; radius = P_DIAM(p) \/ 2.0;<\/div>\n<div>&nbsp; &nbsp; A = PI * radius * radius;<\/div>\n<p><\/p>\n<div>&nbsp; &nbsp; b1 = exp(2.3288 &#8211; 6.4581 * shf + 2.4456 * pow(shf, 2));<\/div>\n<div>&nbsp; &nbsp; b2 = 0.0964 + 0.5565 * shf;<\/div>\n<div>&nbsp; &nbsp; b3 = exp(4.905 &#8211; 13.8944 * shf + 18.4222 * pow(shf, 2) &#8211; 10.2599 * pow(shf, 3));<\/div>\n<div>&nbsp; &nbsp; b4 = exp(1.4681 + 12.2584 * shf &#8211; 20.7322 * pow(shf, 2) + 15.8855 * pow(shf, 3));<\/div>\n<div>&nbsp; &nbsp; Cd = (24 * (1 + b1 * pow(Re, b2)) \/ Re) + (b3 * Re \/ (b4 + Re));<\/div>\n<p><\/p>\n<div>&nbsp; &nbsp; \/\/ Store drag force and other quantities in UDMs<\/div>\n<div>&nbsp; &nbsp; df = (1 \/ 2) * Rho_p * A * Cd * (dvtdn * dvtdn);<\/div>\n<p><\/p>\n<div>&nbsp; &nbsp; \/\/ Store quantities in UDMs<\/div>\n<div>&nbsp; &nbsp; C_UDMI(c, tcell, 0) = df; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ Store drag force<\/div>\n<div>&nbsp; &nbsp; C_UDMI(c, tcell, 1) = dvtdn; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ Store relative velocity<\/div>\n<div>&nbsp; &nbsp; nf = C_P(c, tcell) * A; &nbsp; &nbsp; &nbsp; \/\/ Calculate some quantity &#8216;nf&#8217;<\/div>\n<div>&nbsp; &nbsp; C_UDMI(c, tcell, 2) = nf; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ Store &#8216;nf&#8217;<\/div>\n<div>&nbsp; &nbsp; ff = mu * nf; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ Calculate some quantity &#8216;ff&#8217;<\/div>\n<div>&nbsp; &nbsp; C_UDMI(c, tcell, 3) = ff; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ Store &#8216;ff&#8217;<\/div>\n<div>&nbsp; &nbsp; C_UDMI(c, tcell, 4) = C_P(c, tcell); \/\/ Store cell pressure<\/div>\n<p><\/p>\n<div>&nbsp; &nbsp; P_USER_REAL(p, 0) = df;<\/div>\n<div>&nbsp; &nbsp; P_USER_REAL(p, 1) = dvtdn;<\/div>\n<div>&nbsp; &nbsp; P_USER_REAL(p, 2) = nf;<\/div>\n<div>&nbsp; &nbsp; P_USER_REAL(p, 3) = ff;<\/div>\n<div>&nbsp; &nbsp; P_USER_REAL(p, 4) = C_P(c, tcell);<\/div>\n<div>&nbsp; &nbsp; fp1=fopen (&#8220;Impact1.txt&#8221; , &#8220;a&#8221;) ;<\/div>\n<div>&nbsp; &nbsp; fprintf( fp1 , &#8220;%f %f %f %f %f\\n&#8221;, P_USER_REAL(p, 0), P_USER_REAL(p, 1), P_USER_REAL(p, 2), P_USER_REAL(p, 3), P_USER_REAL(p, 4));<\/div>\n<div>&nbsp; &nbsp; fclose(fp1);<\/div>\n<div>&nbsp; &nbsp; \/\/ Calculate drag force<\/div>\n<div>&nbsp; &nbsp; drag_force = (18 * Cd * Re) \/ 24; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ is this taking the reynolds number of the particle or the flow?<\/div>\n<p><\/p>\n<div>&nbsp; &nbsp; return drag_force;<\/div>\n<div>}<\/div>\n<\/div>\n<div>&nbsp;<\/div>\n<div>Can you please tell me what this error is??<\/div>\n<div>&nbsp;<\/div>\n<div>Thanks,<br \/>Kiran<\/div>\n","protected":false},"template":"","class_list":["post-379237","topic","type-topic","status-publish","hentry"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_subscription":["288381","15180","199"],"_bbp_author_ip":["2607:fea8:7a61:4800:a0ec:a8a3:4385:c710"]," _bbp_last_reply_id":["0"]," _bbp_likes_count":["0"],"_btv_view_count":["630"],"_bbp_topic_status":["unanswered"],"_edit_lock":["1723810572:288381"],"_bbp_topic_id":["379237"],"_bbp_forum_id":["27792"],"_bbp_engagement":["199","288381"],"_bbp_voice_count":["2"],"_bbp_reply_count":["1"],"_bbp_reply_count_hidden":["1"],"_bbp_last_reply_id":["389830"],"_bbp_last_active_id":["389830"],"_bbp_last_active_time":["2024-10-15 15:09:49"]},"test":"kiran-purushothamakeshavanontariotechu-net"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/379237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":2,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/379237\/revisions"}],"predecessor-version":[{"id":379267,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/379237\/revisions\/379267"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=379237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}