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,179 @@
|
|
1
|
+
class CodeRunner
|
2
|
+
class Gs2
|
3
|
+
|
4
|
+
|
5
|
+
def check_converged
|
6
|
+
raise CRFatal.new("It is strongly recommended that you do not use the use_large_cache option (-U) while checking convergence. Doing so will lead to unpredictable results.") if @runner.use_large_cache
|
7
|
+
Dir.chdir(@directory) do
|
8
|
+
logf(:check_converged)
|
9
|
+
return if @checked_converged and not @runner.recalc_all
|
10
|
+
|
11
|
+
log('@runner.class:', @runner.class)
|
12
|
+
unless @runner.current_request == :check_converged
|
13
|
+
@runner.requests.push :check_converged
|
14
|
+
log 'check_converged requested recall'
|
15
|
+
logi '@runner.requests', @runner.requests
|
16
|
+
logi('@runner.object_id', @runner.object_id)
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
return unless @status == :Complete
|
21
|
+
eputs @run_name
|
22
|
+
eputs @checked_converged = true
|
23
|
+
log("finding similar resolutions")
|
24
|
+
@runner.generate_combined_ids(:real)
|
25
|
+
case @grid_option
|
26
|
+
when "box"
|
27
|
+
@similar_resolutions = @runner.similar_runs([:nx, :ny, :ntheta, :negrid, :naky, :ngauss, :nperiod, :delt, :jtwist], self)
|
28
|
+
when "single"
|
29
|
+
@similar_resolutions = @runner.similar_runs([:ntheta, :negrid, :naky, :ngauss, :nperiod], self)
|
30
|
+
else
|
31
|
+
raise CRFatal.new("Unknown grid option - can't get similar runs")
|
32
|
+
end
|
33
|
+
|
34
|
+
logi(@similar_resolutions)
|
35
|
+
unless @similar_resolutions[1]
|
36
|
+
eputs @run_name
|
37
|
+
@converged = Feedback.get_boolean("This is is the biggest job with these params. Do you want to say it is converged?")
|
38
|
+
return
|
39
|
+
end
|
40
|
+
@similar_resolutions.sort! do |id1, id2|
|
41
|
+
run1 = @runner.run_list[id1]
|
42
|
+
run2 = @runner.run_list[id2]
|
43
|
+
if @grid_option == "box" and @nonlinear_mode == "off"
|
44
|
+
(run1.jtwist*run1.nx*run1.negrid*run1.ngauss*run1.ntheta*run1.delt <=> run2.jtwist*run2.nx*run2.negrid*run2.ngauss*run2.ntheta*run2.delt)
|
45
|
+
elsif @grid_option == "single" and @nonlinear_mode == "off"
|
46
|
+
log("using nperiod: #{run1.nperiod}; #{run2.nperiod}")
|
47
|
+
run1.negrid*run1.ngauss*run1.ntheta*run1.nperiod <=> run2.negrid*run2.ngauss*run2.ntheta*run2.nperiod
|
48
|
+
|
49
|
+
elsif @naky
|
50
|
+
|
51
|
+
run1.nx*run1.negrid*run1.ngauss*run1.ntheta*run1.naky <=> run2.nx*run2.negrid*run2.ngauss*run2.ntheta*run2.naky
|
52
|
+
|
53
|
+
else
|
54
|
+
run1.nx*run1.negrid*run1.ngauss*run1.ntheta*run1.ny <=> run2.nx*run2.negrid*run2.ngauss*run2.ntheta*run2.ny
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
# eputs @similar_resolutions
|
61
|
+
|
62
|
+
log("finding my place")
|
63
|
+
my_place = @similar_resolutions.index(@id);
|
64
|
+
# eputs my_place; gets
|
65
|
+
if my_place > 0
|
66
|
+
last_job = @runner.run_list[@similar_resolutions[my_place - 1]]
|
67
|
+
unless last_job.status == :Complete
|
68
|
+
@checked_converged = false
|
69
|
+
return
|
70
|
+
end
|
71
|
+
else
|
72
|
+
@converged = false
|
73
|
+
return
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
log("Checking overall convergence")
|
78
|
+
#graph = graphkit('phi2tot_vs_time_all_kys') + #last_job.graphkit('phi2tot_vs_time_all_kys')
|
79
|
+
#graph.gnuplot
|
80
|
+
eputs "\n \n Warning: there are no bigger jobs" unless @similar_resolutions[my_place + 1]
|
81
|
+
#@converged = Feedback.get_boolean("Is the plot converged?")
|
82
|
+
#graph.close
|
83
|
+
|
84
|
+
#(@checked_converged = true; return) unless @converged
|
85
|
+
|
86
|
+
log("Checking convergence by ky")
|
87
|
+
orn, last_job.runner = last_job.runner, nil
|
88
|
+
log('last_job', last_job.pretty_inspect)
|
89
|
+
last_job.runner = orn
|
90
|
+
# last_job.get_ky_graphs; last_job.get_eigenfunctions
|
91
|
+
# logi(last_job.ky_graphs)
|
92
|
+
catch(:quit_converge_check) do
|
93
|
+
options = {}
|
94
|
+
list(:ky).each do |index, ky|
|
95
|
+
options[:ky] = ky
|
96
|
+
next if index == 1 and @grid_option == "box"
|
97
|
+
graph = (graphkit('phi2_by_ky_vs_time', options)+last_job.graphkit('phi2_by_ky_vs_time', options))
|
98
|
+
graph.gnuplot
|
99
|
+
answer = Feedback.get_choice("Is the graph converged?", ["Yes", "No", "The whole run is converged, stop pestering me!"])
|
100
|
+
graph.close
|
101
|
+
case answer
|
102
|
+
when /No/
|
103
|
+
@converged = false
|
104
|
+
throw(:quit_converge_check)
|
105
|
+
when /stop/
|
106
|
+
@converged = true
|
107
|
+
throw(:quit_converge_check)
|
108
|
+
when /Yes/
|
109
|
+
@converged = true
|
110
|
+
end
|
111
|
+
cgraph = lgraph = 'efnnormmag'
|
112
|
+
graph = (graphkit('efnnormmag', options)+last_job.graphkit('efnnormmag', options))
|
113
|
+
|
114
|
+
# graph.gnuplot
|
115
|
+
|
116
|
+
loop do
|
117
|
+
graph.gnuplot
|
118
|
+
answer = Feedback.get_choice('Is the graph converged?', ['Yes', 'No', 'The whole run is converged, stop pestering me!', 'Show me the magnitude of the eigenfunctions', 'Show me the real part of the eigenfunctions again', 'Normalise the eigenfunctions', 'Denormalise the eigenfunctions', 'Reverse the axis of the current run', 'Flip the current run', 'Toggle xrange'])
|
119
|
+
graph.close
|
120
|
+
case answer
|
121
|
+
when /^Yes$/
|
122
|
+
@converged = true
|
123
|
+
break
|
124
|
+
when /^No$/
|
125
|
+
@converged = false
|
126
|
+
throw(:quit_converge_check)
|
127
|
+
when /stop/
|
128
|
+
@converged = true
|
129
|
+
throw(:quit_converge_check)
|
130
|
+
when /magnitude/
|
131
|
+
log 'checking convergence using magnitude'
|
132
|
+
lgraph += 'mag'; cgraph += 'mag'
|
133
|
+
when /Normalise/
|
134
|
+
log 'normalising'
|
135
|
+
lgraph += 'norm'; cgraph += 'norm'
|
136
|
+
when /Denormalise/
|
137
|
+
log 'denormalising'
|
138
|
+
lgraph.gsub!(/norm/, ''); cgraph.gsub!(/norm/, '')
|
139
|
+
when /real/
|
140
|
+
lgraph.gsub!(/mag/, ''); cgraph.gsub!(/mag/, '')
|
141
|
+
when /Reverse/
|
142
|
+
cgraph = cgraph =~ /rev/ ? cgraph.sub!(/rev/, '') : cgraph + 'rev'
|
143
|
+
# graph = (@eigenfunctions[ky]+last_job.eigenfunctions[ky])
|
144
|
+
when /Flip/
|
145
|
+
cgraph = cgraph =~ /flip/ ? cgraph.sub!(/flip/, '') : cgraph + 'flip'
|
146
|
+
# graph = (@eigenfunctions[ky]+last_job.eigenfunctions[ky])
|
147
|
+
when /xrange/
|
148
|
+
if options[:range]
|
149
|
+
options[:range] = nil
|
150
|
+
else
|
151
|
+
options[:range] = 0
|
152
|
+
end
|
153
|
+
else
|
154
|
+
raise CRFatal.new("couldn't match choice #{answer}")
|
155
|
+
end
|
156
|
+
graph = graphkit(cgraph, options) + last_job.graphkit(lgraph, options)
|
157
|
+
log graph.title
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
end
|
162
|
+
end
|
163
|
+
@checked_converged =true
|
164
|
+
|
165
|
+
if last_job.checked_converged
|
166
|
+
last_job.ky_graphs = nil
|
167
|
+
last_job.eigenfunctions = nil
|
168
|
+
# last_job.t_list = nil
|
169
|
+
# last_job.kx_list = nil
|
170
|
+
end
|
171
|
+
|
172
|
+
# finish_processing
|
173
|
+
end
|
174
|
+
ep self
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
end
|
179
|
+
end
|