Пример #1
0
def setupLASolver():
    lasolver = pyTrilinos.daeCreateTrilinosSolver("AztecOO", "")

    parameterList = lasolver.ParameterList

    lasolver.NumIters = 1000
    lasolver.Tolerance = 1e-3

    parameterList.set_int("AZ_solver", daeAztecOptions.AZ_gmres)
    parameterList.set_int("AZ_kspace", 500)
    parameterList.set_int("AZ_scaling", daeAztecOptions.AZ_none)
    parameterList.set_int("AZ_reorder", 0)
    parameterList.set_int("AZ_conv", daeAztecOptions.AZ_r0)
    parameterList.set_int("AZ_keep_info", 1)
    parameterList.set_int(
        "AZ_output", daeAztecOptions.AZ_none
    )  # {AZ_all, AZ_none, AZ_last, AZ_summary, AZ_warnings}

    # Preconditioner options
    parameterList.set_int("AZ_precond", daeAztecOptions.AZ_dom_decomp)
    parameterList.set_int("AZ_subdomain_solve", daeAztecOptions.AZ_ilu)
    parameterList.set_int("AZ_orthog", daeAztecOptions.AZ_modified)
    parameterList.set_int("AZ_graph_fill", 1)  # default: 0
    parameterList.set_float("AZ_athresh", 1E-5)  # default: 0.0
    parameterList.set_float("AZ_rthresh", 1.0)  # default: 0.0

    parameterList.Print()

    return lasolver
Пример #2
0
def run(**kwargs):
    simulation = simTutorial()
    print('Supported Trilinos solvers: %s' %
          pyTrilinos.daeTrilinosSupportedSolvers())
    lasolver = pyTrilinos.daeCreateTrilinosSolver("Amesos_Klu", "")
    return daeActivity.simulate(simulation,
                                reportingInterval=5,
                                timeHorizon=60,
                                lasolver=lasolver,
                                **kwargs)
Пример #3
0
def run(**kwargs):
    simulation = simCatalystMixing(200, 1.0 / 200)
    nlpsolver = pyIPOPT.daeIPOPT()
    lasolver = pyTrilinos.daeCreateTrilinosSolver("Amesos_Klu", "")
    relativeTolerance = 1e-6
    return daeActivity.optimize(simulation,
                                reportingInterval=1,
                                timeHorizon=1,
                                lasolver=lasolver,
                                nlpsolver=nlpsolver,
                                nlpsolver_setoptions_fn=setOptions,
                                relativeTolerance=relativeTolerance,
                                **kwargs)
Пример #4
0
def run(**kwargs):
    simulation = simTutorial()

    # The default linear solver is Sundials dense sequential solver (LU decomposition).
    # The following 3rd party direct linear solvers are supported:
    #   - Pardiso (multi-threaded - OMP)
    #   - IntelPardiso (multi-threaded - OMP)
    #   - SuperLU (sequential)
    #   - SuperLU_MT (multi-threaded - pthreads, OMP)
    #   - Trilinos Amesos (sequential): Klu, SuperLU, Lapack, Umfpack
    # If you are using Pardiso or IntelPardiso solvers you have to export their bin directories,
    # using, for instance, LD_LIBRARY_PATH shell variable (for more details see their documentation).
    # If you are using OpenMP capable solvers you should set the number of threads
    # (typically to the number of cores), for instance:
    #    export OMP_NUM_THREADS=4
    # or if using IntelPardiso solver:
    #    export MKL_NUM_THREADS=24
    # You can place the above command at the end of $HOME/.bashrc (or type it in shell, before simulation).

    # Import desired solver module (uncomment it from below) and set it using SetLASolver function:
    print("Supported Trilinos 3rd party LA solvers:",
          str(pyTrilinos.daeTrilinosSupportedSolvers()))
    lasolver = pyTrilinos.daeCreateTrilinosSolver("Amesos_Klu", "")
    #lasolver = pyTrilinos.daeCreateTrilinosSolver("Amesos_Umfpack", "")
    #lasolver = pyIntelPardiso.daeCreateIntelPardisoSolver()
    #lasolver = pyPardiso.daeCreatePardisoSolver()

    if lasolver.Name == 'Intel Pardiso':
        # Get Pardiso/IntelPardiso parameters (iparm[64] list of integers)
        iparm = lasolver.get_iparm()
        iparm_def = list(iparm)  # Save it for comparison
        # Change some options
        # Achtung, Achtung!!
        # The meaning of items in iparm[64] is NOT identical in Pardiso and IntelPardiso solvers!!
        iparm[
            7] = 2  # Max. number of iterative refinement steps (common for both Pardiso and IntelPardiso)
        #iparm[27] = 1 # in Pardiso it means:      use METIS parallel reordering
        # in IntelPardiso it means: use single precision (do not change it!)
        # Set them back
        lasolver.set_iparm(iparm)
        iparm = lasolver.get_iparm()
        # Print the side by side comparison
        print('iparm     default new')
        for i in range(64):
            print('iparm[%2d] %7d %3d' % (i, iparm_def[i], iparm[i]))

    return daeActivity.simulate(simulation,
                                reportingInterval=10,
                                timeHorizon=1000,
                                lasolver=lasolver,
                                **kwargs)
Пример #5
0
def run(**kwargs):
    simulation = simTutorial()
    print("Supported Trilinos solvers: %s" %
          pyTrilinos.daeTrilinosSupportedSolvers())
    # lasolver = pyTrilinos.daeCreateTrilinosSolver("Amesos_Klu", "")
    lasolver = pyTrilinos.daeCreateTrilinosSolver("Amesos_Umfpack", "")
    # lasolver = pyTrilinos.daeCreateTrilinosSolver("Amesos_Lapack", "")
    # lasolver = pyTrilinos.daeCreateTrilinosSolver("'AztecOO_ML", "")
    return daeActivity.simulate(
        simulation,
        reportingInterval=1,
        timeHorizon=20 * 60,
        lasolver=lasolver,
        # calculateSensitivities=True,
        **kwargs)
