Updated 2017-03-09 22:24:31 by gold

## Introduction edit

gold Here is some eTCL starter code for calculating product lifetime at operating temperature. The calculations for lifetime ops are usually from figures provided in product specs. Most of the testcases involve replicas or models, using assumptions and rules of thumb.

The 4 given numbers are expected lifetime rated at reference temperature in years (L0), t0 rating temperature in centigrade degrees, t2 operating temperature in degrees centigrade, and t2 operating temperature degrees centigrade. The formula for product lifetime (L2) at operating temperature is L2=L0*{0.5**{(t2-t0)/t1 }} years. The eTCL calculator offers change of halflife factor or base 0.5, but that halflife factor is not expected to change usually in business calculations. The lifetime in years can be converted into lifetime = L2 * 8760 {or 365*24} years.

While the halflife factor (0.5) is not expected to change usually in business calculations, there is some advantage to studying the effects of the halflife factor on the eTCL calculator results. For example, load the first testcase in the calculator and change the halflife factor by 10 percent to 0.5-0.5*90%*1E-2 or 0.45. Pushing solve with loaded entries <10,20,10,10,.45> with 0.45 factor changes the operating lifetime by 0.5 years. The eTCL calculator is very sensitive to the accuracy of the halflife factor or the inferred accuracy of halflife from specs in years.

In planning any software, it is advisable to gather a number of testcases to check the results of the program. The results of the testcases are estimated using the hand calculator and then checked in the eTCL slot calculator. Pseudocode and equations are developed from the hand calculations and theory. Small console programs are written to check or proof the alternate subroutines or procedures, rather than keeping the unblessed code and comment lines in the main slot calculator. Finally the improved or alternate subroutines are loaded into the slot calculator. The eTCL slot calculator is effectively a shell program to input entries, host calculation routines, and display results. Additional significant figures are used to check the eTCL calculator, not to infer the accuracy of inputs and product reports.

*Push Button Operation**

For the push buttons in the eTCL slot calculator, the recommended procedure is push testcase to fill entry frame, change first three entries etc, push solve, and then push report. Report allows copy and paste from console. For testcases in a computer session, the eTCL calculator increments a new testcase number internally, eg. TC(1), TC(2) , TC(3) , TC(N). The testcase number is internal to the calculator and will not be printed until the report button is pushed for the current result numbers. The current result numbers will be cleared on the next solve button. The calculator display has a caution flag subroutine for negative numbers, unrecognizable text characters, and operation outside expected operation range. On a degrading scale, the calculator will post warning flags to the console report, issue degraded accuracy notices, and may reset some negative and offscale numbers to positive defaults. Errors pass through the warning flag routine once on the same testcase and multiple error calls on the same fault are possible. Aside from the TCL calculator display, when one presses the report button on the calculator, one will have console show access to the functions (subroutines).

### Pseudocode and Equations

```     #pseudocode can be developed from rules of thumb.
#pseudocode: some problems can be solved by proportions (rule of three), to some order of magnitude
#pseudocode: enter quantity1,  quantity2, quantity3 and expected output (quantity4) for testcases.
#pseudocode: enter time in years, number of remaining items
#pseudocode: output fraction of (remaining items) over (items at time zero)
#pseudocode: ouput remaining items as fraction or percent
#pseudocode: output fraction of (quantity4 ) over ( quantity1 at time zero)
#pseudocode: output fraction of (quantity2) * (quantity3 ) over (quantity1 at time zero)
#pseudocode: outputs should be in compatible units.
#pseudocode: rules of thumb can be 3 to 15 percent off, partly since g..in g..out.
#pseudocode: need test cases > small,medium, giant
#pseudocode: need testcases within range of expected operation.
#pseudocode: are there any cases too small or large to be solved?```

### Testcases Section

#### Testcase 1

table 1printed in tcl wiki format
quantity value comment, if any
testcase number:1
10.0 :expected lifetime rated at ref temperature years
20.0 :t0 rating temperature
10.0 :t1 temperature for half lifetime
10.0 :t2 operating temperature degrees centigrade
0.5 :halflife factor (optional, usually 0.5)
1825.0 : lifetime at operating temperature days
5.0 : lifetime at operating temperature years

#### Testcase 2

table 2printed in tcl wiki format
quantity value comment, if any
testcase number:2
10.0 :expected lifetime rated at ref temperature years
20.0 :t0 rating temperature
10.0 :t1 temperature for half lifetime
5.0 :t2 operating temperature degrees centigrade
0.5 :halflife factor (optional, usually 0.5)
1290.469 : lifetime at operating temperature days
3.535 : lifetime at operating temperature years

#### Testcase 3

