gs2crmod 0.11.26 → 0.11.27

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 CHANGED
@@ -1 +1 @@
1
- 0.11.26
1
+ 0.11.27
data/gs2crmod.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gs2crmod"
8
- s.version = "0.11.26"
8
+ s.version = "0.11.27"
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"]
@@ -84,7 +84,7 @@ Gem::Specification.new do |s|
84
84
  s.licenses = ["GSLv3"]
85
85
  s.require_paths = ["lib"]
86
86
  s.required_ruby_version = Gem::Requirement.new(">= 1.9.1")
87
- s.rubygems_version = "1.8.11"
87
+ s.rubygems_version = "1.8.23"
88
88
  s.summary = "Module to allow CodeRunner to run and analyse the GS2 and AstroGK codes."
89
89
 
90
90
  if s.respond_to? :specification_version then
@@ -50,7 +50,8 @@ def auto_axiskits(name, options)
50
50
  'spectrum_over_kpar' => ["Spectrum at t = #{sprintf("%.3f" ,(options[:t] or list(:t)[options[:t_index]] or list(:t).values.max))}", '', 1],
51
51
  'spectrum_over_ky_over_kx' => ["Spectrum at t = #{sprintf("%.3f" ,(options[:t] or list(:t)[options[:t_index]] or list(:t).values.max))}", '', 2],
52
52
  'spectrum_over_ky_over_kpar' => ["Spectrum at t = #{sprintf("%.3f" ,(options[:t] or list(:t)[options[:t_index]] or list(:t).values.max))}", '', 2],
53
- 'phi0_over_x_over_y' => ["Phi at t = #{sprintf("%.3f" ,(options[:t] or list(:t)[options[:t_index]] or list(:t).values.max))}", '', 2],
53
+ #'phi0_over_x_over_y' => ["Phi at t = #{sprintf("%.3f" ,(options[:t] or list(:t)[options[:t_index]] or list(:t).values.max))}", '', 2],
54
+ 'phi0_over_x_over_y' => ["Phi at theta = 0", '', 2],
54
55
  'es_mom_flux_over_time' => ["#{species_type((options[:species_index] or 1)).capitalize} Momentum Flux", '', 1]
55
56
 
56
57
 
@@ -1852,20 +1853,19 @@ module GraphKits
1852
1853
  when :help
1853
1854
  return "The potential at the outboard midplane"
1854
1855
  when :options
1855
- return [:rgbformulae, :limit]
1856
+ return [:rgbformulae, :limit, :xres, :x_resolution, :yres, :y_resolution, :no_zonal, :t_index]
1856
1857
  else
1857
1858
  zaxis = axiskit('phi0_over_x_over_y', options)
1858
1859
  zaxis.data = zaxis.data.transpose
1859
1860
  shape = zaxis.data.shape
1860
- kit = GraphKit.autocreate({x: GraphKit::AxisKit.autocreate({data: (GSL::Vector.alloc((0...shape[0]).to_a)/shape[0] - 0.5) * (@x0 or @y0 * @jwist / 2 / Math::PI / @shat), title: "x", units: "rho_#{species_letter}"}), y: AxisKit.autocreate({data: (GSL::Vector.alloc((0...shape[1]).to_a)/shape[1] - 0.5) * @y0, title: "y", units: "rho_#{species_letter}"}), z: zaxis})
1861
- # kit.xrange = [0,shape[0]]
1862
- # kit.yrange = [0,shape[1]]
1861
+ kit = GraphKit.autocreate({x: GraphKit::AxisKit.autocreate({data: (GSL::Vector.alloc((0...shape[0]).to_a)/shape[0] - 0.5) * 2*Math::PI * (@x0 or @y0 * @jtwist / 2 / Math::PI / @shat), title: "x", units: "rho_#{species_letter}"}), y: AxisKit.autocreate({data: (GSL::Vector.alloc((0...shape[1]).to_a)/shape[1] - 0.5) * 2*Math::PI * @y0, title: "y", units: "rho_#{species_letter}"}), z: zaxis})
1863
1862
  kit.zrange = options[:limit] if options[:limit]
