Exemple #1
0
def get_core(number, flag):
    """ Return the core for the C5G7 benchmark.

  See get_pincells for parameter definition.
  """

    assemblies = get_assemblies(number, flag)
    core = Core.Create(3)
    core.add_assembly(assemblies[0])
    core.add_assembly(assemblies[1])
    core.add_assembly(assemblies[2])
    core_map = [0, 1, 2, 1, 0, 2, 2, 2, 2]
    core.finalize(core_map)
    return core
Exemple #2
0
def get_core(number, flag) :
  """ Return the assemblies for the C5G7 benchmark.

  See get_pincells for parameter definition.
  """
  assemblies = get_assemblies(number, flag)
  core       = Core.Create(3)
  core.add_assembly(assemblies[0])
  core.add_assembly(assemblies[1])
  core.add_assembly(assemblies[2])
  core_map = [0,1,2,
              1,0,2,
              2,2,2]
  core.finalize(core_map)
  return core
def run():
    #-----------------------------------------------------------------------------#
    # Input
    #-----------------------------------------------------------------------------#
    inp = InputDB.Create()
    inp.put_str("equation", "dd")
    inp.put_str("problem_type", "eigenvalue")
    inp.put_int("number_groups", 7)
    #
    inp.put_str("inner_solver", "SI")
    inp.put_int("inner_max_iters", 10)
    inp.put_dbl("inner_tolerance", 1e-3)
    inp.put_int("inner_print_level", 0)
    inp.put_int("inner_print_interval", 10)
    #
    inp.put_str("outer_solver", "GS")
    inp.put_int("outer_max_iters", 10)
    inp.put_dbl("outer_tolerance", 1e-4)
    inp.put_int("outer_print_level", 0)
    inp.put_int("outer_print_interval", 1)
    #
    inp.put_str("eigen_solver", "PI")
    inp.put_int("eigen_max_iters", 1000)
    inp.put_dbl("eigen_tolerance", 1e-6)
    inp.put_int("eigen_print_level", 2)
    inp.put_int("eigen_print_interval", 1)
    inp.put_dbl("eigen_pi_omega", 1.0)
    #
    inp.put_str("bc_west", "reflect")
    inp.put_str("bc_east", "reflect")
    inp.put_str("bc_south", "reflect")
    inp.put_str("bc_north", "reflect")
    #
    inp.put_str("quad_type", "quadruplerange")
    inp.put_int("quad_number_polar_octant", 5)
    inp.put_int("quad_number_azimuth_octant", 10)
    #-----------------------------------------------------------------------------#
    # Material
    #-----------------------------------------------------------------------------#
    mat = get_materials()
    #-----------------------------------------------------------------------------#
    # Geometry
    #-----------------------------------------------------------------------------#
    assemblies = get_assemblies(7, True)
    mesh = assemblies[1].mesh()
    #-----------------------------------------------------------------------------#
    # Solve
    #-----------------------------------------------------------------------------#
    start = time.time()
    solver = Eigen2D(inp, mat, mesh)
    solver.solve()
    print "elapsed = ", time.time() - start
    #-----------------------------------------------------------------------------#
    # Plot
    #-----------------------------------------------------------------------------#
    try:
        state = solver.state()
        silo = SiloOutput(mesh)
        silo.initialize("c5g7assembly.silo")
        silo.write_scalar_flux(state)
        silo.finalize()
    except:
        print "Silo error?"
inp.put_str("bc_left",                  "reflect")
inp.put_str("bc_right",                 "reflect")
inp.put_str("bc_bottom",                "reflect")
inp.put_str("bc_top",                   "reflect")
#-----------------------------------------------------------------------------#
# Material
#-----------------------------------------------------------------------------#
mat = get_materials()
for m in range(0, 7) :
  for g in range(0, 7) :
    mat.set_diff_coef(m, g, 1.0/(3.0*mat.sigma_t(m, g)))
