Ejemplo n.º 1
0
Archivo: ewf.py Proyecto: inr-kit/pirs2
def main():
    fmt, iname, mats, factor = get_clp()

    from pirs.mcnp import Material
    from pirs.core.tramat.data_names import name as chemical_names

    d = Material.read_from_input(iname)
    f = '{{:>2s}}-{{:<3d}}: {}'.format(fmt)

    for mn in mats:
        m = d.get(mn, None)
        if m is None:
            continue

        print 'Material ', mn
        e = m.elements(keyform='Z')
        wt = m.amount(2)
        for z in e.keys():
            we = m.how_much(2, Z=z)
            print ' ', f.format(chemical_names[z], z, we / wt * factor)
Ejemplo n.º 2
0
def read_input(iname):
    """
    Read input and write dump for later use.

    The dump is used only when younger than the original input file.
    """
    import cPickle
    import os
    from numjuggler.parser import get_cards, CID
    from pirs.mcnp import Material

    inp = iname
    dmp = '.{}.matdump'.format(iname)
    print inp
    print dmp
    mats = None
    try:
        if os.stat(dmp).st_mtime > os.stat(inp).st_mtime:
            mats = cPickle.load(open(dmp, 'r'))
            print 'Materials read from previous dump ', dmp
    except Exception as e:
        print e

    if mats is None:
        cards = filter(lambda c: c.ctype == CID.data, get_cards(inp))
        for c in cards:
            c.get_values()
        cards = filter(lambda c: c.dtype == 'Mn', cards)
        mats = {}
        for c in cards:
            m = Material.parseCard(c)
            m.name = str(c.name)
            m.T = None
            mats[c.name] = m
        with open(dmp, 'w') as d:
            cPickle.dump(mats, d)
            print 'Materials dumped to ', dmp
    return mats
Ejemplo n.º 3
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

u4_c = 0.1771

u5_f = 1.219
u5_c = 0.9519e-1

u8_f = 0.2998
u8_c = 0.7019e-1

print 'u5: ', u5_f / (u5_f + u5_c)
print 'u8: ', u8_f / (u8_f + u8_c)

from pirs.mcnp import Material
u = Material('U')
a4 = u.how_much(1, 92234).v
a5 = u.how_much(1, 92235).v
a8 = u.how_much(1, 92238).v
print a5, a8
print u.report()

kinf = (a4 * u4_f + a5 * u5_f + a8 * u8_f) / (a4 * (u4_f + u4_c) + a5 *
                                              (u5_f + u5_c) + a8 *
                                              (u8_f + u8_c))
print kinf
Ejemplo n.º 4
0
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PIRS-2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

c1 = Cell()

# Cell 1
c1.mat = Material('Fe')
c1.rho = -10.
c1.vol = Surface('so 8.0').volume()
c1.opt['imp:n'] = 1

# Cell 2
c2 = Cell()
c2.vol = -c1.vol

# direct use of cells
print c1.card()
print c2.card()

# cells in a model
m = Model()
m.cells.append(c1)
Ejemplo n.º 5
0
#
# This file is part of PIRS-2.
#
# PIRS-2 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PIRS-2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# water
h = Material('H')
o = Material('O')

w = 2 * h + o
print w.report()

w.thermal = 'lwtr'
w.T = 450
w.sdict[8018] = 8016
print w.card(comments=False)

# Zircaloy
s = Material(('Zr', 98.23, 1), ('Sn', 1.50, 1), ('Fe', 0.12, 1))
Ejemplo n.º 6
0
#
# This file is part of PIRS-2.
#
# PIRS-2 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PIRS-2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

h = Material('H')
o = Material('O')

h2o = 2 * h + o

# thermal data
h2o.thermal = 'lwtr'

# nuclide substitution
h2o.sdict[8018] = 8016

for t in [300, 350, 400]:
    h2o.T = t
    print h2o.card()
Ejemplo n.º 7
0
                # rz, ra, ri = zai(row[0])
                # if (rz, ra, ri) in mcb_zai:
                for Nb, nd in enumerate(map(float, row[1:])):
                    if nd > 0:
                        mtrl[(label, Nb)].append((n, nd))
                N += 1

    # print 'read {} nuclides'.format(N)

