module Tuscan::Iec60751
Constants
- A
- B
- C
- R0
- R_RANGE
- T90_RANGE
Public Instance Methods
r(t90, r0: R0, a: A, b: B, c: C)
click to toggle source
# File lib/tuscan/iec60751.rb, line 23 def r t90, r0: R0, a: A, b: B, c: C raise RangeError, 't90 is outside the valid range' unless T90_RANGE.include? t90 r_unbound t90, r0, a, b, c end
Also aliased as: res, resistance
resr(t90)
click to toggle source
# File lib/tuscan/iec60751.rb, line 15 def resr t90 r t90 end
t90(r, r0: R0, a: A, b: B, c: C, num: 10, err: 1e-4)
click to toggle source
# File lib/tuscan/iec60751.rb, line 30 def t90 r, r0: R0, a: A, b: B, c: C, num: 10, err: 1e-4 raise RangeError, 'r is outside the valid range' unless R_RANGE.include? r if r >= r0 (-a + (a**2 - 4 * b * (1 - r / r0))**(0.5)) / (2 * b) else args = [r0, a, b, c] Rical.inverse_for f: method(:r_unbound), fargs: args, df: method(:dr), dfargs: args, x0: t90_guess(r, *args), y: r, method: :newton, num: num, err: err end end
Also aliased as: t, temperature
t90r(r)
click to toggle source
# File lib/tuscan/iec60751.rb, line 19 def t90r r t90 r end
Private Instance Methods
dr(t90, r0, a, b, c)
click to toggle source
# File lib/tuscan/iec60751.rb, line 54 def dr t90, r0, a, b, c r0 * (a + 2*b*t90 - 300*c*t90**2 + 4*c*t90**3) # valid for t90 < 0 end
r_unbound(t90, r0, a, b, c)
click to toggle source
# File lib/tuscan/iec60751.rb, line 44 def r_unbound t90, r0, a, b, c t90 >= 0 ? r0*(1 + a*t90 + b*t90**2) : r0*(1 + a*t90 + b*t90**2 - 100*c*t90**3 + c*t90**4) end
t90_guess(r, r0, a, b, c)
click to toggle source
# File lib/tuscan/iec60751.rb, line 50 def t90_guess r, r0, a, b, c ((r / r0) - 1) / (a + 100 * b) # valid for r < r0 end