veritascrmod 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2455690589f577c7c6dfed5f3705f5b91f85bdee
4
+ data.tar.gz: c03ad716e021d6c2fe0a09a0dfcbf328fc1c8668
5
+ SHA512:
6
+ metadata.gz: a53b1669ec156c676d38bd766ae3912358cf6833a6ec9689a14c1049c2aba51ef2f4f9d855a469235a3b83fdd0b4274434b36a9760393ae9feb12d98d8518012
7
+ data.tar.gz: 9b41031c0adf86536182f480f158cfab052a6865cfdb6ae190ac62cf9168e3eaaa89de418ff5bfddccbbffaf27d10da1503d896c018bd228f36409dc221a9289
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,16 @@
1
+ source "https://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ gem "coderunner", ">=1.0.0"
6
+ gem "narray"
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "shoulda", ">= 0"
12
+ gem "rdoc", "~> 3.12"
13
+ gem "bundler", "~> 1.0"
14
+ gem "juwelier", "~> 2.1.0"
15
+ gem "simplecov", ">= 0"
16
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2016 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.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = veritascrmod
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to veritascrmod
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) 2016 Edmund Highcock. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,58 @@
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 'juwelier'
15
+ Juwelier::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "veritascrmod"
18
+ gem.homepage = "http://github.com/coderunner-framework/veritascrmod"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A CodeRunner module for the Veritas Vlasov Solver}
21
+ gem.description = %Q{A CodeRunner module for the Veritas Vlasov Solver}
22
+ gem.email = "edmundhighcock@users.sourceforge.net"
23
+ gem.authors = ["Edmund Highcock"]
24
+
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Juwelier::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ Rake::TestTask.new(:sync_variables) do |test|
37
+ test.libs << 'lib' << 'sync_variables'
38
+ test.pattern = 'sync_variables/sync_variables.rb'
39
+ test.verbose = true
40
+ end
41
+
42
+ desc "Code coverage detail"
43
+ task :simplecov do
44
+ ENV['COVERAGE'] = "true"
45
+ Rake::Task['test'].execute
46
+ end
47
+
48
+ task :default => :test
49
+
50
+ require 'rdoc/task'
51
+ Rake::RDocTask.new do |rdoc|
52
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
53
+
54
+ rdoc.rdoc_dir = 'rdoc'
55
+ rdoc.title = "veritascrmod #{version}"
56
+ rdoc.rdoc_files.include('README*')
57
+ rdoc.rdoc_files.include('lib/**/*.rb')
58
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1 @@
1
+ require 'veritascrmod/veritas'
@@ -0,0 +1,43 @@
1
+ {:time=>
2
+ {:description=>"",
3
+ :should_include=>"true",
4
+ :variables=>
5
+ {:filewrite_freq=>
6
+ {:should_include=>"true",
7
+ :description=>
8
+ "The larger this number, the more often output data is written to disk.",
9
+ :help=>
10
+ "The larger this number, the more often output data is written to disk.",
11
+ :code_name=>:filewrite_freq,
12
+ :must_pass=>
13
+ [{:test=>"kind_of? Integer",
14
+ :explanation=>"This variable must be an integer."}],
15
+ :type=>:Integer}}},
16
+ :particles=>
17
+ {:description=>"",
18
+ :should_include=>"true",
19
+ :variables=>
20
+ {:np=>
21
+ {:should_include=>"true",
22
+ :description=>
23
+ "Number of velocity points for the given species.",
24
+ :help=>
25
+ "Number of velocity points for the given species.",
26
+ :code_name=>:np,
27
+ :must_pass=>
28
+ [{:test=>"kind_of? Integer",
29
+ :explanation=>"This variable must be an integer."}],
30
+ :type=>:Integer}}},
31
+ :grid=>
32
+ {:description=>"",
33
+ :should_include=>"true",
34
+ :variables=>
35
+ {:nx=>
36
+ {:should_include=>"true",
37
+ :description=>"Number of gridpoints in the x spatial dimension.",
38
+ :help=>"Number of gridpoints in the x spatial dimension.",
39
+ :code_name=>:nx,
40
+ :must_pass=>
41
+ [{:test=>"kind_of? Integer",
42
+ :explanation=>"This variable must be an integer."}],
43
+ :type=>:Integer}}}}
@@ -0,0 +1,173 @@
1
+ require 'coderunner'
2
+
3
+ class CodeRunner
4
+ # This is a customised subclass of the CodeRunner::Run class which allows CodeRunner to run and analyse the Vlasov Maxwell solver Veritas.
5
+ #
6
+ # It generates the Veritas input file, and both analyses the results and allows easy plotting of them.
7
+ class Veritas < Run::FortranNamelist
8
+
9
+ # Where this file is
10
+ @code_module_folder = File.dirname(File.expand_path(__FILE__)) # i.e. the directory this file is in
11
+
12
+ # Use the Run::FortranNamelist tools to process the variable database
13
+ setup_namelists(@code_module_folder)
14
+
15
+
16
+ ################################################
17
+ # Quantities that are read or determined by CodeRunner
18
+ # after the simulation has ended
19
+ ###################################################
20
+
21
+ @results = [
22
+ ]
23
+
24
+ @code_long="Veritas Vlasov-Maxwell Solver"
25
+
26
+ @run_info=[:time, :is_a_restart, :restart_id, :percent_complete]
27
+
28
+ @uses_mpi = true
29
+
30
+ @modlet_required = false
31
+
32
+ @naming_pars = []
33
+
34
+ # Any folders which are a number will contain the results from flux simulations.
35
+ @excluded_sub_folders = ['output']
36
+
37
+ # A hook which gets called when printing the standard run information to the screen using the status command.
38
+ def print_out_line
39
+ #p ['id', id, 'ctd', ctd]
40
+ #p rcp.results.zip(rcp.results.map{|r| send(r)})
41
+ name = @run_name
42
+ name += " (res: #@restart_id)" if @restart_id
43
+ name += " real_id: #@real_id" if @real_id
44
+ beginning = sprintf("%2d:%d %-60s %1s:%2.1f(%s) %3s%1s", @id, @job_no, name, @status.to_s[0,1], @run_time.to_f / 60.0, @nprocs.to_s, percent_complete.to_f, "%")
45
+ #if ctd and fusionQ
46
+ #beginning += sprintf("Q:%f, Pfusion:%f MW, Ti0:%f keV, Te0:%f keV, n0:%f x10^20", fusionQ, pfus, ti0, te0, ne0)
47
+ #end
48
+ #beginning += " ---#{@comment}" if @comment
49
+ beginning
50
+ end
51
+
52
+ #def self.load(dir, runner)
53
+ #run = super(dir, runner)
54
+ #grun_list = run.instance_variable_get(:@gs2_run_list)
55
+ #grun_list.values.each{|r| r.runner=runner} if grun_list.kind_of? Hash
56
+ #run
57
+ #end
58
+
59
+
60
+ # Modify new_run so that it becomes a restart of self. Adusts
61
+ # all the parameters of the new run to be equal to the parameters
62
+ # of the run that calls this function, and sets up its run name
63
+ # correctly
64
+ def restart(new_run)
65
+ (rcp.variables).each{|v| new_run.set(v, send(v)) if send(v) or new_run.send(v)}
66
+ raise "restart not implemented yet"
67
+ end
68
+ # This is a hook which gets called just before submitting a simulation. It sets up the folder and generates any necessary input files.
69
+ def generate_input_file
70
+ FileUtils.makedirs("output/rectangleData")
71
+ #@run_name += "_t"
72
+ if @restart_id
73
+ @runner.run_list[@restart_id].restart(self)
74
+ end
75
+ #if uses_ecom?
76
+ #setup_ecom
77
+ #elsif uses_chease?
78
+ #setup_chease
79
+ #end
80
+ #check_parameters
81
+ write_input_file
82
+ end
83
+
84
+
85
+
86
+
87
+
88
+
89
+ def vim_output
90
+ system "vim -Ro #{output_file} #{error_file}"
91
+ end
92
+ alias :vo :vim_output
93
+
94
+ # This command uses the infrastructure provided by Run::FortranNamelist, provided by CodeRunner itself.
95
+ def write_input_file
96
+ File.open(@run_name + ".in", 'w'){|file| file.puts input_file_text}
97
+ end
98
+
99
+ # Parameters which follow the Veritas executable, in this case just the input file.
100
+ def parameter_string
101
+ @run_name + ".in"
102
+ end
103
+
104
+ def parameter_transition
105
+ end
106
+
107
+
108
+
109
+ @source_code_subfolders = []
110
+
111
+ # This method, as its name suggests, is called whenever CodeRunner is asked to analyse a run directory. This happens if the run status is not :Complete, or if the user has specified recalc_all(-A on the command line) or reprocess_all (-a on the command line).
112
+ #
113
+ def process_directory_code_specific
114
+ get_status
115
+ end
116
+
117
+ def get_status
118
+ if @running
119
+ @status = :Running
120
+ else
121
+ @status = :Complete
122
+ end
123
+ end
124
+
125
+
126
+
127
+ def input_file_header
128
+ <<EOF
129
+ !==============================================================================
130
+ ! Veritas INPUT FILE automatically generated by CodeRunner
131
+ !==============================================================================
132
+ !
133
+ ! Veritas is a 1D continuum solver for the Vlasov-Maxwell system
134
+ !
135
+ ! See http://ft.nephy.chalmers.se/veritas/
136
+ !
137
+ ! CodeRunner is a framework for the automated running and analysis
138
+ ! of large simulations.
139
+ !
140
+ ! See http://coderunner.sourceforge.net
141
+ !
142
+ ! Created #{Time.now.to_s}
143
+ ! by CodeRunner version #{CodeRunner::CODE_RUNNER_VERSION.to_s}
144
+ !
145
+ !==============================================================================
146
+
147
+ EOF
148
+ end
149
+ def self.defaults_file_header
150
+ <<EOF1
151
+ ############################################################################
152
+ # #
153
+ # Automatically generated defaults file for the Veritas CodeRunner module #
154
+ # #
155
+ # This defaults file specifies a set of defaults for Veritas which are #
156
+ # used by CodeRunner to set up and run Veritas simulations. #
157
+ # #
158
+ ############################################################################
159
+
160
+ # Created: #{Time.now.to_s}
161
+
162
+ @defaults_file_description = ""
163
+ EOF1
164
+ end
165
+
166
+
167
+ def input_file_extension
168
+ '.in'
169
+ end
170
+
171
+ end
172
+ end
173
+
@@ -0,0 +1,14 @@
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
+
11
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
12
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
13
+ require 'coderunner'
14
+
@@ -0,0 +1,12 @@
1
+ require 'helper'
2
+
3
+ CodeRunner.setup_run_class('veritas')
4
+ #
5
+ ###################################################################################
6
+ # Code to analyse the source code to look for new input variables... very imperfect
7
+ ################################################################################
8
+
9
+ defaults_file = ENV['VERITAS_SOURCE'] + '/inputparameters/defaults.in'
10
+ raise "Could not find defaults_file #{defaults_file}" unless FileTest.exist? defaults_file
11
+ CodeRunner::Veritas.synchronise_variables_from_input_file(defaults_file)
12
+
data/test/helper.rb ADDED
@@ -0,0 +1,14 @@
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
+
11
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
12
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
13
+ require 'coderunner'
14
+
data/test/test.in ADDED
@@ -0,0 +1,10 @@
1
+ &time
2
+ filewrite_freq = 10
3
+ /
4
+
5
+ &grid
6
+ nx = 16
7
+ /
8
+
9
+ &particles
10
+ /
@@ -0,0 +1,41 @@
1
+
2
+ require 'helper'
3
+ require 'minitest/autorun'
4
+
5
+ require 'rbconfig'
6
+ $ruby_command = "#{RbConfig::CONFIG['bindir']}/#{RbConfig::CONFIG['ruby_install_name']}"
7
+ $coderunner_command = "#{$ruby_command} -I lib/ lib/coderunner.rb"
8
+
9
+ class TestVeritas < MiniTest::Test
10
+ def setup
11
+ #puts "setup"; STDIN.gets
12
+ cleanup if FileTest.exist?('test/test_results')
13
+ FileUtils.makedirs('test/test_results/v')
14
+ @runner = CodeRunner.fetch_runner(Y: 'test/test_results', C: 'veritas', X: '/dev/null')
15
+ end
16
+ def cleanup
17
+ FileUtils.rm_r('test/test_results')
18
+ #FileUtils.rm('test/ifspppl/.code_runner_script_defaults.rb')
19
+ #FileUtils.rm('test/ifspppl/.CODE_RUNNER_TEMP_RUN_LIST_CACHE')
20
+ #FileUtils.rm('test/gs2_42982/pr08_jet_42982_1d.dat')
21
+ #FileUtils.rm('test/gs2_42982/pr08_jet_42982_2d.dat')
22
+ #FileUtils.rm_r('test/ifspppl/v')
23
+ end
24
+ def teardown
25
+ end
26
+ def test_basics
27
+ assert_equal(@runner.run_class, CodeRunner::Veritas)
28
+ end
29
+ def test_submit
30
+ @runner.run_class.make_new_defaults_file("rake_test", "test/test.in")
31
+ FileUtils.mv('rake_test_defaults.rb', 'test/test_results')
32
+ if ENV['VERITAS_EXEC']
33
+ CodeRunner.submit(Y: 'test/test_results', T: false, D: 'rake_test', n: '1', X: ENV['VERITAS_EXEC'], p: '{np: [16,16]}')
34
+ end
35
+ base_hash = @runner.run_class.parse_input_file('test/test.in')
36
+ test_hash = @runner.run_class.parse_input_file('test/test_results/v/id_1/v_np_[16,_16]_id_1.in')
37
+ assert_equal(base_hash, test_hash)
38
+ CodeRunner.status(Y: 'test/test_results')
39
+ cleanup if FileTest.exist?('test/test_results')
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: veritascrmod
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Edmund Highcock
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: coderunner
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: narray
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: shoulda
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rdoc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.12'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: juwelier
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.1.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: A CodeRunner module for the Veritas Vlasov Solver
112
+ email: edmundhighcock@users.sourceforge.net
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files:
116
+ - LICENSE.txt
117
+ - README.rdoc
118
+ files:
119
+ - ".document"
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.rdoc
123
+ - Rakefile
124
+ - VERSION
125
+ - lib/veritascrmod.rb
126
+ - lib/veritascrmod/namelists.rb
127
+ - lib/veritascrmod/veritas.rb
128
+ - sync_variables/helper.rb
129
+ - sync_variables/sync_variables.rb
130
+ - test/helper.rb
131
+ - test/test.in
132
+ - test/test_veritas.rb
133
+ homepage: http://github.com/coderunner-framework/veritascrmod
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.4.8
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: A CodeRunner module for the Veritas Vlasov Solver
157
+ test_files: []