Scheme to print Total Heat Transfer Rate after desired number of iterations in a data file.

Knowledge of heat imbalance is needed to check convergence in many cases. But this requires stopping the run which is not desirable. In parallel runs stopping and restarting the case may take quite some time.

This Scheme file calculates total heat transfer rate as given by Report -> Flux -> Total Heat Transfer Rate. It then prints iteration number and the corresponding total heat transfer rate in a output file
"heat_transfer.dat" and avoids the need to stop the run. It works for all possible steady state cases (2D, 2D axisymmetric, 3D) and works for parallel as well.
;This Scheme calculates the Total Heat Transfer Rate for a steady-state ;case.
;To use this scheme file, hook it in your case and type (frequency n) on the ;fluent console,where n is any number.
;A output file "heat_transfer.dat" gets created in the directory where this ;scheme file is located.
;Created by: Padmesh Mandloi, Fluent India
(define i 0)
(define p)
(define list)
(define list-length)
(define surf-name)
(define surf-id)
(define info-list)
(define heat-trans-pair)
(define heat-trans 0)
(define frequenc)
(define iteration_no)
(define thr-type)
(define junk)
(if (not(rp-var-object 'frequency))
(rp-var-define 'frequency 10 'real #f)

(set! iteration_no 0)
;(set! list (inquire-surface-group-names))
(set! list (map thread-name (get-boundary-threads)))
(set! list-length (length list))

(define print_file
(lambda ()
(if (> list-length 0)
(set! heat-trans 0)
(let loop ((i 0))
(set! p (list-ref list i))
(set! surf-name p)
(set! surf-id (surface-name->id surf-name))
(if (surface-id->zone-id surf-id)
(set! zone-id (surface-id->zone-id surf-id))
(set! thr-type (thread-type (get-thread zone-id)))
(pp thr-type)
(if (eq? thr-type 'axis) (set! junk i)
(set! info-list (domain-thread-integrals 1 zone-id))
(set! heat-trans-pair (list-ref info-list 5))
(pp heat-trans-pair)
(pp zone-id)
(set! heat-trans (+ heat-trans (cdr heat-trans-pair)))
(set! i (+ i 1))
(if (< i list-length)
(loop i)

;; (set! iteration_no (+ iteration_no frequenc))
(define outputport (open-file "heat_transfer.dat" "a" ))
(format outputport "~d ~d " iteration_no heat-trans)
(display #newline outputport)
(flush-output-port outputport)

(define frequency
(lambda (freq )
(set! frequenc freq)
(let ((tt1 freq ))
(rpsetvar 'monitor/commands
(list (list 'heat-trans-rate tt1 #f "(print_file)" )

(register-solution-monitor 'progress-bar-and-check
(lambda (niter)
(set! iteration_no niter)

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