gs2crmod 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ Jeweler::Tasks.new do |gem|
20
20
  gem.summary = %Q{Module to allow CodeRunner to run and analyse the GS2 and AstroGK codes.}
21
21
  gem.description = %Q{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.}
22
22
  gem.email = "edmundhighcock@sourceforge.net"
23
- gem.authors = ["Edmund Highcock"]
23
+ gem.authors = ["Edmund Highcock", "Ferdinand van Wyk"]
24
24
  gem.extensions = "ext/extconf.rb"
25
25
  gem.files.include('ext/*.c', 'include/*.h', 'ext/*.rb')
26
26
  gem.required_ruby_version = '>= 1.9.1'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.7
1
+ 0.5.8
data/ext/gs2crmod_ext.c CHANGED
@@ -93,7 +93,14 @@ VALUE gs2crmod_tensor_field_gsl_tensor(VALUE self, VALUE options)
93
93
  cgsl_tensor = RGET_CLASS(cgsl, "Tensor");
94
94
  /*cgsl_vector = RGET_CLASS(cgsl, "Vector");*/
95
95
 
96
- field = RFCALL_11("field_gsl_tensor", options);
96
+ Check_Type(options, T_HASH);
97
+ if(RTEST(CR_HKS(options, "field"))){
98
+ field = CR_HKS(options, "field");
99
+ CR_CHECK_CLASS(field, cgsl_tensor);
100
+ }
101
+ else {
102
+ field = RFCALL_11("field_gsl_tensor", options);
103
+ }
97
104
  field_narray = RFCALL_10_ON(field, "narray");
98
105
  shape = RFCALL_10_ON(field, "shape");
99
106
 
@@ -123,7 +130,7 @@ VALUE gs2crmod_tensor_field_gsl_tensor(VALUE self, VALUE options)
123
130
  {
124
131
  for (i=0; i<c_shape[0]; i++) /*ky loop*/
125
132
  {
126
- for (k=0; k<c_shape[1]; k++) /*ky loop*/
133
+ for (k=0; k<c_shape[1]; k++) /*kx loop*/
127
134
  {
128
135
  /*First copy the field onto the
129
136
  * x workspace, Fourier transform
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.5.7"
8
+ s.version = "0.5.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Edmund Highcock"]
12
- s.date = "2013-04-16"
11
+ s.authors = ["Edmund Highcock", "Ferdinand van Wyk"]
12
+ s.date = "2013-05-07"
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"]
@@ -48,6 +48,12 @@
48
48
  NUM2INT(RARRAY_PTR(array)[cr_internal_xaa11]);\
49
49
  }
50
50
 
51
+ #define CR_CHECK_CLASS(obj,cls){\
52
+ if(!RTEST(rb_obj_is_kind_of(obj,cls))){\
53
+ rb_raise(RGET_CLASS_TOP("TypeError"), "Expecting an instance of %s", StringValueCStr(cls));\
54
+ }\
55
+ }
56
+
51
57
 
52
58
  static VALUE cgsl;
53
59
  static VALUE ccode_runner;
@@ -214,10 +214,6 @@ end
214
214
 
215
215
  module GraphKits
216
216
 
217
- def apar2_by_mode_vs_time_graphkit(options={})
218
- options[:direction] = :mode
219
- apar2_by_kxy_or_mode_vs_time_graphkit(options)
220
- end
221
217
 
222
218
  def apar2_by_kx_vs_time_graphkit(options={})
223
219
  options[:direction] = :kx
@@ -808,6 +804,12 @@ module GraphKits
808
804
  end
809
805
  end
810
806
  def phi_real_space_poloidal_plane_graphkit(options={})
807
+ return field_real_space_poloidal_plane_graphkit(options.absorb(field_name: :phi))
808
+ end
809
+ def density_real_space_poloidal_plane_graphkit(options={})
810
+ return field_real_space_poloidal_plane_graphkit(options.absorb(phi: field_real_space_gsl_tensor(field: moment_gsl_tensor(options.absorb(moment_name: :density)))))
811
+ end
812
+ def field_real_space_poloidal_plane_graphkit(options={})
811
813
  case options[:command]
812
814
  when :help
813
815
  return "The potential as a function of cartesian coordinates showing a cut at one toroidal angle, with multiple periodic copies of the flux tube used to fill the whole circle.."
@@ -828,7 +830,7 @@ module GraphKits
828
830
  #carts = cartesian_coordinates_gsl_tensor(options)
829
831
  #torphiout = 2.6
830
832
  torphiout = options[:torphi]
831
- phi = options[:phi] || phi_real_space_gsl_tensor(options)
833
+ phi = options[:phi] || field_real_space_gsl_tensor(options)
832
834
  torphi_const = constant_torphi_surface_gsl_tensor(options)
833
835
  cyls = cylindrical_coordinates_gsl_tensor(options.absorb({extra_points: true}))
834
836
  #p torphi_const[0,true].to_a;
@@ -133,6 +133,25 @@ class CodeRunner::Gs2
133
133
  tensor = send((name.to_s+"_gsl_tensor").to_sym , options)
134
134
  end
135
135
  module GSLTensors
136
+ def moment_gsl_tensor(options)
137
+ if options[:t_index]
138
+ raise ArgumentError.new("Moments are not written out as a function of time currently")
139
+ #ep options; gets
140
+ raise CRFatal.new("write_phi_over_time is not enabled so this function won't work") unless @write_phi_over_time
141
+ arr = GSL::Tensor.new(netcdf_file.var(options[:field_name].to_s + '_t').get({'start' => [0,(options[:thetamin]||0),0,0, options[:t_index] - 1], 'end' => [-1,(options[:thetamax]||-1),(options[:nakx]||0)-1,(options[:naky]||0)-1, options[:t_index] - 1]}))
142
+ #ep 'arr.shape', arr.shape
143
+ arr.reshape!(*arr.shape.slice(1...arr.shape.size))
144
+
145
+ else
146
+ arr = GSL::Tensor.new(netcdf_file.var(options[:moment_name]).get({'start' => [0,(options[:thetamin]||0),0,0,options[:species_element]], 'end' => [-1,(options[:thetamax]||-1),(options[:nakx]||0)-1,(options[:naky]||0)-1,options[:species_element]]}))
147
+ #ep 'arr.shape', arr.shape
148
+ end
149
+ arr.reshape!(*arr.shape.slice(1...arr.shape.size))
150
+ arr[0, true, true, true] = 0.0 if options[:no_zonal]
151
+ #arr = arr[options[:nakx] ? 0...options[:nakx] : true, options[:naky] ? 0...options[:naky] : true, true, true] if options[:nakx] or options[:naky]
152
+ return arr
153
+
154
+ end
136
155
  def field_gsl_tensor(options)
137
156
  if options[:t_index]
138
157
  #ep options; gets
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gs2crmod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.5.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Edmund Highcock
9
+ - Ferdinand van Wyk
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2013-04-16 00:00:00.000000000 Z
13
+ date: 2013-05-07 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: coderunner