FLUENT 6.1 - How to report the standard deviation, average, min and max of a quantity on a list of surfaces through TUI commands


FLUENT users want to be able to obtain the reports of standard deviation, average value, minimum and maximum value of a field variable on a list of surfaces, using only TUI commands, in a batch run using a journal file.

NOTE:

(1) This Solution can be used only with Single Phase cases in FLUENT 6.1.18 or later versions of FLUENT.

(2) The Scheme file is enclosed below the line. Please be careful when you copy and paste this into a file to remove the end-of-line characters that will apear due to copy and paste - it is essential to be able to have the function work properly. In case you run into problems with this, please ask your consulting engineer for the file.

The following Scheme function can be loaded through the command

(load "sta-sigma.scm")

Once loaded, the user can specify the following command in the journal file:

(g-uniformity type variable-symbol list-of-surface-names)

where

1) g-uniformity is the name of the function

2) type can be one of the following two strings:
a) "average" to use the area-weighted average
b) "mass-average" to use the mass-weighted average

3) variable-symbol is the symbol for the desired quantity, for example 'pressure or 'temperature

4) list-of-surface-names is the list of surfaces as in

(list 'surface-1 'surface-2 'surface-3)

or

'(surface-1 surface-2 surface-3)



The Scheme file is enclosed below the line. Please be careful when you copy
and paste this into a file to remove the end-of-line characters that
will apear due to copy and paste - it is essential to be able to have
the function work properly. In case you run into problems with this,
please ask your consulting engineer for the file.



========================================================
;;; Scheme function computing and reporting in the console
;;; the min, max, average and the standard deviation
;;; of any field variable on a list of surfaces
;;;
;;; Usage
;;;
;;; 1) Load the Scheme file
;;; through File>Read>Scheme ..
;;; or through (load "sta-sigma.scm")
;;;
;;; 2) Complete statistics (min, max, average, standard fluctuation)
;;; is done with the command:
;;;
;;; (g-uniformity type variable-symbol list_of_surface_names)
;;;
;;; for example to compute the average fluctuation of
;;; H2O mass fraction on the surfaces named "plane-22"
;;; and "wall-11" the user will issue the command:
;;;
;;; (g-uniformity "mass-average" 'h2o (list 'plane-22 'wall-11))
;;;
;;; or
;;;
;;; (g-uniformity "average" 'h2o (list 'plane-22 'wall-11))
;;;
;;; 3) If you want just a report of Minimum and Maximum of a
;;; certain quantity on a (list) of surfaces, use the command
;;;
;;; (comp-surf-min-max quantity list-of-surfaces)
;;;
;;; For example
;;;
;;; (comp-surf-min-max 'x-coordinate (list 'plane-22 'wall-11))
;;;
;;;
;;; Do not edit below this line without calling for support
;;; ========================================================
(define list->strip
(lambda (inputlist)
(let ((stri "")
(ll (length inputlist)))
(let loop ((i 0))
(if (< i ll)
(begin
(set! stri (string-append stri " " (number->string (list-ref inputlist i))))
(loop (+ i 1))))
stri ))))

(define (g-surface-average type quantity list-of-surf-names)
(let ((g-surface))
;;;
(set! g-surface
(lambda (typx surfx cell-onlyx?)
(if (equal? typx "average")
(surface-average surfx cell-onlyx?)
(surface-mass-average surfx cell-onlyx?))))
;;;;
(let* ((surf-list (map surface-name->id list-of-surf-names))
(input-strip (list->strip surf-list)))
(ti-menu-load-string (string-append "(cxisetvar 'xy/surfaces "") ()"))
(ti-menu-load-string (string-append "(cxisetvar 'xy/surfaces "") " input-strip ","))
(let ((of quantity))
(if of
(let ((cell-only? (cx-cell-only-field? 'mixture of))
(surfaces (cxgetvar 'xy/surfaces)))
(client-set-node-values #f)
(client-fill-node-values of)
(cx-fill-face-zone-values surfaces of)
(g-surface type surfaces cell-only?)))))))
;;;
(define (g-uniformity type variable-symbol list-of-surface-names)
(let ((favg)
(variable-name)
(sigma))
(set! variable-name (symbol->string variable-symbol))
(set! favg (g-surface-average type variable-symbol list-of-surface-names))
;;;one single line starts here
(custom-field-function/define (quasiquote (((name fprime)
(display (unquote (string-append "abs (" variable-name " - favg)")))
(syntax-tree ("abs" ("-" (unquote variable-name) "favg")))
(code (field-abs (field-- (unquote variable-name) (unquote favg)) ))))))
;;;;one single line ends here
(set! sigma (g-surface-average type 'fprime list-of-surface-names))
(comp-surf-min-max variable-symbol list-of-surface-names)
(format "n Average = ~a n" favg)
(format "n Std. Deviation = ~a n" sigma)
))

(define (comp-surf-min-max quantity list-of-surf-names)
(let* ((surf-list)
(input-strip))
(set! surf-list (map surface-name->id list-of-surf-names))
(set! input-strip (list->strip surf-list))
(ti-menu-load-string (string-append "(cxisetvar 'xy/surfaces "") ()"))
(ti-menu-load-string (string-append "(cxisetvar 'xy/surfaces "") " input-strip
","))
(let ((of quantity))
(if of
(let ((surfaces (cxgetvar 'xy/surfaces))
(mn)
(ma))
(client-set-node-values #f)
(client-fill-node-values of)
(cx-fill-face-zone-values surfaces of)
(set! mn (car (cx-surface-get-min-max surfaces #f)))
(set! ma (cadr (cx-surface-get-min-max surfaces #f)))
(format "n =================================================")
(format "n Min = ~a t t Max = ~a n" mn ma)
)))))





Show Form
No comments yet. Be the first to add a comment!