gs2crmod 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,8 @@
1
1
  source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
- gem "coderunner", ">= 0.12.11"
4
+ gem "coderunner", ">= 0.12.16"
5
+ gem "ruby-netcdf", ">= 0.6.6.1"
5
6
 
6
7
  # Add dependencies to develop your gem here.
7
8
  # Include everything needed to run rake, tests, features, etc.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.0
1
+ 0.9.1
data/gs2crmod.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gs2crmod"
8
- s.version = "0.9.0"
8
+ s.version = "0.9.1"
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", "Ferdinand van Wyk"]
12
- s.date = "2013-07-19"
12
+ s.date = "2013-07-30"
13
13
  s.description = "GS2 is a gyrokinetic flux tube initial value turbulence code which can be used for fusion or astrophysical plasmas. CodeRunner is a framework for the automated running and analysis of large simulations. This module allows GS2 (and its sister code AstroGK) to harness the power of the CodeRunner framework."
14
14
  s.email = "edmundhighcock@sourceforge.net"
15
15
  s.extensions = ["ext/extconf.rb"]
@@ -78,27 +78,30 @@ Gem::Specification.new do |s|
78
78
  s.licenses = ["GSLv3"]
79
79
  s.require_paths = ["lib"]
80
80
  s.required_ruby_version = Gem::Requirement.new(">= 1.9.1")
81
- s.rubygems_version = "1.8.23"
81
+ s.rubygems_version = "1.8.11"
82
82
  s.summary = "Module to allow CodeRunner to run and analyse the GS2 and AstroGK codes."
83
83
 
84
84
  if s.respond_to? :specification_version then
85
85
  s.specification_version = 3
86
86
 
87
87
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
88
- s.add_runtime_dependency(%q<coderunner>, [">= 0.12.11"])
88
+ s.add_runtime_dependency(%q<coderunner>, [">= 0.12.16"])
89
+ s.add_runtime_dependency(%q<ruby-netcdf>, [">= 0.6.6.1"])
89
90
  s.add_development_dependency(%q<shoulda>, [">= 0"])
90
91
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
91
92
  s.add_development_dependency(%q<bundler>, ["> 1.0.0"])
92
93
  s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
93
94
  else
94
- s.add_dependency(%q<coderunner>, [">= 0.12.11"])
95
+ s.add_dependency(%q<coderunner>, [">= 0.12.16"])
96
+ s.add_dependency(%q<ruby-netcdf>, [">= 0.6.6.1"])
95
97
  s.add_dependency(%q<shoulda>, [">= 0"])
96
98
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
97
99
  s.add_dependency(%q<bundler>, ["> 1.0.0"])
98
100
  s.add_dependency(%q<jeweler>, [">= 1.8.4"])
99
101
  end
100
102
  else
101
- s.add_dependency(%q<coderunner>, [">= 0.12.11"])
103
+ s.add_dependency(%q<coderunner>, [">= 0.12.16"])
104
+ s.add_dependency(%q<ruby-netcdf>, [">= 0.6.6.1"])
102
105
  s.add_dependency(%q<shoulda>, [">= 0"])
103
106
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
104
107
  s.add_dependency(%q<bundler>, ["> 1.0.0"])
@@ -20,6 +20,7 @@ def auto_axiskits(name, options)
20
20
  'es_heat_by_ky_over_time' => ['Phi^2 by ky', ''],
21
21
  'es_heat_by_kx_over_time' => ['Phi^2 by ky', ''],
22
22
  'phi2_by_mode_over_time' => ["Phi^2 by mode", ''],
23
+ 'tpar2_by_mode_over_time' => ["(delta T_parallel)^2 by mode", '%'],
23
24
  'hflux_tot' => ['Total Heat Flux', ''],
24
25
  'ky' => ['ky', "1/rho_#{species_letter}"],
25
26
  'kx' => ['kx', "1/rho_#{species_letter}"],
@@ -893,10 +894,10 @@ module GraphKits
893
894
  #shape = zaxis.data.shape
