global mainDir ; set mainDir [file dirname [info script]]
set output [ file join "$mainDir" ex_1p4_fil_electrique.txt ]
exec [ file join "$mainDir" QLMCall ] ClearResults
# init material properties
set rho 0.4 ; # resistance per meter
# init geometry
set L 1.0 ; # wire length
set D 1e-3 ; # wire diameter
# init sources
set range 10 ; # max current
set step 0.5 ; # current step
# useful values
set S [ expr { 3.1416 * (( $D ** 2 ) / 4.0 ) } ] ; # wire section
set V [ expr { $L * $S } ] ; # wire volume
set imax [ expr { int( $range / $step ) } ] ; # number of iterations
set I [ expr -1.0 * $step ] ; # init current
set R [ expr { ( $rho * $L ) } ] ; # total resistance
set results [ open $output w ]
for { set k 0 } { $k <= $imax } { incr k } {
set I [ expr { $I + $step } ] ; # wire current
set P [ expr { $R * $I *$I } ] ; # wire losses
set Pv [ expr { $P / $V } ] ; # losses per unit of volume
set l_answer [exec [ file join "$mainDir" QLMCall ] $Pv]
puts $results "${I},[ expr { $l_answer - 273 } ]"
}
close $results
|