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

UDF crashes fluent

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 15, 2024, 18:41
Default UDF crashes fluent
  #1
New Member
 
Jayden Zwern
Join Date: Apr 2024
Posts: 1
Rep Power: 0
jayden1 is on a distinguished road
I'm trying to update both the surface temp and the mass flow rate of a mass flow inlet boundary condition, in one DEFINE_PROFILE UDF. When I start the calculation it crashes. I have attached the code and the pseudo code I am working from. I am bit confused on how to use the i argument for F_PROFILE when I need to update 2 things. How can I select which one is which in the fluent GUI?


#include "udf.h"
#include <math.h>
#define Hg 2033631 //J/kg
#define Hf -310000 //J/kg
#define Cp 1500 //J/kg
#define A .01104 //m/s
#define E 20557.188
#define rho 754
#define R 8.314
#define tol 1e-6
#define T_ref 298
DEFINE_PROFILE(combined_surface_and_mass_flow_prof ile, t, i)
{
face_t f;
real Ts, heat_flux, Hv, r, Ts_old, Ts_new, m_dot, error;
int iter;
int i;

begin_f_loop(f, t)
{
if (THREAD_ID(t) == 6) // Select fuel grain surface
{
// Initial values and heat flux retrieval
Ts = F_T(f, t);
heat_flux = BOUNDARY_HEAT_FLUX(f, t);

// Iterative calculation for new surface temperature
Ts_old = Ts;
iter = 0;
error = 1;
while (error > tol && iter < 10)
{
Hv = Hg - Hf + Cp * (Ts_old - T_ref); // Update Hv formula as needed
r = heat_flux / (Hv * rho); // Regression rate calculation
Ts_new = E / (R * (log(A) - log(r))); // New surface temperature calculation
error = fabs(Ts_new - Ts_old); // Compute error
Ts_old = Ts_new; // Prepare for next iteration
iter++;
}
// Update the surface temperature profile at the face
F_PROFILE(f, t, i) = (Ts + 0.1 * (Ts_new - Ts));
r = heat_flux / (Hv * rho);
// Compute mass flow rate based on the final regression rate
m_dot = rho * r; // Use the same r calculated for temperature
F_PROFILE(f, t, i+1) = m_dot; // Assuming 'position + 1' is the correct slot for mass flow rate
}
}
end_f_loop(f, t)
}
Attached Images
File Type: png Pseudo Code.png (64.2 KB, 6 views)
jayden1 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
how to run fluent from matlab without using aas toolbox? artemis96 ANSYS 7 May 23, 2022 13:16
Fluent crashes with error using C_W, F_W in UDF HoCH_10 Fluent UDF and Scheme Programming 0 March 3, 2021 04:59
Problem running fluent with udf on batch tobi b. Fluent UDF and Scheme Programming 3 April 14, 2016 14:54
Running UDF with Supercomputer roi247 FLUENT 4 October 15, 2015 14:41
fluent UDF external library lapack problem Rick FLUENT 0 May 7, 2008 11:16


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