示例#1
0
def optmizestringcg(X, Y, E, S, h):
    #the string is optimized by cg method
    S1, S_new = [], []
    n = len(S)
    dx = list(range(n))
    dy = list(range(n))

    inter = xalglib.spline2dbuildbicubicv(X, len(X), Y, len(Y), E, 1)

    #steep descent step
    for i in range(n):
        Ener, dx[i], dy[i], dxy = xalglib.spline2ddiff(inter, S[i][0], S[i][1])
        S1.append([S[i][0] - h * dx[i], S[i][1] - h * dy[i]])

    #orthogonal step
    for i in range(n):
        Ener, Dx, Dy, Dxy = xalglib.spline2ddiff(inter, S1[i][0], S1[i][1])
        a = Dx * dx[i] + Dy * dy[i]
        b = dx[i]**2 + dy[i]**2
        lamda = a / b
        D1x = Dx - lamda * dx[i]
        D1y = Dy - lamda * dy[i]
        S_new.append([S1[i][0] - h * D1x, S1[i][1] - h * D1y])

    return S_new
示例#2
0
def optmizestringsd(X, Y, E, S, h):
    #the string is optimized by sd method
    S_new = []
    inter = xalglib.spline2dbuildbicubicv(X, len(X), Y, len(Y), E, 1)
    for coor in S:
        Ener, dx, dy, dxy = xalglib.spline2ddiff(inter, coor[0], coor[1])
        S_new.append([coor[0] - h * dx, coor[1] - h * dy])
    return S_new
示例#3
0
def printresult(FILE, S, X, Y, E):
    #print all the relative results
    inter = xalglib.spline2dbuildbicubicv(X, len(X), Y, len(Y), E, 1)
    for coor in S:
        E_new = xalglib.spline2dcalcv(inter, coor[0], coor[1])
        string = str(coor[0]) + "    " + str(coor[1]) + "    " + str(
            E_new[0]) + "\n"
        FILE.write(string)
示例#4
0
def  OptimizeString(X,Y,E,S,h):
	S_new = []
	N_x = len(X)
	N_y = len(Y)
	inter = xalglib.spline2dbuildbicubicv(X, N_x, Y, N_y, E, 1)
	for coor in S:
		Ener, dx, dy, dxy = xalglib.spline2ddiff(inter, coor[0], coor[1]) # dx = dE/dx, dy = dE/dy
		S_new.append([coor[0]-h*dx, coor[1]-h*dy])
	return S_new
示例#5
0
def PrintResult(File, S, X, Y, E):
    S_new = []
    N_x = len(X)
    N_y = len(Y)
    inter = xalglib.spline2dbuildbicubicv(X, N_x, Y, N_y, E, 1)
    for coor in S:
        Ener = xalglib.spline2dcalcv(inter, coor[0], coor[1])
        string = str(coor[0]) + "    " + str(coor[1]) + "    " + str(
            Ener[0]) + "\n"
        File.write(string)
示例#6
0
 def build_2d_bicubic_spline(self, x, m, y, n, z, d):
     self.bicubicv2d = xalglib.spline2dbuildbicubicv(x, m, y, n, z, d)