decay_heat_with_nuclear 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cefcf0711745f3546c8b0965529aa4ea97a0c9f1
4
+ data.tar.gz: e505da9206e1da0d7746dc3ad9f330ecf8bf4144
5
+ SHA512:
6
+ metadata.gz: 719356ded9a0b1b548164f6fea5deb2b7e6cdbf7b7a5df41750c14b245694dde809b9d3f99860b52a6a6710d001e408ce17732933992ab6da727d68f9400fe22
7
+ data.tar.gz: 645af1f55684aa918b610cdecca5d0bed1b4f25f5273b22d356ecbd483a612fe26534fddca67b81583738a0542a13f2f8d25adc388d9f94e2a21ca1ce589667e
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in decay_heat_with_nuclear.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,166 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
166
+
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # decay_heat_with_nuclear
2
+
3
+ It's a easy way to get nuclear fuel decay heat when it remove from reactor core.
4
+ Using 3 method `ASB9-2`, `ANS-1973` and `ANS-1979` to calculate it.
5
+
6
+ ## Install this gem
7
+
8
+ ```
9
+ gem install decay_heat_with_nuclear
10
+ ```
11
+
12
+
13
+ ## Yor need a HASH
14
+
15
+ The hash will like this:
16
+
17
+ ```
18
+ hash = {
19
+ ts: array,
20
+ t0: array
21
+ }
22
+ ```
23
+
24
+ where
25
+ ts is `Time after remove (sec)`,
26
+ t0 is `Cumulative reactor operating time (sec)`
27
+
28
+
29
+ ## Calculate from this gem
30
+
31
+ ```
32
+ DecayHeatWithNuclear.run(hash)
33
+ ```
34
+
35
+ and you will get the hash data like:
36
+
37
+ ```
38
+ output_hash = {
39
+ ans1979: { ts: array, P/P0: array },
40
+ ans1973: { ts: array, P/P0: array },
41
+ asb9_2: { ts: array, P/P0: array },
42
+ }
43
+
44
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'decay_heat_with_nuclear/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'decay_heat_with_nuclear'
8
+ spec.version = DecayHeatWithNuclear::VERSION
9
+ spec.authors = ['C.lin']
10
+ spec.email = ['demeter.yeh@gmail.com']
11
+ spec.summary = %q{It's a easy way to get nuclear fuel decay heat when it remove from reactor core.}
12
+ spec.description = %q{It's a easy way to get nuclear fuel decay heat when it remove from reactor core.}
13
+ spec.homepage = ''
14
+ spec.license = 'GPL3.0'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.6'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ end
@@ -0,0 +1,338 @@
1
+ module MainRun
2
+ class RunInit
3
+ attr_accessor :ts, :t0, :power
4
+
5
+ def initialize(hash_data, option = 0, file_name = 'default.txt')
6
+ @ts = hash_data[:ts]
7
+ @t0 = hash_data[:t0]
8
+ @power = []
9
+ @option = option
10
+ @file_name = file_name
11
+ @output_hash = {
12
+ ts: [],
13
+ p_p0: [],
14
+ p_p0_without_k: []
15
+ }
16
+ end
17
+
18
+ def dataout(ts, p_p0, p_p0_without_k = nil)
19
+ @output_hash[:ts] << ts
20
+ @output_hash[:p_p0] << p_p0
21
+ @output_hash[:p_p0_without_k] << p_p0_without_k if p_p0_without_k
22
+ end
23
+
24
+ # day2sec(day)
25
+ def day2sec(day)
26
+ if day < 86400 * 10
27
+ day * 24 * 3600.0
28
+ end
29
+ end
30
+
31
+ # sec2day(sec)
32
+ def sec2day(sec)
33
+ sec / 24 / 3600.0
34
+ end
35
+ end
36
+
37
+ class RunAns1973 < RunInit
38
+ def run(ts = @ts, t0 = @t0, power = @power)
39
+ read_data = ThermalData::DataForANS_5_1_1973.new
40
+ ts.each_index do |i|
41
+ ts_to_f = ts[i].to_f
42
+ t0_to_f = t0[i].to_f
43
+ # power_to_f = power[i].to_f
44
+
45
+ t0_add_ts = ts_to_f + t0_to_f
46
+
47
+ p_p0_source = calc_thermal_fission_functions(t0_to_f, ts_to_f, read_data)
48
+ p_p0 = calc_sum_thermal_fission(p_p0_source)
49
+
50
+ p_p0_U239 = calc_thermal_fission_functions_with_U239(t0_to_f, ts_to_f)
51
+ p_p0_Np239 = calc_thermal_fission_functions_with_Np239(t0_to_f, ts_to_f)
52
+
53
+ p_p0_tatal = p_p0 + p_p0_U239 + p_p0_Np239
54
+
55
+ dataout(ts_to_f, p_p0_tatal)
56
+ end
57
+ @output_hash
58
+ end
59
+
60
+ private
61
+
62
+ # Calculate thermal fission functions from ASB9-2.
63
+ # need t0, ts and data with thermal fission(from class DataForASB_9_2)
64
+ # ts: Time after remove (sec)
65
+ # t0: Cumulative reactor operating time (sec)
66
+ #
67
+ # calc_thermal_fission_functions(t0, ts, read_data)
68
+ #
69
+ # return { :ts => P/P0(t_inf, ts)
70
+ # :ts_add_t0 => P/P0(t_inf, ts + t0) }
71
+ #
72
+ def calc_thermal_fission_functions(t0, ts, read_data)
73
+ total_times = t0 + ts
74
+ ff = { ts: 0.0, ts_add_t0: 0.0 }
75
+
76
+ (0..read_data.theAn.size - 1).each do |i|
77
+ p_p0_tinf2ts = (1.0 / 200.0) * read_data.theAn[i] * Math.exp(-read_data.thean[i] * ts)
78
+
79
+ p_p0_tinf2ts_add_t0 = (1.0 / 200.0) * read_data.theAn[i] * Math.exp(-read_data.thean[i] * total_times)
80
+
81
+ ff[:ts] = ff[:ts] + p_p0_tinf2ts
82
+ ff[:ts_add_t0] = ff[:ts_add_t0] + p_p0_tinf2ts_add_t0
83
+ end
84
+ ff
85
+ end
86
+
87
+ def calc_sum_thermal_fission(p_p0_source)
88
+ p_p0_source[:ts] - p_p0_source[:ts_add_t0]
89
+ end
90
+
91
+ def calc_thermal_fission_functions_with_U239(t0, ts)
92
+ 0.00228 * 0.7 * (1 - Math.exp(-0.000491 * t0)) * Math.exp(-0.000491 * ts)
93
+ end
94
+
95
+ def calc_thermal_fission_functions_with_Np239(t0, ts)
96
+ a1 = 4.91E-4
97
+ a2 = 3.41E-6
98
+ 0.00217 * 0.7 * ((a1 / (a1 + a2)) * (1 - Math.exp(-a2 * t0)) * Math.exp(-a2 * ts) - (a2 / (a1 + a2)) * (1 - Math.exp(-a1 * t0)) * Math.exp(-a1 * ts))
99
+ end
100
+ end
101
+
102
+ class RunAns1979 < RunInit
103
+ def run(ts = @ts, t0 = @t0, power = @power)
104
+ read_data = ThermalData::DataForANS_5_1_1979.new
105
+ ts.each_index do |i|
106
+ ts_to_f = ts[i].to_f
107
+ t0_to_f = t0[i].to_f
108
+ # power_to_f = power[i].to_f
109
+
110
+ t0_add_ts = ts_to_f + t0_to_f
111
+ f_ts2t0 = calc_thermal_fission_functions(t0_to_f, ts_to_f, read_data)
112
+ thePd_apostrophe = calc_sum_thermal_fission(f_ts2t0, read_data)
113
+ thePd = calc_total_fission_product(thePd_apostrophe, t0_to_f, ts_to_f, read_data)
114
+ fU239 = calc_thermal_fission_functions_with_U239(t0_to_f, ts_to_f, read_data)
115
+ fNp239 = calc_thermal_fission_functions_with_Np239(t0_to_f, ts_to_f, read_data)
116
+ thePd_all = thePd + ((fU239 + fNp239)/read_data.theQ[:others])
117
+ un = calc_Un(ts_to_f)
118
+
119
+ if ts_to_f > 1.0E+03 && ts_to_f < 1.0E+04
120
+ thePd_all_un = thePd_all * 1.03
121
+ elsif ts_to_f >= 1.0E+04
122
+ thePd_all_un = thePd_all * (1.0 + un)
123
+ else
124
+ thePd_all_un = thePd_all * (1 + 3.0E-06 * ts_to_f)
125
+ end
126
+
127
+ dataout(ts_to_f, thePd_all_un)
128
+ end
129
+ @output_hash
130
+ end
131
+
132
+ private
133
+
134
+ # Calculate thermal fission functions from ANS-5.1-1979 Table 7~9 include U235, Pu239 and U238.
135
+ # need t0, ts and data with thermal fission(from class DataForANS_5_1_1979)
136
+ # ts: Time after remove (sec)
137
+ # t0: Cumulative reactor operating time (sec)
138
+ #
139
+ # calc_thermal_fission_functions(t0, ts, read_data)
140
+ #
141
+ # return { :U235 => f_U235(ts, t0)
142
+ # :Pu239 => f_Pu235(ts, t0)
143
+ # :U238 => f_U238(ts, t0) }
144
+ #
145
+ def calc_thermal_fission_functions(t0, ts, read_data)
146
+ total_times = t0 + ts
147
+ ff = ThermalData::HashWithThermalFission.new
148
+ (0..read_data.theU235_alpha.size-1).each do |i|
149
+ f_U235_ts2tinf = read_data.theU235_alpha[i] / read_data.theU235_lamda[i] *
150
+ Math.exp(-read_data.theU235_lamda[i] * ts) *
151
+ (1.0 - Math.exp(-read_data.theU235_lamda[i] * read_data.tinf))
152
+
153
+ f_U235_ts_add_t02tinf = read_data.theU235_alpha[i] / read_data.theU235_lamda[i] *
154
+ Math.exp(-read_data.theU235_lamda[i] * total_times) *
155
+ (1.0 - Math.exp(-read_data.theU235_lamda[i] * read_data.tinf))
156
+
157
+ ff.thermal_fission[:U235] = ff.thermal_fission[:U235] + f_U235_ts2tinf - f_U235_ts_add_t02tinf
158
+
159
+ f_Pu239_ts2tinf = read_data.thePu239_alpha[i] / read_data.thePu239_lamda[i] *
160
+ Math.exp(-read_data.thePu239_lamda[i] * ts) *
161
+ (1.0 - Math.exp(-read_data.thePu239_lamda[i] * read_data.tinf))
162
+
163
+ f_Pu239_ts_add_t02tinf = read_data.thePu239_alpha[i] / read_data.thePu239_lamda[i] *
164
+ Math.exp(-read_data.thePu239_lamda[i] * total_times) *
165
+ (1.0 - Math.exp(-read_data.thePu239_lamda[i] * read_data.tinf))
166
+
167
+ ff.thermal_fission[:Pu239] = ff.thermal_fission[:Pu239] + f_Pu239_ts2tinf - f_Pu239_ts_add_t02tinf
168
+
169
+ f_U238_ts2tinf = read_data.theU238_alpha[i] / read_data.theU238_lamda[i] *
170
+ Math.exp(-read_data.theU238_lamda[i] * ts) *
171
+ (1.0 - Math.exp(-read_data.theU238_lamda[i] * read_data.tinf))
172
+
173
+ f_U235_ts_add_t02tinf = read_data.theU238_alpha[i] / read_data.theU238_lamda[i] *
174
+ Math.exp(-read_data.theU238_lamda[i] * total_times) *
175
+ (1.0 - Math.exp(-read_data.theU238_lamda[i] * read_data.tinf))
176
+
177
+ ff.thermal_fission[:U238] = ff.thermal_fission[:U238] + f_U238_ts2tinf - f_U235_ts_add_t02tinf
178
+ end
179
+ ff.thermal_fission
180
+ end
181
+
182
+ # Calculate P'di (the uncorrected decay heat power) from ANS-5.1-1979 Eq.6
183
+ # need f_ts2t0, Pi(thePi), Qi(theQ) from class DataForANS_5_1_1979.
184
+ #
185
+ # calc_sum_thermal_fission(f_ts2t0, read_data)
186
+ #
187
+ # return P'd
188
+ #
189
+ def calc_sum_thermal_fission(f_ts2t0, read_data)
190
+ prd = ThermalData::HashWithThermalFission.new
191
+ pd = 0
192
+ prd.thermal_fission.each do |key, value|
193
+ value = value + read_data.thePi[key] * f_ts2t0[key] / read_data.theQ[key]
194
+ pd += value
195
+ end
196
+ pd
197
+ end
198
+
199
+ # Calculate total fission product decay heat power
200
+ # at t(ts) sec after shutdown from an operating history of T(t0) sec duration. (from ANS-5.1-1979 Eq.1 and 11)
201
+ # need t0, ts and data with thermal fission(from class DataForANS_5_1_1979)
202
+ # ts: Time after remove (sec)
203
+ # t0: Cumulative reactor operating time (sec)
204
+ #
205
+ # calc_total_fission_product(thePd_apostrophe, t0, ts, read_data)
206
+ #
207
+ # return Pd
208
+ #
209
+ def calc_total_fission_product(thePd_apostrophe, t0, ts, read_data)
210
+ g = 1.0 + ((3.24E-06 + 5.23E-10 * ts) * (t0 ** (4.0E-01)) * read_data.phi)
211
+ if g >= 1.1
212
+ g = 1.1
213
+ end
214
+ thePd_apostrophe * g
215
+ end
216
+
217
+ # Calculate U239 fission product decay heat power from ANS-5.1-1979 Eq.14
218
+ # ts: Time after remove (sec)
219
+ # t0: Cumulative reactor operating time (sec)
220
+ #
221
+ # calc_thermal_fission_functions_with_U239(t0, ts, read_data)
222
+ #
223
+ # return fU239
224
+ #
225
+ def calc_thermal_fission_functions_with_U239(t0, ts, read_data)
226
+ read_data.theEU239 * read_data.theR * (1 - Math.exp(-read_data.lamda1 * t0)) * Math.exp(-read_data.lamda1 * ts)
227
+ end
228
+
229
+ # Calculate Np239 fission product decay heat power from ANS-5.1-1979 Eq.15
230
+ # ts: Time after remove (sec)
231
+ # t0: Cumulative reactor operating time (sec)
232
+ #
233
+ # calc_thermal_fission_functions_with_Np239(t0, ts, read_data)
234
+ #
235
+ # return fNp239
236
+ #
237
+ def calc_thermal_fission_functions_with_Np239(t0, ts, read_data)
238
+ read_data.theENp239 * read_data.theR * ((read_data.lamda1 / (read_data.lamda1 - read_data.lamda2)) *
239
+ (1 - Math.exp(-read_data.lamda2 * t0)) * Math.exp(-read_data.lamda2 * ts) -
240
+ (read_data.lamda2 / (read_data.lamda1 - read_data.lamda2)) * (1 - Math.exp(-read_data.lamda1 * t0)) * Math.exp(-read_data.lamda1 * ts))
241
+ end
242
+
243
+ # Calculate Un is a factor which accounts for the SIL-636 additional terms effect.
244
+ # ts: Time after remove (sec)
245
+ #
246
+ # calc_Un(ts)
247
+ #
248
+ # return un
249
+ #
250
+ def calc_Un(ts)
251
+ un = (6.0E-02 - 3.0E-02) / (1.0E+06 - 1.0E+04) * (ts - 1.0E+04) + 3.0E-02
252
+ if un >= 6.0E-02
253
+ un = 6.0E-02
254
+ end
255
+ un
256
+ end
257
+ end
258
+
259
+ class RunASB9_2 < RunInit
260
+ def run(ts = @ts, t0 = @t0, power = @power)
261
+ read_data = ThermalData::DataForASB_9_2.new
262
+ ts.each_index do |i|
263
+ ts_to_f = ts[i].to_f
264
+ t0_to_f = t0[i].to_f
265
+ # power_to_f = power[i].to_f
266
+
267
+ t0_add_ts = ts_to_f + t0_to_f
268
+
269
+ p_p0_source = calc_thermal_fission_functions(t0_to_f, ts_to_f, read_data)
270
+ p_p0 = calc_sum_thermal_fission(p_p0_source, ts_to_f)
271
+
272
+ p_p0_U239 = calc_thermal_fission_functions_with_U239(t0_to_f, ts_to_f)
273
+ p_p0_Np239 = calc_thermal_fission_functions_with_Np239(t0_to_f, ts_to_f)
274
+
275
+ p_p0_tatal = { with_k: 0, without_k: 0 }
276
+ p_p0_tatal[:with_k] = p_p0[:with_k] + p_p0_U239 + p_p0_Np239
277
+ p_p0_tatal[:without_k] = p_p0[:without_k] + p_p0_U239 + p_p0_Np239
278
+
279
+ dataout(ts_to_f, p_p0_tatal[:with_k], p_p0_tatal[:without_k])
280
+ end
281
+ @output_hash
282
+ end
283
+
284
+ private
285
+
286
+ # Calculate thermal fission functions from ASB9-2.
287
+ # need t0, ts and data with thermal fission(from class DataForASB_9_2)
288
+ # ts: Time after remove (sec)
289
+ # t0: Cumulative reactor operating time (sec)
290
+ #
291
+ # calc_thermal_fission_functions(t0, ts, read_data)
292
+ #
293
+ # return { :P/P0(t_inf, ts) => value
294
+ # :P/P0(t_inf, ts+t0) => f_Pu235(ts, t0) }
295
+ #
296
+ def calc_thermal_fission_functions(t0, ts, read_data)
297
+ total_times = t0 + ts
298
+ ff = { ts: 0.0, ts_add_t0: 0.0 }
299
+
300
+ (0..read_data.theAn.size - 1).each do |i|
301
+ p_p0_tinf2ts = (1.0 / 200.0) * read_data.theAn[i] * Math.exp(-read_data.thean[i] * ts)
302
+
303
+ p_p0_tinf2ts_add_t0 = (1.0 / 200.0) * read_data.theAn[i] * Math.exp(-read_data.thean[i] * total_times)
304
+
305
+ ff[:ts] = ff[:ts] + p_p0_tinf2ts
306
+ ff[:ts_add_t0] = ff[:ts_add_t0] + p_p0_tinf2ts_add_t0
307
+ end
308
+ ff
309
+ end
310
+
311
+ def calc_sum_thermal_fission(p_p0_source, ts)
312
+ p_p0 = { with_k: 0.0, without_k: 0.0 }
313
+ if ts >= 0 && ts < 1.0E+03
314
+ k1 = 0.2
315
+ k2 = 0.2
316
+ elsif ts >= 1.0E+03 && ts <= 1.0E+07
317
+ k1 = 0.1
318
+ k2 = 0.1
319
+ else
320
+ k1 = 0.1
321
+ k2 = 0.0
322
+ end
323
+ p_p0[:with_k] = p_p0[:with_k] + ((1 + k1) * p_p0_source[:ts]) - p_p0_source[:ts_add_t0]
324
+ p_p0[:without_k] = p_p0[:without_k] + ((1 + k2) * p_p0_source[:ts]) - p_p0_source[:ts_add_t0]
325
+ p_p0
326
+ end
327
+
328
+ def calc_thermal_fission_functions_with_U239(t0, ts)
329
+ 0.00228 * 0.7 * (1 - Math.exp(-0.000491 * t0)) * Math.exp(-0.000491 * ts)
330
+ end
331
+
332
+ def calc_thermal_fission_functions_with_Np239(t0, ts)
333
+ a1 = 4.91E-4
334
+ a2 = 3.41E-6
335
+ 0.00217 * 0.7 * ((a1 / (a1 + a2)) * (1 - Math.exp(-a2 * t0)) * Math.exp(-a2 * ts) - (a2 / (a1 + a2)) * (1 - Math.exp(-a1 * t0)) * Math.exp(-a1 * ts))
336
+ end
337
+ end
338
+ end
@@ -0,0 +1,328 @@
1
+ module ThermalData
2
+ class HashWithThermalFission
3
+ attr_accessor :thermal_fission
4
+
5
+ def initialize(init_data = 0)
6
+ @thermal_fission = {}
7
+ ary = [:U235, :Pu239, :U238]
8
+ ary.each { |a| @thermal_fission[a] = init_data }
9
+ end
10
+ end
11
+
12
+ # ANSI/ANS-5.1-1979, American National Standard for Decay
13
+ # Heat Power in Light Water Reactors.
14
+ class DataForANS_5_1_1979
15
+ # phi is the number of fissions per initial fissile atoms.
16
+ # tinf is t = inf, setting it 1.0E+13.
17
+ # R(theR) is the nuber of U-239 atoms produced per fission.
18
+ # lamda1 is decay constant for U239 and Np239.
19
+ # lamda2 is decay constant for Np239.
20
+ # theEU239 is average energy from decay of on U239 atom (0.474 MeV)
21
+ # theENp239 is average energy from decay of on Np239 atom (0.419 MeV)
22
+ attr_reader :phi, :tinf, :theR, :lamda1, :lamda2, :theEU239, :theENp239
23
+
24
+ def initialize
25
+ @phi = 3.0
26
+ @tinf = 1.0E+13
27
+ @theR = 6.20E-01
28
+ @lamda1 = 4.91E-04
29
+ @lamda2 = 3.41E-06
30
+ @theEU239 = 0.474
31
+ @theENp239 = 0.419
32
+ end
33
+
34
+ # thePi is Pi in ANS-5.1-1979.
35
+ def thePi
36
+ hash = HashWithThermalFission.new
37
+
38
+ hash.thermal_fission[:U235] = 0.98
39
+ hash.thermal_fission[:Pu239] = 0.01
40
+ hash.thermal_fission[:U238] = 0.01
41
+
42
+ hash.thermal_fission
43
+ end
44
+
45
+ # theQ is Q in ANS-5.1-1979.
46
+ # Total recoverable energy assicuated with on fission of nuclide.
47
+ # Default is 200 MeV/sec in U235, Pu239, U238 and others
48
+ def theQ
49
+ hash = HashWithThermalFission.new(200.0)
50
+ hash.thermal_fission[:others] = 200.0
51
+ hash.thermal_fission
52
+ end
53
+
54
+ # theU235_alpha is alpha in ANS-5.1-1979 Table 7.
55
+ def theU235_alpha
56
+ array = Array.new(23)
57
+
58
+ array[0] = 6.5057E-01
59
+ array[1] = 5.1264E-01
60
+ array[2] = 2.4384E-01
61
+ array[3] = 1.3850E-01
62
+ array[4] = 5.544E-02
63
+ array[5] = 2.2225E-02
64
+ array[6] = 3.3088E-03
65
+ array[7] = 9.3015E-04
66
+ array[8] = 8.0943E-04
67
+ array[9] = 1.9567E-04
68
+ array[10] = 3.2535E-05
69
+ array[11] = 7.5595E-06
70
+ array[12] = 2.5232E-06
71
+ array[13] = 4.9948E-07
72
+ array[14] = 1.8531E-07
73
+ array[15] = 2.6608E-08
74
+ array[16] = 2.2398E-09
75
+ array[17] = 8.1641E-12
76
+ array[18] = 8.7797E-11
77
+ array[19] = 2.5131E-14
78
+ array[20] = 3.2176E-16
79
+ array[21] = 4.5038E-17
80
+ array[22] = 7.4791E-17
81
+
82
+ array
83
+ end
84
+
85
+ # theU235_lamda is lamda in ANS-5.1-1979 Table 7.
86
+ def theU235_lamda
87
+ array = Array.new(23)
88
+
89
+ array[0] = 2.2138E+01
90
+ array[1] = 5.1587E-01
91
+ array[2] = 1.9594E-01
92
+ array[3] = 1.0314E-01
93
+ array[4] = 3.3656E-02
94
+ array[5] = 1.1681E-02
95
+ array[6] = 3.5870E-03
96
+ array[7] = 1.3930E-03
97
+ array[8] = 6.2630E-04
98
+ array[9] = 1.8906E-04
99
+ array[10] = 5.4988E-05
100
+ array[11] = 2.0958E-05
101
+ array[12] = 1.0010E-05
102
+ array[13] = 2.5438E-06
103
+ array[14] = 6.6361E-07
104
+ array[15] = 1.2290E-07
105
+ array[16] = 2.7213E-08
106
+ array[17] = 4.3714E-09
107
+ array[18] = 7.5780E-10
108
+ array[19] = 2.4786E-10
109
+ array[20] = 2.2384E-13
110
+ array[21] = 2.4600E-14
111
+ array[22] = 1.5699E-14
112
+
113
+ array
114
+ end
115
+
116
+ # thePu239_alpha is alpha in ANS-5.1-1979 Table 8.
117
+ def thePu239_alpha
118
+ array = Array.new(23)
119
+
120
+ array[0] = 2.083E-01
121
+ array[1] = 3.853E-01
122
+ array[2] = 2.213E-01
123
+ array[3] = 9.460E-02
124
+ array[4] = 3.531E-02
125
+ array[5] = 2.292E-02
126
+ array[6] = 3.946E-03
127
+ array[7] = 1.317E-03
128
+ array[8] = 7.052E-04
129
+ array[9] = 1.432E-04
130
+ array[10] = 1.765E-05
131
+ array[11] = 7.347E-06
132
+ array[12] = 1.747E-06
133
+ array[13] = 5.481E-07
134
+ array[14] = 1.671E-07
135
+ array[15] = 2.112E-08
136
+ array[16] = 2.996E-09
137
+ array[17] = 5.107E-11
138
+ array[18] = 5.730E-11
139
+ array[19] = 4.138E-14
140
+ array[20] = 1.088E-15
141
+ array[21] = 2.454E-17
142
+ array[22] = 7.557E-17
143
+
144
+ array
145
+ end
146
+
147
+ # thePu239_lamda is lamda in ANS-5.1-1979 Table 8.
148
+ def thePu239_lamda
149
+ array = Array.new(23)
150
+
151
+ array[0] = 1.002E+01
152
+ array[1] = 6.433E-01
153
+ array[2] = 2.186E-01
154
+ array[3] = 1.004E-01
155
+ array[4] = 3.728E-02
156
+ array[5] = 1.435E-02
157
+ array[6] = 4.549E-03
158
+ array[7] = 1.328E-03
159
+ array[8] = 5.356E-04
160
+ array[9] = 1.730E-04
161
+ array[10] = 4.881E-05
162
+ array[11] = 2.006E-05
163
+ array[12] = 8.319E-06
164
+ array[13] = 2.358E-06
165
+ array[14] = 6.450E-07
166
+ array[15] = 1.278E-07
167
+ array[16] = 2.466E-08
168
+ array[17] = 9.378E-09
169
+ array[18] = 7.450E-10
170
+ array[19] = 2.426E-10
171
+ array[20] = 2.210E-13
172
+ array[21] = 2.640E-14
173
+ array[22] = 1.380E-14
174
+
175
+ array
176
+ end
177
+
178
+ # theU238_alpha is alpha in ANS-5.1-1979 Table 9.
179
+ def theU238_alpha
180
+ array = Array.new(23)
181
+
182
+ array[0] = 1.2311E+0
183
+ array[1] = 1.1486E+0
184
+ array[2] = 7.0701E-01
185
+ array[3] = 2.5209E-01
186
+ array[4] = 7.187E-02
187
+ array[5] = 2.8291E-02
188
+ array[6] = 6.8382E-03
189
+ array[7] = 1.2322E-03
190
+ array[8] = 6.8409E-04
191
+ array[9] = 1.6975E-04
192
+ array[10] = 2.4182E-05
193
+ array[11] = 6.6356E-06
194
+ array[12] = 1.0075E-06
195
+ array[13] = 4.9894E-07
196
+ array[14] = 1.6352E-07
197
+ array[15] = 2.3355E-08
198
+ array[16] = 2.8094E-09
199
+ array[17] = 3.6236E-11
200
+ array[18] = 6.4577E-11
201
+ array[19] = 4.4963E-14
202
+ array[20] = 3.6654E-16
203
+ array[21] = 5.6293E-17
204
+ array[22] = 7.1602E-17
205
+
206
+ array
207
+ end
208
+
209
+ # theU238_lamda is lamda in ANS-5.1-1979 Table 9.
210
+ def theU238_lamda
211
+ array = Array.new(23)
212
+
213
+ array[0] = 3.2881E+0
214
+ array[1] = 9.3805E-01
215
+ array[2] = 3.7073E-01
216
+ array[3] = 1.1118E-01
217
+ array[4] = 3.6143E-02
218
+ array[5] = 1.3272E-02
219
+ array[6] = 5.0133E-03
220
+ array[7] = 1.3655E-03
221
+ array[8] = 5.5158E-04
222
+ array[9] = 1.7873E-04
223
+ array[10] = 4.9032E-05
224
+ array[11] = 1.7058E-05
225
+ array[12] = 7.0465E-06
226
+ array[13] = 2.3190E-06
227
+ array[14] = 6.4480E-07
228
+ array[15] = 1.2649E-07
229
+ array[16] = 2.5548E-08
230
+ array[17] = 8.4782E-09
231
+ array[18] = 7.5130E-10
232
+ array[19] = 2.4188E-10
233
+ array[20] = 2.2739E-13
234
+ array[21] = 9.0536E-14
235
+ array[22] = 5.6098E-15
236
+
237
+ array
238
+ end
239
+ end
240
+
241
+ # ANS/ANSI-5.1-1973, Standard for Decay Heat.
242
+ class DataForANS_5_1_1973
243
+ def initialize
244
+ end
245
+
246
+ # theAn is An in ANS/ANSI-5.1-1973.
247
+ def theAn
248
+ array = Array.new(11)
249
+
250
+ array[0] = 0.598
251
+ array[1] = 1.65
252
+ array[2] = 3.1
253
+ array[3] = 3.87
254
+ array[4] = 2.33
255
+ array[5] = 1.29
256
+ array[6] = 0.462
257
+ array[7] = 0.328
258
+ array[8] = 0.17
259
+ array[9] = 0.0865
260
+ array[10] = 0.114
261
+
262
+ array
263
+ end
264
+
265
+ # thean is an in ANS/ANSI-5.1-1973.
266
+ def thean
267
+ array = Array.new(10)
268
+
269
+ array[0] = 1.772E+00
270
+ array[1] = 5.774E-01
271
+ array[2] = 6.743E-02
272
+ array[3] = 6.214E-03
273
+ array[4] = 4.739E-04
274
+ array[5] = 4.810E-05
275
+ array[6] = 5.344E-06
276
+ array[7] = 5.716E-07
277
+ array[8] = 1.036E-07
278
+ array[9] = 2.959E-08
279
+ array[10] = 7.585E-10
280
+
281
+ array
282
+ end
283
+ end
284
+
285
+ # ASB9-2, Standard for Decay Heat.
286
+ class DataForASB_9_2
287
+ def initialize
288
+ end
289
+
290
+ # theAn is An in ASB9-2.
291
+ def theAn
292
+ array = Array.new(11)
293
+
294
+ array[0] = 0.598
295
+ array[1] = 1.65
296
+ array[2] = 3.1
297
+ array[3] = 3.87
298
+ array[4] = 2.33
299
+ array[5] = 1.29
300
+ array[6] = 0.462
301
+ array[7] = 0.328
302
+ array[8] = 0.17
303
+ array[9] = 0.0865
304
+ array[10] = 0.114
305
+
306
+ array
307
+ end
308
+
309
+ # thean is an in ASB9-2.
310
+ def thean
311
+ array = Array.new(10)
312
+
313
+ array[0] = 1.772E+00
314
+ array[1] = 5.774E-01
315
+ array[2] = 6.743E-02
316
+ array[3] = 6.214E-03
317
+ array[4] = 4.739E-04
318
+ array[5] = 4.810E-05
319
+ array[6] = 5.344E-06
320
+ array[7] = 5.716E-07
321
+ array[8] = 1.036E-07
322
+ array[9] = 2.959E-08
323
+ array[10] = 7.585E-10
324
+
325
+ array
326
+ end
327
+ end
328
+ end
@@ -0,0 +1,21 @@
1
+ module Tools
2
+ class TextToArray
3
+ attr_accessor :output
4
+
5
+ def initialize(filename)
6
+ @output = {}
7
+ ts = []
8
+ t0 = []
9
+ power = []
10
+ f = File.open("#{filename}", 'r')
11
+ f.each_line do |line|
12
+ a, b, c = line.split("\t")
13
+ ts << a.to_f
14
+ t0 << b.to_f
15
+ power << c.to_f
16
+ end
17
+ f.close
18
+ @output = { ts: ts, t0: t0, power: power }
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module DecayHeatWithNuclear
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,18 @@
1
+ require 'decay_heat_with_nuclear/version'
2
+ require 'decay_heat_with_nuclear/thermal_data'
3
+ require 'decay_heat_with_nuclear/tools'
4
+ require 'decay_heat_with_nuclear/main_run'
5
+
6
+ module DecayHeatWithNuclear
7
+ def self.run(hash)
8
+ test1 = MainRun::RunAns1979.new(hash)
9
+ test2 = MainRun::RunASB9_2.new(hash)
10
+ test3 = MainRun::RunAns1973.new(hash)
11
+
12
+ {
13
+ ans1979: test1.run,
14
+ ans1973: test3.run,
15
+ asb9_2: test2.run
16
+ }
17
+ end
18
+ end
data/lib/run_this.rb ADDED
@@ -0,0 +1,69 @@
1
+ require './text_to_array.rb'
2
+ require './run_ans_1979.rb'
3
+ require './run_ans_1973.rb'
4
+ require './run_asb_9_2.rb'
5
+
6
+ # 執行此程式需要一個hash
7
+ # 裡面必須含有ts (sec)、t0 (sec)、power (MW)
8
+ #
9
+ # hash = {ts: array,
10
+ # t0: array,
11
+ # power: array}
12
+ #
13
+ # 抑或可以利用TextToArray.new(相對路徑)讀取文字檔
14
+ # 文字檔格式如下,其中(TAB)表示輸入Tab鍵、(ENTER)表示輸入Enter鍵
15
+ #
16
+ # ts(TAB)t0(TAB)power(ENTER)
17
+ #
18
+ # ks_ts_t0_power.txt為範例檔
19
+
20
+ output = TextToArray.new('./ks_ts_t0_power.txt')
21
+ hash1 = output.output
22
+
23
+ # ts = []
24
+ # times = 1
25
+ # t_index = 0
26
+ # while t_index <= 1 * 365 * 86400
27
+ # index = 1
28
+ # while index < 10
29
+ # t_index = index * times
30
+ # ts << t_index
31
+ # index = index + 1
32
+ # end
33
+ # times = times * 10
34
+ # end
35
+ # ts << 365 * 86400
36
+ ts = Array.new(20) { |i| (i + 1) * 365 * 24 * 3600 }
37
+ hash2 = { ts: ts,
38
+ t0: Array.new(ts.size) { 63 * 30 * 24 * 3600 },
39
+ power: Array.new(ts.size) { 2943 } }
40
+
41
+ # 執行RunAns1979.new(hash, case)來配置前置檔案
42
+ # hash即為上面說明的hash
43
+ # case為輸出的類型
44
+ #
45
+ # case = 0
46
+ # ts(year) t(sec) P/P0
47
+ # 1 31536000 0.000281683414
48
+ #
49
+ # case = 1
50
+ # ts P/P0
51
+ # ts = 1 years P/P0= 0.000281683414
52
+ #
53
+ # case = 2
54
+ # ts t0 un P/P0 without un/K P/P0 with un/K power
55
+ # ts = 31536000.0 sec, t0 = 141912000.0 sec, un = 0.06000000, P/P0(without un) = 0.00028168, P/P0(with un) = 0.00029858, power = 0.90471 MW
56
+ # P/P0 with un = (P/P0 without un) * (1 + un)
57
+ #
58
+ # P.S RunASB9_2的K值比較特殊,without K 的意思是指當 ts > 10^7 時將 K = 0
59
+ #
60
+ # 或是可以編輯'run_ans_1979.rb'第37行,增加自訂的輸出方式
61
+
62
+ test2 = RunASB9_2.new(hash2, 3, 'ASB9-2_1to20years.txt')
63
+ test2.run
64
+
65
+ test3 = RunAns1973.new(hash2, 3, 'Ans1973_1to20years.txt')
66
+ test3.run
67
+
68
+ test1 = RunAns1979.new(hash2, 3, 'Ans1979_1to20years.txt')
69
+ test1.run
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: decay_heat_with_nuclear
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - C.lin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: It's a easy way to get nuclear fuel decay heat when it remove from reactor
42
+ core.
43
+ email:
44
+ - demeter.yeh@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - decay_heat_with_nuclear.gemspec
55
+ - lib/decay_heat_with_nuclear.rb
56
+ - lib/decay_heat_with_nuclear/main_run.rb
57
+ - lib/decay_heat_with_nuclear/thermal_data.rb
58
+ - lib/decay_heat_with_nuclear/tools.rb
59
+ - lib/decay_heat_with_nuclear/version.rb
60
+ - lib/run_this.rb
61
+ homepage: ''
62
+ licenses:
63
+ - GPL3.0
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.2.2
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: It's a easy way to get nuclear fuel decay heat when it remove from reactor
85
+ core.
86
+ test_files: []