module Tuscan::Iec60584
Public Instance Methods
emf(t90, type:, a: 0.0, b: 0.0, c: 0.0, d: 0.0, err: 1e-3, num: 10)
click to toggle source
# File lib/tuscan/iec60584.rb, line 12 def emf t90, type:, a: 0.0, b: 0.0, c: 0.0, d: 0.0, err: 1e-3, num: 10 guess = emfr t90, type: type delta = 1e-2 args = { type: type, a: a, b: b, c: c, d: d, err: err, num: num } Rical.inverse_for f: method(:t90), fargs: args, x0: guess - delta, x1: guess + delta, y: t90, method: :secant, num: num, err: err end
emfdev(t90, a, b, c, d)
click to toggle source
# File lib/tuscan/iec60584.rb, line 33 def emfdev t90, a, b, c, d Polynomial.new(a, b, c, d).solve_for t90 end
emfr(t90, type: raise RangeError, 't90 is outside the valid range' if out_of_range? t90, type)
click to toggle source
# File lib/tuscan/iec60584.rb, line 22 def emfr t90, type: raise RangeError, 't90 is outside the valid range' if out_of_range? t90, type emfr_unbound t90, type end
t90(emf, type:, a: 0.0, b: 0.0, c: 0.0, d: 0.0, err: 1e-3, num: 10)
click to toggle source
# File lib/tuscan/iec60584.rb, line 5 def t90 emf, type:, a: 0.0, b: 0.0, c: 0.0, d: 0.0, err: 1e-3, num: 10 emfc = emf - emfdev(t90r(emf, type: type, err: err, num: num), a, b, c, d) t90r emfc, type: type, err: err, num: num end
Also aliased as: t, temperature
t90r(emf, type:, err: 1e-3, num: 10)
click to toggle source
# File lib/tuscan/iec60584.rb, line 27 def t90r emf, type:, err: 1e-3, num: 10 guess = t90r_guess emf, type Rical.inverse_for f: method(:emfr_unbound), fargs: type, x0: guess - 0.5, x1: guess + 0.5, y: emf, method: :secant, num: num, err: err * 1e-3 end
Private Instance Methods
emfr_unbound(t90, type)
click to toggle source
# File lib/tuscan/iec60584.rb, line 42 def emfr_unbound t90, type tc(type).emfr_unbound t90 end
out_of_range?(t90, type)
click to toggle source
# File lib/tuscan/iec60584.rb, line 46 def out_of_range? t90, type !tc(type)::T90_RANGE.include? t90 end
t90r_guess(emf, type)
click to toggle source
# File lib/tuscan/iec60584.rb, line 38 def t90r_guess emf, type tc(type).t90r_guess emf end
tc(type)
click to toggle source
# File lib/tuscan/iec60584.rb, line 50 def tc type self.const_get "Type#{type.upcase}" end