module CodeRunner::Trinity::TrinityGraphKits

Public Instance Methods

ang_mom_prof_graphkit(options) click to toggle source

Graph of toroidal angular momentum against rho for a given t_index

# File lib/trinitycrmod/graphs.rb, line 67
def ang_mom_prof_graphkit(options)
  return nt_prof_graphkit(options.absorb({header: /ang\s+mom/, title: 'Angular Momentum', units: ''}))
end
dens_prof_graphkit(options) click to toggle source

Graph of n against rho for a given t_index

# File lib/trinitycrmod/graphs.rb, line 79
def dens_prof_graphkit(options)
  return nt_prof_graphkit(options.absorb({header: /dens/, title: 'n', units: '10^20 m^-3'}))
end
eln_hflux_calibration_graphkit(options) click to toggle source

Graph of the electron heat calibration factor

# File lib/trinitycrmod/graphs.rb, line 141
def eln_hflux_calibration_graphkit(options)
  calibs = Calib.analyse_file("#@directory/#@run_name.calib")
  k = calibs.map{|c| c.qflux_graphkit(1)}.sum
  k.ylabel = 'Qe'
  k
end
eln_hflux_gb_prof_graphkit(options) click to toggle source

Graph of Qe in gyroBohm units against rho for a given t_index

# File lib/trinitycrmod/graphs.rb, line 55
def eln_hflux_gb_prof_graphkit(options)
  fluxes_prof_graphkit(options.absorb({header: /Qe.*\(GB/, title: 'Electron Heat Flux', units: 'Q_gB'}))
end
eln_hflux_prof_graphkit(options) click to toggle source

Graph of Qe in MW against rho for a given t_index

# File lib/trinitycrmod/graphs.rb, line 59
def eln_hflux_prof_graphkit(options)
  fluxes_prof_graphkit(options.absorb({header: /Qe.*\(MW/, title: 'Electron Heat Flux', units: 'MW'}))
end
eln_pwr_prof_graphkit(options) click to toggle source

Graph of electron power integrated from the magnetic axis to rho vs rho

# File lib/trinitycrmod/graphs.rb, line 88
def eln_pwr_prof_graphkit(options)
  return pbalance_prof_graphkit(options.absorb({header: /e\- pwr/, title: 'Integrated electron power', units: 'MW'}))
end
eln_temp_prof_graphkit(options) click to toggle source

Graph of Te against rho for a given t_index

# File lib/trinitycrmod/graphs.rb, line 75
def eln_temp_prof_graphkit(options)
  return nt_prof_graphkit(options.absorb({header: /e\- temp/, title: 'Te', units: 'keV'}))
end
fluxes_prof_graphkit(options) click to toggle source

Graphs plotting quantities from the '.fluxes' file vs rho for a given t_index

# File lib/trinitycrmod/graphs.rb, line 12
def fluxes_prof_graphkit(options)
  prof_graphkit(options.absorb({outfile: :fluxes, exclude_perturbed_fluxes: true}))
end
integrated_profiles_graphkit(options) click to toggle source

Graph of integrated profiles vs time

# File lib/trinitycrmod/graphs.rb, line 120
def integrated_profiles_graphkit(options)
  t_indices = list(:t).keys
  kit = t_indices.map{|it| profiles_graphkit(options.absorb({t_index: it}))}.inject{|o,n| o.merge(n)}
  #kit.gnuplot
  #area_vectors = t_indices.map{|i| get_2d_array_float('geo', /13:\s*area/, /1.*time/)[i].to_gslv}
  #system "less #@directory/#@run_name.geo"
  area_vectors = new_netcdf_file.var('area_grid').get.to_a[-1].to_gslv
  kit.each_with_index do |k,ik|
    kit[ik] = integrate_profkit(k, area_vectors, t_indices)
  end

end
ion_hflux_calibration_graphkit(options) click to toggle source

Graph of the ion heat calibration factor

# File lib/trinitycrmod/graphs.rb, line 134
def ion_hflux_calibration_graphkit(options)
  calibs = Calib.analyse_file("#@directory/#@run_name.calib")
  k = calibs.map{|c| c.qflux_graphkit(0)}.sum
  k.ylabel = 'Qi'
  k
end
ion_hflux_gb_prof_graphkit(options) click to toggle source

Graph of Qi in gyroBohm units against rho for a given t_index

# File lib/trinitycrmod/graphs.rb, line 47
def ion_hflux_gb_prof_graphkit(options)
  fluxes_prof_graphkit(options.absorb({header: /Qi.*\(GB/, title: 'Ion Heat Flux', units: 'Q_gB'}))
end
ion_hflux_prof_graphkit(options) click to toggle source

Graph of Qi in MW against rho for a given t_index

# File lib/trinitycrmod/graphs.rb, line 51
def ion_hflux_prof_graphkit(options)
  fluxes_prof_graphkit(options.absorb({header: /Qi.*\(MW/, title: 'Ion Heat Flux', units: 'MW'}))
end
ion_pwr_prof_graphkit(options) click to toggle source

Graph of ion power integrated from the magnetic axis to rho vs rho

# File lib/trinitycrmod/graphs.rb, line 84
def ion_pwr_prof_graphkit(options)
  return pbalance_prof_graphkit(options.absorb({header: /i\+ pwr/, title: 'Integrated ion power', units: 'MW'}))
end
ion_temp_prof_graphkit(options) click to toggle source

Graph of Ti against rho for a given t_index

# File lib/trinitycrmod/graphs.rb, line 71
def ion_temp_prof_graphkit(options)
  return nt_prof_graphkit(options.absorb({header: /i\+ temp/, title: 'Ti', units: 'keV'}))
end
lflux_gb_prof_graphkit(options) click to toggle source

Graph of toroidal angular momentum flux in gyroBohm units against rho for a given t_index

# File lib/trinitycrmod/graphs.rb, line 63
def lflux_gb_prof_graphkit(options)
  fluxes_prof_graphkit(options.absorb({header: /Pi.*\(GB/, title: 'Toroidal Angular Momentum Flux', units: 'Pi_gB'}))
end
nt_prof_graphkit(options) click to toggle source

Graphs plotting quantities from the '.nt' file vs rho for a given t_index

# File lib/trinitycrmod/graphs.rb, line 4
def nt_prof_graphkit(options)
  prof_graphkit(options.dup.absorb({outfile: :nt}))
end
pbalance_prof_graphkit(options) click to toggle source

Graphs plotting quantities from the '.pbalance' file vs rho for a given t_index

# File lib/trinitycrmod/graphs.rb, line 16
def pbalance_prof_graphkit(options)
  prof_graphkit(options.absorb({outfile: :pbalance}))
end
pflux_calibration_graphkit(options) click to toggle source

Graph of the particle flux calibration factor

# File lib/trinitycrmod/graphs.rb, line 148
def pflux_calibration_graphkit(options)
  calibs = Calib.analyse_file("#@directory/#@run_name.calib")
  k = calibs.map{|c| c.pflux_graphkit(1)}.sum
  k.ylabel = 'Gamma'
  k
end
prof_graphkit(options) click to toggle source
# File lib/trinitycrmod/graphs.rb, line 19
def prof_graphkit(options)
  raise "Please specify t_index" unless options[:t_index]
  it = options[:t_index] - 1
  if ta  = options[:time_average]
    if ta < 0
      t_indices = (it+ta..it).to_a
    else
      t_indices = (it..it+ta).to_a
    end
  else
    t_indices = [it]
  end
  array = t_indices.map{|i| get_2d_array_float(options[:outfile], options[:header], /1.*time/)[i].to_gslv}.mean.to_a
  rho_array = t_indices.map{|i| get_2d_array_float(options[:outfile], options[:radius_match]||/2.*radius/, /1.*time/)[i].to_gslv}.mean.to_a
  if options[:exclude_perturbed_fluxes]
    #s = array.size
    array = array.slice(0...nrad-1)
    rho_array = rho_array.slice(0...nrad-1)
  end
  #p rho_array, array
  kit = GraphKit.autocreate(x: {data: rho_array.to_gslv, title: 'rho', units: ''},
                      y: {data: array.to_gslv, title: options[:title]||"", units: options[:units]||""}
                     )
  kit.data[0].title += " at time = #{list(:t)[it+1]} s for id #{id}"
  kit.data[0].gp.with = 'lp'
  kit
end
pwr_prof_graphkit(options) click to toggle source

Graphs plotting quantities from the '.nt' file vs rho for a given t_index

# File lib/trinitycrmod/graphs.rb, line 8
def pwr_prof_graphkit(options)
  prof_graphkit(options.dup.absorb({outfile: :pwr, radius_match: /2.*rad/}))
end
torque_prof_graphkit(options) click to toggle source

Graph of ion power integrated from the magnetic axis to rho vs rho

# File lib/trinitycrmod/graphs.rb, line 92
def torque_prof_graphkit(options)
  return pbalance_prof_graphkit(options.absorb({header: /torque/, title: 'Integrated torque', units: 'Nm'}))
end

Private Instance Methods

integrate_profkit(kit, area_vectors, t_indices) click to toggle source
# File lib/trinitycrmod/graphs.rb, line 96
def integrate_profkit(kit, area_vectors, t_indices)
  datavecs = kit.data.map{|d| d.y.data}
  #p 'datavecs.size', datavecs.size
  #rhovec = kit.data[0].x.data
  #rhoarea_vectors = get_1d_array_float('geo', /1:\s*rho/)
  #int = GSL::ScatterInterp.alloc(:linear,  [rhoarea_vectors.to_gslv, area_vectors.to_gslv], false )

  #area2 = rhovec.map{|rh| int.eval(rh)}
  #area_vectors = new_netcdf_file.var('area_grid').get[-1].to_gslv
  grho_vector= new_netcdf_file.var('grho_grid').get.to_a[-1].to_gslv
  rho_vector= new_netcdf_file.var('rad_grid').get.to_a[-1][-1].to_gslv
  integrated_values = datavecs.map{|dat| 
    p 'dat.size', dat.size, area_vectors.size, grho_vector.size
    integrand = dat.to_gslv*area_vectors/grho_vector
    (integrand.subvector(0,dat.size-1) * (rho_vector.subvector(1,dat.size-1) - rho_vector.subvector(0,dat.size-1))).sum
  }
  k2 = GraphKit.quick_create([list(:t).values.to_gslv, integrated_values])
  k2.title = kit.title
  k2.ylabel = kit.ylabel
  return k2
end