Esempio n. 1
0
def run(nodefile, elefile, matfile, eq_type, eigenvalue, source, name):
    # Setup Problem
    grid = FEGrid(nodefile, elefile)
    mats = Materials(matfile)
    if eq_type == 'NDA':
        op = NDA(grid, mats)
        ua_bool = False
    elif eq_type == 'TGNDA':
        op = NDA(grid, mats)
        ua_bool = True
    elif eq_type == 'SAAF':
        op = SAAF(grid, mats)
    elif eq_type == 'Diffusion':
        op = Diffusion(grid, mats)
    else:
        raise Exception("Equation type not supported.")
    solver = Solver(op)

    if eq_type == 'NDA' or eq_type == 'TGNDA':
        fluxes = solver.solve(source, ua_bool=ua_bool, eigenvalue=eigenvalue)
    else:
        fluxes = solver.solve(source, eigenvalue=eigenvalue)

    # Print Eigenvalue
    if eigenvalue:
        print("Eigenvalue: ", fluxes['k'])

    # Save Fluxes
    phis = fluxes['Phi']
    np.savetxt(eq_type + "_" + name + ".out", phis)

    # Plot Everything
    for g in range(mats.get_num_groups()):
        scalar_flux = phis[g]
        plot(grid, scalar_flux, name + "_scalar_flux" + "_group" + str(g))
Esempio n. 2
0
def to_problem(mesh, mat, filename):
    nodefile = "../test_inputs/" + mesh + ".node"
    elefile = "../test_inputs/" + mesh + ".ele"
    matfile = "../test_inputs/" + mat + ".mat"
    grid = FEGrid(nodefile, elefile)
    mats = Materials(matfile)
    n_elements = grid.num_elts
    num_groups = mats.get_num_groups()
    op = NDA(grid, mats)
    solver = Solver(op)
    return Problem(op=op, mats=mats, grid=grid, solver=solver, filename=filename)