mat.finalize()
#-----------------------------------------------------------------------------#
# Geometry
#-----------------------------------------------------------------------------#
assemblies = get_assemblies(7, True)
mesh = assemblies[0].mesh()
#-----------------------------------------------------------------------------#
# State
#-----------------------------------------------------------------------------#
state = State.Create(inp, mesh)
#-----------------------------------------------------------------------------#
# Execute
#-----------------------------------------------------------------------------#
Manager.initialize(sys.argv)
solver = DiffusionEigensolver(inp, mat, mesh, state)
t = time.time()
solver.solve()
print "elapsed = ", time.time()-t
#-----------------------------------------------------------------------------#
# Plot
def run() :

  #for n in range(1, 11) :
    n = 2
    #-----------------------------------------------------------------------------#
    # Input 
    #-----------------------------------------------------------------------------#
    inp = utilities.InputDB.Create()
    inp.put_str("equation",                   "dd")
    inp.put_str("problem_type",               "eigenvalue")
    inp.put_int("number_groups",              7)
    #
    inp.put_str("inner_solver",               "SI")
    inp.put_int("inner_max_iters",            1000000)
    inp.put_dbl("inner_tolerance",            1e-8)
    inp.put_int("inner_print_level",          1)
    inp.put_int("inner_print_interval",       10)
    inp.put_str("inner_pc_type",              "DSA")
    inp.put_int("inner_pc_side",              2)
    #
    inp.put_str("outer_solver",               "GS")
    inp.put_int("outer_max_iters",            1000)
    inp.put_dbl("outer_tolerance",            1e-8)
    inp.put_int("outer_print_level",          1)
    inp.put_int("outer_print_interval",       1)
    #inp.put_str("outer_pc_type",              "mgdsa")
    #inp.put_int("outer_krylov_group_cutoff",  0)
    #inp.put_int("outer_pc_side",              2)
    #
    inp.put_str("bc_west",                    "vacuum")
    inp.put_str("bc_east",                    "vacuum")
    inp.put_str("bc_south",                   "vacuum")
    inp.put_str("bc_north",                   "vacuum")
    #
    inp.put_str("quad_type",                  "chebyshevlegendre")
    inp.put_int("quad_number_polar_octant",   n)
    inp.put_int("quad_number_azimuth_octant", n)
    #
    solver_db = utilities.InputDB.Create("solver_db")
    solver_db.put_dbl("linear_solver_atol",              0.0);
    solver_db.put_dbl("linear_solver_rtol",              1e-8);
    solver_db.put_str("linear_solver_type",              "petsc");
    solver_db.put_int("linear_solver_maxit",             50000);
    solver_db.put_int("linear_solver_gmres_restart",     30);
    solver_db.put_int("linear_solver_monitor_level",     1);
    #
    preconditioner_db = utilities.InputDB.Create("preconditioner_db")
    preconditioner_db.put_dbl("linear_solver_atol",              0.0);
    preconditioner_db.put_dbl("linear_solver_rtol",              0.1);
    preconditioner_db.put_str("linear_solver_type",              "petsc");
    preconditioner_db.put_int("linear_solver_maxit",             5000);
    preconditioner_db.put_int("linear_solver_gmres_restart",     30);
    preconditioner_db.put_int("linear_solver_monitor_level",     0);
    preconditioner_db.put_str("pc_type",                         "petsc_pc");
    preconditioner_db.put_str("petsc_pc_type",                   "ilu");
    preconditioner_db.put_int("petsc_pc_factor_levels",          2);
    #
    inp.put_spdb("inner_solver_db", solver_db)
    inp.put_spdb("inner_pc_db",     preconditioner_db)
    inp.put_spdb("outer_solver_db", solver_db)
    inp.put_spdb("outer_pc_db",     preconditioner_db)
    #-----------------------------------------------------------------------------#
    # Material
    #-----------------------------------------------------------------------------#
    mat = get_materials()
    mat.compute_diff_coef()
    #-----------------------------------------------------------------------------#
    # Geometry
    #-----------------------------------------------------------------------------#
    assemblies = get_assemblies(7, True)
    mesh = assemblies[0].mesh()
    #-----------------------------------------------------------------------------#
    # Source and Solve
    #-----------------------------------------------------------------------------#
    solver = Fixed2D(inp, mat, mesh)
    solver.setup()
    quad = solver.quadrature()
    q_e = external_source.ConstantSource.Create(7, mesh, 1.0, quad)
    solver.set_source(q_e)
    solver.set_solver()
    t = time.time()
    solver.solve()
    print "elapsed = ", time.time()-t
    phi = np.asarray(solver.state().phi(0))