1864
1863
  kit.title = "Spectrum"
1865
1864
  kit.palette = "rgbformulae #{(options[:rgbformulae] or "-3,3,0")}"
1866
- kit.view = "map"
1867
- kit.style = "data pm3d"
1868
- kit.title = "Phi at the outboard midplane"
1865
+ kit.gp.view = "map"
1866
+ kit.gp.style = "data pm3d"
1867
+ kit.gp.size = "ratio #{@y0 / (@x0 or @y0 * @jtwist / 2 / Math::PI / @shat)}"
1868
+ kit.title = "Phi at theta = 0, t = #{sprintf("%.3f" ,list(:t)[options[:t_index]])}"
1869
1869
  # kit.data[0].with = (options[:with] or 'pm3d palette')
1870
1870
  kit.file_name = options[:graphkit_name]
1871
1871
  kit
@@ -1175,11 +1175,10 @@ module GSLMatrices
1175
1175
  def phi0_over_x_over_y_gsl_matrix(options)
1176
1176
  Dir.chdir(@directory) do
1177
1177
 
1178
- options.convert_to_index(:t) if options[:t] or options[:t_element]
1178
+ #options.convert_to_index(:t) if options[:t] or options[:t_element]
1179
+ options.convert_to_index(self, :t) if options[:t] or options[:t_element]
1179
1180
  options[:t_index] ||= list(:t).keys.max
1180
- #phi2_by_mode index order (in Fortran) is kx, ky, t
1181
1181
  phi_re_narray = netcdf_file.var("phi0").get('start' => [0, 0, 0, options[:t_index] - 1], 'end' => [0, -1, -1, options[:t_index] - 1])
1182
- # ep phi_re_narray.shape
1183
1182
  phi_re_narray.reshape!(*phi_re_narray.shape.slice(1..2))
1184
1183
  # The narray has index order ky, kx, but we want kx, ky for historical reasons, hence the transpose.
1185
1184
  gm_re = phi_re_narray.to_gm
@@ -1188,60 +1187,82 @@ module GSLMatrices
1188
1187
  # The narray has index order ky, kx, but we want kx, ky for historical imasons, hence the transpose.
1189
1188
  gm_im = phi_im_narray.to_gm
1190
1189
  gm = GSL::Matrix::Complex.re_im(gm_re, gm_im)
1191
- # ep gm.shape
1192
1190
 
1193
- if options[:no_zonal]
1194
-
1191
+ ntheta0_temp = gm.shape[1]
1192
+ naky_temp = gm.shape[0]
1193
+
1194
+
1195
+ # Due to a strange GS2 convention, non zonal modes must be divided by 2:
1196
+ for i in 1...naky_temp
1197
+ for j in 0...ntheta0_temp
1198
+ gm[i,j] = gm[i,j]/2.0
1199
+ end
1200
+ end
1201
+
1202
+ if options[:no_zonal]
1195
1203
  for i in 0...gm.shape[1]
1196
1204
  gm[0,i] = GSL::Complex.alloc([0,0])
1197
1205
  end
1198
1206
  end
1199
1207
  if xres = (options[:xres] or options[:x_resolution])
1200
- mat = GSL::Matrix::Complex.calloc(gm.shape[0], xres)
1201
- extra = ((xres - gm.shape[1])).floor
1202
- for i in 0...gm.shape[0]
1203
- for j in 0...((gm.shape[1] + 1) / 2 )
1204
- # j+= extra if
1205
- mat[i, j] = gm[i,j]
1206
- mat[i, j+extra] = gm[i,-j] unless j==0
1207
- end
1208
- end
1209
- gm = mat
1210
-
1211
-
1212
- # gm = mat.vertcat(gm).vertcat(mat)
1208
+ if xres < nx
1209
+ puts "Warning: xres should be at least nx. Using nx instead of the xres you specified."
1210
+ xres = nx
1211
+ end
1212
+ else
1213
+ xres = nx
1213
1214
  end
1214
1215
  if yres = (options[:yres] or options[:y_resolution])
