Exemple #1
0
 def find_n_spectrum(self):
     """Determine the neutron output spectrum."""
     E = self.events['E']
     self.Es = np.linspace(0., np.max(E), 25)
     grid = GridSearchCV(KernelDensity(),
                         {'bandwidth': np.linspace(0.1, 1.0, 30)},
                         cv=np.min([len(E), 20]))
     grid.fit(E[:, None])
     kde = grid.best_estimator_
     pdf = np.exp(kde.score_samples(self.Es[:, None]))
     self.frq = pdf
     self.frqh, self.Esh = np.histogram(E, bins=self.Es)
     self.pn_spect = pym.curve(self.Es, self.frq, name='Gaussian KDE')
     self.pn_specth = \
         pym.curve(self.Esh, np.append(self.frqh,[0.]) /
                   (np.max(self.frqh)/np.max(self.frq)),
                   data='binned', name='Histogram')
     self.plot = \
         self.pn_spect.plot(linestyle='-',
                            linecolor=puc.pu_colors['newgold'])
     self.plot = \
         self.pn_specth.plot(linestyle='-',
                             linecolor=puc.pu_colors['lightgray'],
                             addto=self.plot)
     self.plot.xlabel(r'Neutron Energy ($E_{n}$) [$\unit{MeV}$]')
     self.plot.xlim(0.0, 1.1 * np.max(E))
     self.plot.ylabel(r'Probability ($P$) [ ]')
     ymax = 1.1 * np.max([np.max(self.frq), np.max(self.pn_specth.y)])
     print(ymax)
     self.plot.ylim(0.0, ymax)
Exemple #2
0
 def find_n_spectrum(self):
     """Determine the neutron output spectrum."""
     E = self.events['E']
     self.Es = np.linspace(0., np.max(E), 25)
     grid = GridSearchCV(KernelDensity(),
                         {'bandwidth': np.linspace(0.1, 1.0, 30)},
                         cv=np.min([len(E), 20]))
     grid.fit(E[:, None])
     kde = grid.best_estimator_
     pdf = np.exp(kde.score_samples(self.Es[:, None]))
     self.frq = pdf
     self.frqh, self.Esh = np.histogram(E, bins=self.Es)
     self.pn_spect = pym.curve(self.Es, self.frq, name='Gaussian KDE')
     self.pn_specth = \
         pym.curve(self.Esh, np.append(self.frqh,[0.]) /
                   (np.max(self.frqh)/np.max(self.frq)),
                   data='binned', name='Histogram')
     self.plot = \
         self.pn_spect.plot(linestyle='-',
                            linecolor=puc.pu_colors['newgold'])
     self.plot = \
         self.pn_specth.plot(linestyle='-',
                             linecolor=puc.pu_colors['lightgray'],
                             addto=self.plot)
     self.plot.xlabel(r'Neutron Energy ($E_{n}$) [$\unit{MeV}$]')
     self.plot.xlim(0.0, 1.1 * np.max(E))
     self.plot.ylabel(r'Probability ($P$) [ ]')
     ymax = 1.1 * np.max([np.max(self.frq), np.max(self.pn_specth.y)])
     print ymax
     self.plot.ylim(0.0, ymax)
    np.loadtxt('Fig7-Cf-Eff.csv',
               delimiter=",", dtype=object,
               converters={0: float, 1: float, 2: float},
               unpack=True)
# points = [range(0, 6), range(7, 11), range(13, 17), range(19, 25),
#           range(26, 31), range(32, 39), range(40, 48), range(49, 57),
#           range(58, 63), range(64, 68), range(69, 82)]
# pwr = [np.mean(pwr_new[idx]) for idx in points]
# u_pwr = [np.std(pwr_new[idx]) for idx in points]
# eff = np.array([np.mean(eff_new[idx]) for idx in points])
# u_eff = np.array([np.mean(u_eff[idx]) for idx in points])
# std_eff = np.array([np.std(eff_new[idx]) for idx in points])
# u_eff = np.sqrt(np.power(u_eff, 2.0) + np.power(std_eff, 2.0))
pwr = pwr_new
eff = eff_new
cf_tena_eta = ahf.curve(pwr, 100. * eff, u_y=u_eff, name="cf_tena_setup")

pwr_new, eff_new, u_eff = \
    np.loadtxt('Fig7-DD-Eff.csv',
               delimiter=",", dtype=object,
               converters={0: float, 1: float, 2: float},
               unpack=True)
# pwr = [np.mean(pwr_new[0:1]), np.mean(pwr_new[2]), np.mean(pwr_new[3]),
#        np.mean(pwr_new[4:])]
# u_pwr = [np.std(pwr_new[0:1]), np.std(pwr_new[2]), np.std(pwr_new[3]),
#          np.std(pwr_new[4:])]
# eff = np.array([np.mean(eff_new[0:1]), np.mean(eff_new[2]), np.mean(eff_new[3]),
#        np.mean(eff_new[4:])]) / nps_dd
# u_eff = np.array([np.mean(u_eff[0:1]), np.mean(u_eff[2]), np.mean(u_eff[3]),
#          np.mean(u_eff[4:])]) / nps_dd
# std_eff = np.array([np.std(eff_new[0:1]), np.std(eff_new[2]), np.std(eff_new[3]),
Exemple #4
0
import sys
sys.path.append("/Users/ahagen/code")
from pymf import ctmfd as ahi
from pym import func as ahf
from pyg import twod as ahp


def deriv(Y, t):
    return [Y[1], -0.5 * Y[1] - 10 * np.sin(Y[0])]


# use integrate.odeint to determine the solution
x = np.linspace(0, 2.5, 1000, endpoint=True)
sol = integrate.odeint(deriv, [.5, 0], x)

ode_solution = ahf.curve(x, sol[:, 0], name='ode')

t_0_25, y_0_25 = np.loadtxt('pendulum_0.250000.dat',
                            usecols=(0, 1),
                            unpack=True)
h_0_25_solution = ahf.curve(t_0_25, y_0_25, name=r'$h = 0.25 \mathrm{s}$')

t_0_125, y_0_125 = np.loadtxt('pendulum_0.125000.dat',
                              usecols=(0, 1),
                              unpack=True)
h_0_125_solution = ahf.curve(t_0_125, y_0_125, name=r'$h = 0.125 \mathrm{s}$')

t_0_00001, y_0_00001 = np.loadtxt('pendulum_0.000244.dat',
                                  usecols=(0, 1),
                                  unpack=True)
h_0_00001_solution = ahf.curve(t_0_00001,
Exemple #5
0
                 2.0000E+00, 2.2000E+00, 2.4000E+00, 2.6000E+00, 2.8000E+00])
n_52 = np.array([4.91586E-08, 1.06091E-05, 1.11736E-06, 5.39662E-07,
                 5.56099E-07, 1.77157E-07, 1.59955E-07, 1.79698E-07,
                 1.32121E-07, 8.01516E-08, 3.85630E-08, 6.92248E-08,
                 0.00000E+00, 0.00000E+00, 0.00000E+00])
u_n_52 = np.array([0.5288, 0.0538, 0.1673, 0.2384, 0.2289, 0.4050, 0.4480,
                   0.4208, 0.5182, 0.5116, 1.0000, 0.6735, 0.0000, 0.0000,
                   0.0000])

r = [0., 52., 132.]
thresh = 0.250 # estimating the threshold to be around 500 kev
n = np.array([np.sum(n_0[np.where(e_0 > thresh)]),
              np.sum(n_52[np.where(e_52 > thresh)]),
              np.sum(n_132[np.where(e_132 > thresh)])]) / nps
print n
mcnp = ahm.curve(r, n, name='simulation')

d = [0.0, 52.0, 100.0, 132.0]
wt = np.array([2.75, 56.69, 277.15, 3.0 * 121.45])
u_wt = np.array([1.59, 28.34, 277.15, 121.45]) / wt
cr = 1.0 / wt
u_cr = cr * u_wt
u_cr_up = u_cr
u_cr_down = u_cr.copy()
u_cr_down[3] = np.inf
u_cr = np.vstack((u_cr_down, u_cr_up))

expt = ahm.curve(d, cr, u_y=u_cr, name='experiment')

x = np.arange(1.0, 140.)
y = cr[0] / np.power(x, 1.0)
Exemple #6
0
from scipy import integrate
import sys
sys.path.append("/Users/ahagen/code")
from pymf import ctmfd as ahi
from pym import func as ahf
from pyg import twod as ahp
import glob