table 3printed in tcl wiki format
quantity value comment, if any
testcase number:3
10.0 :expected lifetime rated at ref temperature years
20.0 :t0 rating temperature
10.0 :t1 temperature for half lifetime
8. :t2 operating temperature degrees centigrade
0.5 :halflife factor (optional, usually 0.5)
1588. : lifetime at operating temperature days
4.35 : lifetime at operating temperature years

• Influence

## Appendix Code edit

### appendix TCL programs and scripts

```        # pretty print from autoindent and ased editor
# Lifetime at Operating Temperature Calculator
# written on Windows XP on eTCL
# working under TCL version 8.6.x and eTCL 1.0.1
# gold on TCL WIKI, 10oct2014
package require Tk
namespace path {::tcl::mathop ::tcl::mathfunc}
frame .frame -relief flat -bg aquamarine4
pack .frame -side top -fill y -anchor center
set names {{} {expected lifetime rated at ref temperature years:} }
lappend names {t0 rating temperature:}
lappend names {t1 temperature for half lifetime: }
lappend names {t2 operating temperature degrees centigrade:}
lappend names {halflife factor (optional, usually 0.5):}
lappend names {lifetime at operating temperature days: }
lappend names {lifetime at operating temperature years:}
foreach i {1 2 3 4 5 6 7 8} {
label .frame.label\$i -text [lindex \$names \$i] -anchor e
entry .frame.entry\$i -width 35 -textvariable side\$i
proc pi {} {expr acos(-1)}
set msg "Calculator for Lifetime at Operaturing Temperature
from TCL WIKI,
written on eTCL "
tk_messageBox -title "About" -message \$msg }
proc calculate {     } {
global side1 side2 side3 side4 side5
global side6 side7 side8
global testcase_number
incr testcase_number
set side1 [* \$side1 1. ]
set side2 [* \$side2 1. ]
set side3 [* \$side3 1. ]
set side4 [* \$side4 1. ]
set side5 [* \$side5 1. ]
set side6 [* \$side6 1. ]
set side7 [* \$side7 1. ]
set side8 [* \$side8 1. ]
set temperature0_rating 1.
set temperature1_half_life 1.
set temperature_operating 1.
set temperature0_rating \$side2
set temperature1_half_life \$side3
set temperature_operating \$side4
#set base [* 0.5 1. ]
set base [*  \$side5 1. ]
set term_temp [/ [-  \$temperature_operating \$temperature0_rating ] [* \$temperature1_half_life 1. ] ]
set term_temp [abs \$term_temp ]
set side6 [* \$lifetime1_at_temperature_ops 8760. ]
set side7 [* \$lifetime1_at_temperature_ops 365. ]
}
proc fillup {aa bb cc dd ee ff gg hh} {
.frame.entry1 insert 0 "\$aa"
.frame.entry2 insert 0 "\$bb"
.frame.entry3 insert 0 "\$cc"
.frame.entry4 insert 0 "\$dd"
.frame.entry5 insert 0 "\$ee"
.frame.entry6 insert 0 "\$ff"
.frame.entry7 insert 0 "\$gg"
.frame.entry8 insert 0 "\$hh"
}
proc clearx {} {
foreach i {1 2 3 4 5 6 7 8 } {
.frame.entry\$i delete 0 end } }
proc reportx {} {
global side1 side2 side3 side4 side5
global side6 side7 side8
global testcase_number
console show;
puts "%|table \$testcase_number|printed in| tcl wiki format|% "
puts "&| quantity| value| comment, if any|& "
puts "&| testcase number:|\$testcase_number | |&"
puts "&| \$side1 :|expected lifetime rated at ref temperature years |   |&"
puts "&| \$side2 :|t0 rating temperature| |& "
puts "&| \$side3 :|t1 temperature for half lifetime| |& "
puts "&| \$side4 :|t2 operating temperature degrees centigrade |  |&"
puts "&| \$side5 :|halflife factor (optional, usually 0.5)|  |&"
puts "&| \$side7 :| lifetime at operating temperature days|  |&"
puts "&| \$side8 :| lifetime at operating temperature years|  |&"
}
frame .buttons -bg aquamarine4
::ttk::button .calculator -text "Solve" -command { calculate   }
::ttk::button .test2 -text "Testcase1" -command {clearx;fillup 10. 20. 10. 10. 0.5 43800. 1825. 5.}
::ttk::button .test3 -text "Testcase2" -command {clearx;fillup 10.0 20.0 10.0 5. 0.5 30971. 1290. 3.5 }
::ttk::button .test4 -text "Testcase3" -command {clearx;fillup 10.0 20.0 10.0 8. 0.5 38130. 1588. 4.35 }
::ttk::button .clearallx -text clear -command {clearx }