-
Notifications
You must be signed in to change notification settings - Fork 1
/
solve.py
126 lines (104 loc) · 3.39 KB
/
solve.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# -*- coding: utf-8 -*-
# Auxiliary stuff
import nonvarFEM.helpers as hlp
# Elliptic non-variational pdes
import nonvarFEM.problems.testsNVP as NVP
# Parabolic non-variational pdes
import nonvarFEM.problems.testsParabolicNVP as PNVP
# Elliptic HJB equations
import nonvarFEM.problems.testsHJB as HJB
import nonvarFEM.problems.testsParabolicHJB as PHJB
from nonvarFEM import solveProblem
if __name__ == "__main__":
opt = hlp.standardOptions()
opt["initialMeshResolution"] = 16
opt["timeSteps"] = 10
opt["timeStepFactor"] = 2
opt["printCordesInfo"] = 0
opt["plotSolution"] = 1
opt["plotErrorEstimates"] = 0
opt["plotConvergenceRates"] = 0
opt["plotMesh"] = 0
opt["saveMesh"] = 0
opt["holdOn"] = 0
opt["normalizeSystem"] = 0
opt["meshRefinement"] = 0
opt["refinementThreshold"] = .80
opt["p"] = 2
opt["q"] = 2
opt["HessianSpace"] = "CG"
# opt["NdofsThreshold"] = 50000
opt["NdofsThreshold"] = 60000
opt["NdofsThreshold"] = 35000
opt["errorEstimationMethod"] = 1
opt["time_check"] = 1
opt["stabilizationFlag"] = 0
opt["stabilityConstant1"] = 2 # Stability constant for first-order term
opt["stabilityConstant2"] = 0 # Stability constant for second-order term
# opt["solutionMethod"] = 'BHWcomplete'
# opt["solutionMethod"] = 'BHWreduced'
opt["solutionMethod"] = 'NeilanSalgadoZhang'
# opt["solutionMethod"] = 'Neilan'
opt["gmresWarmStart"] = True # GMRES warm start
opt["dolfinLogLevel"] = 21
# P = NVP.Cinfty(0.99)
# alpha = 1.5
# P = NVP.Sol_in_H_alpha(alpha)
# alpha = 0.25
# alpha = 0.5
# alpha = 0.6
# alpha = 0.75
# alpha = 1.0
# alpha = 1.25
# P = NVP.Sol_in_H_alpha_3d(alpha)
# P = NVP.No_Cordes()
# P = NVP.Poisson()
# P = NVP.Poisson_inhomoBC()
# kappa = 0.5
# P = NVP.Cinfty(kappa)
# P = NVP.Discontinuous_A()
# P = NVP.Identity_A()
# P = NVP.Boundary_Layer()
# The following problem doesn't show nice convergence rates
# P = NVP.Discontinuous_2nd_Derivative()
# P = NVP.Neilan_Test1()
# P = NVP.Neilan_5_2()
# P = NVP.Neilan_Talk_2()
# Problems from Lakkis, Pryer
# P = NVP.LP_4_1_Nondiff_A()
# P = NVP.LP_4_2_Conv_Dominated_A()
# P = NVP.LP_4_3_Singular_Sol()
# P = NVP.LP_4_4_Nonsymmetric_Hessian()
# Problems from Feng, Neilan, Schnake
# P = NVP.FNS_5_1_Hoelder_Cont_Coeffs()
# P = NVP.FNS_5_2_Uniform_Cont_Coeffs()
# P = NVP.FNS_5_3_Degenerate_Coeffs()
# P = NVP.FNS_5_4_L_inf_Coeffs()
# Further elliptic nonvariational pdes
# 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))