tuscan 0.0.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -19
- data/lib/tuscan/iec60584.rb +10 -2
- data/lib/tuscan/iec60751.rb +8 -0
- data/lib/tuscan/its90.rb +75 -63
- data/lib/tuscan/version.rb +1 -1
- data/spec/tuscan/iec60584_spec.rb +32 -23
- data/spec/tuscan/its90_spec.rb +63 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7f3655a632e932accfc506be0da201162f2d335
|
4
|
+
data.tar.gz: 86eef0d6a857ffa7da7ee88cfac9db49f59c3c59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e1dc40bdd539f80a0abe660fef874882d1a38a96e3bfed9d4a5835e766462758f273b553f2e467c6b13cd81edd00018539aede201b99ec8f6aa15c169c0ca32
|
7
|
+
data.tar.gz: 5762ef1a39944a570871b38aecd74a3d3c7d8c42d52a49e6df7828214d9fe32f846fb24b9768e10e489f08770c8fc8303f98f8aadf2817c47dd702ace8cc6939
|
data/README.md
CHANGED
@@ -4,18 +4,23 @@
|
|
4
4
|
Makes available functions for:
|
5
5
|
|
6
6
|
* ITS-90 compatible temperature sensors (Standard Platinum Resistance Thermometers), allowing:
|
7
|
-
* Retrieval of reference resistance ratio
|
8
|
-
* Retrieval of reference temperature
|
9
|
-
* Given sensor coefficient's: _sub-range_,
|
10
|
-
* Retrieval of
|
11
|
-
* Retrieval of
|
7
|
+
* Retrieval of reference resistance ratio _W<sub>R</sub>_ from _t<sub>90R</sub>_ reference temperature
|
8
|
+
* Retrieval of reference temperature _t<sub>90R</sub>_ from _W<sub>R</sub>_ reference resistance ratio
|
9
|
+
* Given sensor coefficient's: _sub-range_, _R<sub>tpw</sub>_, _a_, _b_, _c_, _d_, _W<sub>660</sub>_, _c<sub>1</sub>_, _c<sub>2</sub>_, _c<sub>3</sub>_, _c<sub>4</sub>_, _c<sub>5</sub>_
|
10
|
+
* Retrieval of _t<sub>90</sub>_ temperature from sensor's resistance _res_
|
11
|
+
* Retrieval of _res_ resistance from sensor's _t<sub>90</sub>_ temperature.
|
12
12
|
* IEC 60751 compatible temperature sensors (Platinum Resistance Thermometers), allowing:
|
13
|
-
*
|
14
|
-
|
15
|
-
|
13
|
+
* Retrieval of reference resistance _res<sub>R</sub>_ from _t<sub>90R</sub>_ reference temperature
|
14
|
+
* Retrieval of reference temperature _t<sub>90R</sub>_ from _res<sub>R</sub>_ reference resistance
|
15
|
+
* Given sensor coefficient's: _R<sub>0</sub>_, _A_, _B_, _C_
|
16
|
+
* Retrieval of sensor's resistance _res_ from _t<sub>90</sub>_ temperature
|
17
|
+
* Retrieval of temperature _t<sub>90</sub>_ from sensor's resistance _res_
|
16
18
|
* IEC 60584 compatible temperature sensors (Thermocouples), allowing, for a given _type_:
|
17
|
-
* Retrieval of reference voltage
|
18
|
-
* Retrieval of reference temperature
|
19
|
+
* Retrieval of reference voltage _emf<sub>R</sub>_ from _t<sub>90R</sub>_ reference temperature
|
20
|
+
* Retrieval of reference temperature _t<sub>90R</sub>_ from reference voltage _emf<sub>R</sub>_
|
21
|
+
* Given sensor coefficient's: _a_, _b_, _c_, _d_
|
22
|
+
* Retrieval of sensor's voltage _emf_ from _t<sub>90</sub>_ temperature
|
23
|
+
* Retrieval of temperature _t<sub>90</sub>_ from sensor's voltage _emf_
|
19
24
|
|
20
25
|
|
21
26
|
## Installation
|
@@ -38,24 +43,35 @@ Or install it yourself as:
|
|
38
43
|
|
39
44
|
**ITS-90**
|
40
45
|
```ruby
|
41
|
-
|
42
|
-
Tuscan.
|
46
|
+
# Reference functions (ºC vs Ohm/Ohm)
|
47
|
+
Tuscan.wr(:its90, 23.456)
|
48
|
+
Tuscan.t90r(:its90, 1.15)
|
43
49
|
|
44
|
-
|
45
|
-
|
46
|
-
Tuscan.
|
50
|
+
# Corrected for specific sensor (ºC vs Ohm)
|
51
|
+
Tuscan.t90(:its90, 25.319871, rtpw: 25.319871, subrange: 7, a: -1.2134e-04, b: -9.9190e-06)
|
52
|
+
Tuscan.res(:its90, 0.01, rtpw: 25.319871, subrange: 7, a: -1.2134e-04, b: -9.9190e-06)
|
47
53
|
```
|
48
54
|
|
49
55
|
**IEC 60751**
|
50
56
|
```ruby
|
51
|
-
|
52
|
-
Tuscan.
|
57
|
+
# Reference functions (ºC vs Ohm)
|
58
|
+
Tuscan.t90r(:iec60751, 110)
|
59
|
+
Tuscan.resr(:iec60751, 10)
|
60
|
+
|
61
|
+
# Corrected for specific sensor
|
62
|
+
Tuscan.t90(:iec60751, 110, r0: 99.876, a:3.9083e-03, b:-5.7750e-07, c:-4.1830e-12)
|
63
|
+
Tuscan.res(:iec60751, 10, r0: 99.876, a:3.9083e-03, b:-5.7750e-07, c:-4.1830e-12)
|
53
64
|
```
|
54
65
|
|
55
66
|
**IEC 60584**
|
56
67
|
```ruby
|
57
|
-
|
58
|
-
Tuscan.
|
68
|
+
# Reference functions (ºC vs mV)
|
69
|
+
Tuscan.t90r(:iec60584, 1.234, type: :k)
|
70
|
+
Tuscan.emfr(:iec60584, 10.123, type: :k)
|
71
|
+
|
72
|
+
# Corrected for specific sensor
|
73
|
+
Tuscan.t90(:iec60584, 3.6105, type: :k, a: 0, b: -1.39363e-05, c: 3.75578e-08, d: -2.17624e-11)
|
74
|
+
Tuscan.emf(:iec60584, 419.527, type: :k, a: 0, b: -1.39363e-05, c: 3.75578e-08, d: -2.17624e-11)
|
59
75
|
```
|
60
76
|
|
61
77
|
|
data/lib/tuscan/iec60584.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'byebug'
|
2
|
-
|
3
1
|
module Tuscan
|
4
2
|
module Iec60584
|
5
3
|
extend self
|
@@ -11,6 +9,16 @@ module Tuscan
|
|
11
9
|
alias_method :t, :t90
|
12
10
|
alias_method :temperature, :t90
|
13
11
|
|
12
|
+
def emf t90, type:, a: 0.0, b: 0.0, c: 0.0, d: 0.0, err: 1e-3, num: 10
|
13
|
+
guess = emfr t90, type
|
14
|
+
delta = 1e-2
|
15
|
+
args = { type: type, a: a, b: b, c: c, d: d, err: err, num: num }
|
16
|
+
Rical.inverse_for f: method(:t90), fargs: args, x0: guess - delta, x1: guess + delta,
|
17
|
+
y: t90, method: :secant, num: num, err: err
|
18
|
+
end
|
19
|
+
alias_method :v, :emf
|
20
|
+
alias_method :voltage, :emf
|
21
|
+
|
14
22
|
def emfr t90, type
|
15
23
|
raise RangeError, 't90 is outside the valid range' if out_of_range? t90, type
|
16
24
|
emfr_unbound t90, type
|
data/lib/tuscan/iec60751.rb
CHANGED
@@ -12,6 +12,14 @@ module Tuscan
|
|
12
12
|
|
13
13
|
extend self
|
14
14
|
|
15
|
+
def resr t90
|
16
|
+
r t90
|
17
|
+
end
|
18
|
+
|
19
|
+
def t90r r
|
20
|
+
t90 r
|
21
|
+
end
|
22
|
+
|
15
23
|
def r t90, r0: R0, a: A, b: B, c: C
|
16
24
|
raise RangeError, 't90 is outside the valid range' unless T90_RANGE.include? t90
|
17
25
|
r_unbound t90, r0, a, b, c
|
data/lib/tuscan/its90.rb
CHANGED
@@ -3,28 +3,8 @@ module Tuscan
|
|
3
3
|
include Math
|
4
4
|
extend self
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
-0.05332322, 0.28021362, 0.10715224,
|
9
|
-
-0.29302865, 0.04459872, 0.11868632,
|
10
|
-
-0.05248134 ]
|
11
|
-
|
12
|
-
B = [ 0.183324722, 0.240975303, 0.209108771,
|
13
|
-
0.190439972, 0.142648498, 0.077993465,
|
14
|
-
0.012475611, -0.032267127, -0.075291522,
|
15
|
-
-0.05647067, 0.076201285, 0.123893204,
|
16
|
-
-0.029201193, -0.091173542, 0.001317696,
|
17
|
-
0.026025526 ]
|
18
|
-
|
19
|
-
C = [ 2.78157254, 1.64650916, -0.1371439,
|
20
|
-
-0.00649767, -0.00234444, 0.00511868,
|
21
|
-
0.00187982, -0.00204472, -0.00046122,
|
22
|
-
0.00045724 ]
|
23
|
-
|
24
|
-
D = [ 439.932854, 472.41802, 37.684494,
|
25
|
-
7.472018, 2.920828, 0.005184,
|
26
|
-
-0.963864, -0.188732, 0.191203,
|
27
|
-
0.049025 ]
|
6
|
+
T90_RANGE = -273.16..961.78
|
7
|
+
WR_RANGE = 0.00..4.28642053
|
28
8
|
|
29
9
|
def t90 r, rtpw:, **args
|
30
10
|
w = r / rtpw
|
@@ -33,60 +13,60 @@ module Tuscan
|
|
33
13
|
alias_method :t, :t90
|
34
14
|
alias_method :temperature, :t90
|
35
15
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
# WDEV_EQUATIONS[subrange - 1][:valid]
|
46
|
-
# end
|
47
|
-
|
16
|
+
def r t90, rtpw:, num: 100, err: 1e-6, **args
|
17
|
+
guess = wr t90
|
18
|
+
delta = 1e-2
|
19
|
+
Rical.inverse_for f: method(:t90_unbound), fargs: { rtpw: rtpw, **args },
|
20
|
+
x0: guess - delta, x1: guess + delta,
|
21
|
+
y: t90, method: :secant, num: num, err: err * 1e-1
|
22
|
+
end
|
23
|
+
alias_method :res, :r
|
24
|
+
alias_method :resistance, :r
|
48
25
|
|
49
|
-
|
50
|
-
|
51
|
-
#
|
52
|
-
def self.wr t90
|
53
|
-
# return nil unless T90_RANGE.include? t90
|
26
|
+
def wr t90
|
27
|
+
raise RangeError, 't90 is outside the valid range' unless T90_RANGE.include? t90
|
54
28
|
if t90< 0.01
|
55
|
-
|
29
|
+
a = [ -2.13534729, 3.1832472, -1.80143597, 0.71727204, 0.50344027, -0.61899395, -0.05332322,
|
30
|
+
0.28021362, 0.10715224, -0.29302865, 0.04459872, 0.11868632, -0.05248134 ]
|
31
|
+
exp(a.each_with_index.collect{ |ai, i| ai*( (log((t90+273.15)/273.16) + 1.5)/1.5 )**i }.reduce(:+))
|
56
32
|
else
|
57
|
-
|
33
|
+
c = [ 2.78157254, 1.64650916, -0.1371439, -0.00649767, -0.00234444, 0.00511868, 0.00187982,
|
34
|
+
-0.00204472, -0.00046122, 0.00045724 ]
|
35
|
+
c.each_with_index.collect{ |ci, i| ci*((t90-481)/481)**i }.reduce(:+)
|
58
36
|
end
|
59
37
|
end
|
60
38
|
|
61
|
-
def
|
62
|
-
|
39
|
+
def t90r wr
|
40
|
+
raise RangeError, 'wr is outside the valid range' unless WR_RANGE.include? wr
|
63
41
|
if wr < 1.0
|
64
|
-
|
42
|
+
b = [ 0.183324722, 0.240975303, 0.209108771, 0.190439972, 0.142648498, 0.077993465,
|
43
|
+
0.012475611, -0.032267127, -0.075291522, -0.05647067, 0.076201285, 0.123893204,
|
44
|
+
-0.029201193, -0.091173542, 0.001317696, 0.026025526 ]
|
45
|
+
b.each_with_index.collect{ |bi, i| bi*(((wr)**(1.0/6)-0.65)/0.35)**i }.reduce(:+) * 273.16 - 273.15
|
65
46
|
else
|
66
|
-
|
47
|
+
d = [ 439.932854, 472.41802, 37.684494, 7.472018, 2.920828, 0.005184, -0.963864,
|
48
|
+
-0.188732, 0.191203, 0.049025 ]
|
49
|
+
d.each_with_index.collect{ |di, i| di*((wr-2.64)/1.64)**i }.reduce(:+)
|
67
50
|
end
|
68
51
|
end
|
69
52
|
|
70
|
-
#
|
71
|
-
# ITS-90 DEVIATION FUNCTIONS
|
72
|
-
#
|
73
|
-
WDEV_EQUATIONS = [ { valid: (-259.4467..0.01), k: %w(c1 c2 c3 c4 c5), n: 2 },
|
74
|
-
{ valid: (-248.5939..0.01), k: %w(c1 c2 c3 ), n: 0 },
|
75
|
-
{ valid: (-218.7916..0.01), k: %w(c1 ), n: 1 },
|
76
|
-
{ valid: (-189.3442..0.01), k: %w( ) },
|
77
|
-
{ valid: (0.0..961.78), k: %w(a b c d ) },
|
78
|
-
{ valid: (0.0..660.323), k: %w(a b c ) },
|
79
|
-
{ valid: (0.0..419.527), k: %w(a b ) },
|
80
|
-
{ valid: (0.0..231.928), k: %w(a b ) },
|
81
|
-
{ valid: (0.0..156.5985), k: %w(a ) },
|
82
|
-
{ valid: (0.0..29.7646), k: %w(a ) },
|
83
|
-
{ valid: (-38.8344..29.7646), k: %w(a b ) } ]
|
84
|
-
|
85
53
|
def wdev t90, subrange: ,
|
86
54
|
a: 0.0, b: 0.0, c: 0.0, d: 0.0, w660: 0.0,
|
87
55
|
c1: 0.0, c2: 0.0, c3: 0.0, c4: 0.0, c5: 0.0
|
88
|
-
|
89
|
-
|
56
|
+
raise RangeError, 't90 is outside the valid range' if out_of_range? t90, subrange
|
57
|
+
wdev_unbound t90, subrange: subrange, a: a, b: b, c: c, d: d, w660: w660, c1: c1, c2: c2, c3: c3, c4: c4, c5: c5
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
def t90_unbound r, rtpw:, **args
|
62
|
+
w = r / rtpw
|
63
|
+
t90r w - wdev_unbound(t90r(w), args)
|
64
|
+
end
|
65
|
+
|
66
|
+
def wdev_unbound t90, subrange: ,
|
67
|
+
a: 0.0, b: 0.0, c: 0.0, d: 0.0, w660: 0.0,
|
68
|
+
c1: 0.0, c2: 0.0, c3: 0.0, c4: 0.0, c5: 0.0
|
69
|
+
equation = wdev_equation subrange
|
90
70
|
wr_t90 = wr t90
|
91
71
|
case subrange
|
92
72
|
when 1..4
|
@@ -95,7 +75,7 @@ module Tuscan
|
|
95
75
|
wdev += b * (wr_t90 - 1) * log(wr_t90) :
|
96
76
|
wdev += b * (wr_t90 - 1)**2
|
97
77
|
wdev += equation[:k].each_with_index.
|
98
|
-
collect{ |k, i|
|
78
|
+
collect{ |k, i| call(k) * log(wr_t90)**(i + equation[:n]) }.reduce(:+) || 0
|
99
79
|
when 5..11
|
100
80
|
wdev = d * (wr_t90 - w660)**2 if equation[:k].delete('d')
|
101
81
|
wdev ||= 0
|
@@ -103,5 +83,37 @@ module Tuscan
|
|
103
83
|
collect{ |k, i| eval("#{k}") * (wr_t90 - 1)**(i+1) }.reduce(:+)
|
104
84
|
end
|
105
85
|
end
|
86
|
+
|
87
|
+
def wdev_equation subrange
|
88
|
+
case subrange
|
89
|
+
when 1 then { k: %w(c1 c2 c3 c4 c5), n: 2 }
|
90
|
+
when 2 then { k: %w(c1 c2 c3 ), n: 0 }
|
91
|
+
when 3 then { k: %w(c1 ), n: 1 }
|
92
|
+
when 4 then { k: %w( ) }
|
93
|
+
when 5 then { k: %w(a b c d ) }
|
94
|
+
when 6 then { k: %w(a b c ) }
|
95
|
+
when 7 then { k: %w(a b ) }
|
96
|
+
when 8 then { k: %w(a b ) }
|
97
|
+
when 9 then { k: %w(a ) }
|
98
|
+
when 10 then { k: %w(a ) }
|
99
|
+
when 11 then { k: %w(a b ) }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def out_of_range? t90, subrange
|
104
|
+
case subrange
|
105
|
+
when 1 then !(-259.4467..0.01 ).include? t90
|
106
|
+
when 2 then !(-248.5939..0.01 ).include? t90
|
107
|
+
when 3 then !(-218.7916..0.01 ).include? t90
|
108
|
+
when 4 then !(-189.3442..0.01 ).include? t90
|
109
|
+
when 5 then !( 0.0..961.78 ).include? t90
|
110
|
+
when 6 then !( 0.0..660.323 ).include? t90
|
111
|
+
when 7 then !( 0.0..419.527 ).include? t90
|
112
|
+
when 8 then !( 0.0..231.928 ).include? t90
|
113
|
+
when 9 then !( 0.0..156.5985).include? t90
|
114
|
+
when 10 then !( 0.0..29.7646 ).include? t90
|
115
|
+
when 11 then !( -38.8344..29.7646 ).include? t90
|
116
|
+
end
|
117
|
+
end
|
106
118
|
end
|
107
119
|
end
|
data/lib/tuscan/version.rb
CHANGED
@@ -2,8 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
#
|
4
4
|
# TODO:
|
5
|
-
# 1.
|
6
|
-
# 2. compute better t90_guess for 50..250 ºC to allow extension of T90_RANGE down to 50ºC
|
5
|
+
# 1. compute better t90_guess for 50..250 ºC to allow extension of T90_RANGE down to 50ºC
|
7
6
|
#
|
8
7
|
module Tuscan
|
9
8
|
describe Iec60584 do
|
@@ -113,20 +112,6 @@ module Tuscan
|
|
113
112
|
end
|
114
113
|
end
|
115
114
|
|
116
|
-
context 'deviation functions' do
|
117
|
-
context 'emfdev computation' do
|
118
|
-
it 'delegates to Polynomial' do
|
119
|
-
expect(Polynomial).to receive(:new).with(1, 2, 3, 4).and_call_original
|
120
|
-
Iec60584.emfdev 0, 1, 2, 3, 4
|
121
|
-
end
|
122
|
-
|
123
|
-
it 'calls Polynomial#solve_for' do
|
124
|
-
expect_any_instance_of(Polynomial).to receive(:solve_for).with(0)
|
125
|
-
Iec60584.emfdev 0, 1, 2, 3, 4
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
115
|
context 'range validation' do
|
131
116
|
%i{ b c e j k n r s t }.each do |type|
|
132
117
|
context "on a type #{type.upcase} thermocouple" do
|
@@ -142,21 +127,45 @@ module Tuscan
|
|
142
127
|
end
|
143
128
|
end
|
144
129
|
end
|
130
|
+
end
|
145
131
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
]
|
132
|
+
context 'deviation functions' do
|
133
|
+
context 'emfdev computation' do
|
134
|
+
it 'delegates to Polynomial' do
|
135
|
+
expect(Polynomial).to receive(:new).with(1, 2, 3, 4).and_call_original
|
136
|
+
Iec60584.emfdev 0, 1, 2, 3, 4
|
137
|
+
end
|
153
138
|
|
139
|
+
it 'calls Polynomial#solve_for' do
|
140
|
+
expect_any_instance_of(Polynomial).to receive(:solve_for).with(0)
|
141
|
+
Iec60584.emfdev 0, 1, 2, 3, 4
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context 'non-standard coefficients' do
|
147
|
+
tc = { type: :r, a: 0, b: -1.39363e-05, c: 3.75578e-08, d: -2.17624e-11 }
|
148
|
+
examples = [
|
149
|
+
{ emf: 3.6105, t90: 419.527 },
|
150
|
+
{ emf: 10.0054, t90: 961.78 },
|
151
|
+
{ emf: 11.6417, t90: 1084.62 }
|
152
|
+
]
|
153
|
+
|
154
|
+
context 't90 function' do
|
154
155
|
examples.each do |example|
|
155
156
|
it "complies with NPL cert. 2014040275/1/PM03, #{example[:emf]} mV => #{example[:t90]} ºC" do
|
156
157
|
expect(Iec60584.t90 example[:emf], tc).to be_within(0.01).of(example[:t90])
|
157
158
|
end
|
158
159
|
end
|
159
160
|
end
|
161
|
+
|
162
|
+
context 'emf function' do
|
163
|
+
examples.each do |example|
|
164
|
+
it "complies with NPL cert. 2014040275/1/PM03, #{example[:t90]} ºC => #{example[:emf]} mV" do
|
165
|
+
expect(Iec60584.emf example[:t90], tc).to be_within(0.0001).of(example[:emf])
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
160
169
|
end
|
161
170
|
end
|
162
171
|
end
|
data/spec/tuscan/its90_spec.rb
CHANGED
@@ -24,6 +24,18 @@ module Tuscan
|
|
24
24
|
expect(Its90.wr example[:t90]).to be_within(1e-8).of(example[:wr])
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
28
|
+
context 'range validation' do
|
29
|
+
t90lo = -274.0
|
30
|
+
it "raises RangeError when t90r is #{t90lo} ºC" do
|
31
|
+
expect{ Its90.wr t90lo }.to raise_error RangeError
|
32
|
+
end
|
33
|
+
|
34
|
+
t90hi = 962.0
|
35
|
+
it "raises RangeError when t90r is #{t90hi} ºC" do
|
36
|
+
expect{ Its90.wr t90hi }.to raise_error RangeError
|
37
|
+
end
|
38
|
+
end
|
27
39
|
end
|
28
40
|
|
29
41
|
context 't90r computation' do
|
@@ -32,7 +44,21 @@ module Tuscan
|
|
32
44
|
expect(Its90.t90r example[:wr]).to be_within(0.00013).of(example[:t90])
|
33
45
|
end
|
34
46
|
end
|
47
|
+
|
48
|
+
context 'range validation' do
|
49
|
+
wrlo = -0.1
|
50
|
+
it "raises RangeError when wr is #{wrlo}" do
|
51
|
+
expect{ Its90.t90r wrlo }.to raise_error RangeError
|
52
|
+
end
|
53
|
+
|
54
|
+
wrhi = 4.3
|
55
|
+
it "raises RangeError when wr is #{wrhi}" do
|
56
|
+
expect{ Its90.t90r wrhi }.to raise_error RangeError
|
57
|
+
end
|
58
|
+
end
|
35
59
|
end
|
60
|
+
|
61
|
+
|
36
62
|
end
|
37
63
|
|
38
64
|
context 'deviation functions' do
|
@@ -52,6 +78,7 @@ module Tuscan
|
|
52
78
|
expect(Its90.wdev example[:t90], sprt).to be_within(1e-8).of(example[:wdev])
|
53
79
|
end
|
54
80
|
end
|
81
|
+
|
55
82
|
end
|
56
83
|
|
57
84
|
context 'range 6' do
|
@@ -70,10 +97,32 @@ module Tuscan
|
|
70
97
|
end
|
71
98
|
end
|
72
99
|
end
|
100
|
+
|
101
|
+
context 'range validation' do
|
102
|
+
examples =
|
103
|
+
[ -259.4467..0.01, -248.5939..0.01, -218.7916..0.01,
|
104
|
+
-189.3442..0.01, 0.0..961.78, 0.0..660.323 ,
|
105
|
+
0.0..419.527 , 0.0..231.928 , 0.0..156.5985,
|
106
|
+
0.0..29.7646 , -38.8344..29.7646 ]
|
107
|
+
|
108
|
+
(1..11).each do |subrange|
|
109
|
+
context "on a sub-range #{subrange} SPRT" do
|
110
|
+
t90lo = examples[subrange-1].min - 1.0
|
111
|
+
it "raises RangeError when t90 is #{t90lo} ºC" do
|
112
|
+
expect{ Its90.wdev t90lo, subrange: subrange }.to raise_error RangeError
|
113
|
+
end
|
114
|
+
|
115
|
+
t90hi = examples[subrange-1].max + 1.0
|
116
|
+
it "raises RangeError when t90 is #{t90hi} ºC" do
|
117
|
+
expect{ Its90.wdev t90hi, subrange: subrange }.to raise_error RangeError
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
73
122
|
end
|
74
123
|
end
|
75
124
|
|
76
|
-
context '
|
125
|
+
context 'non-standard coefficients' do
|
77
126
|
sprt = { rtpw: 25.319871, subrange: 7, a: -1.2134e-04, b: -9.9190e-06 }
|
78
127
|
examples = [
|
79
128
|
{ r: 25.319871, t90: 0.010 },
|
@@ -81,9 +130,19 @@ module Tuscan
|
|
81
130
|
{ r: 65.039218, t90: 419.527 }
|
82
131
|
]
|
83
132
|
|
84
|
-
|
85
|
-
|
86
|
-
|
133
|
+
context 't90 function' do
|
134
|
+
examples.each do |example|
|
135
|
+
it "complies with IPQ cert. 501.20/1241312 range 7, #{example[:t90]} Celsius" do
|
136
|
+
expect(Its90.t90 example[:r], sprt).to be_within(0.0001).of(example[:t90])
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
context 'res function' do
|
142
|
+
examples.each do |example|
|
143
|
+
it "complies with IPQ cert. 501.20/1241312 range 7, #{example[:r]} Ohm" do
|
144
|
+
expect(Its90.res example[:t90], sprt).to be_within(1e-5).of(example[:r])
|
145
|
+
end
|
87
146
|
end
|
88
147
|
end
|
89
148
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tuscan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis Bacelar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rical
|