Skip to content

Commit

Permalink
added new features
Browse files Browse the repository at this point in the history
  • Loading branch information
xaratustrah committed Oct 6, 2016
1 parent ef3f09b commit 6815df1
Show file tree
Hide file tree
Showing 5 changed files with 231 additions and 87 deletions.
233 changes: 153 additions & 80 deletions doc/barion_getting_started.ipynb

Large diffs are not rendered by default.

49 changes: 43 additions & 6 deletions particle.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Barion
-- GUI Application --
Jul 2015 Xaratustrah
Mar 2016 Xaratustrah
Expand Down Expand Up @@ -75,6 +74,38 @@ def __str__(self):
'Z: ' + str(self.tbl_zz) + ', ' + \
'N: ' + str(self.tbl_nn)

def get_nuclides(self, zz_min, zz_max, nn_min, nn_max, ee_max):
"""
Parameters
----------
zz_min
zz_max
nn_min
nn_max
qq_max: number of charge states. i.e. 2 means bare and H-like
Returns: array of particle object
-------
"""
p_array = []
for i in self.ame_data.ame_table:
if zz_min <= i[4] <= zz_max:
if nn_min <= i[3] <= nn_max:
for eee in range(ee_max):
# create particle
p = Particle(i[4], i[3], self.ame_data, self.ring)
p.qq = i[4] - eee
# give properties of the reference particle
p.ke_u = self.ke_u
p.path_length_m = self.path_length_m
p.f_analysis_mhz = self.f_analysis_mhz
p.i_beam_uA = self.i_beam_uA
# add to array
p_array.append(p)
return p_array

def get_isotopes(self):
"""
Retrieves the isotopes of the current nuclide
Expand Down Expand Up @@ -214,6 +245,9 @@ def get_magnetic_rigidity(self):
def get_electric_rigidity(self):
return self.get_magnetic_rigidity() * self.get_velocity() / 1.0e3

def get_neutron_excess_parameter(self):
return (self.tbl_nn - self.tbl_zz) / (self.get_atomic_mass_in_u())

# --------------------------------

def get_revolution_frequency(self):
Expand Down Expand Up @@ -257,6 +291,8 @@ def calculate_from_energy(self):

s += "m/Q (ionic):\t\t{}\n".format(self.get_ionic_moq())

s += "Neutron excess parameter:\t{}\t[1/u]\n".format(self.get_neutron_excess_parameter())

s += "Tot. Kin. Energy:\t{}\t\t[MeV]\n".format(self.get_total_energy_mev())
s += "gamma:\t\t{}\n".format(self.get_gamma())
s += "beta:\t\t{}\n".format(self.get_beta())
Expand Down Expand Up @@ -301,6 +337,7 @@ def calculate_from_energy_list(self):
['Atomic mass:', str(self.get_atomic_mass_in_u()), '[u]'],
['Ionic mass:', str(self.get_ionic_mass_in_u()), '[u]'],
['Ionic m/Q:', str(self.get_ionic_moq()), '[u]'],
['Neutron Excess Parameter:', str(self.get_neutron_excess_parameter()), '[1/u]'],
['Tot. kin. Energy:', str(self.get_total_energy_mev()), '[MeV]'],
['gamma:', str(self.get_gamma()), ''],
['beta:', str(self.get_beta()), ''], ['beta * gamma:', str(self.get_beta_gamma()), ''],
Expand All @@ -323,10 +360,10 @@ def calculate_from_energy_list(self):

return s

# def identify(self, f_actual, f_unknown, range_zz, range_nn, max_ee, accuracy):
# def identify(self, f_actual, f_unknown, zz_range, nn_range, ee_max, accuracy):
# print(self.ring.get_alpha_p())

def identify(self, f_actual, f_unknown, range_zz, range_nn, max_ee, accuracy):
def identify(self, f_actual, f_unknown, zz_range, nn_range, ee_max, accuracy):
alpha_p = self.ring.get_alpha_p()
delta_f = f_actual - f_unknown
delta_moq = - delta_f / f_actual * self.get_ionic_moq() / alpha_p
Expand All @@ -340,10 +377,10 @@ def identify(self, f_actual, f_unknown, range_zz, range_nn, max_ee, accuracy):
s += 'm/Q of the unknown particle: {}\n'.format(moq_unknown)
moq_dict = {}
for i in self.ame_data.ame_table:
if i[4] in range(self.tbl_zz - range_zz, self.tbl_zz + range_zz):
if i[3] in range(self.tbl_nn - range_nn, self.tbl_nn + range_nn):
if i[4] in range(self.tbl_zz - zz_range, self.tbl_zz + zz_range):
if i[3] in range(self.tbl_nn - nn_range, self.tbl_nn + nn_range):
p = Particle(i[4], i[3], self.ame_data, self.ring)
for eee in range(max_ee):
for eee in range(ee_max):
p.qq = i[4] - eee
moq_dict[str(p)] = p.get_ionic_moq()
# s += 'Current particle: ' + str(self) + '\n'
Expand Down
25 changes: 25 additions & 0 deletions plotcell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
Barion
Okt 2016 Xaratustrah
"""


class PlotCell:
def __init__(self):
self.line_color = 'black'
self.bg_color = 'white'
self.size_px = 20
self.arrow_to = False
self.arrow_from = False
self.arrow_color = 'black'
self.arrow_line_thickness = 2

def create_plot(self):
pass

def bulk_pot(self):
pass
9 changes: 9 additions & 0 deletions ui_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""

from abc import ABCMeta, abstractmethod
import os


class UI_Interface(object):
Expand All @@ -35,3 +36,11 @@ def show_message_box(self, text):
:return:
"""
pass


class DummyIFace(UI_Interface):
def __init__(self):
self.home_folder = os.path.expanduser('~') + '/.barion/'

def show_message(self, msg):
print(msg)
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"""

__version_info__ = (0, 1, 4)
__version_info__ = (0, 1, 6)
__version__ = '.'.join('%d' % d for d in __version_info__)

0 comments on commit 6815df1

Please sign in to comment.