trinitycrmod 0.2.4 → 0.2.6
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.
- data/VERSION +1 -1
- data/lib/trinitycrmod/graphs.rb +25 -6
- data/lib/trinitycrmod/namelists.rb +75 -1
- data/lib/trinitycrmod/output_files.rb +20 -2
- data/sync_variables/sync_variables.rb +1 -1
- data/test/test_trinitycrmod.rb +7 -0
- data/trinitycrmod.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.6
|
data/lib/trinitycrmod/graphs.rb
CHANGED
@@ -6,7 +6,11 @@ class CodeRunner::Trinity
|
|
6
6
|
end
|
7
7
|
# Graphs plotting quantities from the '.fluxes' file vs rho for a given t_index
|
8
8
|
def fluxes_prof_graphkit(options)
|
9
|
-
prof_graphkit(options.
|
9
|
+
prof_graphkit(options.absorb({outfile: :fluxes, exclude_perturbed_fluxes: true}))
|
10
|
+
end
|
11
|
+
# Graphs plotting quantities from the '.pbalance' file vs rho for a given t_index
|
12
|
+
def pbalance_prof_graphkit(options)
|
13
|
+
prof_graphkit(options.absorb({outfile: :pbalance}))
|
10
14
|
end
|
11
15
|
def prof_graphkit(options)
|
12
16
|
raise "Please specify t_index" unless options[:t_index]
|
@@ -19,25 +23,40 @@ class CodeRunner::Trinity
|
|
19
23
|
rho_array = rho_array.slice(0...nrad-1)
|
20
24
|
end
|
21
25
|
#p rho_array, array
|
22
|
-
GraphKit.autocreate(x: {data: rho_array.to_gslv, title: 'rho', units: ''},
|
26
|
+
kit = GraphKit.autocreate(x: {data: rho_array.to_gslv, title: 'rho', units: ''},
|
23
27
|
y: {data: array.to_gslv, title: options[:title]||"", units: options[:units]||""}
|
24
28
|
)
|
29
|
+
kit.data[0].title += " at time = #{list(:t)[it+1]} s"
|
30
|
+
kit
|
25
31
|
end
|
26
32
|
# Graph of Qi in gyroBohm units against rho for a given t_index
|
27
33
|
def ion_hflux_gb_prof_graphkit(options)
|
28
|
-
fluxes_prof_graphkit(options.
|
34
|
+
fluxes_prof_graphkit(options.absorb({header: /Qi.*\(GB/, title: 'Ion Heat Flux', units: 'Q_gB'}))
|
29
35
|
end
|
30
36
|
# Graph of toroidal angular momentum flux in gyroBohm units against rho for a given t_index
|
31
37
|
def lflux_gb_prof_graphkit(options)
|
32
|
-
fluxes_prof_graphkit(options.
|
38
|
+
fluxes_prof_graphkit(options.absorb({header: /Pi.*\(GB/, title: 'Toroidal Angular Momentum Flux', units: 'Pi_gB'}))
|
33
39
|
end
|
34
40
|
# Graph of toroidal angular momentum against rho for a given t_index
|
35
41
|
def ang_mom_prof_graphkit(options)
|
36
|
-
return nt_prof_graphkit(options.
|
42
|
+
return nt_prof_graphkit(options.absorb({header: /ang\s+mom/, title: 'Angular Momentum', units: ''}))
|
37
43
|
end
|
38
44
|
# Graph of Ti against rho for a given t_index
|
39
45
|
def ion_temp_prof_graphkit(options)
|
40
|
-
return nt_prof_graphkit(options.
|
46
|
+
return nt_prof_graphkit(options.absorb({header: /i\+ temp/, title: 'Ti', units: 'keV'}))
|
47
|
+
end
|
48
|
+
|
49
|
+
# Graph of ion power integrated from the magnetic axis to rho vs rho
|
50
|
+
def ion_pwr_prof_graphkit(options)
|
51
|
+
return pbalance_prof_graphkit(options.absorb({header: /i\+ pwr/, title: 'Integrated ion power', units: 'MW'}))
|
52
|
+
end
|
53
|
+
# Graph of electron power integrated from the magnetic axis to rho vs rho
|
54
|
+
def electron_pwr_prof_graphkit(options)
|
55
|
+
return pbalance_prof_graphkit(options.absorb({header: /e\- pwr/, title: 'Integrated electron power', units: 'MW'}))
|
56
|
+
end
|
57
|
+
# Graph of ion power integrated from the magnetic axis to rho vs rho
|
58
|
+
def ion_pwr_prof_graphkit(options)
|
59
|
+
return pbalance_prof_graphkit(options.absorb({header: /i\+ pwr/, title: 'Integrated ion power', units: 'MW'}))
|
41
60
|
end
|
42
61
|
end
|
43
62
|
|
@@ -1198,7 +1198,81 @@
|
|
1198
1198
|
:explanation=>
|
1199
1199
|
"This variable must be a fortran boolean. (In Ruby this is represented as a string: e.g. '.true.')"}],
|
1200
1200
|
:type=>:Fortran_Bool,
|
1201
|
-
:autoscanned_defaults=>[".false."]}
|
1201
|
+
:autoscanned_defaults=>[".false."]},
|
1202
|
+
:nbi_mult=>
|
1203
|
+
{:should_include=>"true",
|
1204
|
+
:description=>
|
1205
|
+
" multiplies QNBII, QNBIE and SNBIE when using the tokamak profile db, may not be self consistent when using TORQ for torque input (as opposed to pioq)",
|
1206
|
+
:help=>
|
1207
|
+
" multiplies QNBII, QNBIE and SNBIE when using the tokamak profile db, may not be self consistent when using TORQ for torque input (as opposed to pioq)",
|
1208
|
+
:code_name=>:nbi_mult,
|
1209
|
+
:must_pass=>
|
1210
|
+
[{:test=>"kind_of? Numeric",
|
1211
|
+
:explanation=>
|
1212
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
|
1213
|
+
:type=>:Float,
|
1214
|
+
:autoscanned_defaults=>[1.0]},
|
1215
|
+
:icrh_mult=>
|
1216
|
+
{:should_include=>"true",
|
1217
|
+
:description=>
|
1218
|
+
" multiplies QICRHI and QICRHE when using the tokamak profile db",
|
1219
|
+
:help=>
|
1220
|
+
" multiplies QICRHI and QICRHE when using the tokamak profile db",
|
1221
|
+
:code_name=>:icrh_mult,
|
1222
|
+
:must_pass=>
|
1223
|
+
[{:test=>"kind_of? Numeric",
|
1224
|
+
:explanation=>
|
1225
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
|
1226
|
+
:type=>:Float,
|
1227
|
+
:autoscanned_defaults=>[1.0]},
|
1228
|
+
:ech_mult=>
|
1229
|
+
{:should_include=>"true",
|
1230
|
+
:description=>
|
1231
|
+
" multiplies QECHI and QECHE when using the tokamak profile db",
|
1232
|
+
:help=>" multiplies QECHI and QECHE when using the tokamak profile db",
|
1233
|
+
:code_name=>:ech_mult,
|
1234
|
+
:must_pass=>
|
1235
|
+
[{:test=>"kind_of? Numeric",
|
1236
|
+
:explanation=>
|
1237
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
|
1238
|
+
:type=>:Float,
|
1239
|
+
:autoscanned_defaults=>[1.0]},
|
1240
|
+
:lh_mult=>
|
1241
|
+
{:should_include=>"true",
|
1242
|
+
:description=>
|
1243
|
+
" multiplies QLHI and QLHE when using the tokamak profile db",
|
1244
|
+
:help=>" multiplies QLHI and QLHE when using the tokamak profile db",
|
1245
|
+
:code_name=>:lh_mult,
|
1246
|
+
:must_pass=>
|
1247
|
+
[{:test=>"kind_of? Numeric",
|
1248
|
+
:explanation=>
|
1249
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
|
1250
|
+
:type=>:Float,
|
1251
|
+
:autoscanned_defaults=>[1.0]},
|
1252
|
+
:ibw_mult=>
|
1253
|
+
{:should_include=>"true",
|
1254
|
+
:description=>
|
1255
|
+
" multiplies QIBWI and QIBWE when using the tokamak profile db",
|
1256
|
+
:help=>" multiplies QIBWI and QIBWE when using the tokamak profile db",
|
1257
|
+
:code_name=>:ibw_mult,
|
1258
|
+
:must_pass=>
|
1259
|
+
[{:test=>"kind_of? Numeric",
|
1260
|
+
:explanation=>
|
1261
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
|
1262
|
+
:type=>:Float,
|
1263
|
+
:autoscanned_defaults=>[1.0]},
|
1264
|
+
:dwn_mult=>
|
1265
|
+
{:should_include=>"true",
|
1266
|
+
:description=>
|
1267
|
+
" multiplies DWIR, DWER, DNER when using the tokamak profile db",
|
1268
|
+
:help=>" multiplies DWIR, DWER, DNER when using the tokamak profile db",
|
1269
|
+
:code_name=>:dwn_mult,
|
1270
|
+
:must_pass=>
|
1271
|
+
[{:test=>"kind_of? Numeric",
|
1272
|
+
:explanation=>
|
1273
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}],
|
1274
|
+
:type=>:Float,
|
1275
|
+
:autoscanned_defaults=>[1.0]}}},
|
1202
1276
|
:physics=>
|
1203
1277
|
{:description=>"",
|
1204
1278
|
:should_include=>"true",
|
@@ -18,6 +18,10 @@ class CodeRunner
|
|
18
18
|
# File ending in '.nt': contains profiles: Ti, Te etc.
|
19
19
|
def nt_outfile
|
20
20
|
TextDataTools::Column::DataFile.new(@directory + '/' + @run_name + '.nt', true, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:|\Z)/)
|
21
|
+
end
|
22
|
+
# File ending in '.pbalance': contains fluxes and sources
|
23
|
+
def pbalance_outfile
|
24
|
+
TextDataTools::Column::DataFile.new(@directory + '/' + @run_name + '.pbalance', true, /\S+/, /(?:\#\s+)?\d:.*?(?=\d:|\Z)/)
|
21
25
|
end
|
22
26
|
def time_outfile
|
23
27
|
TextDataTools::Column::DataFile.new(@directory + '/' + @run_name + '.time', true, /\S+/, /\w+/)
|
@@ -25,9 +29,9 @@ class CodeRunner
|
|
25
29
|
def view_outfiles
|
26
30
|
case ENV['EDITOR']
|
27
31
|
when /vim/i
|
28
|
-
"#{ENV['EDITOR']} -Rp #{info_outfile} #{nt_outfile} #{fluxes_outfile}"
|
32
|
+
system "#{ENV['EDITOR']} -Rp '+tabdo set nu|set nowrap' #{info_outfile} #{nt_outfile} #{fluxes_outfile}"
|
29
33
|
else
|
30
|
-
"#{ENV['EDITOR']} #{info_outfile} #{nt_outfile} #{fluxes_outfile}"
|
34
|
+
system "#{ENV['EDITOR']} #{info_outfile} #{nt_outfile} #{fluxes_outfile}"
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
@@ -42,5 +46,19 @@ class CodeRunner
|
|
42
46
|
cache[:array_2d] ||= {}
|
43
47
|
cache[:array_2d][[outfile, column_header, index_header]] ||= send(outfile + :_outfile).get_2d_array_float(column_header, index_header)
|
44
48
|
end
|
49
|
+
|
50
|
+
# Returns a hash of the specified dimension in the form {index=> value} where index is 1-based
|
51
|
+
# Dimension can be:
|
52
|
+
# :t
|
53
|
+
# :rho
|
54
|
+
# :rho_cc
|
55
|
+
def list(var)
|
56
|
+
case var
|
57
|
+
when :t
|
58
|
+
hash = {}
|
59
|
+
get_2d_array_float(:nt, /1:\s+time/, /1:\s+time/).map{|arr| arr[0]}.each_with_index{|t,i| hash[i+1] = t}
|
60
|
+
hash
|
61
|
+
end
|
62
|
+
end
|
45
63
|
end
|
46
64
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
CodeRunner.setup_run_class('trinity')
|
3
|
-
|
3
|
+
CodeRunner::Trinity.get_input_help_from_source_code(ENV['TRINITY_SOURCE'])
|
4
4
|
CodeRunner::Trinity.update_defaults_from_source_code(ENV['TRINITY_SOURCE'])
|
5
5
|
CodeRunner::Trinity.synchronise_variables(ENV['TRINITY_SOURCE'])
|
6
6
|
|
data/test/test_trinitycrmod.rb
CHANGED
@@ -37,6 +37,9 @@ class TestTrinitycrmodIFSPPPLAnalysis < Test::Unit::TestCase
|
|
37
37
|
CodeRunner.status(Y: 'test/ifspppl_results')
|
38
38
|
assert_equal(@runner.run_list.size, 1)
|
39
39
|
assert_equal(@runner.run_list[1].fusionQ, 0.075658439797815016)
|
40
|
+
list_t = @runner.run_list[1].list(:t)
|
41
|
+
assert_equal(201, list_t.size)
|
42
|
+
assert_equal(0.04375, list_t[10])
|
40
43
|
FileUtils.rm('test/ifspppl_results/.CODE_RUNNER_TEMP_RUN_LIST_CACHE')
|
41
44
|
end
|
42
45
|
def test_graphs
|
@@ -49,6 +52,10 @@ class TestTrinitycrmodIFSPPPLAnalysis < Test::Unit::TestCase
|
|
49
52
|
assert_equal(kit.data[0].class, GraphKit::DataKit)
|
50
53
|
assert_equal(8,kit.data[0].y.data.size)
|
51
54
|
assert_equal(kit.data[0].y.data[0], 0.001944)
|
55
|
+
kit = @runner.run_list[1].graphkit('ion_pwr_prof', {t_index: 2})
|
56
|
+
assert_equal(8,kit.data[0].y.data.size)
|
57
|
+
assert_equal(kit.data[0].y.data[0], 0.2412)
|
58
|
+
#kit.gnuplot
|
52
59
|
end
|
53
60
|
def teardown
|
54
61
|
FileUtils.rm('test/ifspppl_results/.code_runner_script_defaults.rb')
|
data/trinitycrmod.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "trinitycrmod"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Edmund Highcock"]
|
12
|
-
s.date = "2013-06-
|
12
|
+
s.date = "2013-06-24"
|
13
13
|
s.description = "This module allows Trinity, the Multiscale Gyrokinetic Turbulent Transport solver for Fusion Reactors, to harness the power of CodeRunner, a framework for the automated running and analysis of simulations."
|
14
14
|
s.email = "edmundhighcock@sourceforge.net"
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trinitycrmod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: coderunner
|
@@ -151,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
151
|
version: '0'
|
152
152
|
segments:
|
153
153
|
- 0
|
154
|
-
hash:
|
154
|
+
hash: -1744466157144352750
|
155
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
156
|
none: false
|
157
157
|
requirements:
|