コード例 #1
0
ファイル: aer.py プロジェクト: OctavioPJ/AER
    def __init__(self):
        super().__init__()  # llama a la creación de AerModel
        print('- Inicializando Transitorio')
        self._C0 = {}
        self.__Ct_1 = {}
        self._Ct = {}
        self.__FILENAME = 'aer.cii'
        self.__ROOTFILE = self.__FILENAME[:-4]
        self.__DATABASE = self.__ROOTFILE + '_eq.cdb'
        self.__Geom = Geometry(self.__FILENAME.replace('.cii', '_geo.ci@'))
        self.__NuFis = NuFissionMap()
        self.__KM = KineticMap()
        self._NOG = 2  # TODO: Sería mejor extraer del ci@?
        self.chi_g = [1.0, 0.0]  # TODO: Sería mejor extraer del ci@?
        self.__Flux_t_1 = self.Flux = MeshFlux(
            self.__DATABASE + '.meshflux', *self.__Geom.Cantidad_de_Nodos(),
            self._NOG)
        Nx, Ny, Nz, _NOG = self.Flux.shape[1:]
        self.BetaM = np.empty((1, Nx, Ny, Nz, 6))
        self.LambdaM = np.empty((1, Nx, Ny, Nz, 6))
        self.NuFisM = np.empty((1, Nx, Ny, Nz, _NOG))
        self.VelocityM = np.empty((1, Nx, Ny, Nz, _NOG))
        state = 0
        static_react = -123.1  # reactividad inicial inicial, no inicial
        self.keff = 1 / (1 - static_react / 100000)
        self._Q = {}
        self.EQUILIBRIUM = True
        self.powers = []

        for _x in range(Nx):
            for _y in range(Ny):
                for _z in range(Nz):
                    meshmaterial = self.__Geom.sc5[_x][_y][_z]

                    kwargs = {'list_fuels': self.list_fuels, 'time': 0}
                    self.BetaM[state][_x][_y][_z][:] = \
                        self.__KM.MapMaterial(meshmaterial, **kwargs)['Beta']
                    self.LambdaM[state][_x][_y][_z][:] = \
                        self.__KM.MapMaterial(meshmaterial, **kwargs)['Decays']
                    self.VelocityM[state][_x][_y][_z][:] = \
                        self.__KM.MapMaterial(meshmaterial, **kwargs)['Neutron Velocity']
                    self.NuFisM[state][_x][_y][_z][:] = \
                        self.__NuFis.MapMaterial(meshmaterial, **kwargs)['XS'][:, 3] / self.keff
コード例 #2
0
ファイル: cube.py プロジェクト: OctavioPJ/CUBEM
        if args:
            return self._FISS[DEFAULT_STATE][DEFAULT_BURNUP][args[0]].shape[0]
        return self._FISS[DEFAULT_STATE][DEFAULT_BURNUP]['Decays'].shape[0]


if __name__ == '__main__':

    from citvappru.SourceCAREM2_1_1 import Geometry, PrecCalc
    import re

    os.chdir('C:\\CUBEM\\')
    FILENAME = 'cube.cii'
    ROOTFILE = FILENAME[:-4]
    DATABASE = ROOTFILE + '_eq.cdb'

    Geom = Geometry(FILENAME.replace('.cii', '0.cii'))

    NuFis = Nu_Fission_Map()
    KM = Kinetic_Map(NPRC=1)

    _NOG = 1

    NPRC = KM.get_NPRC()

    Flux = MeshFlux(DATABASE + '.meshflux', *Geom.Cantidad_de_Nodos(), _NOG)
    Nx, Ny, Nz = Flux.shape[1:4]

    BetaM = np.empty((1, Nx, Ny, Nz, NPRC))
    LambdaM = np.empty((1, Nx, Ny, Nz, NPRC))
    NuFisM = np.empty((1, Nx, Ny, Nz, _NOG))
    VelocityM = np.empty((1, Nx, Ny, Nz, _NOG))
