Class: CodeRunner::Veritas
- Inherits:
-
Run::FortranNamelist
- Object
- Run::FortranNamelist
- CodeRunner::Veritas
- Defined in:
- lib/veritascrmod/veritas.rb
Overview
This is a customised subclass of the CodeRunner::Run class which allows CodeRunner to run and analyse the Vlasov Maxwell solver Veritas.
It generates the Veritas input file, and both analyses the results and allows easy plotting of them.
Class Method Summary collapse
Instance Method Summary collapse
-
#generate_input_file ⇒ Object
This is a hook which gets called just before submitting a simulation.
- #get_status ⇒ Object
- #input_file_extension ⇒ Object
- #input_file_header ⇒ Object
-
#parameter_string ⇒ Object
Parameters which follow the Veritas executable, in this case just the input file.
- #parameter_transition ⇒ Object
-
#print_out_line ⇒ Object
A hook which gets called when printing the standard run information to the screen using the status command.
-
#process_directory_code_specific ⇒ Object
This method, as its name suggests, is called whenever CodeRunner is asked to analyse a run directory.
-
#restart(new_run) ⇒ Object
Modify new_run so that it becomes a restart of self.
- #vim_output ⇒ Object (also: #vo)
-
#write_input_file ⇒ Object
This command uses the infrastructure provided by Run::FortranNamelist, provided by CodeRunner itself.
Class Method Details
.defaults_file_header ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/veritascrmod/veritas.rb', line 149 def self.defaults_file_header "############################################################################\n# #\n# Automatically generated defaults file for the Veritas CodeRunner module #\n# #\n# This defaults file specifies a set of defaults for Veritas which are #\n# used by CodeRunner to set up and run Veritas simulations. #\n# #\n############################################################################\n\n# Created: \#{Time.now.to_s}\n\n@defaults_file_description = \"\"\n" end |
Instance Method Details
#generate_input_file ⇒ Object
This is a hook which gets called just before submitting a simulation. It sets up the folder and generates any necessary input files.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/veritascrmod/veritas.rb', line 69 def generate_input_file FileUtils.makedirs("output/rectangleData") #@run_name += "_t" if @restart_id @runner.run_list[@restart_id].restart(self) end #if uses_ecom? #setup_ecom #elsif uses_chease? #setup_chease #end #check_parameters write_input_file end |
#get_status ⇒ Object
117 118 119 120 121 122 123 |
# File 'lib/veritascrmod/veritas.rb', line 117 def get_status if @running @status = :Running else @status = :Complete end end |
#input_file_extension ⇒ Object
167 168 169 |
# File 'lib/veritascrmod/veritas.rb', line 167 def input_file_extension '.in' end |
#input_file_header ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/veritascrmod/veritas.rb', line 127 def input_file_header "!==============================================================================\n! Veritas INPUT FILE automatically generated by CodeRunner\n!==============================================================================\n!\n! Veritas is a 1D continuum solver for the Vlasov-Maxwell system\n!\n! See http://ft.nephy.chalmers.se/veritas/\n!\n! CodeRunner is a framework for the automated running and analysis\n! of large simulations.\n!\n! See http://coderunner.sourceforge.net\n!\n! Created \#{Time.now.to_s}\n! by CodeRunner version \#{CodeRunner::CODE_RUNNER_VERSION.to_s}\n!\n!==============================================================================\n\n" end |
#parameter_string ⇒ Object
Parameters which follow the Veritas executable, in this case just the input file.
100 101 102 |
# File 'lib/veritascrmod/veritas.rb', line 100 def parameter_string @run_name + ".in" end |
#parameter_transition ⇒ Object
104 105 |
# File 'lib/veritascrmod/veritas.rb', line 104 def parameter_transition end |
#print_out_line ⇒ Object
A hook which gets called when printing the standard run information to the screen using the status command.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/veritascrmod/veritas.rb', line 38 def print_out_line #p ['id', id, 'ctd', ctd] #p rcp.results.zip(rcp.results.map{|r| send(r)}) name = @run_name name += " (res: #@restart_id)" if @restart_id name += " real_id: #@real_id" if @real_id 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, "%") #if ctd and fusionQ #beginning += sprintf("Q:%f, Pfusion:%f MW, Ti0:%f keV, Te0:%f keV, n0:%f x10^20", fusionQ, pfus, ti0, te0, ne0) #end #beginning += " ---#{@comment}" if @comment beginning end |
#process_directory_code_specific ⇒ Object
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).
113 114 115 |
# File 'lib/veritascrmod/veritas.rb', line 113 def process_directory_code_specific get_status end |
#restart(new_run) ⇒ Object
Modify new_run so that it becomes a restart of self. Adusts all the parameters of the new run to be equal to the parameters of the run that calls this function, and sets up its run name correctly
64 65 66 67 |
# File 'lib/veritascrmod/veritas.rb', line 64 def restart(new_run) (rcp.variables).each{|v| new_run.set(v, send(v)) if send(v) or new_run.send(v)} raise "restart not implemented yet" end |
#vim_output ⇒ Object Also known as: vo
89 90 91 |
# File 'lib/veritascrmod/veritas.rb', line 89 def vim_output system "vim -Ro #{output_file} #{error_file}" end |
#write_input_file ⇒ Object
This command uses the infrastructure provided by Run::FortranNamelist, provided by CodeRunner itself.
95 96 97 |
# File 'lib/veritascrmod/veritas.rb', line 95 def write_input_file File.open(@run_name + ".in", 'w'){|file| file.puts input_file_text} end |