Пример #6
0
def run(**kwargs):
    simulation = simOilCracking_opt()
    nlpsolver = pyIPOPT.daeIPOPT()
    lasolver = pyTrilinos.daeCreateTrilinosSolver("Amesos_Klu", "")
    relativeTolerance = 1e-6
    reportingTimes = times.tolist()
    return daeActivity.optimize(simulation,
                                reportingInterval=1,
                                timeHorizon=1,
                                reportingTimes=reportingTimes,
                                lasolver=lasolver,
                                nlpsolver=nlpsolver,
                                nlpsolver_setoptions_fn=setOptions,
                                relativeTolerance=relativeTolerance,
                                **kwargs)
Пример #7
0
def createLASolver():
    print("Supported Trilinos solvers:", str(pyTrilinos.daeTrilinosSupportedSolvers()))
    
    # Amesos SuperLU solver
    lasolver = pyTrilinos.daeCreateTrilinosSolver("Amesos_Umfpack", "")

    # AztecOO built-in preconditioners are specified through AZ_precond option
    #lasolver = pyTrilinos.daeCreateTrilinosSolver("AztecOO", "")

    # Ifpack preconditioner can be one of: [ILU, ILUT, PointRelaxation, BlockRelaxation, IC, ICT]
    #lasolver = pyTrilinos.daeCreateTrilinosSolver("AztecOO_Ifpack", "ILU")
    
    # ML preconditioner can be one of: [SA, DD, DD-ML, DD-ML-LU, maxwell, NSSA]
    #lasolver = pyTrilinos.daeCreateTrilinosSolver("AztecOO_ML", "DD-ML")
    
    return lasolver
Пример #8
0
def run(**kwargs):
    simulation = simMarinePopulation_opt()
    #nlpsolver = pyNLOPT.daeNLOPT('NLOPT_LD_SLSQP')
    nlpsolver = pyIPOPT.daeIPOPT()
    lasolver = pyTrilinos.daeCreateTrilinosSolver("Amesos_Klu", "")
    relativeTolerance = 1e-6
    reportingTimes = times.tolist()
    return daeActivity.optimize(simulation,
                                reportingInterval=1,
                                timeHorizon=1,
                                reportingTimes=reportingTimes,
                                lasolver=lasolver,
                                nlpsolver=nlpsolver,
                                nlpsolver_setoptions_fn=setOptions,
                                relativeTolerance=relativeTolerance,
                                reportSensitivities=True,
                                **kwargs)
Пример #9
0
def createLASolver(lasolverIndex):
    lasolver = None

    if lasolverIndex == laSundialsLU:
        pass

    elif lasolverIndex == laSuperLU:
        from daetools.solvers.superlu import pySuperLU
        lasolver = pySuperLU.daeCreateSuperLUSolver()

    elif lasolverIndex == laSuperLU_MT:
        from daetools.solvers.superlu_mt import pySuperLU_MT
        lasolver = pySuperLU_MT.daeCreateSuperLUSolver()

    elif lasolverIndex == laAmesos_Klu:
        from daetools.solvers.trilinos import pyTrilinos
        lasolver = pyTrilinos.daeCreateTrilinosSolver("Amesos_Klu", "")

    elif lasolverIndex == laAmesos_Superlu:
        from daetools.solvers.trilinos import pyTrilinos
        lasolver = pyTrilinos.daeCreateTrilinosSolver("Amesos_Superlu", "")

    elif lasolverIndex == laAmesos_Umfpack:
        from daetools.solvers.trilinos import pyTrilinos
        lasolver = pyTrilinos.daeCreateTrilinosSolver("Amesos_Umfpack", "")

    elif lasolverIndex == laAmesos_Lapack:
        from daetools.solvers.trilinos import pyTrilinos
        lasolver = pyTrilinos.daeCreateTrilinosSolver("Amesos_Lapack", "")

    elif lasolverIndex == laAztecOO:
        from daetools.solvers.trilinos import pyTrilinos
        lasolver = pyTrilinos.daeCreateTrilinosSolver("AztecOO", "ILUT")

    elif lasolverIndex == laPardiso:
        from daetools.solvers.pardiso import pyPardiso
        lasolver = pyPardiso.daeCreatePardisoSolver()

    elif lasolverIndex == laIntelPardiso:
        from daetools.solvers.intel_pardiso import pyIntelPardiso
        lasolver = pyIntelPardiso.daeCreateIntelPardisoSolver()

    elif lasolverIndex == laIntelMKL:
        from daetools.solvers import pyIntelMKL
        lasolver = pyIntelMKL.daeCreateLapackSolver()

    elif lasolverIndex == laAmdACML:
        from daetools.solvers import pyAmdACML
        lasolver = pyAmdACML.daeCreateLapackSolver()

    elif lasolverIndex == laLapack:
        from daetools.solvers import pyLapack
        lasolver = pyLapack.daeCreateLapackSolver()

    elif lasolverIndex == laMagmaLapack:
        from daetools.solvers import pyMagma
        lasolver = pyMagma.daeCreateLapackSolver()

    elif lasolverIndex == laSuperLU_CUDA:
        from daetools.solvers.superlu_cuda import pySuperLU_CUDA
        lasolver = pySuperLU_CUDA.daeCreateSuperLUSolver()

    elif lasolverIndex == laCUSP:
        from daetools.solvers import pyCUSP
        lasolver = pyCUSP.daeCreateCUSPSolver()

    else:
        raise RuntimeError("Unsupported LA Solver selected")

    return lasolver