global mainDir ; set mainDir [file dirname [info script]]
# source [file join "$mainDir" optimize.tcl]
console show
package require math::optimize
proc Fh { x } {
expr { 10.9 * ( abs($x) ** 0.8) }
}
proc deltaT { air_velocity } {
global mainDir
global Temp_final
set convection_heat_coefficient [ Fh $air_velocity ]
set l_answer [ exec [ file join "$mainDir" QLMCall ] $convection_heat_coefficient ]
return [ expr { abs($l_answer - $Temp_final) } ]
}
set output [ file join "$mainDir" ex_1p5_pile_combustible.txt ]
exec [ file join "$mainDir" QLMCall ] ClearResults
# init goal
set Temp_final [ expr 56.4 + 273 ]
# init geometry
set Height 50.0e-3 ; # Cell height
set Length 50.0e-3 ; # Cell length
set Thickness 10.0e-3 ; # Cell thickness
# init sources
set hmin 1 ; # minimum convection heat coefficient
set hmax 250 ; # maximum convection heat coefficient
set P 11.25 ; # heat power to remove
# useful values
set S [ expr { $Height * $Length } ] ; # cell section
set V [ expr { $Thickness * $S } ] ; # cell volume
set Pv [ expr { $P / $V } ] ; # losses per unit of volume
set l_answer [ ::math::optimize::nelderMead deltaT 1 -scale 2.0 -ftol 0.1 -maxiter 30 -trace yes ]
set results [ open $output w ]
puts $results "$l_answer"
close $results
return
|