1215
- mat = GSL::Matrix::Complex.calloc(yres, gm.shape[1])
1216
- extra = ((yres - gm.shape[0])).floor
1217
- for i in 0...gm.shape[0]
1218
- for j in 0...gm.shape[1]
1219
- # j+= extra if
1220
- mat[i, j] = gm[i,j]
1221
- # mat[i, j+extra] = gm[i,-j] unless j==0
1222
- end
1223
- end
1224
- gm = mat
1225
-
1226
-
1227
- # gm = mat.vertcat(gm).vertcat(mat)
1216
+ if yres < ny
1217
+ puts "Warning: yres should be at least ny. Using ny instead of the yres you specified."
1218
+ yres = ny
1219
+ end
1220
+ else
1221
+ yres = ny
1228
1222
  end
1229
- # ep gm_re, gm_im
1230
- # re = GSL::Complex.alloc([1.0, 0.0])
1231
- # gm = GSL::Matrix::Complex.calloc(*gm_re.shape)
1232
- # gm = gm_re * re + gm_im * GSL::Complex.alloc([0.0, 1.0])
1233
- # gm_re, gm_im = fourier_transform_gm_matrix_complex_rows(gm_re, gm_im)
1234
-
1235
- gm = gm.backward_cols_c2c(true).backward_rows_cc2r(true)
1223
+
1224
+ # Next, pad with 0's:
1225
+ padded = GSL::Matrix::Complex.calloc(yres, xres)
1226
+ # Zonal modes first:
1227
+ for ix in 0...((ntheta0_temp+1)/2)
1228
+ padded[0, ix] = gm[0, ix]
1229
+ end
1230
+ for ix in ((ntheta0_temp+1)/2)...ntheta0_temp
1231
+ padded[0, ix+xres-ntheta0_temp] = gm[0, ix]
1232
+ end
1233
+ # Now include the non-zonal modes in the padded matrix mat:
1234
+ for iy in 1...naky_temp
1235
+ for ix in 0...((ntheta0_temp + 1)/2)
1236
+ padded[iy, ix] = gm[iy, ix]
1237
+ end
1238
+ for ix in ((ntheta0_temp+1)/2)...ntheta0_temp
1239
+ padded[iy, ix+xres-ntheta0_temp] = gm[iy, ix]
1240
+ end
1241
+ padded[yres-iy, 0] = gm[iy,0].conj
1242
+ for ix in 1...xres
1243
+ padded[yres-iy, ix] = padded[iy, xres-ix].conj
1244
+ end
1245
+ end
1246
+ gm = padded
1247
+
1248
+ gm = gm.backward_cols_c2c(false).backward_rows_c2c(false)
1249
+ # At this point, gm should be purely real (within machine precision), but let's check to be sure:
1250
+ should_be_zero = gm.imag.abs.max
1251
+ if should_be_zero > 1.0e-10
1252
+ puts "should_be_zero = #{should_be_zero}"
1253
+ raise "Something went wrong - reconstructed phi is not purely real."
1254
+ end
1255
+
1256
+ gm = gm.real
1257
+
1236
1258
  if options[:limit]
1237
1259
  for i in 0...gm.shape[0]
1238
1260
  for j in 0...gm.shape[1]
1239
- # j+= extra if
1240
1261
  gm[i, j] = [[gm[i,j], options[:limit][0]].max, options[:limit][1]].min
1241
- # mat[i, j+extra] = gm[i,-j] unless j==0
1242
1262
  end
1243
1263
  end
1244
1264
  end
1265
+
1245
1266
  return gm
1246
1267
  end
1247
1268
  end
@@ -85,6 +85,22 @@ class GSL::Matrix::Complex
85
85
  gm
86
86
  end
87
87
 
88
+ def backward_rows_c2c(normalise = false)
89
+ gm = self.dup
90
+ rows, cols = gm.shape
91
+ table = GSL.cache[[:fft_table, :complex, cols]] ||= GSL::FFT::ComplexWavetable.alloc(cols)
92
+ work = GSL.cache[[:fft_work, :complex, cols]] ||= GSL::FFT::ComplexWorkspace.alloc(cols)
93
+ for i in 0...rows
94
+ vec = gm.row(i)
95
+ vec.backward!(table, work)
96
+ for j in 0...cols
97
+ gm[i,j] = vec[j]
98
+ end
99
+ end
100
+ gm = gm / cols if normalise
101
+ gm
102
+ end
103
+
88
104
  def forward_cols_c2c
