예제 #1
0
def experiment(P, opt, expname):
    # First run with regular refinement
    opt["meshRefinement"] = 1
    df_uniform = solveProblem(P, opt)
    if WRITE_CSV:
        fname = '{}_{}_uniform'.format(opt['id'], expname)
        hlp.writeOutputToCsv(df_uniform, opt, fname)

    # Second run with adaptive refinement
    opt["meshRefinement"] = 2
    opt["refinementThreshold"] = 0.9
    df_adaptive = solveProblem(P, opt)
    if WRITE_CSV:
        fname = '{}_{}_adaptive'.format(opt['id'], expname)
        hlp.writeOutputToCsv(df_adaptive, opt, fname)
def experiment(P, opt, expname):
    # First run with regular refinement
    opt["meshRefinement"] = 1
    df_uniform = solveProblem(P, opt)
    if WRITE_CSV:
        fname = '{}_{}_uniform'.format(opt['id'], expname)
        hlp.writeOutputToCsv(df_uniform, opt, fname)
def experiment(P, opt, expname):
    # First run with regular refinement
    opt["meshRefinement"]    = 1
    df_uniform = solveProblem(P, opt)
    if WRITE_CSV:
        hlp.writeOutputToCsv(CSV_DIR + opt['id'] + expname + '_uniform.csv', df_uniform)

    # Second run with adaptive refinement
    opt["meshRefinement"]      = 2
    opt["refinementThreshold"] = 0.95
    opt["plotMesh"] = 1
    opt["saveMesh"] = 1
    opt["plotSolution"] = 1
    df_adaptive = solveProblem(P, opt)
    if WRITE_CSV:
        hlp.writeOutputToCsv(CSV_DIR + opt['id'] + expname + '_adaptive.csv', df_adaptive)
예제 #4
0
def experiment(P, opt, expname):
    # First run with regular refinement
    opt["meshRefinement"] = 1
    df_uniform = solveProblem(P, opt)
    if WRITE_CSV:
        hlp.writeOutputToCsv(df_uniform, opt, opt['id'] + expname + '_uniform',
                             df_uniform)
예제 #5
0
def degreeStudy(P, opt, minDegree=1, maxDegree=4, filename=None):

    out = []

    for deg in range(minDegree, maxDegree + 1):
        opt["p"] = deg
        opt["q"] = deg
        df = solveProblem(P, opt)
        out.append(df)
        if WRITE_CSV:
            fname = '{}_degree_study_{}_deg_{}'.format(opt['id'], filename,
                                                       deg)
            hlp.writeOutputToCsv(df, opt, fname)

    return out
예제 #6
0
# Solve routine
from nonvarFEM import solveProblem

# Auxiliary stuff
import nonvarFEM.helpers as hlp

if __name__ == "__main__":

    # Load standard options
    global_opt = hlp.standardOptions()

    P = FNS_5_4_L_inf_Coeffs()
    global_opt["id"] = "FNS_5_4"

    global_opt["NdofsThreshold"] = 30000
    # Fix polynomial degree
    global_opt["p"] = 2
    global_opt["q"] = 2
    global_opt["plotMesh"] = 1
    global_opt["saveMesh"] = 1
    global_opt["plotSolution"] = 1
    global_opt["saveSolution"] = 1
    global_opt["meshRefinement"] = 2
    global_opt["refinementThreshold"] = .90
    global_opt["writeToCsv"] = 0

    # Determine method to estimate error norms
    global_opt["errorEstimationMethod"] = 1
    df = solveProblem(P, hlp.opt_Own_CG_0_stab(global_opt))
예제 #7
0
    # P = NVP.FullNVP_1()
    # P = NVP.FullNVP_2()
    # P = NVP.FullNVP_3_1d()

    # Parabolic PDEs
    # P = PNVP.PNVP_1_2d()
    # P = PNVP.PNVP_2()
    # P = PNVP.PNVP_WorstOfTwoAssetsPut()
    # P = PNVP.PNVP_1_1d()
    # P = PNVP.PNVP_1_3d()
    # P = PNVP.PNVP_Degenerate_1()

    # Elliptic HJB equations
    # P = HJB.MinimumArrivalTime(alpha=0.1, beta=0.1)
    # P = HJB.MinimumArrivalTimeRadial(alpha=0.1)
    # P = HJB.Mother()
    # opt["lambda"] = 1.
    # P = HJB.Gallistl_Sueli_1()

    # Parabolic HJB equations
    # P = PHJB.JensenSmears_1()
    # P = PHJB.JensenSmears_2()
    # P = PHJB.Mother()
    P = PHJB.MinimumArrivalTimeParabolic(corrxy=0.9)
    # P = PHJB.Merton()
    # P = PHJB.Chen_Forsyth()
    from time import time
    t1 = time()
    df = solveProblem(P, opt)
    print('Time for solution: {}'.format(time() - t1))