894
895
  #carts = cartesian_coordinates_gsl_tensor(options)
895
896
  #torphiout = 2.6
896
- torphiout = options[:torphi]
897
+ torphiout = options[:constant_torphi] || options[:torphi]
897
898
  field = options[:field] || field_real_space_gsl_tensor(options)
898
899
  torphi_const = constant_torphi_surface_gsl_tensor(options)
899
- cyls = cylindrical_coordinates_gsl_tensor(options.absorb({extra_points: true}))
900
+ cyls = cylindrical_coordinates_gsl_tensor(options.absorb({extra_points: true}))
900
901
  #p torphi_const[0,true].to_a;
901
902
  #p 'sh', cyls.shape[1], '','','','';
902
903
  #exit
@@ -1891,7 +1892,50 @@ module GraphKits
1891
1892
  kit
1892
1893
  end
1893
1894
  end
1894
- def apar2_vs_time_graphkit(options={})
1895
+
1896
+ def tpar2_by_mode_vs_time_graphkit(options={})
1897
+ case options[:command]
1898
+ when :help
1899
+ return "'tpar2_by_ky_vs_time' or 'tpar2_by_kx_vs_time': tpar^2 over time for a given kx or ky, integrated over the other direction"
1900
+ when :options
1901
+ return [:ky, :ky_index, :kx, :kx_index]
1902
+ else
1903
+ kxy = :mode
1904
+
1905
+ # i.e. tpar2_by_ky_vs_time or tpar2_by_kx_vs_time or tpar2_by_mode_vs_time
1906
+
1907
+ nt_options = options.dup # 'no time' options
1908
+ nt_options.delete(:t_index) if nt_options[:t_index]
1909
+ nt_options.delete(:frame_index) if nt_options[:frame_index]
1910
+ tparax = axiskit("tpar2_by_#{kxy}_over_time", nt_options)
1911
+ kit = GraphKit.autocreate({x: axiskit('t', options), y: tparax})
1912
+ kit.data[0].title = "Tpar^2 total: #{kxy} = #{options[kxy]}"
1913
+ if options[:t_index]
1914
+ # p 'hello'
1915
+ array_element = options[:t_index_window] ? options[:t_index] - options[:t_index_window][0] : options[:t_index] - 1
1916
+ # p tparax.data.size, array_element
1917
+ # p options[:t_index], options[:t_index_window]
1918
+ time = DataKit.autocreate({x: {data: GSL::Vector.alloc([list(:t)[options[:t_index]]])}, y: {data: GSL::Vector.alloc([tparax.data[array_element]]) } })
1919
+ time.pointsize = 3.0
1920
+ # p time
1921
+ # kit.data[0].axes[:x].data = -kit.data[0].axes[:x].data
1922
+ kit.data.push time
1923
+ end
1924
+ if options[:norm]
1925
+ xrange, yrange = kit.plot_area_size
1926
+ kit.each_axiskit(:y) do |axiskit|
1927
+ axiskit.data /= yrange[1] / (options[:height] or 1.0)
1928
+ end
1929
+ end
1930
+ kit.log_axis = 'y'
1931
+ #kit.data[0].title = "gs2:#@run_name"
1932
+ kit.data[0].with = "l" #"linespoints"
1933
+ kit.file_name = options[:graphkit_name]
1934
+ kit
1935
+ end
1936
+ end
1937
+
1938
+ def apar2_vs_time_graphkit(options={})
1895
1939
  case options[:command]
1896
1940
  when :help
1897
1941
  return "Graph of apar^2 vs time integrated over all space. No options"
@@ -426,6 +426,30 @@ module GSLVectors
426
426
  end
427
427
  end
428
428
 