89
105
  gm = self.dup
90
106
  rows, cols = gm.shape
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.11.26
4
+ version: 0.11.27
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2014-03-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: coderunner
17
- requirement: &10326280 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,15 @@ dependencies:
22
22
  version: 0.14.10
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *10326280
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: 0.14.10
26
31
  - !ruby/object:Gem::Dependency
27
32
  name: rubyhacks
28
- requirement: &10325680 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
29
34
  none: false
30
35
  requirements:
31
36
  - - ! '>='
@@ -33,10 +38,15 @@ dependencies:
33
38
  version: 0.1.2
34
39
  type: :runtime
35
40
  prerelease: false
36
- version_requirements: *10325680
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 0.1.2
37
47
  - !ruby/object:Gem::Dependency
38
48
  name: ruby-netcdf-updated
39
- requirement: &10325060 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
40
50
  none: false
41
51
  requirements:
42
52
  - - ! '>='
@@ -44,10 +54,15 @@ dependencies:
44
54
  version: 0.6.6.1
45
55
  type: :runtime
46
56
  prerelease: false
47
- version_requirements: *10325060
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: 0.6.6.1
48
63
  - !ruby/object:Gem::Dependency
49
64
  name: shoulda
50
- requirement: &10324220 !ruby/object:Gem::Requirement
65
+ requirement: !ruby/object:Gem::Requirement
51
66
  none: false
52
67
  requirements:
53
68
  - - ! '>='
@@ -55,10 +70,15 @@ dependencies:
55
70
  version: '0'
56
71
  type: :development
57
72
  prerelease: false
58
- version_requirements: *10324220
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
59
79
  - !ruby/object:Gem::Dependency
60
80
  name: rdoc
61
- requirement: &10323080 !ruby/object:Gem::Requirement
81
+ requirement: !ruby/object:Gem::Requirement
62
82
  none: false
63
83
  requirements:
64
84
  - - ~>
@@ -66,10 +86,15 @@ dependencies:
66
86
  version: '3.12'
67
87
  type: :development
68
88
  prerelease: false
69
- version_requirements: *10323080
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ version: '3.12'
70
95
  - !ruby/object:Gem::Dependency
71
96
  name: bundler
72
- requirement: &10322500 !ruby/object:Gem::Requirement
97
+ requirement: !ruby/object:Gem::Requirement
73
98
  none: false
74
99
  requirements:
75
100
  - - ! '>'
@@ -77,10 +102,15 @@ dependencies:
77
102
  version: 1.0.0
78
103
  type: :development
79
104
  prerelease: false
80
- version_requirements: *10322500
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>'
109
+ - !ruby/object:Gem::Version
110
+ version: 1.0.0
81
111
  - !ruby/object:Gem::Dependency
82
112
  name: jeweler
83
- requirement: &10321640 !ruby/object:Gem::Requirement
113
+ requirement: !ruby/object:Gem::Requirement
84
114
  none: false
85
115
  requirements:
86
116
  - - ! '>='
@@ -88,7 +118,12 @@ dependencies:
88
118
  version: 1.8.4
89
119
  type: :development
90
120
  prerelease: false
91
- version_requirements: *10321640
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: 1.8.4
92
127
  description: GS2 is a gyrokinetic flux tube initial value turbulence code which can
93
128
  be used for fusion or astrophysical plasmas. CodeRunner is a framework for the automated
94
129
  running and analysis of large simulations. This module allows GS2 (and its sister
@@ -183,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
218
  version: '0'
184
219
  requirements: []
185
220
  rubyforge_project:
186
- rubygems_version: 1.8.11
221
+ rubygems_version: 1.8.23
187
222
  signing_key:
188
223
  specification_version: 3
189
224
  summary: Module to allow CodeRunner to run and analyse the GS2 and AstroGK codes.