2023 가을학기 계산전자공학 Homework #2 report 20224058 이승욱 Problem #1 Problem #2 dt : 설정한 x0 값이 변화하는 시간 간격 iter : 반복한 계산 횟수 10시간 까지 계산 횟수를 다르게 하여 시간에 따른 x0 값의 변화를 구했을 때, 계산 횟수가 늘어 날수록 해석적으로 계산하여 구한 값에 가까워지는 것을 확인했다. 소스코드 Problem #1 import matplotlib.pyplot as plt import numpy as np B=0.0117 # (um^2/hr) Deal-Grove parameter,B DG=0.0709 # (um/hr), Deal-Grove parameter,B/A A=B/DG # (um) tau=0.37 #(hr) # set up time domain time=np.arange(0, 10, 0.25) # set up function x_0(t) x0=A/2*(np.sqrt(1+4*DG/A*(time+tau))-1) #plot the graph fig, ax = plt.subplots() ax.set(title=r'time evolution of $x_0$', xlabel=r'Time (hr)', ylabel=r'$x_0$ (um)') plt.plot(time, x0,'.') plt.show() Problem #2 import matplotlib.pyplot as plt import numpy as np B=0.0117 # (um^2/hr), Deal-Grove parameter,B DG=0.0709 # (um/hr), Deal-Grove parameter,B/A A=B/DG # (um) tau=0.37 #(hr) time constant #when t ~ 0, x_0 can be estimated to B/A*tau, x0(um) x0=tau*DG #delta t(hr) = t_k+1 - t_k #set up 3 different dt value dt1=0.2 dt2=1 dt3=2 #iteration number = it #set up 3 different iteration number it1=50 it2=10 it3=5 # calculate numerically approximated value of x_0(t) in each t # time range : 0~iteration * dt def lin_approx(x0,dt,it): x0t=np.zeros(it+1) x0t[0]=x0 for i in np.arange(1,it+1,1): x0t[i]=x0t[i-1]+dt*B/(A+2*x0t[i-1]) return x0t time1 = np.arange(0,it1+1,1)*dt1 time2 = np.arange(0,it2+1,1)*dt2 time3 = np.arange(0,it3+1,1)*dt3 #x_0(t) from anlytically solved solution time4=np.arange(0, 10, 0.1) x0_a=A/2*(np.sqrt(1+4*DG/A*(time4+tau))-1) #plot fig, ax = plt.subplots() ax.set(title=r'time evolution of $x_0$', xlabel=r'Time (hr)', ylabel=r'$x_0$ (um)') plt.plot(time1, lin_approx(x0, dt1, it1), marker='o', markersize=3) plt.plot(time2, lin_approx(x0, dt2, it2), marker='^', markersize=3) plt.plot(time3, lin_approx(x0, dt3, it3), marker='d', markersize=3) plt.plot(time4,x0_a, 'k-') plt.legend(('dt=0.2, iter=50','dt=1, iter=10', 'dt=2, iter=5','Analytic Solution')) plt.show()