-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathellipse.jl
64 lines (52 loc) · 1.67 KB
/
ellipse.jl
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
# ************************************
# This file specifies the model.
# It defines functions related to ellipse and contains the parameters in the system.
# ************************************
# the reaction coordniate map \xi: \mathbb{R}^d -> \mathbb{R}^k
d = 2
k = 1
# parameters of the ellipse
c = 3
c2 = c * c
# how many different quantities of interest (QoI) will be recorded
num_qoi = 1
# for each quantity of interest, it contains number of bins, lower and upper ranges of the histgram.
qoi_hist_info = [[100, 0.0, 2*pi]]
# initial state
x0 = [3.0, 0.0]
# potential in the target distribution
function V(x)
return 2.0 * x[1] * x[1]
# return 0.0
end
# gradient of the potential V(x)
function grad_V(x)
return [4.0 * x[1], 0.0]
# return [0.0, 0.0]
end
# quantity of interest
# make sure that the length of return vector equals the number num_qoi defined above
function QoI(x)
phi = atan(x[2], x[1]/c)
if phi < 0
phi += 2 * pi
end
return [phi]
end
# the ith component \xi_i of the map \xi
function xi_i(x, idx)
return (x[1] * x[1] / c2 + x[2] * x[2] - 1.0) * 0.5
end
# gradient of the ith component \xi_i of the map \xi
function grad_xi_i(x, idx)
return [x[1] / c2 , x[2]]
end
if solve_multiple_solutions_frequency > 0
# initialize constraint equation for HomotopyContinuation
@polyvar lam[1:k] p[1:((1+k)*d)]
# equations of the Lagrange multipliers, p contains parameters, lam is the unknown multipliers
#
# The general form is \xi_i(x + \nabla\xi \lam) = 0,
# where \lam is the unknown multipliers, x is given by p[1:d], and \nabla\xi is given by p[(d+1):((k+1)*d)]
F = [(p[1] + p[d + 1] * lam[1])^2 / c2 + (p[2] + p[d+2] * lam[1])^2 - 1.0]
end