gs2crmod 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.document +5 -0
  2. data/Gemfile +13 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.md +4 -0
  5. data/README.rdoc +19 -0
  6. data/Rakefile +56 -0
  7. data/VERSION +1 -0
  8. data/ext/extconf.rb +9 -0
  9. data/ext/gs2crmod_ext.c +366 -0
  10. data/gs2crmod.gemspec +98 -0
  11. data/include/gs2crmod_ext.h +58 -0
  12. data/lib/gs2crmod/astrogk/astrogk.rb +201 -0
  13. data/lib/gs2crmod/astrogk/calculations.rb +57 -0
  14. data/lib/gs2crmod/astrogk/check_convergence.rb +7 -0
  15. data/lib/gs2crmod/astrogk/deleted_variables.rb +76 -0
  16. data/lib/gs2crmod/astrogk/graphs.rb +13 -0
  17. data/lib/gs2crmod/astrogk/gsl_data.rb +13 -0
  18. data/lib/gs2crmod/astrogk/gsl_tools.rb +182 -0
  19. data/lib/gs2crmod/astrogk/ingen.rb +18 -0
  20. data/lib/gs2crmod/astrogk/input_file_tools.rb +7 -0
  21. data/lib/gs2crmod/astrogk/namelist_tools.rb +14 -0
  22. data/lib/gs2crmod/astrogk/namelists.rb +2800 -0
  23. data/lib/gs2crmod/astrogk/properties.rb +17 -0
  24. data/lib/gs2crmod/astrogk/species_dependent_namelists.rb +228 -0
  25. data/lib/gs2crmod/astrogk/test_gs2.rb +231 -0
  26. data/lib/gs2crmod/astrogk.rb +200 -0
  27. data/lib/gs2crmod/calculations.rb +780 -0
  28. data/lib/gs2crmod/check_convergence.rb +179 -0
  29. data/lib/gs2crmod/deleted_variables.rb +916 -0
  30. data/lib/gs2crmod/graphs.rb +1899 -0
  31. data/lib/gs2crmod/graphs_rdoc.rb +556 -0
  32. data/lib/gs2crmod/gs2.rb +1143 -0
  33. data/lib/gs2crmod/gsl_data.rb +1181 -0
  34. data/lib/gs2crmod/gsl_data_3d.rb +705 -0
  35. data/lib/gs2crmod/gsl_tools.rb +187 -0
  36. data/lib/gs2crmod/ingen.rb +218 -0
  37. data/lib/gs2crmod/namelists.rb +5142 -0
  38. data/lib/gs2crmod/properties.rb +22 -0
  39. data/lib/gs2crmod/species_dependent_namelists.rb +228 -0
  40. data/lib/gs2crmod/test_gs2.rb +231 -0
  41. data/lib/gs2crmod.rb +2 -0
  42. data/lib/gs2crmod_extension.rb +1 -0
  43. data/test/helper.rb +18 -0
  44. data/test/test_gs2crmod.rb +7 -0
  45. metadata +176 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ gem "coderunner", ">= 0.11.0"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "> 1.0.0"
