Report mass flow rates through various inlets / outlets vs time in a file
The users wanted to be able to export a file in a spreadsheet type of format containing time as the first column and the mass flow rates through a given list of inlets / outlets in the other columns. 1) The user defines the export file through the Scheme command (define p (open-output-file "mf-export.xls")) 2) Then the Scheme file pasted below (wmf-file.scm) has to be loaded through File>Read>Scheme or through (load "wmf-file.scm") 3) A Command Monitor is set in Solve>Execute Commands with the (generic) content (write-mf-file list-of-zone-names) where list-of-zone-names contains the Scheme symbols of various inlet/outlet zones through which the user is interested to record the mass flow rates. An example of correct syntax: (write-mf-file (list 'inlet-1 'outlet-2)) 4) After the transient run is completed, it is good to close the output port "p" through the Scheme command (close-output-port p) Scheme file starts below this line. If any problems appear when you copy and paste from here, you can get the file through email. -------------------------------------------------------------------------------------------------------------------- ;;; This Scheme function is computing ;;; the mass flow rate through a list of ;;; zones identified through their names ;;; and saves the values in spreadsheet format ;;; in a file named mf-export.xls ;;; ;;; ;;; Usage ;;; 1) After reading the case and data file, type the ;;; TUI command ;;; ;;; (define p (open-output-file "mf-export.xls")) ;;; This command will open the file for output ;;; ;;; 2) File>Read>Scheme .. this file (wmf-file.scm) ;;; 3) Set a monitor command in GUI ;;; Solve>Monitor>Command ;;; with the following content ;;; ;;; (write-mf-file list-of-zone-names) ;;; ;;; A correct syntax for the list-of-zone-names looks like ;;; ;;; (list 'inlet-1 'outlet-2 'outlet-3) ;;; so for this example the content of the Command Monitor is: ;;; ;;; (write-mf-file (list 'inlet-1 'outlet-2 'outlet-3)) ;;; ;;; 4) Set the frequency of executions - Every "n" Time steps ;;; 5) Run the transient analysis ;;; 6) Once you want to close this file you must type the TUI command ;;; ;;; (close-output-port p) ;;; ;;; Do not change below this line without calling for support ;;; ========================================================== (define (write-mf-file list-zone-names) (let ((tim)(ll)(mass-flow-zone)) (set! mass-flow-zone (lambda (name) (let ((id (zone-name->id name))) (let ((fluxes (thread-integrals id))) (if fluxes (let ((f (cdr (assq 'mass-flow fluxes)))) f) 0.0))))) (set! tim (rpgetvar 'flow-time)) (format p " ~a " tim) (set! ll (length list-zone-names)) (let loop ((i 0)) (if (< i ll) (begin (format p " t ~a" (mass-flow-zone (list-ref list-zone-names i))) (loop (+ i 1))) (newline p) )) )) |
||
![]()
|