コード例 #3
0
ファイル: aer.py プロジェクト: OctavioPJ/AER
def mainnomain():
    os.chdir('D:\\AER\\')
    FILENAME = 'aer.cii'
    ROOTFILE = FILENAME[:-4]
    DATABASE = ROOTFILE + '_eq.cdb'

    Geom = Geometry(FILENAME.replace('.cii', '_geo.ci@'))
    NuFis = NuFissionMap()
    KM = KineticMap()
    _NOG = 2
    Flux = MeshFlux(DATABASE + '.meshflux', *Geom.Cantidad_de_Nodos(), _NOG)
    Nx, Ny, Nz = Flux.shape[1:4]

    BetaM = np.empty((1, Nx, Ny, Nz, 1))
    LambdaM = np.empty((1, Nx, Ny, Nz, 1))
    NuFisM = np.empty((1, Nx, Ny, Nz, _NOG))
    VelocityM = np.empty((1, Nx, Ny, Nz, _NOG))

    state = 0

    Vmesh = Geom.Vmesh()

    react = -123.1  # reactividad inicial inicial, no inicial
    keff = 1 / (1 - react / 100000)

    for _x in range(Nx):
        for _y in range(Ny):
            for _z in range(Nz):
                meshmaterial = Geom.sc5[_x][_y][_z]

                KinParam = KM.MapMaterial(meshmaterial)  # Obsoleto

                BetaM[state][_x][_y][_z][:] = KinParam['Beta']

                LambdaM[state][_x][_y][_z][:] = KinParam['Decays']

                VelocityM[state][_x][_y][_z][:] = KinParam['Neutron Velocity']

                NuFisM[state][_x][_y][_z][:] = NuFis.MapMaterial(
                    meshmaterial)['XS'][:, 3] / keff

    C0 = {}
    NPRC = BetaM.shape[-1]
    C0[state] = {}
    for nx in range(Flux.shape[1]):
        C0[state][nx] = {}
        for ny in range(Flux.shape[2]):
            C0[state][nx][ny] = {}
            for nz in range(Flux.shape[3]):
                FluxL = [
                    Flux[state, nx, ny, nz, group]
                    for group in range(Flux.shape[-1])
                ]
                NuFisL = [
                    NuFisM[state][nx][ny][nz][group]
                    for group in range(Flux.shape[-1])
                ]
                Nu_FluxM = [
                    NuFisL[group] * FluxL[group] * Vmesh
                    for group in range(Flux.shape[-1])
                ]

                Bet_k = BetaM[state][nx][ny][nz]
                Lamb_k = LambdaM[state][nx][ny][nz]
                Nu_Flux = sum(Nu_FluxM)

                C0[state][nx][ny][nz] = [
                    Bet_k[prec] * Nu_Flux /
                    Lamb_k[prec] if Lamb_k[prec] != 0 else 0.0
                    for prec in range(NPRC)
                ]

    p = re.compile(r'POWER\(WATTS\)\s+([0-9]\.[0-9]{5}E\+[0-9]{2})')
    powers = []

    Q = {}
    EQUILIBRIUM = True
    chi_g = [1.0, 0.0]

    v1 = 1.25E+7
    v2 = 2.50E+5
    dt = 0.01
    tfinal = 0.5
    DATABASE = ROOTFILE + 'S.cdb'
    Times = np.arange(0, tfinal + 2 * dt, dt)
    FAILED_COMPLETE_TEST = False
    DERIVATIVE = True
    for t in Times:
        if EQUILIBRIUM:
            C_t_1 = C0.copy()
            C_t = C0.copy()
            Flux_t_1 = Flux
        else:
            TFlux = MeshFlux(DATABASE + '.meshflux', Nx, Ny, Nz, _NOG)
            # noinspection PyUnboundLocalVariable
            C_t = PrecCalc(C_t_1,
                           TFlux,
                           NuFisM,
                           Vmesh,
                           dt,
                           LambdaM=LambdaM,
                           BetaM=BetaM)

            C_t_1 = C_t.copy()
            Flux_t_1 = TFlux

        for group in range(Flux.shape[-1]):
            Q[group] = {}
            for state in range(Flux.shape[0]):
                Q[group][state] = {}
                for nx in range(Flux.shape[1]):
                    Q[group][state][nx] = {}
                    for ny in range(Flux.shape[2]):
                        Q[group][state][nx][ny] = {}
                        for nz in range(Flux.shape[3]):
                            _Lmk = LambdaM[state][nx][ny][nz]
                            _C = C_t[state][nx][ny][nz]

                            _invV = VelocityM[state, nx, ny, nz, group]
                            T_1Flux = Flux_t_1[state, nx, ny, nz, group]

                            Q[group][state][nx][ny][nz] = \
                                chi_g[group] * sum([_Lmk[prc] * _C[prc] for prc in range(NPRC)]) \
                                + _invV / dt * T_1Flux * Vmesh * DERIVATIVE  #

        with open('source.dat', 'w') as fod:
            for group in range(_NOG):
                for state in range(Flux.shape[0]):
                    for nz in range(Flux.shape[3]):
                        for ny in range(Flux.shape[2]):
                            for nx in range(Flux.shape[1]):
                                fod.write('{:15.7E}'.format(
                                    Q[group][state][nx][ny][nz]))
                fod.write('\n')
        # Ejecución de archivo AQUI
        OsArgs = (FILENAME.replace('.cii',
                                   'S.cii'), _NOG, Nx, Ny, Nz, EQUILIBRIUM,
                  *['{:12.5E}'.format(_d) for _d in [dt * DERIVATIVE, t]])
        # PARA HACER UNA PERTURBACION ESCALOR,COLOCAR t=1
        # PARA CALCULAR SIN DERIVADA TEMPORAL dt=0
        try:
            os.system('ExAer.bat ' + ' '.join(map(str, OsArgs)))
            fid = open(ROOTFILE + 'S.cio', 'r')
            powers.append(float(next(p.finditer(fid.read())).groups()[0]))
            print(powers[-1])
            fid.close()
            if EQUILIBRIUM: EQUILIBRIUM = False
        except StopIteration:
            FAILED_COMPLETE_TEST = True
            break
            pass

    Normalized_Pow = np.array(powers) / 1E+06
    if FAILED_COMPLETE_TEST: Times = [k * dt for k in range(len(powers))]
    return
