‌Fluent GUI制作体验分享:虽无大用但震撼人心‌

源码:

;; show `apply` button and `OK` button or not

(define apply-cb #t)

(define update-cb #f)

;; define input variables

(define velocity)

(define density)

(define viscosity)

(define hydraulicDiameter)

;; define output variables

(define turbulentKineticEnergy)

(define turbulentIntensity )

(define turbulentScale)

(define turbulentDissipationRate)

(define turbulentViscosity )

(define turbulentViscosityRatio)

(define turbulentSpecificDissipationRate)

(define reynoldNumber)

;; define what happened when the dialog loaded

(define (update-cb . args)

    (cx-set-real-entry velocity 1.0)

    (cx-set-real-entry density 1.0)

    (cx-set-real-entry viscosity 1.0)

    (cx-set-real-entry hydraulicDiameter 1.0)

)

;; define the function to calculate outputs

(define (Calc)

    (define pVelocity (cx-show-real-entry velocity))

    (define pDensity (cx-show-real-entry density))

    (define pViscosity (cx-show-real-entry viscosity))

    (define pHydraulicDiameter (cx-show-real-entry hydraulicDiameter))

    (define cmu 0.09)

    (define pTurbulentScale)

    (define pTurbulentIntensity)

    (define pTurbulentDissipationRate)

    (define pTurbulentKineticEnergy)

    (define pTurbulentViscosity)

    (define pTurbulentViscosityRatio)

    (define pReynoldNumber)

    (define pTurbulentSpecificDissipationRate)

    ;calculate

    (set! pTurbulentScale (/ (* 0.07 pHydraulicDiameter) (expt cmu 0.75)))

    (set! pReynoldNumber (* pDensity (* pHydraulicDiameter (/ pVelocity pViscosity))))

    (set! pTurbulentIntensity (* 0.16 (expt pReynoldNumber (/ -1 8))))

    (set! pTurbulentKineticEnergy (* 1.5 (expt (* pVelocity pTurbulentIntensity) 2)))

    (set! pTurbulentDissipationRate (/ (expt pTurbulentKineticEnergy 1.5) pTurbulentScale))

    (set! pTurbulentViscosity (/ (* pDensity (* cmu (expt pTurbulentIntensity 2))) pTurbulentDissipationRate))

    (set! pTurbulentViscosityRatio (/ turbulentViscosity pViscosity))

    (set! pTurbulentSpecificDissipationRate (/ (expt turbulentKineticEnergy 0.5) (* cmu pTurbulentScale)))

    ; show outputs

    (cx-set-real-entry turbulentScale pTurbulentScale)

    (cx-set-real-entry reynoldNumber pReynoldNumber)

    (cx-set-real-entry turbulentViscosity pTurbulentViscosity)

    (cx-set-real-entry turbulentKineticEnergy pTurbulentKineticEnergy)

    (cx-set-real-entry turbulentDissipationRate pTurbulentDissipationRate)

    (cx-set-real-entry turbulentIntensity pTurbulentIntensity)

    (cx-set-real-entry turbulentViscosityRatio pTurbulentDissipationRate)

    (cx-set-real-entry turbulentSpecificDissipationRate pTurbulentSpecificDissipationRate)

)

;兔年快乐~

(define (Hello)

    (newline)

    (display "/ \\`\\          __    \n")

    (display "|  \\ `\\      /`/ \\   \n")

    (display "\\_/`\\  \\-\"-/` /\\  \\  ")

    (newline)

    (display "     |       |  \\  | \n")

    (display "     (d     b)   \\_/ \n")

    (display "     /       \\       \n")

    (display " ,\".|.'.\\_/.'.|.\",   \n")

    (display "/   /\\' _|_ '/\\   \\  \n")

    (display "|  /  '-`\"`-'  \\  |  ")

    (newline)

    (display "| |             | |  \n")

    (display "| \\    \\   /    / |  \n")

    (display " \\ \\    \\ /    / /   \n")

    (display "  `\"`\\   :   /'\"`    \n")

    (display "      `\"\"`\"\"`        \n")

)

;; bound the Calc function to a button-clicked event

(define (apply-cb .args) (Hello))

(define (button-cb . args) (Calc))

;; create the panel

(define dialog-box (cx-create-panel "Turbulent Parameters" apply-cb update-cb))

(define table (cx-create-table dialog-box "" 'border #f 'below 0 'right-of 0))

(define inputBox (cx-create-table table "Data Inputs" 'row 0 'col 0))

(define zoneDropList (cx-create-drop-down-list inputBox "Compute From:" 'row 0 'col 0))

(cx-set-list-items zoneDropList (map thread-name (sort-threads-by-name(get-face-threads))))

(set! velocity (cx-create-real-entry inputBox "Velocity[m/s]:" 'row 1 'col 0))

(set! density (cx-create-real-entry inputBox "Density[kg/m3]:" 'row 2 ))

(set! viscosity (cx-create-real-entry inputBox "Viscosity[Pa.s]:" 'row 3 ))

(set! hydraulicDiameter (cx-create-real-entry inputBox "Hydraulic Diameter[m]:" 'row 4 ))

(define outputBox (cx-create-table table "Outputs" 'row 0 'col 2))

(set! turbulentScale (cx-create-real-entry outputBox "Turbulent Scale[m]:" 'row 1 'col 0))

(set! reynoldNumber (cx-create-real-entry outputBox "Reynold Number:" 'row 2 'col 0))

(set! turbulentIntensity (cx-create-real-entry outputBox "Turbulent Intensity[m2/s2]:" 'row 3 'col 0))

(set! turbulentDissipationRate (cx-create-real-entry outputBox "Turbulent Dissipation Rate[m2/s3]:" 'row 4 'col 0))

(set! turbulentKineticEnergy (cx-create-real-entry outputBox "Turbulent Kinetic Energy[m3/s2]:" 'row 1 'col 2))

(set! turbulentViscosity (cx-create-real-entry outputBox "Turbulent Viscosity[Pa.s]:" 'row 2 'col 2))

(set! turbulentViscosityRatio (cx-create-real-entry outputBox "Turbulent Viscosity Ratio:" 'row 3 'col 2))

(set! turbulentSpecificDissipationRate (cx-create-real-entry outputBox "Specific Dissipation Rate:" 'row 4 'col 2))

;; bound the button-cb event to `Calculate>>` button

(cx-create-button outputBox "Calculate>>" 'activate-callback button-cb 'row 5 'col 2)

(cx-show-panel dialog-box)

QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空