# This file contains methods which allow Trinity to use GS2 as # the flux solver #class NumRu::NetCDF #def _dump_data #Marshal.dump(nil) #end #end class CodeRunner class Gs2 class TrinityComponent < Gs2 attr_accessor :trinity_run def initialize(runner, trinity_run) super(runner) @trinity_run = trinity_run self end def output_file #@output_file ||= '../' + self.class.to_s '../' + @trinity_run.output_file #'aa' end def error_file '../' + @trinity_run.error_file #'aa' end def dup return self.class.new(@runner, @trinity_run).learn_from(self) end def save #p ['output_file', output_file] #p ['ancestors', self.class.ancestors] trinrun, @trinity_run = @trinity_run, nil component_runs.each{|cr| cr.trinity_run = nil} #@trinity_run = nil #@output_file = nil #GC.start #p self.instance_variables.find_all{|v| instance_variable_get(v).class.to_s =~ /NumRu::NetCDF/} super @trinity_run = trinrun end end end class Trinity # This function creates a new Trinity defaults file, with Trinity parameters taken from # trinity_input_file, and GS2 parameters taken from gs2_input_file. The file is then moved # to the CodeRunner central defaults location, the current folder is configured to use # the defaults file. def self.use_new_defaults_file_with_gs2(name = ARGV[-3], trinity_input_file = ARGV[-2], gs2_input_file = ARGV[-1]) raise "Please specify a name, a trinity input file and a gs2 input file" if name == "use_new_gs2_defaults_file" defaults_filename = "#{name}_defaults.rb" tmp_filename = "#{name}_gs2tmp_defaults.rb" central_defaults_filename = rcp.user_defaults_location + "/" + defaults_filename FileUtils.rm(name + '_defaults.rb') if FileTest.exist?(name + '_defaults.rb') FileUtils.rm(central_defaults_filename) if FileTest.exist?(central_defaults_filename) FileUtils.rm(tmp_filename) if FileTest.exist?(tmp_filename) raise "Defaults file: #{central_defaults_filename} already exists" if FileTest.exist? central_defaults_filename make_new_defaults_file(name, trinity_input_file) CodeRunner::Gs2.make_new_defaults_file(name + '_gs2tmp', gs2_input_file) File.open(defaults_filename, 'a'){|file| file.puts <= n_flux_tubes_jac jn = i - n_flux_tubes_jac + 1 run_name = "calibrate_" + @run_name + (jn).to_s else jn = i + 1 run_name = @run_name + (jn).to_s end run_name end def gs2_folder_name(i) if i >= n_flux_tubes_jac jn = i - n_flux_tubes_jac + 1 folder = "calibrate_#{jn}" else jn = i + 1 folder = "flux_tube_#{jn}" end folder end end end