Exemple #6
0
def run():

    #for n in range(1, 11) :
    n = 2
    #-----------------------------------------------------------------------------#
    # Input
    #-----------------------------------------------------------------------------#
    inp = utilities.InputDB.Create()
    inp.put_str("equation", "dd")
    inp.put_str("problem_type", "eigenvalue")
    inp.put_int("number_groups", 7)
    #
    inp.put_str("inner_solver", "SI")
    inp.put_int("inner_max_iters", 1000000)
    inp.put_dbl("inner_tolerance", 1e-8)
    inp.put_int("inner_print_level", 1)
    inp.put_int("inner_print_interval", 10)
    inp.put_str("inner_pc_type", "DSA")
    inp.put_int("inner_pc_side", 2)
    #
    inp.put_str("outer_solver", "GS")
    inp.put_int("outer_max_iters", 1000)
    inp.put_dbl("outer_tolerance", 1e-8)
    inp.put_int("outer_print_level", 1)
    inp.put_int("outer_print_interval", 1)
    #inp.put_str("outer_pc_type",              "mgdsa")
    #inp.put_int("outer_krylov_group_cutoff",  0)
    #inp.put_int("outer_pc_side",              2)
    #
    inp.put_str("bc_west", "vacuum")
    inp.put_str("bc_east", "vacuum")
    inp.put_str("bc_south", "vacuum")
    inp.put_str("bc_north", "vacuum")
    #
    inp.put_str("quad_type", "chebyshevlegendre")
    inp.put_int("quad_number_polar_octant", n)
    inp.put_int("quad_number_azimuth_octant", n)
    #
    solver_db = utilities.InputDB.Create("solver_db")
    solver_db.put_dbl("linear_solver_atol", 0.0)
    solver_db.put_dbl("linear_solver_rtol", 1e-8)
    solver_db.put_str("linear_solver_type", "petsc")
    solver_db.put_int("linear_solver_maxit", 50000)
    solver_db.put_int("linear_solver_gmres_restart", 30)
    solver_db.put_int("linear_solver_monitor_level", 1)
    #
    preconditioner_db = utilities.InputDB.Create("preconditioner_db")
    preconditioner_db.put_dbl("linear_solver_atol", 0.0)
    preconditioner_db.put_dbl("linear_solver_rtol", 0.1)
    preconditioner_db.put_str("linear_solver_type", "petsc")
    preconditioner_db.put_int("linear_solver_maxit", 5000)
    preconditioner_db.put_int("linear_solver_gmres_restart", 30)
    preconditioner_db.put_int("linear_solver_monitor_level", 0)
    preconditioner_db.put_str("pc_type", "petsc_pc")
    preconditioner_db.put_str("petsc_pc_type", "ilu")
    preconditioner_db.put_int("petsc_pc_factor_levels", 2)
    #
    inp.put_spdb("inner_solver_db", solver_db)
    inp.put_spdb("inner_pc_db", preconditioner_db)
    inp.put_spdb("outer_solver_db", solver_db)
    inp.put_spdb("outer_pc_db", preconditioner_db)
    #-----------------------------------------------------------------------------#
    # Material
    #-----------------------------------------------------------------------------#
    mat = get_materials()
    mat.compute_diff_coef()
    #-----------------------------------------------------------------------------#
    # Geometry
    #-----------------------------------------------------------------------------#
    assemblies = get_assemblies(7, True)
    mesh = assemblies[0].mesh()
    #-----------------------------------------------------------------------------#
    # Source and Solve
    #-----------------------------------------------------------------------------#
    solver = Fixed2D(inp, mat, mesh)
    solver.setup()
    quad = solver.quadrature()
    q_e = external_source.ConstantSource.Create(7, mesh, 1.0, quad)
    solver.set_source(q_e)
    solver.set_solver()
    t = time.time()
    solver.solve()
    print "elapsed = ", time.time() - t
    phi = np.asarray(solver.state().phi(0))
def run() :
  #-----------------------------------------------------------------------------#
  # Input 
  #-----------------------------------------------------------------------------#
  inp = InputDB.Create()
  inp.put_str("equation",                       "dd")
  inp.put_str("problem_type",                   "eigenvalue")
  inp.put_int("number_groups",                  7)
  #
  inp.put_str("inner_solver",                   "SI")
  inp.put_int("inner_max_iters",                10)
  inp.put_dbl("inner_tolerance",                1e-3)
  inp.put_int("inner_print_level",              0)
  inp.put_int("inner_print_interval",           10)
  #
  inp.put_str("outer_solver",                   "GS")
  inp.put_int("outer_max_iters",                10)
  inp.put_dbl("outer_tolerance",                1e-4)
  inp.put_int("outer_print_level",              0)
  inp.put_int("outer_print_interval",           1)
  #
  inp.put_str("eigen_solver",                   "PI")
  inp.put_int("eigen_max_iters",                1000)
  inp.put_dbl("eigen_tolerance",                1e-6)
  inp.put_int("eigen_print_level",              2)
  inp.put_int("eigen_print_interval",           1)
  inp.put_dbl("eigen_pi_omega",                 1.0)
  #
  inp.put_str("bc_west",                        "reflect")
  inp.put_str("bc_east",                        "reflect")
  inp.put_str("bc_south",                       "reflect")
  inp.put_str("bc_north",                       "reflect")
  #
  inp.put_str("quad_type",                      "quadruplerange")
  inp.put_int("quad_number_polar_octant",       5)
  inp.put_int("quad_number_azimuth_octant",     10)
  #-----------------------------------------------------------------------------#
  # Material
  #-----------------------------------------------------------------------------#
  mat = get_materials()
  #-----------------------------------------------------------------------------#
  # Geometry
  #-----------------------------------------------------------------------------#
  assemblies = get_assemblies(7, True)
  mesh = assemblies[1].mesh()
  #-----------------------------------------------------------------------------#
  # Solve
  #-----------------------------------------------------------------------------#
  start = time.time()
  solver = Eigen2D(inp, mat, mesh)
  solver.solve()
  print "elapsed = ", time.time() - start
  #-----------------------------------------------------------------------------#
  # Plot
  #-----------------------------------------------------------------------------#
  try :
    state = solver.state()
    silo = SiloOutput(mesh)
    silo.initialize("c5g7assembly.silo")
    silo.write_scalar_flux(state)
    silo.finalize()
  except :
    print "Silo error?"