if __name__ == '__main__': import InputParameters as BP VOLTRANGE = fmfy(np.linspace(0.01, 50, 5)) * BP.GLOBAL_VOLT basedist = mpf(1.0) / mpf(10**6) distance = np.linspace(.5, 1.0, 3) * basedist distance2 = np.ones_like(distance) * basedist example1 = { "v": [mpf(i) * mpf(10**j) for (i, j) in [(2, 3), (2, 3), (8, 3), (8, 3)]], "c": [1, 1, 1, 1], "g": [1 / mpf(8), 1 / mpf(8), 1 / mpf(8), 1 / mpf(8)], "x": [distance2, -distance, distance2, -distance] } A = BP.base_parameters(example1, V=VOLTRANGE, Q=1 / mpf(4), T=mpf(5) / mpf(10**3)) B = Rfunc_CNCT(parameters=A.parameters, g=A.g, gtot=A.gtot, T=A.T, maxParameter=A.maxParameter, prefac=A.prefac, V=A.V, scaledVolt=A.scaledVolt, distance=A.input_parameters["x"][0], Vq=A.Vq) B.setParameter(nterms=400, maxA=8, maxK=10) B.genAnswer() plt.figure() plt.plot(B.rrfunction)
# B = Rfunc_series(parameters = A.parameters, g = A.g, gtot = A.gtot, T = A.T, # maxParameter = A.maxParameter, prefac = A.prefac, # V = A.V, scaledVolt = A.scaledVolt, # distance = A.input_parameters["x"][0], Vq = A.Vq) # B.setParameter(nterms = 200, maxA = 8, maxK = 10) # B.genAnswer() # plt.figure() # plt.plot(B.rrfunction) # plt.show() #=============================================================================== # #=============================================================================== Vpoints = mp.linspace(0, mpf('2.')/mpf(10**4), 201) dist1 = np.array([mpf('1.7') / mpf(10**(6)), mpf('1.7')/ mpf(10**(6))]) dist2 = np.array([mpf('1.5') / mpf(10**(6)), mpf('1.7') / mpf(10**(6))]) genData = { "v":[mpf(i) * mpf(10**j) for (i,j) in [(3,4),(3,4)]], "c":[1,1], "g":[1/mpf(8), 1/mpf(8)], "x":[dist1, -dist2]} A = BP.base_parameters(genData, V = Vpoints, Q = 1/mpf(4), T = 0) B = Rfunc_series(parameters = A.parameters, g = A.g, gtot = A.gtot, T = A.T, maxParameter = A.maxParameter, prefac = A.prefac, V = A.V, scaledVolt = A.scaledVolt, distance = A.input_parameters["x"][0], Vq = A.Vq) B.genAnswer() plt.figure() plt.plot(B.rrfunction) plt.show()
if method == 'series': constr = Rseries elif method == 'cnct': constr = Rcnct return constr(parameters=A.parameters, g=A.g, gtot=A.gtot, T=A.T, maxParameter=A.maxParameter, prefac=A.prefac, V=A.V, scaledVolt=A.scaledVolt, distance=A.input_parameters["x"][0]) a = BP.base_parameters(example1, V=VOLTRANGE) A = Rfunc_constructor(a, method='cnct') b = BP.base_parameters(example2, V=GLOBAL_VOLT) B = Rfunc_constructor(b, method='cnct') A.genAnswer() #cProfile.runctx('A.genAnswer()', globals(), locals() ) B.genAnswer() def plot_surface(A): if not hasattr(A, 'rrfunction'): A.genAnswer() X = np.float64(freal(A.V)) Y = np.float64(freal(A.distance)) Z = np.float64(A.rrfunction)
"x":[distance2, -distance2, distance2, -distance2]} def Rfunc_constructor(A, method = 'series'): if method == 'series': constr = Rseries elif method =='cnct': constr = Rcnct return constr(parameters = A.parameters, g = A.g, gtot = A.gtot, T = A.T, maxParameter = A.maxParameter, prefac = A.prefac, V = A.V, scaledVolt = A.scaledVolt, distance = A.input_parameters["x"][0]) a = BP.base_parameters(example1, V = VOLTRANGE ) A = Rfunc_constructor(a, method = 'cnct') b = BP.base_parameters(example2, V= GLOBAL_VOLT) B = Rfunc_constructor(b, method = 'cnct') A.genAnswer() #cProfile.runctx('A.genAnswer()', globals(), locals() ) B.genAnswer() def plot_surface(A): if not hasattr(A, 'rrfunction'): A.genAnswer() X = np.float64(freal(A.V)) Y = np.float64(freal(A.distance)) Z = np.float64(A.rrfunction) #return X, Y, Z X, Y = np.meshgrid(X,Y)
#return X, Y, Z X, Y = np.meshgrid(X, Y) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot_wireframe(X, Y, np.transpose(Z)) ax.set_xlabel('Voltage') ax.set_ylabel('Distance') ax.set_zlabel('R function') plt.show() if __name__ == '__main__': VOLTRANGE = fmfy(np.linspace(0, 50, 2)) * BP.GLOBAL_VOLT basedist = mpf(1.0) / mpf(10**6) distance = np.linspace(.5, 1.0, 3) * basedist distance2 = np.ones_like(distance) * basedist example1 = { "v": [mpf(i) * mpf(10**j) for (i, j) in [(2, 3), (2, 3)]], "c": [1, 1], "g": [1 / mpf(8), 1 / mpf(8)], "x": [distance, -distance] } A = BP.base_parameters(example1, V=VOLTRANGE) B = Rfunc_constructor(A, 'fortran') B.setParameter(nterms=800, maxA=8, maxK=10) B.genAnswer() single, interference = Current(B) # plt.figure() # plt.plot(B.rrfunction) # plt.show()
# "x":[distance2, -distance]} # A = BP.base_parameters(example1, V =VOLTRANGE, Q= 1/mpf(4), T = 5/ mpf(10**3)) # B = Rfunc_fortran(parameters = A.parameters, g = A.g, gtot = A.gtot, T = A.T, # maxParameter = A.maxParameter, prefac = A.prefac, # V = A.V, scaledVolt = A.scaledVolt, # distance = A.input_parameters["x"][0], Vq = A.Vq) # B.setParameter(nterms = 1500, maxA = 15, maxK = 15) # B.genAnswer() # plt.figure() # plt.plot(B.rrfunction) # plt.show() basedist = mpf(1.5)/mpf(10**6) distance = np.linspace(.8, 1.2, 3) * basedist distance2 = np.ones_like(distance) * basedist example1 = { "v":[mpf(i) * mpf(10**j) for (i,j) in [(3,4),(3,4),(5,3),(5,3)]], "c":[1,1,1,1], "g":[1/mpf(8),1/mpf(8),1/mpf(8),1/mpf(8)], "x":[distance2, -distance, distance2, -distance]} A = BP.base_parameters(example1, V =VOLTRANGE, Q= 1/mpf(4), T = mpf(20)/10**3 ) B = Rfunc_fortran(parameters = A.parameters, g = A.g, gtot = A.gtot, T = A.T, maxParameter = A.maxParameter, prefac = A.prefac, V = A.V, scaledVolt = A.scaledVolt, distance = A.input_parameters["x"][0], Vq = A.Vq) B.setParameter(nterms = 200000, maxA = 15, maxK = 15) B.genAnswer() plt.figure() plt.plot(B.rrfunction) plt.show()
X = np.float64(freal(A.V)) Y = np.float64(freal(A.distance)) Z = np.float64(A.rrfunction) #return X, Y, Z X, Y = np.meshgrid(X,Y) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot_wireframe(X, Y, np.transpose(Z)) ax.set_xlabel('Voltage') ax.set_ylabel('Distance') ax.set_zlabel('R function') plt.show() if __name__ == '__main__': VOLTRANGE = fmfy(np.linspace(0,50,2)) * BP.GLOBAL_VOLT basedist = mpf(1.0)/mpf(10**6) distance = np.linspace(.5, 1.0, 3) * basedist distance2 = np.ones_like(distance) * basedist example1 = { "v":[mpf(i) * mpf(10**j) for (i,j) in [(2,3),(2,3)]], "c":[1,1], "g":[1/mpf(8),1/mpf(8)], "x":[distance, -distance]} A = BP.base_parameters(example1, V =VOLTRANGE) B = Rfunc_constructor(A, 'fortran') B.setParameter(nterms = 800, maxA = 8, maxK = 10) B.genAnswer() single, interference = Current(B) # plt.figure() # plt.plot(B.rrfunction) # plt.show()