gtengine 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7a6124fbc51b2021b795bdaeeddf672e29bbc1f
4
- data.tar.gz: 0e3e1fc6b8a5e2ce233fb83aeb16b319252abe99
3
+ metadata.gz: 63698ae2d1f94f7ac92937dc0d0219aab3eaa77b
4
+ data.tar.gz: b26b469da2e306d1d8563b9744f531e9ed513a52
5
5
  SHA512:
6
- metadata.gz: ae805ae344231992d2974dccd6724bfaa38905048d129b2eb49d811ee0e1eaa36ec0a073f1c4f941a9104c953da6c11126f0faf3c3c76895f7c1ceaece386a9b
7
- data.tar.gz: 030452f07c07cbf8878c756739b9f0e610c492c575443ab75b56af22baf4169afb4a5e0b5b794fde417b3ad280b4700cd5134b224195b59311f23aa5091b5fa6
6
+ metadata.gz: 1d2c9805c67d1de50113b1154b33966d4d054278ebd590e69a0ee02f7d33caf965e5fbae8b0bb063d95366899ba9d05e33cd67815bc062ebe7319737e71bd2de
7
+ data.tar.gz: 30d3b7e15818c2f0432fd6e029cd296ecc8ca1228a24a38ad5e961241d8114223e7fa178a002720a8584df9ac915231b4e00719222e8ce3caaaad4abc8f8effb
data/Readme.md CHANGED
@@ -1,10 +1,53 @@
1
+ # GTEngine
1
2
  [![Build Status](https://travis-ci.org/arrowcircle/engine.png?branch=master)](https://travis-ci.org/arrowcircle/engine)
2
3
  [![Code Climate](https://codeclimate.com/github/arrowcircle/engine.png)](https://codeclimate.com/github/arrowcircle/engine)
3
4
 
4
- # GTEngine
5
-
6
5
  Math models of gas turbine engine and its parts made with ruby language
7
6
 
7
+ ## Usage
8
+
9
+ ### Simple
10
+
11
+ For simple parts calculation:
12
+
13
+ require_relative 'lib/gtengine'
14
+ gas = Gtengine::Gas.new 300, 101325
15
+
16
+ k = Gtengine::Simple::Compressor.new gas, 4.5, 0.85
17
+ b = Gtengine::Simple::Burner.new k.output, 1500
18
+ t = Gtengine::Simple::Turbine.new b, k.l_k, 0.9
19
+
20
+ k.info; b.info; t.info
21
+
22
+ To play with cycle (compressor -> burner -> turbine)
23
+
24
+ require_relative 'lib/gtengine'
25
+ gas = Gtengine::Gas.new 300, 101325
26
+
27
+ c = Gtengine::Simple::Cycle.new gas, 20, 1500.0
28
+
29
+ c.compressor.info; c.burner.info; c.turbine.info; c.info
30
+
31
+ To play with pi_k optimization
32
+
33
+ require_relative 'lib/gtengine'
34
+ gas = Gtengine::Gas.new 300, 101325
35
+
36
+ opt = Gtengine::Simple::PikOptimizer.new gas, 3, 40, 1500, 1
37
+ opt.info
38
+
39
+ Cycle research with T_g and pik
40
+
41
+ require_relative 'lib/gtengine'
42
+ gas = Gtengine::Gas.new 300, 101325
43
+
44
+ res = {}
45
+ [900, 1000, 1100, 1200, 1300, 1400, 1500].each do |t_g|
46
+ opt = Gtengine::Simple::PikOptimizer.new(gas, 3, 40, t_g, 1)
47
+ res[t_g.to_s] = opt.optimal.pi_k
48
+ end
49
+ puts res
50
+
8
51
  ## Requirements
9
52
 
10
53
  * Ruby 2.0.0 or newer
@@ -8,9 +8,7 @@ class Gtengine::Simple::Burner
8
8
  L0 = 14.7
9
9
 
10
10
  def initialize input, t_g
11
- @input = input
12
- @t_g = t_g
13
- @output = Gtengine::Gas.new(t_g, @input.p, @input.alfa)
11
+ @input, @t_g = input, t_g
14
12
  cycle
15
13
  end
16
14
 
@@ -26,6 +24,10 @@ class Gtengine::Simple::Burner
26
24
  @input.t
27
25
  end
28
26
 
27
+ def p_vh
28
+ @input.p
29
+ end
30
+
29
31
  def q_ks
30
32
  (cp_vyh * t_g - cp_vh * t_vh - (cp_vyh - cp_vh) * T0) / (QN * ETA_G - (cp_vyh * t_g - cp_mult_t_0))
31
33
  end
@@ -43,8 +45,13 @@ class Gtengine::Simple::Burner
43
45
  end
44
46
 
45
47
  def cycle
46
- 5.times do
47
- @output.alfa = alfa
48
- end
48
+ @output = Gtengine::Gas.new(t_g, p_vh, input.alfa)
49
+ 5.times { @output.alfa = alfa }
50
+ end
51
+
52
+ def info
53
+ puts "== Burner q_ks: #{q_ks}, ALFA: #{alfa}"
54
+ puts "==== Вход T: #{@input.t.to_i} K, P: #{@input.p.to_i} Па"
55
+ puts "==== Выход T: #{@output.t.to_i} K, P: #{@output.p.to_i} Па\n\n"
49
56
  end
50
57
  end
@@ -2,10 +2,7 @@ class Gtengine::Simple::Compressor
2
2
  attr_accessor :input, :output, :g, :pi_k, :kpd, :average
3
3
 
4
4
  def initialize input, pi_k, kpd
5
- @input = input
6
- @pi_k = pi_k.to_f
7
- @kpd = kpd.to_f
8
- @average = Gtengine::Gas.new input.t.to_f, input.p.to_f
5
+ @input, @pi_k, @kpd = input, pi_k.to_f, kpd.to_f
9
6
  cycle
10
7
  end
11
8
 
@@ -47,19 +44,15 @@ class Gtengine::Simple::Compressor
47
44
  end
48
45
 
49
46
  def cycle
50
- 5.times do
51
- update_average
52
- end
47
+ @average = Gtengine::Gas.new input.t.to_f, input.p.to_f
48
+ 5.times { update_average }
53
49
  @output = Gtengine::Gas.new t_vyh, p_vyh
54
50
  end
55
51
 
56
52
  def info
57
- puts "== Compressor"
58
- puts "==== Pi_k: #{@pi_k}, КДП: #{@kpd}"
53
+ puts "== Compressor Pi_k: #{@pi_k}, КДП: #{@kpd}, Cp_sr: #{cp}, K: #{k}"
59
54
  puts "==== Вход T: #{@input.t.to_i} K, P: #{@input.p.to_i} Па"
60
- puts "====== Cp_sr: #{cp}, K: #{k}"
61
- puts "==== Выход T: #{@output.t.to_i} K, P: #{@output.p.to_i} Па, ALFA: #{alfa}"
62
- puts
55
+ puts "==== Выход T: #{@output.t.to_i} K, P: #{@output.p.to_i} Па, ALFA: #{alfa}\n\n"
63
56
  end
64
57
 
65
58
  end
@@ -2,23 +2,22 @@ class Gtengine::Simple::PikOptimizer
2
2
  attr_accessor :start_pik, :end_pik, :t_g, :step, :optimum, :cycles, :air
3
3
 
4
4
  def initialize air, start_pik, end_pik, t_g, step=1
5
- @air = air
6
- @start_pik = start_pik
7
- @end_pik = end_pik
8
- @t_g = t_g
9
- @step = step
5
+ @air, @start_pik, @end_pik, @t_g, @step = air, start_pik, end_pik, t_g, step
10
6
  optimize
11
7
  end
12
8
 
13
9
  def optimize
14
10
  @cycles = []
15
11
  Range.new(start_pik, end_pik).step(step).each do |pik|
16
- begin
17
- c = Cycle.new(air, pik, t_g)
18
- @cycles << c if c.burner.q_ks
19
- rescue
20
-
21
- end
12
+ calc_result(pik)
13
+ end
14
+ end
15
+
16
+ def calc_result(pik)
17
+ begin
18
+ c = Gtengine::Simple::Cycle.new(air, pik, t_g)
19
+ @cycles << c if c.burner.q_ks
20
+ rescue
22
21
  end
23
22
  end
24
23
 
@@ -27,9 +26,7 @@ class Gtengine::Simple::PikOptimizer
27
26
  end
28
27
 
29
28
  def info
30
- @cycles.each do |c|
31
- puts "pi_k: #{c.pi_k}, q_ks: #{c.q_ks}"
32
- end
29
+ @cycles.each { |c| c.info }
33
30
  puts "Optimal pi_k: #{optimal.pi_k}, q_ks: #{optimal.q_ks}"
34
31
  end
35
32
  end
@@ -7,10 +7,7 @@ class Gtengine::Simple::Turbine
7
7
  G_OHL = 0.001
8
8
 
9
9
  def initialize burner, l_k, kpd = 0.9
10
- @burner = burner
11
- @l_k = l_k
12
- @kpd = kpd.to_f
13
- @average = Gtengine::Gas.new t_vh, p_vh
10
+ @burner, @l_k, @kpd = burner, l_k, kpd.to_f
14
11
  cycle
15
12
  end
16
13
 
@@ -34,9 +31,8 @@ class Gtengine::Simple::Turbine
34
31
  end
35
32
 
36
33
  def cycle
37
- 5.times do
38
- update_average
39
- end
34
+ @average = Gtengine::Gas.new t_vh, p_vh
35
+ 5.times { update_average }
40
36
  @output = Gtengine::Gas.new t_vyh, p_vyh
41
37
  end
42
38
 
@@ -66,12 +62,9 @@ class Gtengine::Simple::Turbine
66
62
  end
67
63
 
68
64
  def info
69
- puts "== Turbine"
70
- puts "==== Pi_t: #{pi_t}, КДП: #{ETA}"
65
+ puts "== Turbine Cp_sr: #{cp}, K: #{k}, Pi_t: #{pi_t}, КДП: #{ETA}"
71
66
  puts "==== Вход T: #{t_vh.to_i} K, P: #{p_vh.to_i} Па, ALFA: #{input.alfa}, Cp: #{input.cp}"
72
- puts "====== Cp_sr: #{cp}, K: #{k}"
73
- puts "==== Выход T: #{@output.t.to_i} K, P: #{@output.p.to_i} Па, , Cp: #{@output.cp}"
74
- puts
67
+ puts "==== Выход T: #{@output.t.to_i} K, P: #{@output.p.to_i} Па, , Cp: #{@output.cp}\n\n"
75
68
  end
76
69
 
77
70
  end
@@ -10,10 +10,15 @@ module Gtengine
10
10
 
11
11
  def initialize air=Gas.new(300, 101325), pi_k, t_g
12
12
  @air = air
13
+ @t_g = t_g
13
14
  @pi_k = pi_k
15
+ init_cycle
16
+ end
17
+
18
+ def init_cycle
14
19
  @compressor = Compressor.new air, pi_k, 0.85
15
20
  @burner = Burner.new @compressor.output, t_g
16
- @turbine = Turbine.new @burner, @compressor.l_k, 0.9
21
+ @turbine = Turbine.new burner, compressor.l_k, 0.9
17
22
  end
18
23
 
19
24
  def q_ks
@@ -21,8 +26,7 @@ module Gtengine
21
26
  end
22
27
 
23
28
  def info
24
- puts "== Cycle info"
25
- puts "pi_k: #{@compressor.pi_k}, q_ks: #{q_ks}"
29
+ puts "== Cycle info: pi_k: #{@compressor.pi_k}, q_ks: #{q_ks}"
26
30
  end
27
31
  end
28
32
  end
@@ -1,3 +1,3 @@
1
1
  module Gtengine
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gtengine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Bovykin