

October 10, 2024 at 2:55 amyf70512Subscriber
Hello all,
I am trying to modify the source term (Changing the temperature power exponent from 1 to 4) of energy equation in nonequilibrium thermal model by UDS and UDF (DEFINE_SOURCE macro). But the Fluent crashed when the code runned with the error "999999:mpt_accept:error: accept failed: No error". I think there may be two questions:
1 how to access the solid temperature in the fluid zone and fluid temperature in the solid zone?
2 how to specify the UDS Scalar as the energy source (Figure 2)?
Could anybody help with this? Thank you in advance.
Best regards,Fan

October 10, 2024 at 7:33 amyf70512Subscriber
Here is my UDFï¼š
#include "udf.h"
#define HFS_CONSTANT 1000Â Â
#define AFS_CONSTANT 0.1Â Â Â// Fluid Source Term
DEFINE_SOURCE(Fluid_source, c, t, dS, eqn)
{
Â Â real Tf, Ts;
Â Â real hfs, Afs;
Â Â real source;Â Â // Obtain the fluid temperature (Tf) and solid temperature (Ts)
Â Â Tf = C_STORAGE_R(c, t, SV_T_F); Â // Access fluid temperature
Â Â Ts = C_STORAGE_R(c, t, SV_T_S); Â // Access solid temperature
Â Â Â
Â Â // Calculate or use constants for hfs (heat transfer coefficient) and Afs (interfacial area density)
Â Â hfs = HFS_CONSTANT; Â // Define or calculate hfs
Â Â Afs = AFS_CONSTANT; Â // Define or calculate AfsÂ Â // Calculate the source term using modified expression hA(Tf^4  Ts^4)
Â Â source = hfs * Afs * (pow(Ts, 4)  pow(Tf, 4));Â Â // Define the derivative of the source term with respect to Tf
Â Â dS[eqn] = 4 * hfs * Afs * pow(Tf, 3);Â Â return source; Â // Return the calculated source term
}// Solid Source Term
DEFINE_SOURCE(Solid_source, c, t, dS, eqn)
{
Â Â real Tf, Ts;
Â Â real hfs, Afs;
Â Â real source;Â Â // Obtain the fluid temperature (Tf) and solid temperature (Ts)
Â Â Ts = C_STORAGE_R(c, t, SV_T_S); Â // Access solid temperature
Â Â Tf = C_STORAGE_R(c, t, SV_T_F); Â // Access fluid temperatureÂ Â // Calculate or use constants for hfs (heat transfer coefficient) and Afs (interfacial area density)
Â Â hfs = HFS_CONSTANT; Â // Define or calculate hfs
Â Â Afs = AFS_CONSTANT; Â // Define or calculate AfsÂ Â // Calculate the source term using modified expression hA(Ts^4  Tf^4)
Â Â source = hfs * Afs * (pow(Ts, 4)  pow(Tf, 4));Â Â // Define the derivative of the source term with respect to Ts
Â Â dS[eqn] = 4 * hfs * Afs * pow(Ts, 3);Â Â return source; Â // Return the calculated source term
}I am not sure if it is right to access theÂ solid temperature in the fluid zone and fluid temperature in the solid zone.

October 10, 2024 at 1:33 pmRobForum Moderator
The problem isn't so much getting the fluid temperature as seen by the solid or vice versa but that you need to link to the two cells: so some care will be needed there.Â
Changing the exponent from 1 to 4 suggests radiation effects? Will this effect anything other than the front and rear (ie external surfaces) of the solid?

October 11, 2024 at 12:37 amyf70512Subscriber
Hi Rob,
Many thanks for your suggestions. I would like to ask how to link the two cells.
I have tried to link them by the spatial coordinate because a dual cell approach is used inÂ nonequilibrium thermal model.
But the same errors occured "999999:mpt_accept:error: accept failed: No error" . The code is following:
DEFINE_SOURCE(Fluid_source,c,t,dS,eqn)Â{Âreal xc[ND_ND], xcs[ND_ND];real Tf, Ts;real hfs = HFS_CONSTANT;Â // Placeholder value for heat transfer coefficientÂ Â real Afs = AFS_CONSTANT;Â Â // Placeholder value for interfacial area densityÂ Â real source;int zone_ID;Thread *st;cell_t sc;Domain *domain;// Solid_Cell_id *st;Â// FindÂ the coordinate position of the centroidC_CENTROID(xc,c,t);ÂÂ Â // Obtain fluid and solid temperaturesÂ Â Tf = C_T(c, t);Â // Fluid temperatureÂ Â // Ts = C_STORAGE_R(c, t, SV_T_S);Â // Solid temperatureÂÂzone_ID = THREAD_ID (t);Âif (zone_ID == 11){domainÂ = Get_Domain(27);thread_loop_c(st, domain) // loop over all cell threads in the domain{begin_c_loop (sc,st) // loop over all cellsÂ{C_CENTROID(xcs,sc,st);if (fabs(xc[0]  xcs[0]) < 1.0e6 && fabs(xc[1]  xcs[1]) < 1.0e6 && fabs(xc[2]  xcs[2]) < 1.0e6)Ts = C_T(sc,st);break;}end_c_loop (sc,st)}Â Â // DEFINE_PROFILE(Ts, st, xc);}if (zone_ID == 14){domainÂ = Get_Domain(33);thread_loop_c(st, domain){begin_c_loop (sc,st){C_CENTROID(xcs,sc,st);if (fabs(xc[0]  xcs[0]) < 1.0e6 && fabs(xc[1]  xcs[1]) < 1.0e6 && fabs(xc[2]  xcs[2]) < 1.0e6)Ts = C_T(sc,st);break;}end_c_loop (sc,st)}Â}Â Â // DEFINE_PROFILE(Ts, st, xc);ÂÂ Â // Calculate the source term based on the modified expressionÂ Â source = hfs * Afs * (pow(Ts, 4.0)  pow(Tf, 4.0));ÂÂ Â // Set the derivative of the source term with respect to TfÂ Â dS[eqn] =  4.0 * hfs * Afs * pow(Tf, 3.0);ÂÂ Â return source;Â}Besides, the effect (exponent from 1 to 4) in my caseÂ only affect the heat transfer in the interface between the solid and fluid.


 You must be logged in to reply to this topic.

861

427

368

225

201
Â© 2024 Copyright ANSYS, Inc. All rights reserved.