toji 2.26.0 → 2.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,29 +3,16 @@ module Toji
3
3
  module MotoState
4
4
  include BaseState
5
5
 
6
- OPTIONAL_KEYS = [
7
- :temps,
8
- :preset_temp,
9
- :room_temp,
10
- :room_psychrometry,
11
-
6
+ KEYS = (BaseState::KEYS + [
12
7
  :baume,
13
8
  :acid,
14
-
15
9
  :warmings,
16
- :note,
17
- ].freeze
18
-
19
- # @dynamic temps
20
- # @dynamic preset_temp
21
- # @dynamic room_temp
22
- # @dynamic room_psychrometry
10
+ ]).freeze
23
11
 
24
12
  # @dynamic baume
25
13
  # @dynamic acid
26
14
 
27
15
  # @dynamic warmings
28
- # @dynamic note
29
16
  end
30
17
  end
31
18
  end
@@ -0,0 +1,24 @@
1
+ require 'toji/swvp'
2
+
3
+ module Toji
4
+ # 乾湿差から相対湿度へ変換
5
+ class PsychrometryToRelativeHumidity
6
+ attr_reader :swvp
7
+ attr_reader :pressure
8
+ attr_reader :k
9
+
10
+ def initialize(swvp: Swvp.default, pressure: 1013, k: 0.000662)
11
+ @swvp = swvp
12
+ @pressure = pressure
13
+ @k = k
14
+ end
15
+
16
+ def convert(t_wet, t_dry)
17
+ p_wet = swvp.calc(t_wet)
18
+ p_dry = swvp.calc(t_dry)
19
+
20
+ p_w = p_wet - pressure * k * (t_dry - t_wet)
21
+ p_w / p_dry
22
+ end
23
+ end
24
+ end
data/lib/toji/recipe.rb CHANGED
@@ -56,6 +56,12 @@ module Toji
56
56
  steps.map(&:compact!)
57
57
  steps.select! {|step| 0<step.ingredients.to_a.length}
58
58
 
59
+ indexes = steps.map{|step| {index: step.index, subindex: step.subindex}}
60
+ duplicates = indexes - indexes.uniq
61
+ if 0<duplicates.length
62
+ raise DuplicateStepIndexError.new(duplicates)
63
+ end
64
+
59
65
  ab_expects.select! {|ab| ab.alcohol && ab.nihonshudo}
60
66
  ab_expects.uniq! {|ab| [ab.alcohol, ab.nihonshudo]}
61
67
 
data/lib/toji/swvp.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'toji/swvp/base'
2
+ require 'toji/swvp/tetens'
3
+ require 'toji/swvp/wagner'
4
+ require 'toji/swvp/sonntag'
5
+
6
+ module Toji
7
+ # 飽和水蒸気圧 SWVP: saturation water vapor pressure
8
+ module Swvp
9
+ cattr_accessor :default
10
+ self.default = Wagner.instance
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ require 'singleton'
2
+
3
+ module Toji
4
+ module Swvp
5
+ module Base
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,23 @@
1
+ require 'toji/swvp/base'
2
+
3
+ module Toji
4
+ module Swvp
5
+
6
+ # Sonntagの式
7
+ class Sonntag
8
+ include Base
9
+ include Singleton
10
+
11
+ A = -6096.9385
12
+ B = 21.2409642
13
+ C = 2.711193 * 10**-2
14
+ D = 1.673852 * 10**-5
15
+ E = 2.433502
16
+
17
+ def calc(temp)
18
+ temp = temp.to_f
19
+ (Math.exp(A * ((temp + 273.15)**-1) + B - C * (temp + 273.15) + D * ((temp + 273.15)**2) + E * Math.log(temp + 273.15))) / 100
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ require 'toji/swvp/base'
2
+
3
+ module Toji
4
+ module Swvp
5
+
6
+ # Tetensの式
7
+ class Tetens
8
+ include Base
9
+ include Singleton
10
+
11
+ def calc(temp)
12
+ temp = temp.to_f
13
+ 6.11 * 10 ** ((7.5 * temp) / (237.3 + temp))
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ require 'toji/swvp/base'
2
+
3
+ module Toji
4
+ module Swvp
5
+
6
+ # Wagnerの式
7
+ class Wagner
8
+ include Base
9
+ include Singleton
10
+
11
+ Pc = 221200 # hPa:臨界圧
12
+ Tc = 647.3 # K:臨界温度
13
+ A = -7.76451
14
+ B = 1.45838
15
+ C = -2.7758
16
+ D = -1.2303
17
+
18
+ def calc(temp)
19
+ x = 1 - (temp.to_f + 273.15) / Tc
20
+ Pc * Math.exp((A * x + B * x**1.5 + C * x**3 + D * x**6) / (1 - x))
21
+ end
22
+ end
23
+
24
+ end
25
+ end
data/lib/toji/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Toji
2
- VERSION = "2.26.0"
2
+ VERSION = "2.27.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toji
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.26.0
4
+ version: 2.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshida Tetsuya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-07 00:00:00.000000000 Z
11
+ date: 2021-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -174,6 +174,7 @@ files:
174
174
  - lib/toji/progress/state.rb
175
175
  - lib/toji/progress/state/baume_to_nihonshudo.rb
176
176
  - lib/toji/progress/state/nihonshudo_to_baume.rb
177
+ - lib/toji/psychrometry_to_relative_humidity.rb
177
178
  - lib/toji/recipe.rb
178
179
  - lib/toji/recipe/ab_expect.rb
179
180
  - lib/toji/recipe/action.rb
@@ -184,6 +185,11 @@ files:
184
185
  - lib/toji/schedule/kake_schedule.rb
185
186
  - lib/toji/schedule/koji_schedule.rb
186
187
  - lib/toji/schedule/rice_schedule.rb
188
+ - lib/toji/swvp.rb
189
+ - lib/toji/swvp/base.rb
190
+ - lib/toji/swvp/sonntag.rb
191
+ - lib/toji/swvp/tetens.rb
192
+ - lib/toji/swvp/wagner.rb
187
193
  - lib/toji/utils.rb
188
194
  - lib/toji/version.rb
189
195
  - toji.gemspec