plot = ahp.ah2d()

fname = glob.glob('fem_sol/*.dat')
for i in range(len(fname)):
    arr = np.loadtxt(fname[i])
    z = arr[:, 0] * 1.0E4
    C = arr[:, 1]
    fem = ahf.curve(z, C, name=r'fem')

    plot = fem.plot(linestyle='-', linecolor='#5C8727')
    plot.lines_on()
    plot.markers_off()

    arr = np.loadtxt(fname[i].replace('fem', 'fdm'))
    z = arr[:, 0] * 1.0E4
    C = arr[:, 1]

    fdm = ahf.curve(z, C, name=r'fdm')
    fdm.plot(linestyle='-', linecolor='#2EAFA4', addto=plot)
    plot.lines_on()
    plot.markers_off()

    for x in z[::10]:
Exemple #7
0
import numpy as np
from scipy import integrate
import sys
sys.path.append("/Users/ahagen/code")
from pymf import ctmfd as ahi
from pym import func as ahf
from pyg import twod as ahp

nonuniform = int(sys.argv[1])

arr = np.loadtxt('sim/0000')
z = arr[:, 0] * 1.0E4
C = arr[:, 1]

concentration1 = ahf.curve(z, C, name=r'$t=0\,\mathrm{s}$')

plot = ahp.ah2d()
concentration1.plot(linestyle='-', linecolor='#5C8727', addto=plot)
plot.lines_on()
plot.markers_off()

arr = np.loadtxt('sim/0001')
z = arr[:, 0] * 1.0E4
C = arr[:, 1]

concentration2 = ahf.curve(z, C, name=r'$t=1\,\mathrm{\mu s}$')
concentration2.plot(linestyle='-', linecolor='#2EAFA4', addto=plot)
plot.lines_on()
plot.markers_off()

arr = np.loadtxt('sim/0004')
Exemple #8
0
import numpy as np
from scipy import integrate
import matplotlib.pyplot as plt
import sys
sys.path.append("/Users/ahagen/code")
from pymf import ctmfd as ahi
from pym import func as ahf
from pyg import twod as ahp
import glob

fname = glob.glob('fem_sol/*.dat')
for i in range(len(fname)):
    arr = np.loadtxt(fname[i])
    z = arr[:, 0] * 1.0E4
    C = arr[:, 1]
    fem = ahf.curve(z, C, name=r'fem')

    plot = fem.plot(linestyle='-', linecolor='#B63F97')
    plot.lines_on()
    plot.markers_off()

    arr = np.loadtxt(fname[i].replace('fem', 'fdm'))
    z = arr[:, 0] * 1.0E4
    C = arr[:, 1]

    fdm = ahf.curve(z, C, name=r'fdm')
    fdm.plot(linestyle='-', linecolor='#2EAFA4', addto=plot)
    plot.lines_on()
    plot.markers_off()

    for x in z[::10]:
Exemple #9
0
import sys
import numpy as np
from colour import Color
from dateutil import parser
import matplotlib.dates as md
from os.path import expanduser
sys.path.append(expanduser("~") + "/code")
from pymf import ctmfd as ahi
from pym import func as ahf

pneg, eff, u_eff = \
    np.loadtxt('Fig8-Cf-Eff.csv',
               delimiter=",", dtype=object,
               converters={0: float, 1: float, 2: float},
               unpack=True)
m16_cf_curve = ahf.curve(pneg, 100. * eff, u_y=u_eff, name='$Cf$')
pneg, eff, u_eff = \
    np.loadtxt('Fig8-DD-Eff.csv',
               delimiter=",", dtype=object,
               converters={0: float, 1: float, 2: float},
               unpack=True)
m16_dd_curve = ahf.curve(pneg, 100. * eff, u_y=u_eff, name='$DD$')
pneg, u_pneg, r, u_r = \
    np.loadtxt('Fig9-Ratio.csv',
               delimiter=",", dtype=object,
               converters={0: float, 1: float, 2: float, 3: float},
               unpack=True)
m16_ratio_curve = ahf.curve(pneg, r, u_x=u_pneg, u_y=u_r, name='$r$')

