Fan pressure drop as a function of radius
Compute fan pressure drop as a function of radial distance from the center of rotation of the fan (and flow kinetic energy).
This solution consists of the following files: * jump.c = UDF to compute dp across fan as a function of (distance from fan center) and flow ke. * fan_gui.scm = Scheme file for entering fan axis center through GUI ========================== Instructions for use * Start fluent * Compile UDF * Read fan_gui.scm * Read cas and data file * Enter fan coordinates: Define->Define Fan Center * Select Profile Specification of Pressure Jump under Define->Boundary Conditions->fan->Set. * Under Pressure Jump profile, enter pjump for the udf function That's it. Initialize and iterate. /***** BEGINNING OF pjump.c ******/ /*====================================== * jump.c = Pressure jump across a fan as a function of * radius and kinetic energy * */ #include "udf.h" real pressure_drop(real d, real ke); DEFINE_PROFILE(pjump, thread, index) { real fcx, fcy, fcz; /* fan center position */ real dp; /* pressure drop */ real rho; /* density */ real ke; /* kinetic energy of fluid */ real dxmag; /* distance from fan center to face */ real vmag; /* gas speed */ real vx, vy, vz; real NV_VEC(v); /* velocity vector */ real NV_VEC(x); /* vector position of face */ real NV_VEC(xo); /* vector position of fan center */ real NV_VEC(dx); /* vector from fan_center to face */ Thread *t0 = thread->t0; /* Cell thread on the 0-side of face thread */ Thread *t1 = thread->t1; /* Cell thread on the 1-side of face thread */ face_t face; cell_t c0, c1; /* Read variables from FLUENT GUI */ fcx = RP_Get_Real("fan-center-x"); fcy = RP_Get_Real("fan-center-y"); fcz = RP_Get_Real("fan-center-z"); /* Fan center (vector) */ NV_D (xo, =, fcx, fcy, fcz); begin_f_loop(face,thread) { /* Cell centers on cells adjacent to the face */ c0 = F_C0(face,thread); c1 = F_C1(face,thread); /* Get face centroid location */ F_CENTROID(x, face, thread); /* Determine distance vector from fan center */ NV_VV (dx, =, x, -, xo); /* Magnitude of dx */ dxmag = NV_MAG(dx); /* Get the velocity vector at the face */ vx = 0.5 * (C_U(c0,t0) + C_U(c1,t1)); vy = 0.5 * (C_V(c0,t0) + C_V(c1,t1)); #if RP_3D vz = 0.5 * (C_W(c0,t0) + C_W(c1,t1)); #endif NV_D (v, =, vx, vy, vz); /* Velocity magnitude at the face */ vmag = NV_MAG(v); /* Gas density */ rho = 0.5 * (C_R(c0,t0) + C_R(c1,t1)); /* Gas kinetic energy */ ke = 0.5 * rho * vmag * vmag; /* Pressure drop */ dp = pressure_drop(dxmag, ke); F_PROFILE(face, thread, index) = dp; } end_f_loop(f, thread) } real pressure_drop(real d, real ke) { /* d = distance from fan center */ real dp; real factor; /* ratio of dp to ke */ /* Ratio of dp to gas kinetic energy */ factor = 0.10 * d; dp = factor * ke; return dp; } /**** END OF jump.c *****/ /****** BEGINNING of fan_gui.scm *********/ ;; (define (make-new-rpvar name default type) (if (not (rp-var-object name)) (rp-var-define name default type #f))) ;; ;; Create rpvars for udf, assign initial (ie: default) values ;; types: real, boolean, integer, thread-list ;; () is empty list, #f is false (off) ;; (make-new-rpvar 'fan-center-x 0.0 'real) (make-new-rpvar 'fan-center-y 0.0 'real) (make-new-rpvar 'fan-center-z 0.0 'real) ;; ;; Create a panel for the udf ;; (define gui-define-output-data-panel ;;; "panel" is a variable name ;;; panel #f - no panel made yet (let ((panel #f) ;;; declare variables - assign values later (mybox) (fan-center-x) (fan-center-y) (fan-center-z) ) ;;; ;;; Function which is called when panel is opened ;;; sets panel variables to values in make-new-rpvar section ;;; default: all options off, no surfaces selected ;;; (define (update-cb . args) (cx-set-real-entry fan-center-x (rpgetvar 'fan-center-x)) (cx-set-real-entry fan-center-y (rpgetvar 'fan-center-y)) (cx-set-real-entry fan-center-z (rpgetvar 'fan-center-z)) ) ;;; ;;; Function which is called when OK button is hit. ;;; assigns variable values that were set in panel after clicking "ok" ;;; (define (apply-cb . args) (rpsetvar 'fan-center-x (cx-show-real-entry fan-center-x)) (rpsetvar 'fan-center-y (cx-show-real-entry fan-center-y)) (rpsetvar 'fan-center-z (cx-show-real-entry fan-center-z)) ) (lambda args ;;; if panel does not exist, make panel (if (not panel) ;; create panel (let ((table)) (set! panel (cx-create-panel "Fan Center Panel" apply-cb update-cb)) ;; create table w/o title in panel to enable row by column format (set! table (cx-create-table panel "" 'border #f 'below 0 'right-of 0)) ;;; Create Custom Variable input. (set! mybox (cx-create-table table "Fan Center Coordinates" 'border #t 'row 0)) (set! fan-center-x (cx-create-real-entry mybox "x-location" 'row 0 'col 0)) (set! fan-center-y (cx-create-real-entry mybox "y-location" 'row 1 'col 0)) (set! fan-center-z (cx-create-real-entry mybox "z-location" 'row 2 'col 0)) ) ) ;; tell solver to display the panel (cx-show-panel panel) ) ) ) ;; ;; Add new panel to end of User-Defined menu. ;; no need to modify here except panel name and menu location ;; (cx-add-item "Define" "Define Fan Center..." #U #f cx-client? gui-define-output-data-panel ) /******* END OF fan_gui.scm ***************/ |
||
![]()
|