429
+ def tpar2_by_mode_over_time_gsl_vector(options)
430
+ Dir.chdir(@directory) do #Necessary options: :ky and :kx
431
+ #Optional options: :t_index_window
432
+ # eputs "got here"
433
+ #options[:begin_element], options[:end_element] = (options[:t_index_window] ? options[:t_index_window].map{|ind| ind -1} : [0, -1])
434
+ options.setup_time_window
435
+ tpar_t_array=nil
436
+ if @grid_option == "single"
437
+ tpar_t_array = netcdf_file.var('tpar2').get('start' => [options[:begin_element]], 'end' => [options[:end_element]]).to_a.flatten
438
+ else
439
+ # value = options[:ky]
440
+ # eputs value
441
+ # get_list_of(:ky)
442
+ # index = @ky_list.find{|index,val| (val-value).abs < Float::EPSILON}[0]
443
+ options.convert_to_index(self, :kx, :ky, :species)
444
+ # p options
445
+ tpar_t_array = netcdf_file.var("tpar2_by_mode").get('start' => [options[:kx_index] - 1, options[:ky_index] - 1, options[:species_index] - 1, options[:begin_element]], 'end' => [options[:kx_index] - 1, options[:ky_index] - 1, options[:species_index] - 1, options[:end_element]]).to_a.flatten
446
+ # eputs 'tpar_t_array.size', tpar_t_array.size
447
+ end
448
+ return GSL::Vector.alloc(tpar_t_array)
449
+
450
+ end
451
+ end
452
+
429
453
  def phi0_by_kx_by_ky_over_time_gsl_vector(options)
430
454
  Dir.chdir(@directory) do
431
455
  options.convert_to_index(self, :kx, :ky)
@@ -178,7 +178,7 @@ class CodeRunner::Gs2
178
178
  ep 'species_element', species_element
179
179
  if options[:t_index]
180
180
  #ep options; gets
181
- raise CRFatal.new("write_phi_over_time is not enabled so this function won't work") unless @write_phi_over_time
181
+ #raise CRFatal.new("write_phi_over_time is not enabled so this function won't work") unless @write_phi_over_time
182
182
  arr = GSL::Tensor.new(netcdf_file.var(field_netcdf_name(options[:field_name], true)).get({'start' => [0,(options[:thetamin]||0),0,0, species_element, options[:t_index] - 1].compact, 'end' => [-1,(options[:thetamax]||-1),(options[:nakx]||0)-1,(options[:naky]||0)-1, species_element, options[:t_index] - 1].compact}))
183
183
  #ep 'arr.shape', arr.shape
184
184
  arr.reshape!(*arr.shape.slice(1...arr.shape.size))
@@ -379,7 +379,7 @@ class CodeRunner::Gs2
379
379
  theta_vec_short = gsl_vector(:theta, {})
380
380
  p 'sizes', [theta_vec_short.size, values[i+1].to_gslv.size]
381
381
  interp = GSL::ScatterInterp.alloc(:linear, [theta_vec_short, values[i+1].to_gslv], true)
382
- for j in 0...shape[1]
382
+ for j in 0...theta_vec.size
383
383
  factors[i,j] = interp.eval(theta_vec[j])
384
384
  end
385
385
  end
@@ -219,6 +219,12 @@ def ingen
219
219
  end
220
220
  end
221
221
 
222
+ ################
223
+ # Damping Rate #
224
+ ################
225
+
226
+ warning("Recommend that const_amp = TRUE for linear runs.") if @nonlinear_mode == "off" and (!@const_amp or @const_amp.fortran_false?)
227
+
222
228
  end
223
229
 
224
230
  # A hash which gives the actual numbers of gridpoints indexed by their corresponding letters in the layout string.
@@ -2331,9 +2331,9 @@
2331
2331
  :type=>:String,
2332
2332
  :module=>:hyper},
2333
2333
  :const_amp=>