12
+ gem "jeweler", ">= 1.8.4"
13
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Edmund Highcock
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ gs2crmod
2
+ ========
3
+
4
+ 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.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = gs2crmod
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to gs2crmod
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 Edmund Highcock. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "gs2crmod"
18
+ gem.homepage = "http://gs2crmod.sourceforge.net"
19
+ gem.license = "GSLv3"
20
+ gem.summary = %Q{Module to allow CodeRunner to run and analyse the GS2 and AstroGK codes.}
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
+ gem.email = "edmundhighcock@sourceforge.net"
23
+ gem.authors = ["Edmund Highcock"]
24
+ gem.extensions = "ext/extconf.rb"
25
+ gem.files.include('ext/*.c', 'include/*.h', 'ext/*.rb')
26
+ gem.required_ruby_version = '>= 1.9.1'
27
+ # dependencies defined in Gemfile
28
+ end
29
+ Jeweler::RubygemsDotOrgTasks.new
30
+
31
+ require 'rake/testtask'
32
+ Rake::TestTask.new(:test) do |test|
33
+ test.libs << 'lib' << 'test'
34
+ test.pattern = 'test/**/test_*.rb'
35
+ test.verbose = true
36
+ end
37
+
38
+ #require 'rcov/rcovtask'
39
+ #Rcov::RcovTask.new do |test|
40
+ #test.libs << 'test'
41
+ #test.pattern = 'test/**/test_*.rb'
42
+ #test.verbose = true
43
+ #test.rcov_opts << '--exclude "gems/*"'
44
+ #end
45
+
46
+ task :default => :test
47
+
48
+ require 'rdoc/task'
49
+ Rake::RDocTask.new do |rdoc|
50
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "gs2crmod #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.5.2
data/ext/extconf.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'mkmf'
2
+
3
+ $CFLAGS = " -Wall -I../include "
4
+
5
+ srcs = Dir.glob("*.c")
6
+
7
+ $objs = srcs.collect { |f| f.sub(".c", ".o") }
8
+
9
+ create_makefile("gs2crmod_ext")
@@ -0,0 +1,366 @@
1
+ #include "gs2crmod_ext.h"
2
+
3
+ VALUE gs2crmod_tensor_complexes_field_gsl_tensor_complex_2(VALUE self, VALUE options)
4
+ {
5
+ VALUE field, field_complex, field_narray;
6
+ VALUE field_complex_narray;
7
+ VALUE cgsl_tensor_complex;
8
+ VALUE ccomplex;
9
+ VALUE shape;
10
+ int *c_shape;
11
+ int i, j, k;
12
+
13
+ ccomplex = RGET_CLASS_TOP("Complex");
14
+ field = RFCALL_11("field_gsl_tensor", options);
15
+ cgsl_tensor_complex = RGET_CLASS(cgsl, "TensorComplex");
16
+ shape = rb_funcall(field, rb_intern("shape"), 0);
17
+ /*rb_p(shape);*/
18
+
19
+ CR_INT_ARY_R2C_STACK(shape, c_shape);
20
+ field_complex = rb_funcall3(cgsl_tensor_complex, rb_intern("alloc"), 3, RARRAY_PTR(shape));
21
+ field_narray = RFCALL_10_ON(field, "narray");
22
+ field_complex_narray = RFCALL_10_ON(field_complex, "narray");
23
+ /*rb_p(field_complex);*/
24
+ for (i=0;i<c_shape[0];i++)
25
+ for (j=0;j<c_shape[1];j++)
26
+ for (k=0;k<c_shape[2];k++)
27
+ {
28
+
29
+ /*printf("%d %d %d\n", i, j, k);*/
30
+ VALUE cmplex, re, im;
31
+ re = rb_funcall(
32
+ field_narray,
33
+ rb_intern("[]"),
34
+ 4,
35
+ INT2FIX(0),
36
+ INT2FIX(k), INT2FIX(j), INT2FIX(i)
37
+ );
38
+ /*printf("%d %d %d re\n", i, j, k);*/
39
+ im = rb_funcall(
40
+ field_narray,
41
+ rb_intern("[]"),
42
+ 4,
43
+ INT2FIX(1),
44
+ INT2FIX(k), INT2FIX(j), INT2FIX(i)
45
+ );
46
+ /*printf("%d %d %d im\n", i, j, k);*/
47
+ cmplex =
48
+ rb_funcall(
49
+ ccomplex,
50
+ rb_intern("rectangular"),
51
+ 2, re, im
52
+ );
53
+ /*printf("%d %d %d again\n", i, j, k);*/
54
+ rb_funcall(
55
+ field_complex_narray,
56
+ rb_intern("[]="),
57
+ 4,
58
+ INT2FIX(k), INT2FIX(j), INT2FIX(i),
59
+ cmplex
60
+ );
61
+
62
+ }
63
+ /*rb_p(field);*/
64
+
65
+
66
+
67
+ /*field_complex = */
68
+ return field_complex;
69
+ }
70
+
71
+ VALUE gs2crmod_tensor_field_gsl_tensor(VALUE self, VALUE options)
72
+ {
73
+ VALUE cgsl_tensor;
74
+ VALUE field, field_narray;
75
+ VALUE field_real_space, field_real_space_narray;
76
+ VALUE field_real_space_new, field_real_space_new_narray;
77
+ VALUE shape, shape_real_space, shape_real_space_new;
78
+ VALUE workspacex, workspacey;
79
+ VALUE ccomplex, cgsl_complex;
80
+ VALUE re, im, cmplex;
81
+ VALUE *ary_ptr;
82
+ VALUE range_x, range_y;
83
+ int shape0;
84
+ double* c_field, *c_field_real_space;
85
+ int* c_shape, *c_shape_real_space;
86
+ int * c_shape_real_space_new;
87
+ int i,j,k,m;
88
+ int kint,km,kold;
89
+ double frac, interp_value;
90
+
91
+ ccomplex = RGET_CLASS_TOP("Complex");
92
+ cgsl_complex = RGET_CLASS(cgsl, "Complex");
93
+ cgsl_tensor = RGET_CLASS(cgsl, "Tensor");
94
+ /*cgsl_vector = RGET_CLASS(cgsl, "Vector");*/
95
+
96
+ field = RFCALL_11("field_gsl_tensor", options);
97
+ field_narray = RFCALL_10_ON(field, "narray");
98
+ shape = RFCALL_10_ON(field, "shape");
99
+
100
+
101
+ workspacex = RFCALL_11_ON(cgsl_vector_complex, "alloc", RARRAY_PTR(shape)[1]);
102
+ shape0 = NUM2INT(RARRAY_PTR(shape)[0]);
103
+ workspacey = RFCALL_11_ON(cgsl_vector, "alloc", INT2NUM(shape0 * 2 - 2 + shape0%2));
104
+
105
+ field_real_space = rb_funcall(
106
+ cgsl_tensor,
107
+ rb_intern("alloc"),
108
+ 3,
109
+ RFCALL_10_ON(workspacey, "size"),
110
+ RARRAY_PTR(shape)[1],
111
+ RARRAY_PTR(shape)[2]
112
+ );
113
+ field_real_space_narray = RFCALL_10_ON(field_real_space, "narray");
114
+ shape_real_space = RFCALL_10_ON(field_real_space, "shape");
115
+
116
+ CR_INT_ARY_R2C_STACK(shape, c_shape);
117
+ CR_INT_ARY_R2C_STACK(RFCALL_10_ON(field_real_space, "shape"), c_shape_real_space);
118
+
119
+ c_field = ALLOC_N(double, c_shape[0] * c_shape[1] * c_shape[2] * c_shape[3]);
120
+
121
+ /*printf("Allocated stuff\n");*/
122
+ for (j=0; j<c_shape[2]; j++) /*theta loop*/
123
+ {
124
+ for (i=0; i<c_shape[0]; i++) /*ky loop*/
125
+ {
126
+ for (k=0; k<c_shape[1]; k++) /*ky loop*/
127
+ {
128
+ /*First copy the field onto the
129
+ * x workspace, Fourier transform
130
+ * the workspace and copy it onto
131
+ * the c array*/
132
+ re = rb_funcall(
133
+ field_narray,
134
+ rb_intern("[]"),
135
+ 4,
136
+ INT2FIX(0),
137
+ INT2FIX(j), INT2FIX(k), INT2FIX(i)
138
+ );
139
+ /*printf("%d %d %d re\n", i, j, k);*/
140
+ im = rb_funcall(
141
+ field_narray,
142
+ rb_intern("[]"),
143
+ 4,
144
+ INT2FIX(1),
145
+ INT2FIX(j), INT2FIX(k), INT2FIX(i)
146
+ );
147
+ /*printf("%d %d %d im\n", i, j, k);*/
148
+ cmplex =
149
+ rb_funcall(
150
+ cgsl_complex,
151
+ rb_intern("alloc"),
152
+ 2, re, im
153
+ );
154
+ /*printf("%d %d %d again\n", i, j, k);*/
155
+ /*printf("Made complex\n");*/
156
+ rb_funcall(
157
+ workspacex,
158
+ rb_intern("[]="),
159
+ 2,
160
+ INT2FIX(k),
161
+ cmplex);
162
+ /*printf("Added complex\n");*/
163
+
164
+ }
165
+ /*printf("Made complex vector\n");*/
166
+ workspacex = RFCALL_10_ON(workspacex, "backward");
167
+ /*printf("Done x transform\n");*/
168
+ for (k=0;k<c_shape[1];k++){
169
+ cmplex = RFCALL_11_ON(workspacex,"[]",INT2FIX(k));
170
+ c_field[
171
+ j*c_shape[0]*c_shape[1]*2 +
172
+ i*c_shape[1]*2 +
173
+ k*2
174
+ ] = NUM2DBL(RFCALL_10_ON(cmplex,"real"));
175
+ c_field[
176
+ j*c_shape[0]*c_shape[1]*2 +
177
+ i*c_shape[1]*2 +
178
+ k*2 + 1
179
+ ] = NUM2DBL(RFCALL_10_ON(cmplex,"imag"));
180
+
181
+ }
182
+ }
183
+ /*printf("Done x\n");*/
184
+ /* Now copy onto the y workspace,
185
+ * Fourier transform and copy onto
186
+ * the second c array*/
187
+ for (k=0;k<c_shape[1];k++)
188
+ {
189
+ m=0;
190
+ for (i=0;i<c_shape[0];i++)
191
+ {
192
+ rb_funcall(
193
+ workspacey,
194
+ rb_intern("[]="),
195
+ 2,
196
+ INT2FIX(m),
197
+ rb_float_new(c_field[
198
+ j*c_shape[0]*c_shape[1]*2 +
199
+ i*c_shape[1]*2 +
200
+ k*2
201
+ ])
202
+ );
203
+ m++;
204
+ /* We are converting a complex array
205
+ * to a half complex array in
206
+ * preparation for transforming
207
+ * it to real space, and so their
208
+ * are one or two elements we leave
209
+ * unfilled.*/
210
+ if (i==0 || (c_shape[0]%2==0 && i == c_shape[0]/2 + 1)) continue;
211
+ rb_funcall(
212
+ workspacey,
213
+ rb_intern("[]="),
214
+ 2,
215
+ INT2FIX(m),
216
+ rb_float_new(c_field[
217
+ j*c_shape[0]*c_shape[1]*2 +
218
+ i*c_shape[1]*2 +
219
+ k*2 + 1
220
+ ])
221
+ );
222
+ m++;
223
+ }
224
+ /*printf("Made y vector\n");*/
225
+ /*rb_p(workspacey);*/
226
+ /*rb_p(RFCALL_10_ON(workspacey, "class"));*/
227
+ workspacey = RFCALL_10_ON(workspacey, "backward");
228
+ /*printf("Done y transform\n");*/
229
+ for (i=0;i<FIX2INT(RFCALL_10_ON(workspacey, "size"));i++)
230
+ {
231
+ rb_funcall(
232
+ field_real_space_narray,
233
+ rb_intern("[]="), 4,
234
+ INT2FIX(j), INT2FIX(k), INT2FIX(i),
235
+ RFCALL_11_ON(workspacey, "[]", INT2FIX(i))
236
+ );
237
+ }
238
+ }
239
+ }
240
+ /*printf("HERE!\n");*/
241
+ range_x = CR_RANGE_INC(
242
+ (RTEST(CR_HKS(options, "ymin")) ?
243
+ FIX2INT(CR_HKS(options, "ymin")) :
244
+ 0),
245
+ (RTEST(CR_HKS(options, "ymax")) ?
246
+ FIX2INT(CR_HKS(options, "ymax")) :
247
+ c_shape_real_space[0]-1)
248
+ );
249
+ /*rb_p(range_x);*/
250
+ range_y = CR_RANGE_INC(
251
+ (RTEST(CR_HKS(options, "xmin")) ?
252
+ FIX2INT(CR_HKS(options, "xmin")) :
253
+ 0),
254
+ (RTEST(CR_HKS(options, "xmax")) ?
255
+ FIX2INT(CR_HKS(options, "xmax")) :
256
+ c_shape_real_space[1]-1)
257
+ );
258
+ /*printf("Made ranges\n");*/
259
+ /*rb_p(rb_funcall(field_real_space, rb_intern("[]"), 3, INT2FIX(0), INT2FIX(2), INT2FIX(3)));*/
260
+ field_real_space = rb_funcall(
261
+ field_real_space,
262
+ rb_intern("[]"), 3,
263
+ range_x,
264
+ range_y,
265
+ Qtrue);
266
+ /*rb_p(rb_funcall(field_real_space, rb_intern("[]"), 3, INT2FIX(0), INT2FIX(2), INT2FIX(3)));*/
267
+ /*printf("SHORTENED!\n");*/
268
+ if (RTEST(CR_HKS(options, "interpolate_theta")))
269
+ {
270
+ shape_real_space_new = RFCALL_10_ON(shape_real_space, "dup");
271
+ kint = NUM2INT(CR_HKS(options, "interpolate_theta"));
272
+ rb_funcall(
273
+ shape_real_space_new,
274
+ rb_intern("[]="), 2, INT2FIX(-1),
275
+ INT2FIX((c_shape_real_space[2] - 1)*kint+1)
276
+ );
277
+ CR_INT_ARY_R2C_STACK(shape_real_space_new, c_shape_real_space_new);
278
+ ary_ptr = RARRAY_PTR(shape_real_space_new);
279
+ field_real_space_new = rb_funcall(
280
+ cgsl_tensor,
281
+ rb_intern("float"),
282
+ 3,
283
+ ary_ptr[0], ary_ptr[1], ary_ptr[2]);
284
+ field_real_space_new_narray = RFCALL_10_ON(field_real_space_new, "narray");
285
+ /*printf("Allocated");*/
286
+ /*rb_p(shape_real_space_new);*/
287
+ for (i=0;i<c_shape_real_space_new[0];i++)
288
+ for (j=0;j<c_shape_real_space_new[1];j++)
289
+ {
290
+ /*printf("i %d j %d k %d\n", i, j, c_shape_real_space_new[2]-1); */
291
+ rb_funcall(
292
+ field_real_space_new_narray,
293
+ rb_intern("[]="),
294
+ 4,INT2FIX(c_shape_real_space_new[2]-1),
295
+ INT2FIX(j),INT2FIX(i),
296
+ rb_funcall(
297
+ field_real_space_narray,
298
+ rb_intern("[]"), 3,
299
+ INT2FIX(c_shape_real_space[2]-1),
300
+ INT2FIX(j),INT2FIX(i)
301
+ )
302
+ );
303
+ for (k=0;k<c_shape_real_space_new[2]-1;k++)
304
+ {
305
+ /*printf("i %d j %d k %d\n", i, j, k); */
306
+ km = k%kint;
307
+ frac = (double)km/(double)kint;
308
+ kold = (k-km)/kint;
309
+ interp_value = NUM2DBL(
310
+ rb_funcall(
311
+ field_real_space_narray,
312
+ rb_intern("[]"),3,
313
+ INT2FIX(kold),INT2FIX(j),INT2FIX(i)
314
+ )
315
+ )*(1.0-frac) + NUM2DBL(
316
+ rb_funcall(
317
+ field_real_space_narray,
318
+ rb_intern("[]"),3,
319
+ INT2FIX(kold+1),INT2FIX(j),INT2FIX(i)
320
+ )
321
+ ) * frac;
322
+ rb_funcall(
323
+ field_real_space_new_narray,
324
+ rb_intern("[]="), 4,
325
+ INT2FIX(k),INT2FIX(j),INT2FIX(i),
326
+ rb_float_new(interp_value)
327
+ );
328
+ /*if (i==0 && j==2 && k==3){*/
329
+ /*printf("frac %f\n", frac);*/
330
+ /*}*/
331
+ }
332
+ }
333
+
334
+ field_real_space = field_real_space_new;
335
+ }
336
+ /*rb_p(shape_real_space_new);*/
337
+ return field_real_space;
338
+ }
339
+
340
+ void Init_gs2crmod_ext()
341
+ {
342
+ /*printf("HERE!!!");*/
343
+ ccode_runner = RGET_CLASS_TOP("CodeRunner");
344
+ ccode_runner_gs2 = rb_define_class_under(ccode_runner, "Gs2",
345
+ RGET_CLASS(
346
+ RGET_CLASS(ccode_runner, "Run"),
347
+ "FortranNamelist"
348
+ )
349
+ );
350
+
351
+ ccode_runner_gs2_gsl_tensor_complexes = rb_define_module_under(ccode_runner_gs2, "GSLComplexTensors");
352
+ rb_include_module(ccode_runner_gs2, ccode_runner_gs2_gsl_tensor_complexes);
353
+
354
+ ccode_runner_gs2_gsl_tensors = rb_define_module_under(ccode_runner_gs2, "GSLTensors");
355
+ rb_include_module(ccode_runner_gs2, ccode_runner_gs2_gsl_tensors);
356
+
357
+ cgsl = RGET_CLASS_TOP("GSL");
358
+ cgsl_vector = RGET_CLASS(cgsl, "Vector");
359
+ cgsl_vector_complex = RGET_CLASS(cgsl_vector, "Complex");
360
+
361
+ rb_define_method(ccode_runner_gs2_gsl_tensor_complexes, "field_gsl_tensor_complex_2", gs2crmod_tensor_complexes_field_gsl_tensor_complex_2, 1);
362
+ rb_define_method(ccode_runner_gs2_gsl_tensors, "field_real_space_gsl_tensor", gs2crmod_tensor_field_gsl_tensor, 1);
363
+
364
+ /*rb_define_method(ccode_runner_ext, "hello_world", code_runner_ext_hello_world, 0);*/
365
+ }
366
+
data/gs2crmod.gemspec ADDED
@@ -0,0 +1,98 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "gs2crmod"
8
+ s.version = "0.5.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Edmund Highcock"]
12
+ s.date = "2012-10-10"
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
+ s.email = "edmundhighcock@sourceforge.net"
15
+ s.extensions = ["ext/extconf.rb"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.md",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ "Gemfile",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "ext/extconf.rb",
30
+ "ext/gs2crmod_ext.c",
31
+ "gs2crmod.gemspec",
32
+ "include/gs2crmod_ext.h",
33
+ "lib/gs2crmod.rb",
34
+ "lib/gs2crmod/astrogk.rb",
35
+ "lib/gs2crmod/astrogk/astrogk.rb",
36
+ "lib/gs2crmod/astrogk/calculations.rb",
37
+ "lib/gs2crmod/astrogk/check_convergence.rb",
38
+ "lib/gs2crmod/astrogk/deleted_variables.rb",
39
+ "lib/gs2crmod/astrogk/graphs.rb",
40
+ "lib/gs2crmod/astrogk/gsl_data.rb",
41
+ "lib/gs2crmod/astrogk/gsl_tools.rb",
42
+ "lib/gs2crmod/astrogk/ingen.rb",
43
+ "lib/gs2crmod/astrogk/input_file_tools.rb",
44
+ "lib/gs2crmod/astrogk/namelist_tools.rb",
45
+ "lib/gs2crmod/astrogk/namelists.rb",
46
+ "lib/gs2crmod/astrogk/properties.rb",
47
+ "lib/gs2crmod/astrogk/species_dependent_namelists.rb",
48
+ "lib/gs2crmod/astrogk/test_gs2.rb",
49
+ "lib/gs2crmod/calculations.rb",
50
+ "lib/gs2crmod/check_convergence.rb",
51
+ "lib/gs2crmod/deleted_variables.rb",
52
+ "lib/gs2crmod/graphs.rb",
53
+ "lib/gs2crmod/graphs_rdoc.rb",
54
+ "lib/gs2crmod/gs2.rb",
55
+ "lib/gs2crmod/gsl_data.rb",
56
+ "lib/gs2crmod/gsl_data_3d.rb",
57
+ "lib/gs2crmod/gsl_tools.rb",
58
+ "lib/gs2crmod/ingen.rb",
59
+ "lib/gs2crmod/namelists.rb",
60
+ "lib/gs2crmod/properties.rb",
61
+ "lib/gs2crmod/species_dependent_namelists.rb",
62
+ "lib/gs2crmod/test_gs2.rb",
63
+ "lib/gs2crmod_extension.rb",
64
+ "test/helper.rb",
65
+ "test/test_gs2crmod.rb"
66
+ ]
67
+ s.homepage = "http://gs2crmod.sourceforge.net"
68
+ s.licenses = ["GSLv3"]
69
+ s.require_paths = ["lib"]
70
+ s.required_ruby_version = Gem::Requirement.new(">= 1.9.1")
71
+ s.rubygems_version = "1.8.24"
72
+ s.summary = "Module to allow CodeRunner to run and analyse the GS2 and AstroGK codes."
73
+
74
+ if s.respond_to? :specification_version then
75
+ s.specification_version = 3
76
+
77
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
78
+ s.add_runtime_dependency(%q<coderunner>, [">= 0.11.0"])
79
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
80
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
81
+ s.add_development_dependency(%q<bundler>, ["> 1.0.0"])
82
+ s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
83
+ else
84
+ s.add_dependency(%q<coderunner>, [">= 0.11.0"])
85
+ s.add_dependency(%q<shoulda>, [">= 0"])
86
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
87
+ s.add_dependency(%q<bundler>, ["> 1.0.0"])
88
+ s.add_dependency(%q<jeweler>, [">= 1.8.4"])
89
+ end
90
+ else
91
+ s.add_dependency(%q<coderunner>, [">= 0.11.0"])
92
+ s.add_dependency(%q<shoulda>, [">= 0"])
93
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
94
+ s.add_dependency(%q<bundler>, ["> 1.0.0"])
95
+ s.add_dependency(%q<jeweler>, [">= 1.8.4"])
96
+ end
97
+ end
98
+
@@ -0,0 +1,58 @@
1
+ #include "ruby.h"
2
+
3
+
4
+ #define RGET_CLASS(class_over, x) (rb_const_get(class_over, rb_intern(x)))
5
+ #define RGET_CLASS_TOP(x) (RGET_CLASS(rb_cObject, x))
6
+ #define RFCALL_10(name) (rb_funcall(self, rb_intern(name), 0))
7
+ #define RFCALL_10_ON(obj, name) (rb_funcall(obj, rb_intern(name), 0))
8
+ #define RFCALL_11(name, arg1) (rb_funcall(self, rb_intern(name), 1, arg1))
9
+ #define RFCALL_11_ON(obj, name, arg1) (rb_funcall(obj, rb_intern(name), 1, arg1))
10
+ #define CR_ELEMENT_ACCESS(recvr, key) ( \
11
+ RFCALL_11_ON(recvr, "[]", key) \
12
+ )
13
+ #define CR_HKS(hash, cstr) (CR_ELEMENT_ACCESS(hash, ID2SYM(rb_intern(cstr))))
14
+ #define CR_RANGE_INC(start, end) (rb_funcall(RGET_CLASS_TOP("Range"), rb_intern("new"), 2, INT2FIX(start), INT2FIX(end)))
15
+ #define CR_RANGE_EXC(start, end) (rb_funcall(RGET_CLASS_TOP("Range"), rb_intern("new"), 3, INT2FIX(start), INT2FIX(end), Qtrue))
16
+
17
+ /*Allocates an integer array on the heap
18
+ with values of array. int_ptr should be
19
+ an unallocated int*. array should not
20
+ contain anything except ints. */
21
+ #define CR_INT_ARY_R2C_STACK( array,int_ptr)\
22
+ { int cr_internal_xaa12; \
23
+ cr_internal_xaa12 = RARRAY_LEN(array); \
24
+ int_ptr = ALLOCA_N(int, cr_internal_xaa12);\
25
+ int cr_internal_xaa11;\
26
+ for (cr_internal_xaa11=0;\
27
+ cr_internal_xaa11< cr_internal_xaa12;\
28
+ cr_internal_xaa11++)\
29
+ int_ptr[cr_internal_xaa11] = \
30
+ FIX2INT(RARRAY_PTR(array)[cr_internal_xaa11]);\
31
+ }
32
+
33
+
34
+ /*Allocates an integer array on the heap
35
+ with values of array. int_ptr should be
36
+ an unallocated int*. array should not
37
+ contain anything except ints; this is
38
+ checked in this macro. */
39
+ #define CR_INT_ARY_R2C_STACK_TCHECK( array,int_ptr)\
40
+ { int cr_internal_xaa12; \
41
+ cr_internal_xaa12 = RARRAY_LEN(array); \
42
+ int_ptr = ALLOCA_N(int, cr_internal_xaa12);\
43
+ int cr_internal_xaa11;\
44
+ for (cr_internal_xaa11=0;\
45
+ cr_internal_xaa11< cr_internal_xaa12;\
46
+ cr_internal_xaa11++)\
47
+ int_ptr[cr_internal_xaa11] = \
48
+ NUM2INT(RARRAY_PTR(array)[cr_internal_xaa11]);\
49
+ }
50
+
51
+
52
+ static VALUE cgsl;
53
+ static VALUE ccode_runner;
54
+ static VALUE ccode_runner_gs2;
55
+ static VALUE ccode_runner_gs2_gsl_tensor_complexes;
56
+ static VALUE ccode_runner_gs2_gsl_tensors;
57
+ static VALUE cgsl_vector, cgsl_vector_complex;
58
+ /*void Init_code_runner_ext();*/