コード例 #4
0
    elements = [hexag.type[0] for hexag in
                list(filter(lambda column: 26 in map(lambda hexag: hexag.type[1], column), alf.grid))[0] if
                hexag.type[1] not in [5, 1999]]
    pows = PowDens('aer.cdb.powerdensities')
    plt.plot(pows[0, min(elements) - 1:max(elements) - 1, :], '-o')

    Pows = OrderedDict({ file.strip('.pow') : np.genfromtxt(file) for file in glob('INFO\\*.pow')})

    Nods = OrderedDict({file.strip('.nod'): np.genfromtxt(file, comments='*') for file in glob('INFO\\*.nod')})
    Nods = OrderedDict({ key:value.reshape(value.shape[0]//2210,2210,value.shape[1]) for key,value in Nods.items()})

    plt.plot(*reduce(add,[(Pow[:,0],Pow[:,1],'-o') for Pow in Pows.values()]))
    plt.legend(Pows.keys())

    file = 'INFO\\solaeki.reac'
    alf = np.loadtxt(file)
    plt.plot(alf[:, 0], alf[:, 1], 'o')
    return


if __name__ == '__main__':
    # alf = GroupFlux('aer.cdb.flux')
    # plt.plot(range(10),alf[0,0,:,1],'-o',range(10),alf[0,0,:,0],'o-')

    Geo = Geometry('aer_geo.ci@')
    import re
    alfred = re.compile(r'(?<=\s{2}3\n)(?:[\s0-9]{3}){4}([\s0-9]{3})')
    findings = alfred.search(open('aer_geo.ci@').read())
    pass

コード例 #5
0
 def _init_mesh_parameters(self):
     self.Geom = Geometry(self.__file.replace(
         'S.cii', '0.cii'))  # HARDCODEADO el *S.cii
     self.Vmesh = self.Geom.Vmesh()
     self.Nx, self.Ny, self.Nz = self.Geom.Cantidad_de_Nodos()
     return