gs2crmod 0.7.3 → 0.8.0
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 +1 -1
- data/gs2crmod.gemspec +3 -1
- data/lib/gs2crmod/spectrogk/namelists.rb +2800 -0
- data/lib/gs2crmod/spectrogk.rb +150 -0
- data/test/test_gs2crmod.rb +17 -0
- metadata +3 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
##########################################
|
|
2
|
+
# = Code Runner GS2 Module
|
|
3
|
+
##########################################
|
|
4
|
+
#
|
|
5
|
+
# Authors: Edmund Highcock
|
|
6
|
+
# Copyright: 2009 Edmund Highcock
|
|
7
|
+
#
|
|
8
|
+
# This is free software released under the GPL v3
|
|
9
|
+
#
|
|
10
|
+
# This module allows easy running of the plasma turbulence simulation code gs2 using Code Runner, by automatically organising, naming and submitting runs, and analysing the run data.
|
|
11
|
+
#
|
|
12
|
+
# See Code Runner documentation, or documentation for individual methods.
|
|
13
|
+
#
|
|
14
|
+
# Notes
|
|
15
|
+
#
|
|
16
|
+
# index variables, e.g. kx_index, ky_index etc always refer to the 1-based Fortran index, to keep correspondance with the gs2 indices. Element variables, e.g. kx_element, always refer to the 0-based C/ruby index
|
|
17
|
+
#
|
|
18
|
+
# raw NumRu::NetCDF grids are in Fortran row-major order. This means that when you access grids using the NetCDF function NetCDF#get, you must specify the indices in fortran order (but 0-based!). The NetCDF#get function then returns a C-like NArray with the indices in the opposite order. You can convert this to a Ruby Array using the method NArray#to_a (the indices will still be in the same order).
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
#
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class CodeRunner
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#CodeRunner.setup_run_class('g2') # Astrogk Inherits from GS2
|
|
29
|
+
|
|
30
|
+
# This is a customised subclass of CodeRunner::Run which allows CodeRunner to submit and analyse simulations from the gyrokinetic flux tube code AstroGK, which is principally used for simulating plasmas in magnetic confinement fusion.
|
|
31
|
+
#
|
|
32
|
+
# It performs two distinct roles: submitting simulations and analysing the data.
|
|
33
|
+
#
|
|
34
|
+
# = Submitting Simulations
|
|
35
|
+
#
|
|
36
|
+
# This principally involves generating the input file, which is a very nontrivial task. In order to do this, it maintains a complete record of every possible input parameter for AstroGK, as well as what datatype that parameter is, and sometimes what values it is allowed to take. This allows that not only to generate the input file, but to check that the input file makes sense. However, although generating the input file works beautifully, the set of sanity checks that it makes is not exhaustive: intelligent use is still required!
|
|
37
|
+
#
|
|
38
|
+
# In tandem with this, it maintains a whole set of tools for manipulating its database of input parameters. This includes updating their allowed values and also editing and accessing help for every input parameter.
|
|
39
|
+
#
|
|
40
|
+
# = Analysing Simulations
|
|
41
|
+
#
|
|
42
|
+
# The amount of analysis possible on AstroGK data is enormous, and CodeRunner hasn't got close to getting there. What it can do is:
|
|
43
|
+
#
|
|
44
|
+
# * Check if the run is complete by comparing the number of completed timesteps against nstep
|
|
45
|
+
# * Calculate growth rates for linear runs.
|
|
46
|
+
# * Check if non-linear runs have saturated and calculate fluxes for those runs.
|
|
47
|
+
# * Automatically plot a huge variety of different graphs, ranging from simple plots of heat flux versus time to three-dimensional plots of the spectrum and potential.
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
CodeRunner.setup_run_class('gs2', modlet: 'astrogk') # SpectroGK Inherits from AstroGK
|
|
51
|
+
|
|
52
|
+
class Gs2::Spectrogk < Gs2::Astrogk
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# Include the other files
|
|
58
|
+
@code_module_folder = folder = File.dirname(File.expand_path(__FILE__)) + '/spectrogk' # i.e. the directory this file is in
|
|
59
|
+
setup_namelists(folder)
|
|
60
|
+
#require folder + '/graphs.rb'
|
|
61
|
+
## require folder + '/namelist_tools.rb'
|
|
62
|
+
## require folder + '/input_file_tools.rb'
|
|
63
|
+
#require folder + '/gsl_data.rb'
|
|
64
|
+
#require folder + '/check_convergence.rb'
|
|
65
|
+
#require folder + '/calculations.rb'
|
|
66
|
+
#require folder + '/ingen.rb'
|
|
67
|
+
#require folder + '/properties.rb'
|
|
68
|
+
#require folder + '/test_gs2.rb'
|
|
69
|
+
|
|
70
|
+
NaN = GSL::NAN
|
|
71
|
+
# GSL::Neg
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
################################################
|
|
78
|
+
# Quantities that are calculated or determined by CodeRunner
|
|
79
|
+
# after the simulation has ended, i.e. quantities
|
|
80
|
+
# that are not available from the AstroGK output files.
|
|
81
|
+
################################################
|
|
82
|
+
# Get GS2 results and add any
|
|
83
|
+
# astrogk ones (currently empty)
|
|
84
|
+
|
|
85
|
+
@results = rcp.results + []
|
|
86
|
+
|
|
87
|
+
###############################################
|
|
88
|
+
# Other useful information about the run
|
|
89
|
+
###############################################
|
|
90
|
+
|
|
91
|
+
@astrogk_run_info = rcp.gs2_run_info + []
|
|
92
|
+
|
|
93
|
+
@run_info = @astrogk_run_info.dup
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@naming_pars = rcp.naming_pars + []
|
|
98
|
+
|
|
99
|
+
@code_long = "SpectroGK Astrophysical Full Spectral Gyrokinetic Code"
|
|
100
|
+
|
|
101
|
+
@excluded_sub_folders =[]
|
|
102
|
+
|
|
103
|
+
def input_file_header
|
|
104
|
+
<<EOF
|
|
105
|
+
!==============================================================================
|
|
106
|
+
! SpectroGK INPUT FILE automatically generated by CodeRunner
|
|
107
|
+
!==============================================================================
|
|
108
|
+
!
|
|
109
|
+
! SpectroGK is a gyrokinetic flux tube initial value turbulence code
|
|
110
|
+
! which can be used for fusion or astrophysical plasmas. It is explicit
|
|
111
|
+
! and treats velocity spectrally.
|
|
112
|
+
!
|
|
113
|
+
!
|
|
114
|
+
! See http://gyrokinetics.sourceforge.net
|
|
115
|
+
!
|
|
116
|
+
! CodeRunner is a framework for the automated running and analysis
|
|
117
|
+
! of large simulations.
|
|
118
|
+
!
|
|
119
|
+
! See http://coderunner.sourceforge.net
|
|
120
|
+
! by CodeRunner version #{CodeRunner::CODE_RUNNER_VERSION.to_s}
|
|
121
|
+
!
|
|
122
|
+
!==============================================================================
|
|
123
|
+
|
|
124
|
+
EOF
|
|
125
|
+
end
|
|
126
|
+
def self.defaults_file_header
|
|
127
|
+
<<EOF1
|
|
128
|
+
######################################################################
|
|
129
|
+
# Automatically generated defaults file for SpectroGK CodeRunner module#
|
|
130
|
+
# #
|
|
131
|
+
# This defaults file specifies a set of defaults for SpectroGK which are#
|
|
132
|
+
# used by CodeRunner to set up and run GS2 simulations. #
|
|
133
|
+
# #
|
|
134
|
+
# Created #{Time.now.to_s} #
|
|
135
|
+
# #
|
|
136
|
+
######################################################################
|
|
137
|
+
|
|
138
|
+
@defaults_file_description = ""
|
|
139
|
+
EOF1
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
@source_code_subfolders = ['utils']
|
|
143
|
+
|
|
144
|
+
folder = File.dirname(File.expand_path(__FILE__)) # i.e. the directory this file is in
|
|
145
|
+
|
|
146
|
+
end # class SpectroGK
|
|
147
|
+
|
|
148
|
+
end # class CodeRunner
|
|
149
|
+
|
|
150
|
+
|
data/test/test_gs2crmod.rb
CHANGED
|
@@ -202,3 +202,20 @@ else
|
|
|
202
202
|
puts "\n************************************\nWarning: agk submission tests not run. Please specify the evironment variable AGK_EXEC (the path to the agk executable) if you wish to test submission.\n************************************\n"
|
|
203
203
|
sleep 0.1
|
|
204
204
|
end
|
|
205
|
+
|
|
206
|
+
class TestBasicsSpectroGK < Test::Unit::TestCase
|
|
207
|
+
def setup
|
|
208
|
+
@runner = CodeRunner.fetch_runner(Y: 'test/slab_itg', C: 'gs2', X: '/dev/null', m: 'spectrogk')
|
|
209
|
+
end
|
|
210
|
+
def teardown
|
|
211
|
+
FileUtils.rm('test/slab_itg/.code_runner_script_defaults.rb')
|
|
212
|
+
#FileUtils.rm('test/slab_itg/.CODE_RUNNER_TEMP_RUN_LIST_CACHE')
|
|
213
|
+
end
|
|
214
|
+
def test_basics
|
|
215
|
+
assert_equal(@runner.run_class, CodeRunner::Gs2::Spectrogk)
|
|
216
|
+
end
|
|
217
|
+
def test_variables
|
|
218
|
+
assert_equal(Hash, @runner.run_class.rcp.namelists.class)
|
|
219
|
+
assert_equal(@runner.run_class.rcp.namelists[:layouts_knobs].class, Hash)
|
|
220
|
+
end
|
|
221
|
+
end
|
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.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -146,6 +146,8 @@ files:
|
|
|
146
146
|
- lib/gs2crmod/namelists.rb
|
|
147
147
|
- lib/gs2crmod/properties.rb
|
|
148
148
|
- lib/gs2crmod/species_dependent_namelists.rb
|
|
149
|
+
- lib/gs2crmod/spectrogk.rb
|
|
150
|
+
- lib/gs2crmod/spectrogk/namelists.rb
|
|
149
151
|
- lib/gs2crmod/test_gs2.rb
|
|
150
152
|
- lib/gs2crmod_extension.rb
|
|
151
153
|
- test/agk_slab_itg_low_kperp.in
|