-
-
April 15, 2024 at 4:11 amZwernjaydenSubscriber
I want my udf to update the surface tempurature to T(f), and the mass flow inlet to m_dot at the end. When try and use the DEFINE_ADJUST macro it crashes and says "999999: mpt_accept: error: accept failed: No error." The current code below compiles and works at printing the values (although they aren't really what I expected). I have also attached the pseudo code of what I am trying to do.
#include "udf.h"#includeDEFINE_EXECUTE_AT_END(print_heat_flux){Domain *d;Thread *t;face_t f;real Ts, heat_flux, Hv, r, Ts_old, Ts_new, m_dot, T; // Declare all variables at the top of the blockreal error;int iter;d = Get_Domain(1); // Adjust the domain ID as per your case/* Loop over all face threads in the domain */thread_loop_f(t, d){/* Check if this is the boundary with the ID you're interested in */if (THREAD_ID(t) == 6) // Adjust the surface ID as per your case{/* Loop over all faces in this thread */begin_f_loop(f, t){Ts = F_T(f, t); // Get the temperature at face fheat_flux = BOUNDARY_HEAT_FLUX(f, t); // Calculate the heat fluxprintf("Heat flux on face %d: %g W/m^2\n", f, heat_flux);Ts_old = Ts;iter = 0;error = 1;while (error>1e-6 && iter <10){Hv = 2033631 + 310000 + 1500;r = heat_flux/(Hv*900);Ts_new = 20557.188 / (8.314 * (log(0.01104) - log(r)));error=fabs(Ts_new-Ts_old);iter++;}T(f)=Ts+0.1*(Ts_new-Ts);r = heat_flux/(Hv*900);printf("Regression Rate: %g\n", r);m_dot=900*r;printf("M_dot: %g\n", m_dot);}end_f_loop(f, t)}}} -
April 15, 2024 at 10:10 amRobForum Moderator
We'd normally use DEFINE_PROFILE to set boundary conditions. Is this for a transient flow?
-
April 15, 2024 at 6:31 pmZwernjaydenSubscriber
Its steady state. Would it be like this? Im a bit confused how the arguments for the F_PROFILE work. What does the i and the i+1 do? It says its supposed to determine which profile is which but I don't see a way to actually select it in the GUI.
#include "udf.h"#includeDEFINE_PROFILE(combined_surface_and_mass_flow_profile, t, i){face_t f;real Ts, heat_flux, Hv, r, Ts_old, Ts_new, m_dot, error;int iter;begin_f_loop(f, t){if (THREAD_ID(t) == 6) // Select fuel grain surface{// Initial values and heat flux retrievalTs = F_T(f, t);heat_flux = BOUNDARY_HEAT_FLUX(f, t);// Iterative calculation for new surface temperatureTs_old = Ts;iter = 0;error = 1;while (error > 1e-6 && iter < 10){Hv = 2033631 + 310000 + 1500 * (Ts_old - 298); // Update Hv formula as neededr = heat_flux / (Hv * 754); // Regression rate calculationTs_new = 20557.188 / (8.314 * (log(0.01104) - log(r))); // New surface temperature calculationerror = fabs(Ts_new - Ts_old); // Compute errorTs_old = Ts_new; // Prepare for next iterationiter++;}// Update the surface temperature profile at the faceF_PROFILE(f, t, i) = (Ts + 0.1 * (Ts_new - Ts));r = heat_flux / (Hv * 754);// Compute mass flow rate based on the final regression ratem_dot = 754 * r; // Use the same r calculated for temperatureF_PROFILE(f, t, i+1) = m_dot; // Assuming 'position + 1' is the correct slot for mass flow rate}}end_f_loop(f, t)} -
April 16, 2024 at 9:56 amRobForum Moderator
i , i+1 , i++ are generally integers and used to count up for "something". I'm not sure you should be using them like that in F_PROFILE(f, t, i+1) as i may be the surface ID: check the macro.
In a steady case you're trying to update a boundary at each iteration so effectively you're changing the problem. If there's no damping you may find you oscillate around a value until the solver fails.
Rather than trying to write ever more complex code, take a step back and figure out exactly what you're trying to acheive. Can it be done by running a model and manually altering a value to then run it again?
-
- The topic ‘Need help with UDF. “999999: mpt_accept: error: accept failed: No error.”’ is closed to new replies.
- Non-Intersected faces found for matching interface periodic-walls
- Script error Code: 800a000d
- Unburnt Hydrocarbons contour in ANSYS FORTE for sector mesh
- Help: About the expression of turbulent viscosity in Realizable k-e model
- Fluent fails with Intel MPI protocol on 2 nodes
- Cyclone (Stairmand) simulation using RSM
- error udf
- Diesel with Ammonia/Hydrogen blend combustion
- Mass Conservation Issue in Methane Pyrolysis Shock Tube Simulation
- Script Error
-
1281
-
591
-
544
-
524
-
366
© 2024 Copyright ANSYS, Inc. All rights reserved.