plot = m16_ratio_curve.plot(linestyle='-', linecolor='#E3AE24')
m16_ratio_curve.fit_exp()
Exemple #10
0
W_i = 600.0e3
theta = 3.0 * np.pi / 2.0
xi = 0.99
A_1s = np.linspace(1., 5., 5)
P_2 = np.linspace(2.e8, 10.e8, 10)
epsilon_0 = 8.854e-12
M = 2.0 * 938.0e8 * (1.6e-13)
q = 1.0
alpha = 1.0
R_E = alpha / (1.0 - xi)
plot = pyg.pyg2d()
for A_1 in A_1s:
    a = 4.0 * epsilon_0 * A_1 * theta * np.sqrt(0.5 / M) / (q**2)
    h_2 = np.sqrt(a * np.sqrt(xi) * np.power(W_i, 5. / 2.) / (P_2 * (1 - xi)))
    r_2 = R_E * A_1 / (h_2 * theta)
    heights = pym.curve(P_2, h_2, name='$h_{2, %d m^{2}}$' % A_1)
    plot = heights.plot(linestyle='--', linecolor='black', addto=plot)
    plot.add_text(1.9e8,
                  h_2[0],
                  string=r'$h_{2}\left( %d m^{2}\right)$' % A_1,
                  ha='right')
    radii = pym.curve(P_2, r_2, name='$r_{2, %d m^{2}}$' % A_1)
    if A_1 == 1.0:
        yy = True
        axes = None
    else:
        yy = False
        axes = plot.ax2
    plot = radii.plot(linestyle=':',
                      linecolor='black',
                      yy=yy,
Exemple #11
0
import sys
import numpy as np
import os
sys.path.append(os.environ['HOME'] + '/code/')
from pym import func as ahf

x = np.arange(0., 24.)
y = np.append(np.arange(0., 12.), np.arange(11., -1., -1.))

curve = ahf.curve(x, y)
print curve.find(8.5)
print curve.at(8.5)
print curve.at(14.5)
Exemple #12
0
from pynk.talys import talys as t
from pym import func as f
import numpy as np
import copy
from pyg.colors import pu as puc

E_g, phi_g = np.loadtxt("/home/ahagen/data/clinac_6ex_data/spectrum_bremsstrahlung.txt",
                   delimiter=',', skiprows=1, unpack=True)

spectrum = f.curve(E_g, phi_g, name='bremsstrahlung')
spectrum.normalize()
print spectrum.integrate()

elements = np.genfromtxt('/home/ahagen/code/pynk/isotopic_abundances.csv',
                         delimiter=' ', dtype=None)
#elements = [(9, 'Be', 100.)]
for element in elements:
    if element[1] != 'H' and element[1] != 'He':
        input = t(Z=element[1], A=element[0],
                  energy=np.linspace(0.0, 7.0, 100),
                  projectile='g', ejectile='n')
        input.run()
        input.proc_output(addtl_rxns=['fission'])
        sigma = f.curve(input.E, input.sigma,
                        name=r'%s-%d $\sigma_{\left(\gamma, n\right)}$' % \
                            (element[1], element[0]))
        sa = copy.deepcopy(sigma) * spectrum
        xs = sa.integrate(0., 6.)
        if np.max(input.sigma > 0.0) and input.Q > -6.:
            print '(g,n) %3s-%3d: Q = %10f | abundance = %10f | xs = %10f' % \
                (element[1], element[0], input.Q, element[2],
Exemple #13
0
 def return_eff(self):
     return ahf.curve(self.p, 100. * self.eta, u_x=self.u_p, u_y=self.u_eta,
                      name=self.export_name + '_eta')
Exemple #14
0
 def return_cr(self):
     return ahf.curve(self.p, self.cr, u_x=self.u_p, u_y=self.u_cr,
                      name=self.export_name + '_cr')
Exemple #15
0
import sys
import numpy as np
sys.path.append("/Users/ahagen/code")
from pymf import ctmfd as ahi
from pyg import twod as ahp
from pym import func as ahm

E = np.linspace(0, 20, num=1000)
phi = 0.64 * np.multiply(np.exp(-E / 1.175), np.sinh(np.sqrt(1.0401 * E)))
a = 1
b = 2.45
c = 0.1
phi_dd = a * np.exp(-np.multiply((E - b), (E - b)) / (2.0 * c * c))
dd_curve = ahm.curve(E, phi_dd)
a = dd_curve.integrate(0, 20)
phi_dd = a * np.exp(-np.multiply((E - b), (E - b)) / (2.0 * c * c))

fiss_curve = ahm.curve(E, np.multiply(E, phi), name='$^{252}Cf$')
dd_curve = ahm.curve(E, np.multiply(E, phi_dd), name='$DD$')

figure = fiss_curve.plot()
figure = dd_curve.plot(addto=figure)
figure.lines_on()
figure.markers_off()
figure.legend()
figure.xlim(0, 15)
figure.fill_between(E[E > 2.6],
                    np.zeros(np.size(E[E > 2.6])),
                    np.multiply(E[E > 2.6], phi[E > 2.6]),
                    fc='#E3AE24')
figure.add_data_pointer(4.5,
Exemple #16
0
    def __init__(self, y, u_y, name=None, spectrum=None, nps=None, ts=None,
                 Es=None, vals=None, u_vals=None):
        self.y = y
        self.u_y = u_y
        self.nps = nps
        self.ts = ts
        self.Es = Es
        self.vals = vals
        self.u_vals = u_vals
        self.signals = {}
        if name is not None:
            self.name = name
        if spectrum is not None:
            self.spectrum = spectrum
        logging.debug(self.y)
        logging.debug("vals: %d, ts: %d, Es: %d" % (len(self.vals), len(self.ts), len(self.Es)))
        #self.ts = np.array([0.] + list(self.ts))
        #self.Es = np.array([0.] + list(self.Es))
        #logging.debug("vals: %d, ts: %d, Es: %d, ts*Es: %d" % (len(self.vals), len(self.ts), len(self.Es), len(self.Es) * len(self.ts)))
        i = 0
        if ts is not None:
            pos_cos_data = vals
            #pos_cos_data = vals[::2]
            #pos_cos_data = vals[len(vals)/2:]
            for E in Es:
                key = r'$E_{n} < %.2f\unit{MeV}$' % E
                vals = pos_cos_data[i*len(self.ts)+i:(i+1) * len(self.ts) + i - 1]
                logging.debug("len ts: %d, len vals: %d" % (len(self.ts[:-1]), len(vals)))
                self.signals[key] = pym.curve(1.0E-8 * np.array(self.ts[:-1]), vals, key, data='binned')
                i += 1
            try:
                vals = pos_cos_data[i*len(self.ts) + i:(i+1)*len(self.ts) + i - 1]
                logging.debug("len ts: %d, len vals: %d" % (len(self.ts[:-1]), len(vals)))
                i += 1
                self.signals['total'] = pym.curve(1.0E-8 * np.array(self.ts[:-1]), vals, 'total', data='binned')
            except IndexError:
                pass
        '''if ts is not None:
            for E in Es:
                for j in range(2):
                    key = r'$E_{n} < %.2f\unit{MeV}$' % E
                    vals = self.vals[i*len(self.ts)+(i/(j+1)):(i+1)*len(self.ts)+(i/(j+1)) - 1]
                    logging.debug("len ts: %d, len vals: %d" % (len(self.ts[:-1]), len(vals)))
                    self.signals[key] = pym.curve(1.0E-8 * np.array(self.ts[:-1]), vals, key, data='binned')
                i += 1
            vals = self.vals[i*len(self.ts)+(i/(j+1)):(i+1)*len(self.ts)+(i/(j+1)) - 1]
            logging.debug("len ts: %d, len vals: %d" % (len(self.ts[:-1]), len(vals)))
            i += 1
            self.signals['total'] = pym.curve(1.0E-8 * np.array(self.ts[:-1]), vals, 'total', data='binned')'''

        def set_loc(self, loc):
            """ Set the location of the current tally.

            ``set_loc`` sets an internal tuple for the location of the tally,
            usually specified by the center of the cell volume.

            :param tuple loc: The location in an ``(x, y, z)`` format.
            :returns: the modified ``tally`` object.
            """
            self.loc = loc
            return self

        def set_shape(self, shape='rpp'):
            """ Set the shape of the current tally.

            ``set_shape`` holds a string describing the shape of the tally
            volume.  In the future, this will also hold the sizes and directions
            needed to replicate the shape for plotting.

            .. todo:: Add in size and directions to ``tally.set_shape``

            :param str shape: The shape designation of the tally, default 'rpp'
            :returns: the modified ``tally`` object.
            """
            self.shape = shape
            return self
Exemple #17
0
from pyg import twod as ahp

mid = []
trap = []
simp = []

evals = [2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 50, 100]

for i in evals:
    output = os.popen("./maxwellian %d" % (i)).read()
    floats = map(float, output.strip().split("\n"))
    mid = np.append(mid, floats[0])
    trap = np.append(trap, floats[1])
    simp = np.append(simp, floats[2])

mid_curve = ahf.curve(evals, mid, name="midpoint")
trap_curve = ahf.curve(evals, trap, name="trapezoidal")
simp_curve = ahf.curve(evals, simp, name="simpson's")

plot = ahp.ah2d()
mid_curve.plot(linestyle='-', linecolor="#E3AE24", addto=plot)
trap_curve.plot(linestyle='-', linecolor="#746C66", addto=plot)
simp_curve.plot(linestyle='-', linecolor="#2EAFA4", addto=plot)

plot.lines_on()
plot.legend()
plot.xlabel(r'Number of subintervals ($\frac{E_{high} - E_{low}}{h}$) [ ]')
plot.ylabel(r'Probability ($\frac{N\left( E \right)}{N}$) [ ]')

plot.ax.set_xscale('log')
Exemple #18
0
from scipy import integrate
import sys
sys.path.append("/Users/ahagen/code")
from pymf import ctmfd as ahi
from pym import func as ahf
from pyg import twod as ahp
import glob

plot = ahp.ah2d()

fname = glob.glob('fem_sol/*.dat')
for i in range(len(fname)):
    arr = np.loadtxt(fname[i])
    z = arr[:, 0] * 1.0E4
    C = arr[:, 1]
    fem = ahf.curve(z, C, name=r'fem')

    plot = fem.plot(linestyle='-', linecolor='#5C8727')
    plot.lines_on()
    plot.markers_off()

    arr = np.loadtxt(fname[i].replace('fem', 'fdm'))
    z = arr[:, 0] * 1.0E4
    C = arr[:, 1]

    fdm = ahf.curve(z, C, name=r'fdm')
    fdm.plot(linestyle='-', linecolor='#2EAFA4', addto=plot)
    plot.lines_on()
    plot.markers_off()

    for x in z[::10]:
Exemple #19
0
    dt = (t - datetime.datetime(2016, 4, 8, 16, 0)).total_seconds()
    x = np.append(x, dt)
    y = np.append(y, float(time['tempi']))

arrival = (datetime.datetime(2016, 4, 8, 17, 0) -
           datetime.datetime(2016, 4, 8, 16, 0)).total_seconds()
departure = (datetime.datetime(2016, 4, 9, 5, 0) -
             datetime.datetime(2016, 4, 8, 16, 0)).total_seconds()
x1 = x[x > arrival]
y = y[x > arrival]
x = x1
x1 = x[x < departure]
y = y[x < departure]
x = x1

temp = ahf.curve(x, y, name=r'$T$')
plot = temp.plot(linestyle='-', linecolor='#D1D3D4')
plot.fill_between(x, np.zeros_like(x), y, fc='#D1D3D4')
plot.lines_on()
plot.markers_off()
plot.ax.tick_params(axis="x", colors='#D1D3D4')
plot.ax.tick_params(axis="y", colors='#D1D3D4')
plot.ax.yaxis.label.set_color('#D1D3D4')
plot.ax.xaxis.label.set_color('#D1D3D4')
plot.ax.spines['bottom'].set_visible(False)
plot.ax.spines['left'].set_visible(False)


plot.xticks([np.min(x), 1.0 * (np.max(x) - np.min(x)) / 3.0 + np.min(x),
             2.0 * (np.max(x) - np.min(x)) / 3.0 + np.min(x), np.max(x)],
            ["5pm", "9pm", "1am", "5am"])
Exemple #20
0
    def __init__(self,
                 y,
                 u_y,
                 name=None,
                 spectrum=None,
                 nps=None,
                 ts=None,
                 Es=None,
                 vals=None,
                 u_vals=None):
        self.y = y
        self.u_y = u_y
        self.nps = nps
        self.ts = ts
        self.Es = Es
        self.vals = vals
        self.u_vals = u_vals
        self.signals = {}
        if name is not None:
            self.name = name
        if spectrum is not None:
            self.spectrum = spectrum
        logging.debug(self.y)
        logging.debug("vals: %d, ts: %d, Es: %d" %
                      (len(self.vals), len(self.ts), len(self.Es)))
        #self.ts = np.array([0.] + list(self.ts))
        #self.Es = np.array([0.] + list(self.Es))
        #logging.debug("vals: %d, ts: %d, Es: %d, ts*Es: %d" % (len(self.vals), len(self.ts), len(self.Es), len(self.Es) * len(self.ts)))
        i = 0
        if ts is not None:
            pos_cos_data = vals
            #pos_cos_data = vals[::2]
            #pos_cos_data = vals[len(vals)/2:]
            for E in Es:
                key = r'$E_{n} < %.2f\unit{MeV}$' % E
                vals = pos_cos_data[i * len(self.ts) +
                                    i:(i + 1) * len(self.ts) + i - 1]
                logging.debug("len ts: %d, len vals: %d" %
                              (len(self.ts[:-1]), len(vals)))
                self.signals[key] = pym.curve(1.0E-8 * np.array(self.ts[:-1]),
                                              vals,
                                              key,
                                              data='binned')
                i += 1
            try:
                vals = pos_cos_data[i * len(self.ts) +
                                    i:(i + 1) * len(self.ts) + i - 1]
                logging.debug("len ts: %d, len vals: %d" %
                              (len(self.ts[:-1]), len(vals)))
                i += 1
                self.signals['total'] = pym.curve(1.0E-8 *
                                                  np.array(self.ts[:-1]),
                                                  vals,
                                                  'total',
                                                  data='binned')
            except IndexError:
                pass

        def set_loc(self, loc):
            """ Set the location of the current tally.

            ``set_loc`` sets an internal tuple for the location of the tally,
            usually specified by the center of the cell volume.

            :param tuple loc: The location in an ``(x, y, z)`` format.
            :returns: the modified ``tally`` object.
            """
            self.loc = loc
            return self

        def set_shape(self, shape='rpp'):
            """ Set the shape of the current tally.

            ``set_shape`` holds a string describing the shape of the tally
            volume.  In the future, this will also hold the sizes and directions
            needed to replicate the shape for plotting.

            .. todo:: Add in size and directions to ``tally.set_shape``

            :param str shape: The shape designation of the tally, default 'rpp'
            :returns: the modified ``tally`` object.
            """
            self.shape = shape
            return self
Exemple #21
0
import math
import sys
import numpy as np
sys.path.append("/Users/ahagen/code")
from pym import func as ahm
from pyg import twod as ahp
from ah_py.simulation import fluids as ahf

dfp = ahf.fluid('dfp')
T_b = dfp.T_b
P_b = dfp.P_b
dfp_pos_curve = ahm.curve(P_b, T_b - 273.15, name='dfp')

ace = ahf.fluid('ace')
T_b = ace.T_b
P_b = ace.P_b
ace_pos_curve = ahm.curve(P_b, T_b - 273.15, name='ace')

plot = dfp_pos_curve.plot(linestyle='-', linecolor='#E3AE24')

'''
A = 6.43876
B = 1242.510
C = 46.568
P = np.linspace(1., -700000., 500) / 1.0E3 # in kPa
T_b = - B / (np.log10(P) - A) + C
dfp_neg_curve = ahm.curve(P * 1.0E3, T_b, name='dfp-neg')
plot = dfp_neg_curve.plot(linestyle='--', linecolor='#E3AE24', addto=plot)
'''

dfp_exp_curve = ahm.curve([-3.2 * 1.0E5], [24.], name='dfp expt')
sys.path.append(expanduser("~") + "/code")
from pymf import ctmfd as ahsoa
from pym import func as ahm

E_high = 6.00;

p = [5.0,6.0,7.0,10.0];
wt = [186.31,4.53,2.81,0.00];
wt_err = [0.00,4.53,1.99,0.00];
p_u = [5.0];
wt_u = [46.216];
wt_u_err = [20.668];
p_be = [5.0];
wt_be = [6.882];
wt_be_err = [3.07];
detection = ahm.curve(p,wt,name='connector',u_y=wt_err);
detection_plot = detection.plot(linecolor='#746C66', linestyle='-', legend=False);
u_det = ahm.curve(p_u,wt_u,name='U-235',u_y=wt_u_err);
be_det = ahm.curve(p_be,wt_be,name='Be',u_y=wt_be_err);
detection_plot = u_det.plot(linecolor='#E3AE24', addto=detection_plot);
detection_plot = be_det.plot(linecolor='#2EAF9B', addto=detection_plot);
detection_plot.add_text(7.25, 100.0, string="Detection of \n photoneutron contamination")
detection_plot.markers_on();
detection_plot.lines_off();
detection_plot.lines['connector'].set_linewidth(1.0);
detection_plot.lines['connector'].set_markersize(0)
detection_plot.ylim(0,200.0);
detection_plot.xlim(0,10.0);
detection_plot.add_data_pointer(p_u[0],point=wt_u[0],
	string="NU Detection",place=(3.0,100.0));
detection_plot.add_data_pointer(p_be[0],point=wt_be[0],
Exemple #23
0
gold = '#E3AE24'
teal = '#2EAFA4'
orange = '#B95915'

t = [0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 20., 40., 60., 80., 100.,
     120., 140., 160., 180., 200.]
alpha = np.log(np.array([102515., 79205., 61903., 48213., 37431., 29367., 23511.,
                  18495., 14829., 11853., 9595., 2372., 1421., 1135., 862.,
                  725., 551., 462., 359., 265., 225.]) / 3600.)
t_1 = np.linspace(0., 50.)
m_1 = (-0.4 - 3.3) / 20.0
alpha_1 = m_1 * t_1 + 3.3
t_2 = np.linspace(20., 200.)
m_2 = ((-2.8 + 0.4) / 180.)
alpha_2 = m_2 * t_2 + m_2 * 20.
curve = ahf.curve(t, alpha, name=r'$\alpha_{1} + \alpha_{2}$')
a1 = ahf.curve(t_1, alpha_1, name=r'$\alpha_{1}$')
a2 = ahf.curve(t_2, alpha_2, name=r'$\alpha_{2}$')
plot = curve.plot(linecolor=gold, linestyle='-')
plot = a1.plot(linecolor=teal, linestyle='--', addto=plot)
plot = a2.plot(linecolor=orange, linestyle='--', addto=plot)
plot.lines_on()
plot.markers_off()
plot.xlabel(r'Time ($t$) [$d$]')
plot.ylabel(r'Log Activity ($\ln \left( \alpha_{X} \right)$) [$bq$]')
plot.legend()
plot.add_data_pointer(0., curve=curve,
                      string=r'$\alpha \left( %.1f \right) = %.1f$' %
                      (0.0, curve.at(0.0)), place=(20., 2.))
plot.add_data_pointer(20., curve=curve,
                      string=r'$\alpha \left( %.1f \right) = %.1f$' %
Exemple #24
0
sys.path.append(expanduser("~") + "/code")
from pymf import ctmfd as ahi
from pym import func as ahf
from pyg import twod as ahp

panel_dd = ahi.ctmfd_data()
panel_dd.add_data(
    expanduser("~") + "/data/tena/m41_panel_dd_1E8_200_cm_02_18_16.lvm")
panel_dd.add_data(
    expanduser("~") + "/data/tena/m16_panel_dd_1E8_200_cm_02_18_16.lvm")
panel_dd.add_data(
    expanduser("~") + "/data/tena/m42_panel_dd_1E8_200_cm_02_18_16.lvm")
panel_dd.remove_pressure(4.00)
panel_dd_curve = ahf.curve(panel_dd.p,
                           panel_dd.wt,
                           name="Panel - DD",
                           u_x=panel_dd.p_sigma,
                           u_y=panel_dd.wt_sigma)

panel_dd_cf = ahi.ctmfd_data()
panel_dd_cf.add_data(
    expanduser("~") +
    "/data/tena/m41_panel_dd_1E8_200_cm_cf_100_cm_02_18_16.lvm")
panel_dd_cf.add_data(
    expanduser("~") +
    "/data/tena/m16_panel_dd_1E8_200_cm_cf_100_cm_02_18_16.lvm")
panel_dd_cf.add_data(
    expanduser("~") +
    "/data/tena/m42_panel_dd_1E8_200_cm_cf_100_cm_02_18_16.lvm")
panel_dd_cf.remove_pressure(4.00)
panel_dd_cf_curve = ahf.curve(panel_dd_cf.p,
from colour import Color

from os.path import expanduser
sys.path.append(expanduser("~") + "/code")
from pymf import ctmfd as ahi
from pym import func as ahm
from pyg import twod as ahp


def exp_comp(x, a, b):
    return a * (1.0 - np.exp(b * x))


v = [4.0, 15.0, 40.0, 65.0]
eff = [15.0, 36.0, 60.0, 80.0]
f = ahm.curve(v, eff, name='$\eta$')
f.fit_gen(exp_comp, guess=[100.0, -0.05])
figure = f.plot(linecolor="#746C66")
figure.lines_off()
figure = f.plot_fit(addto=figure, linecolor="#E3AE24", xmin=0.0, xmax=100.0)
figure.lines['$\eta$0'].set_linewidth(0.0)
figure.lines['$\eta$0'].set_markersize(6)
figure.lines['$\eta$fit0'].set_linewidth(1.0)
figure.lines['$\eta$fit0'].set_markersize(0)
figure.add_data_pointer(50.0,
                        point=f.fit_at(50.0),
                        string='Interaction efficiency scales\n' +
                        'by  attenuation law',
                        place=(40.0, 20.0))
figure.ylim(0.0, 100.0)
figure.xlim(0.0, 100.0)
Exemple #26
0
    np.loadtxt('Fig7-Cf-Eff.csv',
               delimiter=",", dtype=object,
               converters={0: float, 1: float, 2: float},
               unpack=True)
# points = [range(0, 6), range(7, 11), range(13, 17), range(19, 25),
#           range(26, 31), range(32, 39), range(40, 48), range(49, 57),
#           range(58, 63), range(64, 68), range(69, 82)]
# pwr = [np.mean(pwr_new[idx]) for idx in points]
# u_pwr = [np.std(pwr_new[idx]) for idx in points]
# eff = np.array([np.mean(eff_new[idx]) for idx in points])
# u_eff = np.array([np.mean(u_eff[idx]) for idx in points])
# std_eff = np.array([np.std(eff_new[idx]) for idx in points])
# u_eff = np.sqrt(np.power(u_eff, 2.0) + np.power(std_eff, 2.0))
pwr = pwr_new
eff = eff_new
cf_tena_eta = ahf.curve(pwr, 100. * eff, u_y=u_eff, name="cf_tena_setup")

pwr_new, eff_new, u_eff = \
    np.loadtxt('Fig7-DD-Eff.csv',
               delimiter=",", dtype=object,
               converters={0: float, 1: float, 2: float},
               unpack=True)
# pwr = [np.mean(pwr_new[0:1]), np.mean(pwr_new[2]), np.mean(pwr_new[3]),
#        np.mean(pwr_new[4:])]
# u_pwr = [np.std(pwr_new[0:1]), np.std(pwr_new[2]), np.std(pwr_new[3]),
#          np.std(pwr_new[4:])]
# eff = np.array([np.mean(eff_new[0:1]), np.mean(eff_new[2]), np.mean(eff_new[3]),
#        np.mean(eff_new[4:])]) / nps_dd
# u_eff = np.array([np.mean(u_eff[0:1]), np.mean(u_eff[2]), np.mean(u_eff[3]),
#          np.mean(u_eff[4:])]) / nps_dd
# std_eff = np.array([np.std(eff_new[0:1]), np.std(eff_new[2]), np.std(eff_new[3]),
Exemple #27
0
import numpy as np
from scipy import integrate
import sys
sys.path.append("/Users/ahagen/code")
from pymf import ctmfd as ahi
from pym import func as ahf
from pyg import twod as ahp

arr = np.loadtxt('mc_results_4.dat')
z = arr[:, 0]
C = arr[:, 1]

mc4 = ahf.curve(z, C, name=r'$N = 10^{4}$')

plot = ahp.ah2d()
mc4.plot(linestyle='-', linecolor='#5C8727', addto=plot)
plot.lines_on()
plot.markers_off()

arr = np.loadtxt('mc_results_6.dat')
z = arr[:, 0]
C = arr[:, 1]

mc6 = ahf.curve(z, C, name=r'$N = 10^{6}$')
mc6.plot(linestyle='-', linecolor='#2EAFA4', addto=plot)

plot.lines_on()
plot.markers_off()

arr = np.loadtxt('mc_results_8.dat')
z = arr[:, 0]
Exemple #28
0
import numpy as np
from scipy import integrate
import sys
sys.path.append("/Users/ahagen/code")
from pymf import ctmfd as ahi
from pym import func as ahf
from pyg import twod as ahp

def deriv(Y, t):
    return [Y[1], -0.5 * Y[1] - 10 * np.sin(Y[0])]

# use integrate.odeint to determine the solution
x = np.linspace(0, 2.5, 1000, endpoint=True)
sol = integrate.odeint(deriv, [.5, 0], x)

ode_solution = ahf.curve(x, sol[:, 0], name='ode')

t_0_25, y_0_25 = np.loadtxt('pendulum_0.250000.dat', usecols=(0, 1), unpack=True)
h_0_25_solution = ahf.curve(t_0_25, y_0_25, name=r'$h = 0.25 \mathrm{s}$')

t_0_125, y_0_125 = np.loadtxt('pendulum_0.125000.dat', usecols=(0, 1),
                              unpack=True)
h_0_125_solution = ahf.curve(t_0_125, y_0_125,
                             name=r'$h = 0.125 \mathrm{s}$')

t_0_00001, y_0_00001 = np.loadtxt('pendulum_0.000244.dat', usecols=(0, 1),
                                  unpack=True)
h_0_00001_solution = ahf.curve(t_0_00001, y_0_00001,
                               name=r'$h = 0.000244 \mathrm{s}$')

plot = ahp.ah2d()
Exemple #29
0
from pyg import twod as ahp

mid = []
trap = []
simp = []

evals = [2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 50, 100]

for i in evals:
    output = os.popen("./maxwellian %d" % (i)).read()
    floats = map(float, output.strip().split("\n"))
    mid = np.append(mid, floats[0])
    trap = np.append(trap, floats[1])
    simp = np.append(simp, floats[2])

mid_curve = ahf.curve(evals, mid, name="midpoint")
trap_curve = ahf.curve(evals, trap, name="trapezoidal")
simp_curve = ahf.curve(evals, simp, name="simpson's")

plot = ahp.ah2d()
mid_curve.plot(linestyle='-', linecolor="#E3AE24", addto=plot)
trap_curve.plot(linestyle='-', linecolor="#746C66", addto=plot)
simp_curve.plot(linestyle='-', linecolor="#2EAFA4", addto=plot)

plot.lines_on()
plot.legend()
plot.xlabel(r'Number of subintervals ($\frac{E_{high} - E_{low}}{h}$) [ ]')
plot.ylabel(r'Probability ($\frac{N\left( E \right)}{N}$) [ ]')

plot.ax.set_xscale('log')
sys.path.append(expanduser("~") + "/code")
from pymf import ctmfd as ahsoa
from pym import func as ahm

E_high = 6.00

p = [5.0, 6.0, 7.0, 10.0]
wt = [186.31, 4.53, 2.81, 0.00]
wt_err = [0.00, 4.53, 1.99, 0.00]
p_u = [5.0]
wt_u = [46.216]
wt_u_err = [20.668]
p_be = [5.0]
wt_be = [6.882]
wt_be_err = [3.07]
detection = ahm.curve(p, wt, name='connector', u_y=wt_err)
detection_plot = detection.plot(linecolor='#746C66',
                                linestyle='-',
                                legend=False)
u_det = ahm.curve(p_u, wt_u, name='U-235', u_y=wt_u_err)
be_det = ahm.curve(p_be, wt_be, name='Be', u_y=wt_be_err)
detection_plot = u_det.plot(linecolor='#E3AE24', addto=detection_plot)
detection_plot = be_det.plot(linecolor='#2EAF9B', addto=detection_plot)
detection_plot.add_text(7.25,
                        100.0,
                        string="Detection of \n photoneutron contamination")
detection_plot.markers_on()
detection_plot.lines_off()
detection_plot.lines['connector'].set_linewidth(1.0)
detection_plot.lines['connector'].set_markersize(0)
detection_plot.ylim(0, 200.0)
Exemple #31
0
import sys
import numpy as np
from colour import Color
from dateutil import parser
import matplotlib.dates as md
from os.path import expanduser
sys.path.append(expanduser("~") + "/code")
from pymf import ctmfd as ahi
from pym import func as ahf

pneg, eff, u_eff = \
    np.loadtxt('Fig8-Cf-Eff.csv',
               delimiter=",", dtype=object,
               converters={0: float, 1: float, 2: float},
               unpack=True)
m16_cf_curve = ahf.curve(pneg, 100. * eff, u_y=u_eff, name='$Cf$')
pneg, eff, u_eff = \
    np.loadtxt('Fig8-DD-Eff.csv',
               delimiter=",", dtype=object,
               converters={0: float, 1: float, 2: float},
               unpack=True)
m16_dd_curve = ahf.curve(pneg, 100. * eff, u_y=u_eff, name='$DD$')
pneg, u_pneg, r, u_r = \
    np.loadtxt('Fig9-Ratio.csv',
               delimiter=",", dtype=object,
               converters={0: float, 1: float, 2: float, 3: float},
               unpack=True)
m16_ratio_curve = ahf.curve(pneg, r, u_x=u_pneg, u_y=u_r, name='$r$')

plot = m16_ratio_curve.plot(linestyle='-', linecolor='#E3AE24')
m16_ratio_curve.fit_exp()
Exemple #32
0
    def __init__(self, filename, nps=None, tmesh=False, times=True):
        orig_filename = filename
        # check for tallies file
        # check for meshtal file
        # check for source file
        self.src_fname = filename + '_source.out'
        if '_tallies.out' not in filename and 'meshtal' not in filename:
            filename = filename + '_tallies.out'
        with open(filename, 'r') as f:
            file_string = f.read()

        # check if source file exists
        self.source = None
        print self.src_fname
        if os.path.isfile(self.src_fname):
            print "checking source file"
            self.source = src_analysis(self.src_fname)

        tallies = list()
        strings = file_string.split('tally')
        # print strings[0].split()
        if '_tallies.out' in filename:
            if nps is None:
                try:
                    self.nps = float(strings[0].split()[5])
                except ValueError:
                    self.nps = 1.0
                    print "could not get nps, defaulting to 1.0"
            else:
                self.nps = nps
        elif 'meshtal' in filename:
            #self.nps = float(strings[0].split()[19])
            self.nps = 1.0e9
        #print "%e" % self.nps
        if '_tallies.out' in filename:
            if tmesh:
                for string in strings[1:]:
                    try:
                        E_bins, xs, ys, zs, phis, u_phis = \
                            self.import_tmesh_section(string)
                        tallies.extend([meshtal(xs, ys, zs, E_bins, phis, u_phis)])
                    except IndexError:
                        total, u_total, name, e_bins, vals, u_vals, t_bins = \
                            self.import_tally_section(string)
                        self.ts = t_bins
                        self.Es = e_bins
                        self.vals = vals
                        if len(t_bins) > 1:
                            spect = pym.curve([], [], u_y=[], name=name,
                                              data='binned')
                        else:
                            spect = pym.curve(e_bins, vals, u_y=u_vals,
                                              name=name, data='binned')
                        tallies.extend([tally(total, u_total, name, spect,
                                              nps=self.nps, ts=t_bins,
                                              Es=e_bins, vals=vals,
                                              u_vals=u_vals)])
            else:
                for string in strings[1:]:
                    total, u_total, name, e_bins, vals, u_vals, t_bins = \
                        self.import_tally_section(string)
                    self.ts = t_bins
                    self.Es = e_bins
                    self.vals = vals
                    if len(t_bins) > 1:
                        spect = pym.curve([], [], u_y=[], name=name,
                                          data='binned')
                    else:
                        logging.debug(len(e_bins))
                        logging.debug(len(vals))
                        spect = pym.curve(e_bins, vals, u_y=u_vals,
                                          name=name, data='binned')
                    tallies.extend([tally(total, u_total, name, spect,
                                          nps=self.nps, ts=t_bins, Es=e_bins,
                                          vals=vals, u_vals=u_vals)])
        elif 'meshtal' in filename:
            meshtals = list()
            strings = file_string.split('Mesh Tally Number')
            if len(strings) < 2:
                strings = file_string.split('tally')
            logging.debug("Length of strings %d" % len(strings))
            for string in strings[1:]:
                E_bins, xs, ys, zs, phis, u_phis = \
                    self.import_meshtal_section(string)
                tallies.extend([meshtal(xs, ys, zs, E_bins, phis, u_phis)])
        self.tallies = tallies
Exemple #33
0
import sys
import numpy as np
from colour import Color

from os.path import expanduser
sys.path.append(expanduser("~") + "/code")
from pymf import ctmfd as ahi
from pym import func as ahm
from pyg import twod as ahp

def exp_comp(x,a,b):
    return a * (1.0 - np.exp(b * x))

v = [4.0, 15.0, 40.0, 65.0]
eff = [15.0, 36.0, 60.0, 80.0]
f = ahm.curve(v, eff, name='$\eta$')
f.fit_gen(exp_comp, guess=[100.0, -0.05])
figure = f.plot(linecolor="#746C66")
figure.lines_off()
figure = f.plot_fit(addto=figure, linecolor="#E3AE24", xmin=0.0, xmax=100.0)
figure.lines['$\eta$0'].set_linewidth(0.0)
figure.lines['$\eta$0'].set_markersize(6)
figure.lines['$\eta$fit0'].set_linewidth(1.0)
figure.lines['$\eta$fit0'].set_markersize(0)
figure.add_data_pointer(50.0, point=f.fit_at(50.0),
                        string='Interaction efficiency scales\n' +
                               'by  attenuation law',
                        place=(40.0, 20.0))
figure.ylim(0.0, 100.0)
figure.xlim(0.0, 100.0)
figure.xlabel(r'Sensitive Volume ($v$) [$cm^{3}$]')
Exemple #34
0
f = np.array([
    1., 2., 6., 10., 20., 60., 100., 200., 600., 1E3, 2E3, 6E3, 10E3, 20E3,
    60E3, 100E3, 200E3, 600E3, 1E6, 2E6, 6E6
])
v_out = np.array([
    34E-3, 44E-3, 72E-3, 91E-3, 144E-3, 344E-3, 469E-3, 600E-3, 770E-3, 800E-3,
    880E-3, 890E-3, 890E-3, 880E-3, 810E-3, 730E-3, 580E-3, 359E-3, 259E-3,
    147E-3, 63E-3
])
v_in = np.array([
    1.16, 1.13, 1.13, 1.13, 1.13, 1.13, 1.13, 1.16, 1.16, 1.16, 1.13, 1.13,
    1.13, 1.13, 1.13, 1.13, 1.13, 1.13, 1.13, 1.09, 1.00
])

freq_response = ahf.curve(f, v_out / v_in)
print v_out / v_in
freq_plot = freq_response.plot()
freq_plot.lines_on()
freq_plot.markers_off()
freq_plot.ax.set_xscale("log", nonposx='clip')
freq_plot.ylim(0., 1.)
freq_plot.ax.set_yticks([0.0, 0.5, 1.0])
freq_plot.ax.set_xticks([10.E0, 10.E3, 10.E6])
freq_plot.xlabel(r'Frequency ($f$) [$Hz$]')
freq_plot.ylabel(r'Gain ($A_{V}$) [ ]')
freq_plot.export('../img/filter_frequency_response',
                 sizes=['cs'],
                 formats=['pdf', 'pgf'],
                 customsize=(0.75, 0.75))
freq_plot.show()
Exemple #35
0
    3.85630E-08, 6.92248E-08, 0.00000E+00, 0.00000E+00, 0.00000E+00
])
u_n_52 = np.array([
    0.5288, 0.0538, 0.1673, 0.2384, 0.2289, 0.4050, 0.4480, 0.4208, 0.5182,
    0.5116, 1.0000, 0.6735, 0.0000, 0.0000, 0.0000
])

r = [0., 52., 132.]
thresh = 0.250  # estimating the threshold to be around 500 kev
n = np.array([
    np.sum(n_0[np.where(e_0 > thresh)]),
    np.sum(n_52[np.where(e_52 > thresh)]),
    np.sum(n_132[np.where(e_132 > thresh)])
]) / nps
print n
mcnp = ahm.curve(r, n, name='simulation')

d = [0.0, 52.0, 100.0, 132.0]
wt = np.array([2.75, 56.69, 277.15, 3.0 * 121.45])
u_wt = np.array([1.59, 28.34, 277.15, 121.45]) / wt
cr = 1.0 / wt
u_cr = cr * u_wt
u_cr_up = u_cr
u_cr_down = u_cr.copy()
u_cr_down[3] = np.inf
u_cr = np.vstack((u_cr_down, u_cr_up))

expt = ahm.curve(d, cr, u_y=u_cr, name='experiment')

x = np.arange(1.0, 140.)
y = cr[0] / np.power(x, 1.0)
Exemple #36
0
 def __init__(self, name=None):
     if name.lower() in ['acetone', 'ace']:
         self.P_c = 4690000.0
         self.T_c = 508.100
         P_b = [1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14.,
                15., 16., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26.,
                27., 28., 29., 30., 31., 32., 33., 34., 35., 36., 37., 38.,
                39., 40., 41., 42., 43., 44., 45., 46., 47., 48., 49.,
                50., 51., 52., 53., 54., 55., 56., 57., 58., 59., 60., 61.,
                62., 63., 64., 65., 66., 67., 68., 69., 70., 71., 72., 73.,
                74., 75., 76., 77., 78., 79., 80., 81., 82., 83., 84., 85.,
                86., 87., 88., 89., 90., 91., 92., 93., 94., 95., 96., 97.,
                98., 99., 100., 101., 102., 103., 104., 105., 106., 107.,
                108., 109., 110., 111., 112., 113., 114., 115., 116., 117.,
                118., 119., 120., 121., 122., 123., 124., 125., 126., 127.,
                128., 129., 130., 131., 132., 133., 134., 135., 136., 137.,
                138., 139., 140., 141., 142., 143., 144., 145., 146., 147.,
                148., 149., 150., 151., 152., 153., 154., 155., 156., 157.,
                158., 159., 160., 161., 162., 163., 164., 165., 166., 167.,
                168., 169., 170., 171., 172., 173., 174., 175., 176., 177.,
                178., 179., 180., 181., 182., 183., 184., 185., 186., 187.,
                188., 189., 190., 191., 192., 193., 194., 195., 196., 197.,
                198., 199., 200.]
         T_b = [237.48, 247.36, 253.59, 258.25, 262.00, 265.17, 267.91,
                270.35, 272.54, 274.53, 276.36, 278.06, 279.65, 281.14,
                282.54, 283.87, 285.12, 286.32, 287.47, 288.57, 289.62,
                290.63, 291.61, 292.55, 293.45, 294.33, 295.19, 296.01,
                296.82, 297.60, 298.36, 299.10, 299.82, 300.52, 301.21,
                301.88, 302.53, 303.18, 303.80, 304.42, 305.02, 305.61,
                306.19, 306.76, 307.32, 307.87, 308.41, 308.94, 309.46,
                309.97, 310.47, 310.97, 311.46, 311.94, 312.41, 312.88,
                313.34, 313.80, 314.24, 314.69, 315.12, 315.55, 315.98,
                316.40, 316.81, 317.22, 317.62, 318.02, 318.42, 318.81,
                319.19, 319.57, 319.95, 320.32, 320.69, 321.06, 321.42,
                321.77, 322.13, 322.48, 322.83, 323.17, 323.51, 323.85,
                324.18, 324.51, 324.84, 325.16, 325.48, 325.80, 326.12,
                326.43, 326.74, 327.05, 327.35, 327.65, 327.96, 328.25,
                328.55, 328.84, 329.13, 329.42, 329.71, 329.99, 330.27,
                330.55, 330.83, 331.10, 331.38, 331.65, 331.92, 332.19,
                332.45, 332.71, 332.98, 333.24, 333.50, 333.75, 334.01,
                334.26, 334.51, 334.76, 335.01, 335.26, 335.50, 335.75,
                335.99, 336.23, 336.47, 336.71, 336.94, 337.18, 337.41,
                337.64, 337.87, 338.10, 338.33, 338.56, 338.78, 339.01,
                339.23, 339.45, 339.67, 339.89, 340.11, 340.33, 340.54,
                340.76, 340.97, 341.18, 341.39, 341.60, 341.81, 342.02,
                342.23, 342.43, 342.64, 342.84, 343.04, 343.25, 343.45,
                343.65, 343.85, 344.04, 344.24, 344.44, 344.63, 344.83,
                345.02, 345.21, 345.40, 345.59, 345.78, 345.97, 346.16,
                346.35, 346.53, 346.72, 346.90, 347.09, 347.27, 347.45,
                347.63, 347.82, 348.00, 348.17, 348.35, 348.53, 348.71,
                348.88, 349.06, 349.23, 349.41, 349.58, 349.76, 349.93,
                350.10, 350.27, 350.44, 350.61]
         self.T_b_curve = ahm.curve(np.array(P_b) * 1.0E3, np.array(T_b))
         self.M = 58.0791 / 1000.0
         self.omega_c = 0.347
         self.omega_rho = 0.625  # 0.30667
         self.T_b = np.array(T_b)
         self.P_b = np.array(P_b) * 1.0E3
     if name.lower() in ['dfp', 'decafluoropentane']:
         self.P_c = 2070000.
         self.T_c = 457.
         A = 6.43876
         B = 1242.510
         C = 46.568
         T_b = np.linspace(237., 350., 1000)  # in K
         P_b = np.power(10., A - (B / (T_b - C)))  # in kPa
         self.T_b_curve = ahm.curve(np.array(P_b) * 1.0E3, np.array(T_b))
         self.M = 252.055032 / 1000.0
         self.omega_rho = 0.62
         self.T_b = np.array(T_b)
         self.P_b = np.array(P_b) * 1.0E3
Exemple #37
0
y = []
toty = 0.

for row in data:
    if row[1] == 'Running':
        t = datetime.datetime.strptime(row[0], '%Y-%m-%d %H:%M:%S')
        dt = (t - datetime.datetime(2015, 5, 1, 12, 0)).total_seconds()
        x = np.append(x, -dt)
        toty = toty + float(row[2])
        y = np.append(y, toty)


print x
print y

mileage = ahf.curve(x, y, name=r'$s$')
plot = mileage.plot(linestyle='-', linecolor='#285668')
plot.fill_between(x, np.zeros_like(x), y, fc='#285668')
plot.lines_on()
plot.markers_off()
plot.ax.tick_params(axis="x", colors='#285668')
plot.ax.tick_params(axis="y", colors='#285668')
plot.ax.yaxis.label.set_color('#285668')
plot.ax.xaxis.label.set_color('#285668')
plot.ax.spines['bottom'].set_visible(False)
plot.ax.spines['left'].set_visible(False)


plot.xticks([-(datetime.datetime(2015, 6, 1, 12, 0) -
             datetime.datetime(2015, 5, 1, 12, 0)).total_seconds(),
             -(datetime.datetime(2015, 9, 1, 12, 0) -
Exemple #38
0
import sys
import os
import numpy as np
sys.path.append(os.path.expanduser('~') + "code");
from pymf import ctmfd as ahi
from pym import func as ahf
from colour import Color

x = np.linspace(0,1.0);
k_1 = 2.02875;
k_2 = 4.91318;
y_1 = np.sin(k_1*x);
y_2 = np.sin(k_2*x);

fund_curve = ahf.curve(x,y_1,name='Fundamental');
plot = fund_curve.plot(linecolor='#A3792C',linestyle='--');
over_curve = ahf.curve(x,y_2,name='1st Overtone');
plot = over_curve.plot(addto=plot,linecolor='#2EAFA4',linestyle='--');

plot.lines_on();
plot.lines_off();
plot.xlabel('X-Coordinate ($x$) [ ]');
plot.ylabel('Wave Function ($y_{n}$) [ ]');
plot.ylim(-1.5,1.5);
plot.legend();

plot.export("waveforms",sizes=['cs'],formats=['png','svg','pgf'],customsize=[6,3]);
Exemple #39
0
import sys
import numpy as np
from os.path import expanduser
sys.path.append(expanduser("~") + "/code")
from pymf import ctmfd as ahi
from pym import func as ahm
from pyg import twod as ahp

t = np.linspace(0,5.0*2.0*3.14/40000.0,num=1000)
p = np.sin(40000*t);
v = p.copy();
v[p>-0.75]=0.0;
v[p<=-0.75]=-1.0 * p[p<=-0.75];

p_curve = ahm.curve(t,p,name='$p$');
v_curve = ahm.curve(t,v,name='$V$');


figure = p_curve.plot();
figure.ax.set_yticks([-1,0,1],['$\max\,p_{neg}$','$0.0$','$\min\,p_{neg}$'])
figure = v_curve.plot(addto=figure, yy=True)
figure.ax.set_yticks([0,1],['$0.0$','$\max\,V$'])
figure.fill_between(t,np.zeros(np.size(t)),
    v,fc='#E3AE24');
figure.lines_on();
figure.markers_off();
#figure.xlabel('Time ($t$)');
figure.ylabel('Pressure Amplitude '
    +'($\left| p \\right|$)');
figure.ax2.set_ylabel('Sensitive Volume '
    +'($V$)');
Exemple #40
0
    def __init__(self, filename, nps=None, tmesh=False, times=True):
        orig_filename = filename
        # check for tallies file
        # check for meshtal file
        # check for source file
        self.src_fname = filename + '_source.out'
        if '_tallies.out' not in filename and 'meshtal' not in filename:
            filename = filename + '_tallies.out'
        with open(filename, 'r') as f:
            file_string = f.read()

        # check if source file exists
        self.source = None
        print(self.src_fname)
        if os.path.isfile(self.src_fname):
            print("checking source file")
            self.source = src_analysis(self.src_fname)

        tallies = list()
        strings = file_string.split('tally')
        # print strings[0].split()
        if '_tallies.out' in filename:
            if nps is None:
                try:
                    self.nps = float(strings[0].split()[5])
                except ValueError:
                    self.nps = 1.0
                    print("could not get nps, defaulting to 1.0")
            else:
                self.nps = nps
        elif 'meshtal' in filename:
            #self.nps = float(strings[0].split()[19])
            self.nps = 1.0e9
        #print "%e" % self.nps
        if '_tallies.out' in filename:
            if tmesh:
                for string in strings[1:]:
                    try:
                        E_bins, xs, ys, zs, phis, u_phis = \
                            self.import_tmesh_section(string)
                        tallies.extend(
                            [meshtal(xs, ys, zs, E_bins, phis, u_phis)])
                    except IndexError:
                        total, u_total, name, e_bins, vals, u_vals, t_bins = \
                            self.import_tally_section(string)
                        self.ts = t_bins
                        self.Es = e_bins
                        self.vals = vals
                        if len(t_bins) > 1:
                            spect = pym.curve([], [],
                                              u_y=[],
                                              name=name,
                                              data='binned')
                        else:
                            spect = pym.curve(e_bins,
                                              vals,
                                              u_y=u_vals,
                                              name=name,
                                              data='binned')
                        tallies.extend([
                            tally(total,
                                  u_total,
                                  name,
                                  spect,
                                  nps=self.nps,
                                  ts=t_bins,
                                  Es=e_bins,
                                  vals=vals,
                                  u_vals=u_vals)
                        ])
            else:
                for string in strings[1:]:
                    total, u_total, name, e_bins, vals, u_vals, t_bins = \
                        self.import_tally_section(string)
                    self.ts = t_bins
                    self.Es = e_bins
                    self.vals = vals
                    if len(t_bins) > 1:
                        spect = pym.curve([], [],
                                          u_y=[],
                                          name=name,
                                          data='binned')
                    else:
                        logging.debug(len(e_bins))
                        logging.debug(len(vals))
                        spect = pym.curve(e_bins,
                                          vals,
                                          u_y=u_vals,
                                          name=name,
                                          data='binned')
                    tallies.extend([
                        tally(total,
                              u_total,
                              name,
                              spect,
                              nps=self.nps,
                              ts=t_bins,
                              Es=e_bins,
                              vals=vals,
                              u_vals=u_vals)
                    ])
        elif 'meshtal' in filename:
            meshtals = list()
            strings = file_string.split('Mesh Tally Number')
            if len(strings) < 2:
                strings = file_string.split('tally')
            logging.debug("Length of strings %d" % len(strings))
            for string in strings[1:]:
                E_bins, xs, ys, zs, phis, u_phis = \
                    self.import_meshtal_section(string)
                tallies.extend([meshtal(xs, ys, zs, E_bins, phis, u_phis)])
        self.tallies = tallies
Exemple #41
0
    if 'starttime:' in line:
        t_s = int(line.replace('starttime:',''));
        #print "the start time is %10.4e" % (t_s);
        # line here includes the start time for a run of 10000 reads
        #print line
    elif 'endtime:' in line:

        t_e = int(line.replace('endtime:',''));
        #print "the end time is %10.4e" % (t_e);
        x = np.linspace(t_s, t_e, 10000);
        t=np.append(t,x);
        w_f = np.append(w_f,y);
        num_val=0;
        # line here includes the end time for a run of 10000 reads
        #print line
    else:
        # line here includes the reading from the adc
        val = int(line);
        y[num_val] = val;
        num_val = num_val+1;

waveform = ahm.curve(t,w_f);
waveform_plot = waveform.plot(linestyle='-',linecolor='#E3AE24');
waveform_plot.lines_on();
waveform_plot.markers_off();
waveform_plot.xlim(15010,15025);
waveform_plot.xlabel('Time ($t$) [$ms$]');
waveform_plot.ylabel('ADC Reading ($\\frac{1024\cdot V}{5.0}$) [ ]');
waveform_plot.export('../img/filtered',sizes=['cs'],formats=['png','pgf'],
	customsize=[4.25,2.25]);
Exemple #42
0
import numpy as np
from scipy import integrate
import matplotlib.pyplot as plt
import sys
sys.path.append("/Users/ahagen/code")
from pymf import ctmfd as ahi
from pym import func as ahf
from pyg import twod as ahp
import glob

fname = glob.glob('fem_sol/*.dat')
for i in range(len(fname)):
    arr = np.loadtxt(fname[i])
    z = arr[:, 0] * 1.0E4
    C = arr[:, 1]
    fem = ahf.curve(z, C, name=r'fem')
    print np.max(C)

    plot = fem.plot(linestyle='-', linecolor='#B63F97')
    plot.lines_on()
    plot.markers_off()

    arr = np.loadtxt(fname[i].replace('fem', 'fdm'))
    z = arr[:, 0] * 1.0E4
    C = arr[:, 1]

    fdm = ahf.curve(z, C, name=r'fdm')
    fdm.plot(linestyle='-', linecolor='#2EAFA4', addto=plot)
    plot.lines_on()
    plot.markers_off()
Exemple #43
0
    0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 20., 40., 60., 80., 100.,
    120., 140., 160., 180., 200.
]
alpha = np.log(
    np.array([
        102515., 79205., 61903., 48213., 37431., 29367., 23511., 18495.,
        14829., 11853., 9595., 2372., 1421., 1135., 862., 725., 551., 462.,
        359., 265., 225.
    ]) / 3600.)
t_1 = np.linspace(0., 50.)
m_1 = (-0.4 - 3.3) / 20.0
alpha_1 = m_1 * t_1 + 3.3
t_2 = np.linspace(20., 200.)
m_2 = ((-2.8 + 0.4) / 180.)
alpha_2 = m_2 * t_2 + m_2 * 20.
curve = ahf.curve(t, alpha, name=r'$\alpha_{1} + \alpha_{2}$')
a1 = ahf.curve(t_1, alpha_1, name=r'$\alpha_{1}$')
a2 = ahf.curve(t_2, alpha_2, name=r'$\alpha_{2}$')
plot = curve.plot(linecolor=gold, linestyle='-')
plot = a1.plot(linecolor=teal, linestyle='--', addto=plot)
plot = a2.plot(linecolor=orange, linestyle='--', addto=plot)
plot.lines_on()
plot.markers_off()
plot.xlabel(r'Time ($t$) [$d$]')
plot.ylabel(r'Log Activity ($\ln \left( \alpha_{X} \right)$) [$bq$]')
plot.legend()
plot.add_data_pointer(0.,
                      curve=curve,
                      string=r'$\alpha \left( %.1f \right) = %.1f$' %
                      (0.0, curve.at(0.0)),
                      place=(20., 2.))