gs2crmod 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +20 -0
- data/README.md +4 -0
- data/README.rdoc +19 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/ext/extconf.rb +9 -0
- data/ext/gs2crmod_ext.c +366 -0
- data/gs2crmod.gemspec +98 -0
- data/include/gs2crmod_ext.h +58 -0
- data/lib/gs2crmod/astrogk/astrogk.rb +201 -0
- data/lib/gs2crmod/astrogk/calculations.rb +57 -0
- data/lib/gs2crmod/astrogk/check_convergence.rb +7 -0
- data/lib/gs2crmod/astrogk/deleted_variables.rb +76 -0
- data/lib/gs2crmod/astrogk/graphs.rb +13 -0
- data/lib/gs2crmod/astrogk/gsl_data.rb +13 -0
- data/lib/gs2crmod/astrogk/gsl_tools.rb +182 -0
- data/lib/gs2crmod/astrogk/ingen.rb +18 -0
- data/lib/gs2crmod/astrogk/input_file_tools.rb +7 -0
- data/lib/gs2crmod/astrogk/namelist_tools.rb +14 -0
- data/lib/gs2crmod/astrogk/namelists.rb +2800 -0
- data/lib/gs2crmod/astrogk/properties.rb +17 -0
- data/lib/gs2crmod/astrogk/species_dependent_namelists.rb +228 -0
- data/lib/gs2crmod/astrogk/test_gs2.rb +231 -0
- data/lib/gs2crmod/astrogk.rb +200 -0
- data/lib/gs2crmod/calculations.rb +780 -0
- data/lib/gs2crmod/check_convergence.rb +179 -0
- data/lib/gs2crmod/deleted_variables.rb +916 -0
- data/lib/gs2crmod/graphs.rb +1899 -0
- data/lib/gs2crmod/graphs_rdoc.rb +556 -0
- data/lib/gs2crmod/gs2.rb +1143 -0
- data/lib/gs2crmod/gsl_data.rb +1181 -0
- data/lib/gs2crmod/gsl_data_3d.rb +705 -0
- data/lib/gs2crmod/gsl_tools.rb +187 -0
- data/lib/gs2crmod/ingen.rb +218 -0
- data/lib/gs2crmod/namelists.rb +5142 -0
- data/lib/gs2crmod/properties.rb +22 -0
- data/lib/gs2crmod/species_dependent_namelists.rb +228 -0
- data/lib/gs2crmod/test_gs2.rb +231 -0
- data/lib/gs2crmod.rb +2 -0
- data/lib/gs2crmod_extension.rb +1 -0
- data/test/helper.rb +18 -0
- data/test/test_gs2crmod.rb +7 -0
- metadata +176 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
class CodeRunner
|
2
|
+
class Gs2
|
3
|
+
|
4
|
+
|
5
|
+
######################################
|
6
|
+
# GS2 CodeRunner Module
|
7
|
+
#
|
8
|
+
# Calculated Properties
|
9
|
+
#
|
10
|
+
# These are methods which calculate
|
11
|
+
# miscellaneous properties of the run.
|
12
|
+
#
|
13
|
+
#####################################
|
14
|
+
|
15
|
+
|
16
|
+
def has_electrons?
|
17
|
+
return @nspec.times.inject(false){|bool, i| bool or send(:type_ + i.to_sym) =~ /electrons/i}
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,228 @@
|
|
1
|
+
{:species_parameters=>
|
2
|
+
{:description=>"SPECIES ",
|
3
|
+
:include_conditions=>"true",
|
4
|
+
:variables=>
|
5
|
+
{:z=>
|
6
|
+
{:help=>"Charge",
|
7
|
+
:include_conditions=>"true",
|
8
|
+
:description=>"Charge",
|
9
|
+
:tests=>["Tst::FLOAT"],
|
10
|
+
:autoscanned_defaults=>[],
|
11
|
+
:must_pass=>
|
12
|
+
[{:test=>"kind_of? Numeric",
|
13
|
+
:explanation=>
|
14
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}]},
|
15
|
+
:mass=>
|
16
|
+
{:help=>"Mass",
|
17
|
+
:include_conditions=>"true",
|
18
|
+
:description=>"Mass",
|
19
|
+
:tests=>["Tst::FLOAT"],
|
20
|
+
:autoscanned_defaults=>[],
|
21
|
+
:must_pass=>
|
22
|
+
[{:test=>"kind_of? Numeric",
|
23
|
+
:explanation=>
|
24
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}]},
|
25
|
+
:dens=>
|
26
|
+
{:help=>"Density\t",
|
27
|
+
:include_conditions=>"true",
|
28
|
+
:description=>"Density\t",
|
29
|
+
:tests=>["Tst::FLOAT"],
|
30
|
+
:autoscanned_defaults=>[],
|
31
|
+
:must_pass=>
|
32
|
+
[{:test=>"kind_of? Numeric",
|
33
|
+
:explanation=>
|
34
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}]},
|
35
|
+
:temp=>
|
36
|
+
{:help=>"Temperature",
|
37
|
+
:include_conditions=>"true",
|
38
|
+
:description=>"Temperature",
|
39
|
+
:tests=>["Tst::FLOAT"],
|
40
|
+
:autoscanned_defaults=>[],
|
41
|
+
:must_pass=>
|
42
|
+
[{:test=>"kind_of? Numeric",
|
43
|
+
:explanation=>
|
44
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}]},
|
45
|
+
:tprim=>
|
46
|
+
{:help=>"6.0 !-1/T (dT/drho)",
|
47
|
+
:include_conditions=>"true",
|
48
|
+
:description=>"6.0 !-1/T (dT/drho)",
|
49
|
+
:tests=>["Tst::FLOAT"],
|
50
|
+
:autoscanned_defaults=>[],
|
51
|
+
:must_pass=>
|
52
|
+
[{:test=>"kind_of? Numeric",
|
53
|
+
:explanation=>
|
54
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}]},
|
55
|
+
:fprim=>
|
56
|
+
{:help=>"2.22 !-1/n (dn/drho)",
|
57
|
+
:include_conditions=>"true",
|
58
|
+
:description=>"2.22 !-1/n (dn/drho)",
|
59
|
+
:tests=>["Tst::FLOAT"],
|
60
|
+
:autoscanned_defaults=>[],
|
61
|
+
:must_pass=>
|
62
|
+
[{:test=>"kind_of? Numeric",
|
63
|
+
:explanation=>
|
64
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}]},
|
65
|
+
:uprim=>
|
66
|
+
{:help=>"?",
|
67
|
+
:include_conditions=>"true",
|
68
|
+
:description=>"?",
|
69
|
+
:tests=>["Tst::FLOAT"],
|
70
|
+
:autoscanned_defaults=>[],
|
71
|
+
:must_pass=>
|
72
|
+
[{:test=>"kind_of? Numeric",
|
73
|
+
:explanation=>
|
74
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}]},
|
75
|
+
:vnewk=>
|
76
|
+
{:help=>"1.e-2 !collisionality parameter",
|
77
|
+
:include_conditions=>"true",
|
78
|
+
:description=>"1.e-2 !collisionality parameter",
|
79
|
+
:tests=>["Tst::FLOAT"],
|
80
|
+
:autoscanned_defaults=>[],
|
81
|
+
:must_pass=>
|
82
|
+
[{:test=>"kind_of? Numeric",
|
83
|
+
:explanation=>
|
84
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}]},
|
85
|
+
:type=>
|
86
|
+
{:help=>"'ion' Thermal ion species ",
|
87
|
+
:include_conditions=>"true",
|
88
|
+
:description=>"'ion' Thermal ion species ",
|
89
|
+
:tests=>["Tst::STRING"],
|
90
|
+
:autoscanned_defaults=>[],
|
91
|
+
:must_pass=>
|
92
|
+
[{:test=>"kind_of? String",
|
93
|
+
:explanation=>"This variable must be a string."}]},
|
94
|
+
:dens0=>
|
95
|
+
{:should_include=>"true",
|
96
|
+
:description=>nil,
|
97
|
+
:help=>nil,
|
98
|
+
:tests=>["Tst::FLOAT"],
|
99
|
+
:gs2_name=>:dens0,
|
100
|
+
:must_pass=>
|
101
|
+
{:test=>"kind_of? Numeric",
|
102
|
+
:explanation=>
|
103
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."},
|
104
|
+
:autoscanned_defaults=>[1.0]},
|
105
|
+
:u0=>
|
106
|
+
{:should_include=>"true",
|
107
|
+
:description=>nil,
|
108
|
+
:help=>nil,
|
109
|
+
:tests=>["Tst::FLOAT"],
|
110
|
+
:gs2_name=>:u0,
|
111
|
+
:must_pass=>
|
112
|
+
{:test=>"kind_of? Numeric",
|
113
|
+
:explanation=>
|
114
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."},
|
115
|
+
:autoscanned_defaults=>[1.0]},
|
116
|
+
:uprim2=>
|
117
|
+
{:should_include=>"true",
|
118
|
+
:description=>nil,
|
119
|
+
:help=>nil,
|
120
|
+
:tests=>["Tst::FLOAT"],
|
121
|
+
:gs2_name=>:uprim2,
|
122
|
+
:must_pass=>
|
123
|
+
{:test=>"kind_of? Numeric",
|
124
|
+
:explanation=>
|
125
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."},
|
126
|
+
:autoscanned_defaults=>[0.0]},
|
127
|
+
:nustar=>
|
128
|
+
{:should_include=>"true",
|
129
|
+
:description=>nil,
|
130
|
+
:help=>nil,
|
131
|
+
:tests=>["Tst::FLOAT"],
|
132
|
+
:gs2_name=>:nustar,
|
133
|
+
:must_pass=>
|
134
|
+
{:test=>"kind_of? Numeric",
|
135
|
+
:explanation=>
|
136
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."},
|
137
|
+
:autoscanned_defaults=>[-1.0]},
|
138
|
+
:nu=>
|
139
|
+
{:should_include=>"true",
|
140
|
+
:description=>nil,
|
141
|
+
:help=>nil,
|
142
|
+
:tests=>["Tst::FLOAT"],
|
143
|
+
:gs2_name=>:nu,
|
144
|
+
:must_pass=>
|
145
|
+
{:test=>"kind_of? Numeric",
|
146
|
+
:explanation=>
|
147
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."},
|
148
|
+
:autoscanned_defaults=>[-1.0]},
|
149
|
+
:nu_h=>
|
150
|
+
{:should_include=>"true",
|
151
|
+
:description=>nil,
|
152
|
+
:help=>nil,
|
153
|
+
:tests=>["Tst::FLOAT"],
|
154
|
+
:gs2_name=>:nu_h,
|
155
|
+
:must_pass=>
|
156
|
+
{:test=>"kind_of? Numeric",
|
157
|
+
:explanation=>
|
158
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."},
|
159
|
+
:autoscanned_defaults=>[0.0]},
|
160
|
+
:tperp0=>
|
161
|
+
{:should_include=>"true",
|
162
|
+
:description=>nil,
|
163
|
+
:help=>nil,
|
164
|
+
:tests=>["Tst::FLOAT"],
|
165
|
+
:gs2_name=>:tperp0,
|
166
|
+
:must_pass=>
|
167
|
+
{:test=>"kind_of? Numeric",
|
168
|
+
:explanation=>
|
169
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."},
|
170
|
+
:autoscanned_defaults=>[0.0]},
|
171
|
+
:tpar0=>
|
172
|
+
{:should_include=>"true",
|
173
|
+
:description=>nil,
|
174
|
+
:help=>nil,
|
175
|
+
:tests=>["Tst::FLOAT"],
|
176
|
+
:gs2_name=>:tpar0,
|
177
|
+
:must_pass=>
|
178
|
+
{:test=>"kind_of? Numeric",
|
179
|
+
:explanation=>
|
180
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."},
|
181
|
+
:autoscanned_defaults=>[0.0]}}},
|
182
|
+
:dist_fn_species_knobs=>
|
183
|
+
{:description=>"",
|
184
|
+
:include_conditions=>"true",
|
185
|
+
:variables=>
|
186
|
+
{:fexpr=>
|
187
|
+
{:help=>
|
188
|
+
"0.5 !Temporal implicitness parameter. Recommended value: 0.48",
|
189
|
+
:include_conditions=>"true",
|
190
|
+
:description=>
|
191
|
+
"0.5 !Temporal implicitness parameter. Recommended value: 0.48",
|
192
|
+
:tests=>["Tst::FLOAT"],
|
193
|
+
:autoscanned_defaults=>[],
|
194
|
+
:must_pass=>
|
195
|
+
[{:test=>"kind_of? Numeric",
|
196
|
+
:explanation=>
|
197
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}]},
|
198
|
+
:fexpi=>
|
199
|
+
{:help=>nil,
|
200
|
+
:include_conditions=>"true",
|
201
|
+
:description=>nil,
|
202
|
+
:tests=>["Tst::FLOAT"],
|
203
|
+
:autoscanned_defaults=>[],
|
204
|
+
:must_pass=>
|
205
|
+
[{:test=>"kind_of? Numeric",
|
206
|
+
:explanation=>
|
207
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}]},
|
208
|
+
:bakdif=>
|
209
|
+
{:help=>"0.0 !Spatial implicitness parameter. Recommended value: 0.05",
|
210
|
+
:include_conditions=>"true",
|
211
|
+
:description=>
|
212
|
+
"0.0 !Spatial implicitness parameter. Recommended value: 0.05",
|
213
|
+
:tests=>["Tst::FLOAT"],
|
214
|
+
:autoscanned_defaults=>[],
|
215
|
+
:must_pass=>
|
216
|
+
[{:test=>"kind_of? Numeric",
|
217
|
+
:explanation=>
|
218
|
+
"This variable must be a floating point number (an integer is also acceptable: it will be converted into a floating point number)."}]},
|
219
|
+
:bd_exp=>
|
220
|
+
{:should_include=>"true",
|
221
|
+
:description=>nil,
|
222
|
+
:help=>nil,
|
223
|
+
:tests=>["Tst::INT"],
|
224
|
+
:gs2_name=>:bd_exp,
|
225
|
+
:must_pass=>
|
226
|
+
{:test=>"kind_of? Integer",
|
227
|
+
:explanation=>"This variable must be an integer."},
|
228
|
+
:autoscanned_defaults=>["bd_exp_out"]}}}}
|
@@ -0,0 +1,231 @@
|
|
1
|
+
class CodeRunner
|
2
|
+
class Gs2
|
3
|
+
|
4
|
+
# See TestGs2
|
5
|
+
|
6
|
+
def self.test_gs2(*args)
|
7
|
+
TestGs2.test_gs2(*args)
|
8
|
+
end
|
9
|
+
|
10
|
+
# = Gs2 Test Suite
|
11
|
+
# This class is designed to run a set of functional tests to test the GS2 source. It is not a test suite for GS2crmod, the GS2 CodeRunner module. It takes all the input files from the folder <tt>test_cases</tt>, runs them and checks that they give the same output as the standard case. Only the NetCDF file from the standard case should be included, and should have the same name as the test case input file.
|
12
|
+
|
13
|
+
module TestGs2
|
14
|
+
|
15
|
+
|
16
|
+
# The folder where all the test files are stored.
|
17
|
+
|
18
|
+
TEST_FOLDER = Dir.pwd #File.dirname(__FILE__) + "../test_cases"
|
19
|
+
|
20
|
+
|
21
|
+
# Give the standardised name of the test_results folder, given the name of the test case input file
|
22
|
+
|
23
|
+
def self.results_folder(input_file)
|
24
|
+
'test_results/' + input_file.sub(/\.in$/, '')
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.test_case_folder(input_file)
|
28
|
+
TEST_FOLDER + '/' + input_file.sub(/\.in$/, '')
|
29
|
+
end
|
30
|
+
|
31
|
+
# The io object all test info is written to.
|
32
|
+
|
33
|
+
TEST_OUT = STDERR
|
34
|
+
|
35
|
+
# Run all the test cases. test_case_location should be the folder test_cases in the gs2 source.
|
36
|
+
#
|
37
|
+
# Options are
|
38
|
+
# * restart (default: true) Delete all results and start again.
|
39
|
+
# * submit (default: true) Submit any runs that haven't been submitted.
|
40
|
+
# * serial (default: true) Wait till one test run has finished before starting another
|
41
|
+
|
42
|
+
def self.test_gs2(test_case_location, options={})
|
43
|
+
Gs2.send(:include, self)
|
44
|
+
test_case_location.sub!(/~/, ENV['HOME'])
|
45
|
+
TEST_FOLDER.gsub!(/^.*$/, test_case_location)
|
46
|
+
raise "The first argument should be the test_cases folder" unless File.basename(TEST_FOLDER) == "test_cases"
|
47
|
+
@tests_failed = {}
|
48
|
+
|
49
|
+
|
50
|
+
serial = true unless ["false", false].include? options[:serial]
|
51
|
+
restart = true unless ["false", false].include? options[:restart]
|
52
|
+
submit = true unless ["false", false].include? options[:submit]
|
53
|
+
|
54
|
+
|
55
|
+
@test_runner = CodeRunner.fetch_runner(Y: Dir.pwd, u: true)
|
56
|
+
@submitted_tests = @test_runner.runs.map{|run| run.run_name}
|
57
|
+
test_cases = Dir.entries(TEST_FOLDER).find_all do |entry|
|
58
|
+
# p entry
|
59
|
+
File.directory?(TEST_FOLDER + '/' + entry) and not entry =~ /^\./
|
60
|
+
end
|
61
|
+
# p test_cases
|
62
|
+
|
63
|
+
if restart
|
64
|
+
FileUtils.rm_r 'test_results' if FileTest.exist? 'test_results'
|
65
|
+
FileUtils.makedirs 'test_results'
|
66
|
+
end
|
67
|
+
|
68
|
+
# Submit the tests
|
69
|
+
if submit
|
70
|
+
test_cases.each do |test_case|
|
71
|
+
next if FileTest.exist? results_folder(test_case)
|
72
|
+
submit_run(test_case)
|
73
|
+
run_tests if serial
|
74
|
+
end
|
75
|
+
end
|
76
|
+
run_tests
|
77
|
+
|
78
|
+
if @tests_failed.size == 0
|
79
|
+
TEST_OUT.puts "All Tests Completed Successfully"
|
80
|
+
eputs "All Tests Completed Successfully" unless TEST_OUT == STDERR
|
81
|
+
else
|
82
|
+
eputs "Tests Were Failed"
|
83
|
+
@tests_failed.each do |name, hash|
|
84
|
+
sep = "----------------------------------------------"
|
85
|
+
TEST_OUT.puts '', sep, " Test Failed", sep
|
86
|
+
TEST_OUT.puts "Name: #{name}"
|
87
|
+
TEST_OUT.puts "Description: \n#{hash[:description]}", ''
|
88
|
+
TEST_OUT.puts "This test failed on these checks: #{hash[:checks_failed]}", ''
|
89
|
+
TEST_OUT.puts sep, ''
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
# Check to see which run has completed and run tests for those runs.
|
96
|
+
|
97
|
+
def self.run_tests
|
98
|
+
eputs "Waiting for runs to complete"
|
99
|
+
loop do
|
100
|
+
break if @submitted_tests.size ==0
|
101
|
+
@test_runner.update(false)
|
102
|
+
i = 0
|
103
|
+
loop do
|
104
|
+
tst = @submitted_tests[0]
|
105
|
+
run = @test_runner.runs.find{|run| run.run_name == tst}
|
106
|
+
if [:Complete, :Failed].include? run.status
|
107
|
+
run_checks run
|
108
|
+
@submitted_tests.delete(tst)
|
109
|
+
end
|
110
|
+
i += 1
|
111
|
+
break if i >= @submitted_tests.size
|
112
|
+
end
|
113
|
+
sleep 3
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
# Run the test case with the given input file.
|
119
|
+
|
120
|
+
def self.submit_run(test_case)
|
121
|
+
|
122
|
+
dir = results_folder(test_case)
|
123
|
+
input_text = File.read("#{test_case_folder(test_case)}/#{test_case}.in")
|
124
|
+
|
125
|
+
description = input_text.scan(Regexp.new("#{/^\s*!\s*description\s*=\s* /}(#{Regexp.quoted_string})")).flatten[0]
|
126
|
+
(eputs "----Rejecting '#{file}', no description provided or description is not in the correct format: description = \" description \"";return) unless description
|
127
|
+
run = Gs2.new(@test_runner)
|
128
|
+
|
129
|
+
# This cryptic statement updates the run parameters from the input file
|
130
|
+
run.instance_eval(
|
131
|
+
Gs2.defaults_file_text_from_input_file("#{test_case_folder(test_case)}/#{test_case}.in"))
|
132
|
+
|
133
|
+
run.run_name = test_case
|
134
|
+
run.instance_variable_set(:@dir_name, dir)
|
135
|
+
@test_runner.test_submission = true
|
136
|
+
@test_runner.submit(run)
|
137
|
+
|
138
|
+
other_files = Dir.entries(test_case_folder(test_case)).find_all do |f|
|
139
|
+
not (f =~ /\.in/ or f =~ /\.out\.nc/ or f =~ /\.svn/ or [".", ".."].include? f)
|
140
|
+
end
|
141
|
+
other_files.each do |f|
|
142
|
+
# p f
|
143
|
+
FileUtils.cp(test_case_folder(test_case)+'/'+f, results_folder(test_case)+'/'+f)
|
144
|
+
end
|
145
|
+
|
146
|
+
@test_runner.test_submission = false
|
147
|
+
@test_runner.submit(run)
|
148
|
+
@submitted_tests.push run.run_name
|
149
|
+
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.run_checks(run)
|
154
|
+
checks_failed = []
|
155
|
+
|
156
|
+
input_text = File.read("#{test_case_folder(run.run_name)}/#{run.run_name}.in")
|
157
|
+
description = input_text.scan(Regexp.new("#{/^\s*!\s*description\s*=\s* /}(#{Regexp.quoted_string})")).flatten[0]
|
158
|
+
description.gsub!(/(.{25,45} |.{45})/){"#$1\n"} if description
|
159
|
+
if input_text =~ Regexp.new("#{/^\s*!\s*custom_checks\s*=\s* /}(#{Regexp.properly_nested("\\[", "\\]", false)})")
|
160
|
+
custom_checks = eval($1)
|
161
|
+
custom_checks.each{|check| checks_failed.push check unless run.run_check check}
|
162
|
+
else
|
163
|
+
checks_failed.push :standard unless run.run_check :standard
|
164
|
+
end
|
165
|
+
unless checks_failed.size == 0
|
166
|
+
@tests_failed[run.run_name] = {checks_failed: checks_failed, description: description}
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
# Relative error which differences cannot exceed in the standard case
|
171
|
+
|
172
|
+
TOLERANCE = 1.0e-10
|
173
|
+
|
174
|
+
# A list of variables that are allowed to be different in the standard test
|
175
|
+
|
176
|
+
EXCLUDED_VARIABLES = ['input_file']
|
177
|
+
|
178
|
+
# Check the results against standard cases using the checks described here. Any custom tests should be implemented here!
|
179
|
+
|
180
|
+
def run_check(check)
|
181
|
+
netcdf_standard_case = NumRu::NetCDF.open(TestGs2.test_case_folder(@run_name) + '/' + @run_name + '.out.nc')
|
182
|
+
Dir.chdir(@directory) do
|
183
|
+
case check
|
184
|
+
when :standard
|
185
|
+
netcdf = NumRu::NetCDF.open(@run_name + '.out.nc')
|
186
|
+
netcdf.vars.map{|v| v.name}.each do |v|
|
187
|
+
unless netcdf_standard_case.var(v)
|
188
|
+
TEST_OUT.puts "Warning: variable '#{v}' is missing from the test case netcdf output for '#@run_name'. Suggest updating the test case netcdf file. This is not a GS2 fault."
|
189
|
+
end
|
190
|
+
end
|
191
|
+
netcdf_standard_case.vars.map{|v| v.name}.each do |v|
|
192
|
+
next if EXCLUDED_VARIABLES.include? v
|
193
|
+
begin
|
194
|
+
unless netcdf.var(v)
|
195
|
+
TEST_OUT.puts "Error: Variable #{v} is missing from the netcdf output for #@run_name"
|
196
|
+
return false
|
197
|
+
end
|
198
|
+
|
199
|
+
narray = netcdf.var(v).get
|
200
|
+
standard_narray = netcdf_standard_case.var(v).get
|
201
|
+
|
202
|
+
if standard_narray.abs.max < TOLERANCE
|
203
|
+
if narray.abs.max < TOLERANCE
|
204
|
+
next
|
205
|
+
else
|
206
|
+
TEST_OUT.puts "Error: Variable '#{v}' has failed check in '#@run_name'"
|
207
|
+
return false
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
|
212
|
+
difference = narray - standard_narray
|
213
|
+
return false unless difference.abs.max / standard_narray.abs.max < TOLERANCE
|
214
|
+
# ep 'var', difference.abs.max
|
215
|
+
rescue => err
|
216
|
+
TEST_OUT.puts "Error: #{err}"
|
217
|
+
TEST_OUT.puts "Error: Variable '#{v}' has failed check in '#@run_name'"
|
218
|
+
return false
|
219
|
+
end
|
220
|
+
end
|
221
|
+
return true
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
|
227
|
+
end #module TestGs2
|
228
|
+
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
data/lib/gs2crmod.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require('gs2crmod_ext')
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'gs2crmod'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gs2crmod
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Edmund Highcock
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: coderunner
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.11.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.11.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: shoulda
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rdoc
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.12'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.12'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: bundler
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>'
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.0.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>'
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.0.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: jeweler
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.8.4
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.8.4
|
94
|
+
description: GS2 is a gyrokinetic flux tube initial value turbulence code which can
|
95
|
+
be used for fusion or astrophysical plasmas. CodeRunner is a framework for the automated
|
96
|
+
running and analysis of large simulations. This module allows GS2 (and its sister
|
97
|
+
code AstroGK) to harness the power of the CodeRunner framework.
|
98
|
+
email: edmundhighcock@sourceforge.net
|
99
|
+
executables: []
|
100
|
+
extensions:
|
101
|
+
- ext/extconf.rb
|
102
|
+
extra_rdoc_files:
|
103
|
+
- LICENSE.txt
|
104
|
+
- README.md
|
105
|
+
- README.rdoc
|
106
|
+
files:
|
107
|
+
- .document
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- README.rdoc
|
112
|
+
- Rakefile
|
113
|
+
- VERSION
|
114
|
+
- ext/extconf.rb
|
115
|
+
- ext/gs2crmod_ext.c
|
116
|
+
- gs2crmod.gemspec
|
117
|
+
- include/gs2crmod_ext.h
|
118
|
+
- lib/gs2crmod.rb
|
119
|
+
- lib/gs2crmod/astrogk.rb
|
120
|
+
- lib/gs2crmod/astrogk/astrogk.rb
|
121
|
+
- lib/gs2crmod/astrogk/calculations.rb
|
122
|
+
- lib/gs2crmod/astrogk/check_convergence.rb
|
123
|
+
- lib/gs2crmod/astrogk/deleted_variables.rb
|
124
|
+
- lib/gs2crmod/astrogk/graphs.rb
|
125
|
+
- lib/gs2crmod/astrogk/gsl_data.rb
|
126
|
+
- lib/gs2crmod/astrogk/gsl_tools.rb
|
127
|
+
- lib/gs2crmod/astrogk/ingen.rb
|
128
|
+
- lib/gs2crmod/astrogk/input_file_tools.rb
|
129
|
+
- lib/gs2crmod/astrogk/namelist_tools.rb
|
130
|
+
- lib/gs2crmod/astrogk/namelists.rb
|
131
|
+
- lib/gs2crmod/astrogk/properties.rb
|
132
|
+
- lib/gs2crmod/astrogk/species_dependent_namelists.rb
|
133
|
+
- lib/gs2crmod/astrogk/test_gs2.rb
|
134
|
+
- lib/gs2crmod/calculations.rb
|
135
|
+
- lib/gs2crmod/check_convergence.rb
|
136
|
+
- lib/gs2crmod/deleted_variables.rb
|
137
|
+
- lib/gs2crmod/graphs.rb
|
138
|
+
- lib/gs2crmod/graphs_rdoc.rb
|
139
|
+
- lib/gs2crmod/gs2.rb
|
140
|
+
- lib/gs2crmod/gsl_data.rb
|
141
|
+
- lib/gs2crmod/gsl_data_3d.rb
|
142
|
+
- lib/gs2crmod/gsl_tools.rb
|
143
|
+
- lib/gs2crmod/ingen.rb
|
144
|
+
- lib/gs2crmod/namelists.rb
|
145
|
+
- lib/gs2crmod/properties.rb
|
146
|
+
- lib/gs2crmod/species_dependent_namelists.rb
|
147
|
+
- lib/gs2crmod/test_gs2.rb
|
148
|
+
- lib/gs2crmod_extension.rb
|
149
|
+
- test/helper.rb
|
150
|
+
- test/test_gs2crmod.rb
|
151
|
+
homepage: http://gs2crmod.sourceforge.net
|
152
|
+
licenses:
|
153
|
+
- GSLv3
|
154
|
+
post_install_message:
|
155
|
+
rdoc_options: []
|
156
|
+
require_paths:
|
157
|
+
- lib
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
160
|
+
requirements:
|
161
|
+
- - ! '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: 1.9.1
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
none: false
|
166
|
+
requirements:
|
167
|
+
- - ! '>='
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
requirements: []
|
171
|
+
rubyforge_project:
|
172
|
+
rubygems_version: 1.8.24
|
173
|
+
signing_key:
|
174
|
+
specification_version: 3
|
175
|
+
summary: Module to allow CodeRunner to run and analyse the GS2 and AstroGK codes.
|
176
|
+
test_files: []
|