2334
- {:help=>nil,
2334
+ {:help=>'Determines whether hyperviscosity includes time dependent amplitude factor when calculating damping rate. Recommend TRUE for linear runs and FALSE for nolinear runs, since amplutide of turbulence grows linearly with time in linear run.',
2335
2335
  :should_include=>"true",
2336
- :description=>nil,
2336
+ :description=>'Detrmines whether damping rate depends on amplitude variations. Recommend FALSE for nonlinear, TRUE for linear.',
2337
2337
  :tests=>["Tst::STRING"],
2338
2338
  :autoscanned_defaults=>[".false."],
2339
2339
  :must_pass=>
@@ -189,7 +189,7 @@
189
189
  ! write_gyx not specified --- Write dist fn at a given physical spacial point to a file
190
190
  write_hrate = .false. ! Write heating rate, collisonal entropy generation etc to '.heat'
191
191
  ! write_final_epar not specified --- If (write_ascii = T) E_parallel(theta) written to runname.eigenfunc
192
- write_avg_moments = .F. ! Write flux surface averaged low-order moments of g to runname.out.nc and runname.moments (if write_ascii = T)
192
+ write_avg_moments = .T. ! Write flux surface averaged low-order moments of g to runname.out.nc and runname.moments (if write_ascii = T)
193
193
  ! write_lorentzian not specified --- Frequency Sweep Data
194
194
  write_omega = .false. ! If (write_ascii = T) instantaneous omega to output file. Very heavy output
195
195
  write_omavg = .false. ! If (write_ascii = T) time-averaged growth rate and frequency to the output file.
Binary file
@@ -3,11 +3,13 @@ require 'helper'
3
3
  CYCLONE_LOW_RES_FOLDER = 'test/cyclone_low_res'
4
4
  class TestBasics < Test::Unit::TestCase
5
5
  def setup
6
+ FileUtils.makedirs('test/slab_itg')
6
7
  @runner = CodeRunner.fetch_runner(Y: 'test/slab_itg', C: 'gs2', X: '/dev/null')
7
8
  end
8
9
  def teardown
9
10
  FileUtils.rm('test/slab_itg/.code_runner_script_defaults.rb')
10
11
  FileUtils.rm('test/slab_itg/.CODE_RUNNER_TEMP_RUN_LIST_CACHE')
12
+ FileUtils.rmdir('test/slab_itg')
11
13
  end
12
14
  def test_basics
13
15
  assert_equal(@runner.run_class, CodeRunner::Gs2)
@@ -34,7 +36,7 @@ if ENV['GS2_EXEC']
34
36
  FileUtils.rm_r(tfolder)
35
37
  end
36
38
  def test_submission
37
- CodeRunner.submit(C: 'gs2', X: ENV['GS2_EXEC'], D: 'test_gs2crmod', n: '4', Y: tfolder, p: '{write_moments: ".true."}')
39
+ CodeRunner.submit(C: 'gs2', X: ENV['GS2_EXEC'], D: 'test_gs2crmod', n: '1', Y: tfolder, p: '{write_moments: ".true."}')
38
40
  CodeRunner.status(Y: tfolder)
39
41
  end
40
42
  end
@@ -91,6 +93,11 @@ class TestAnalysis < Test::Unit::TestCase
91
93
  #kit.gnuplot
92
94
  assert_equal(51, kit.data[0].y.data.size)
93
95
  assert_equal(@runner.run_list[1].netcdf_file.var('phi2_by_ky').get('start' => [1,4], 'end' => [1,4]).to_a[0][0], kit.data[0].y.data[4])
96
+
97
+ kit = @run.graphkit('tpar2_by_mode_vs_time', {ky_index:2, kx_index:1, species_index:1})
98
+ #kit.gnuplot
99
+
100
+ assert_equal(@runner.run_list[1].netcdf_file.var('tpar2_by_mode').get('start' => [0,1,0,4], 'end' => [0,1,0,4]).to_a[0][0][0][0], kit.data[0].y.data[4])
94
101
  end
95
102
  def test_3d_graphs
96
103
  kit = @runner.run_list[1].graphkit('phi_real_space', {n0: 3, Rgeo: 3})
@@ -136,7 +143,7 @@ class TestAnalysis < Test::Unit::TestCase
136
143
  CYCLONE_LOW_RES_FOLDER
137
144
  end
138
145
  def teardown
139
- FileUtils.rm_r(tfolder)
146
+ FileUtils.rm_rf(tfolder)
140
147
  end
141
148
  end
142
149
 
@@ -166,7 +173,7 @@ class TestAgkAnalysis < Test::Unit::TestCase
166
173
  assert_equal(:Complete, @runner.run_list[1].status)
167
174
  end
168
175
  def teardown
169
- FileUtils.rm_r(tfolder)
176
+ FileUtils.rm_rf(tfolder)
170
177
  end
171
178
  end
172
179
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gs2crmod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,27 +10,33 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-07-19 00:00:00.000000000 Z
13
+ date: 2013-07-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: coderunner
17
- requirement: !ruby/object:Gem::Requirement
17
+ requirement: &20442560 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.12.11
22
+ version: 0.12.16
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
25
+ version_requirements: *20442560
26
+ - !ruby/object:Gem::Dependency
27
+ name: ruby-netcdf
28
+ requirement: &20441580 !ruby/object:Gem::Requirement
26
29
  none: false
27
30
  requirements:
28
31
  - - ! '>='
29
32
  - !ruby/object:Gem::Version
30
- version: 0.12.11
33
+ version: 0.6.6.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *20441580
31
37
  - !ruby/object:Gem::Dependency
32
38
  name: shoulda
33
- requirement: !ruby/object:Gem::Requirement
39
+ requirement: &20455280 !ruby/object:Gem::Requirement
34
40
  none: false
35
41
  requirements:
36
42
  - - ! '>='
@@ -38,15 +44,10 @@ dependencies:
38
44
  version: '0'
39
45
  type: :development
40
46
  prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ! '>='
45
- - !ruby/object:Gem::Version
46
- version: '0'
47
+ version_requirements: *20455280
47
48
  - !ruby/object:Gem::Dependency
48
49
  name: rdoc
49
- requirement: !ruby/object:Gem::Requirement
50
+ requirement: &20373540 !ruby/object:Gem::Requirement
50
51
  none: false
51
52
  requirements:
52
53
  - - ~>
@@ -54,15 +55,10 @@ dependencies:
54
55
  version: '3.12'
55
56
  type: :development
56
57
  prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ~>
61
- - !ruby/object:Gem::Version
62
- version: '3.12'
58
+ version_requirements: *20373540
63
59
  - !ruby/object:Gem::Dependency
64
60
  name: bundler
65
- requirement: !ruby/object:Gem::Requirement
61
+ requirement: &20383260 !ruby/object:Gem::Requirement
66
62
  none: false
67
63
  requirements:
68
64
  - - ! '>'
@@ -70,15 +66,10 @@ dependencies:
70
66
  version: 1.0.0
71
67
  type: :development
72
68
  prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
- requirements:
76
- - - ! '>'
77
- - !ruby/object:Gem::Version
78
- version: 1.0.0
69
+ version_requirements: *20383260
79
70
  - !ruby/object:Gem::Dependency
80
71
  name: jeweler
81
- requirement: !ruby/object:Gem::Requirement
72
+ requirement: &20381900 !ruby/object:Gem::Requirement
82
73
  none: false
83
74
  requirements:
84
75
  - - ! '>='
@@ -86,12 +77,7 @@ dependencies:
86
77
  version: 1.8.4
87
78
  type: :development
88
79
  prerelease: false
89
- version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
- requirements:
92
- - - ! '>='
93
- - !ruby/object:Gem::Version
94
- version: 1.8.4
80
+ version_requirements: *20381900
95
81
  description: GS2 is a gyrokinetic flux tube initial value turbulence code which can
96
82
  be used for fusion or astrophysical plasmas. CodeRunner is a framework for the automated
97
83
  running and analysis of large simulations. This module allows GS2 (and its sister
@@ -180,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
166
  version: '0'
181
167
  requirements: []
182
168
  rubyforge_project:
183
- rubygems_version: 1.8.23
169
+ rubygems_version: 1.8.11
184
170
  signing_key:
185
171
  specification_version: 3
186
172
  summary: Module to allow CodeRunner to run and analyse the GS2 and AstroGK codes.