# construct materials:
mats = {}
fs = '{:>6d}.{}    {:21.15e}'
for ((label, b), recipe) in mtrl.items():
    # print label, b, len(recipe)
    if b != 'burnup':
        m = Material(*recipe)
        m.conc = m.moles().v * 1e24
        m.normalize(1)
        m.isotope_format_string = fs
        key = '{0}_{1}'.format(label, b)
        mats[key] = m
        m.name = key
        # substitute 40000 with natural composition of Zr:
        if 'ifba' in m.name:
            # m.sdict[40000] = Material('Zr')
            m.sdict[40000] = Material('Zr')
            print 'substitution rule for', m.name, m.sdict

        # substitutions for metastable isotopes:
        m.sdict[61548] = 61198
        m.sdict[47510] = 47160
Ejemplo n.º 8
0
# This file is part of PIRS-2.
#
# PIRS-2 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PIRS-2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

u = Material((92235, 4, 2), (92238, 96, 2))
p = Material((94239, 90, 2), (94240, 10, 2))
o = Material(8016)

uox = u + 2 * o
pox = p + 2 * o

mox = Material((uox, 1), (pox, 1))
print mox.report()


def of(m):
    a1 = m.how_much(1, ZAID=[92235, 94239])
    a2 = m.how_much(1, Z=[92, 94])
    return a1 / a2 - 0.10
Ejemplo n.º 9
0
from pirs.mcnp import Material
# Copyright 2015 Karlsruhe Institute of Technology (KIT)
#
# This file is part of PIRS-2.
#
# PIRS-2 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PIRS-2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

fe = Material('Fe')  # Fe chemical element with nat. occuring isotopes

for T in [300, 350, 400]:
    fe.T = T
    print fe.card()
Ejemplo n.º 10
0
from pirs.mcnp import Material
# Copyright 2015 Karlsruhe Institute of Technology (KIT)
#
# This file is part of PIRS-2.
#
# PIRS-2 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PIRS-2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

m1 = Material(('H', 2, 1), ('O', 1, 1))
m1.sdict[8018] = 8016
m1.thermal = 'lwtr'

m1.T = 300
print m1.card()

m1.T = 450
print m1.card()
Ejemplo n.º 11
0
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PIRS-2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from pirs.mcnp import Material
from pirs import McnpInterface

# GEOMETRY 
b = Box(material='m1')
b.dens.set_values(18.8)

# MCNP-SPECIFIC DATA
i = McnpInterface(b)
i.materials['m1'] = Material('U')  # material
i.bc['axial'] = '*'               # b.c.
i.bc['radial'] = '*'
i.adc.append('ksrc 0 0 0')        # kcode source
i.adc.append('kcode 100 1 30 100')

if __name__ == '__main__':
    # RUN MCNP
    i.run('R')                # start MCNP 
    print 'K-inf:', i.keff()  # print Keff
Ejemplo n.º 12
0
#
# PIRS-2 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PIRS-2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# depleted u, mass fractions
ud = Material((92235,  0.2, 2),
              (92238, 99.8, 2))
# simplified o for oxide
o = Material(8016)
# pu  
pu = Material((94239, 93.6, 2),
              (94240,  5.9, 2),
              (94241,  0.4, 2),
              (94242,  0.1, 2))
# oxides and mox
ux = Material((ud, 1), (o, 2))
px = Material((pu, 1), (o, 2))
mox = Material((ux, 0.5), (px, 0.5))
print mox.report()
# objective function
def obj(mix):
    a1 = mix.how_much(2, ZAID=[92235, 94239, 94241, 94243])
Ejemplo n.º 13
0
# Check "emply" mixture as void.

from pirs.mcnp import Material

v = Material()  # This should be void. It can be added only with vol. fractions
u = Material('U')
u.dens = 18.0

uu = Material(u, (1, 3), v, (1, 3))

print(uu.report())
Ejemplo n.º 14
0
from pirs.mcnp import Material
# Copyright 2015 Karlsruhe Institute of Technology (KIT)
#
# This file is part of PIRS-2.
#
# PIRS-2 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PIRS-2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# zircaloy-2, Table 5, p.7
zr = Material(('Zr', 98.23), ('Sn', 1.50), ('Fe', 0.12), ('Cr', 0.10),
              ('N', 0.05))

print zr.card()
Ejemplo n.º 15
0
import logging, sys
from autologging import TRACE
logging.basicConfig(level=TRACE,
                    stream=sys.stdout,
                    format='%(levelname)s:%(name)s:%(funcName)s:%(message)s')

from pirs.mcnp import Material

# Check constructors
m = Material(1001)  # from int ZAID
m = Material('Al')  # Element name
m = Material('U3Si2')  # Chemical formula
m2 = Material(m)  # bypass single Material argument
assert m is m2

m = Material(1001, 1, 1002, 1)  # Amounts as integers