Guest User

Untitled

a guest
Jan 21st, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. # sample parameter §§ Gold
  4. la0 = 429 # conductivity in W/mK
  5. gma = 62.8 # thermal constant J/m^3K^2
  6. Cl = 2.6*10**6 # phonon specific heat in J/m^3K
  7. Gel = 3.5*10**16 # lelectron phonon coupling constant
  8. tau_e = 0.04 # e relaxation t const
  9. tau_l = 0.6 # l relaxation t const
  10. Tm = 300
  11. L = 100 # sample thickness in nm
  12. # Laser pulse parameters
  13. T = 6
  14.  
  15. R = 0.93 # reflectivity
  16. I0 = 100 # fulence in J/m^2
  17. tp = 0.1 # in ps
  18. zz0 = 15.3 # penetration depth in nm
  19.  
  20.  
  21. #F = 0.5
  22.  
  23. def las(x,t):
  24. pt = 0.93*((1-R)/(zz0*tp))*I0*np.exp(-(x/zz0)-2.772*((t-2*tp)**2/tp**2))
  25. return pt
  26.  
  27. def I(x):
  28. tin = Tm
  29. return tin
  30.  
  31. a = la0
  32.  
  33.  
  34.  
  35. def solver_FE(I, a, las, L, T):
  36. """
  37.  
  38. """
  39. import time; t0 = time.clock() # For measuring the CPU time
  40.  
  41. dt = 0.001
  42. Nt = int(round(T/float(dt)))
  43. t = np.linspace(0, Nt*dt, Nt+1) # Mesh points in time
  44.  
  45. dx = 1
  46. Nx = int(round(L/dx))
  47. x = np.linspace(0, L, Nx+1) # Mesh points in space
  48.  
  49.  
  50. F = a*(dt/dx**2)
  51. u = np.zeros(Nx+1)
  52. u_n = np.zeros(Nx+1)
  53. v = np.zeros(Nx+1)
  54. v_n = np.zeros(Nx+1)
  55.  
  56.  
  57.  
  58. # Set initial condition u(x,0) = I(x)
  59. for i in range(0, Nx+1):
  60. u_n[i] = I(x[i])
  61. v_n[i] = I(x[i])
  62.  
  63.  
  64.  
  65. for n in range(0, Nt):
  66. # Compute u, v at inner mesh points
  67. for i in range(1, Nx):
  68. u[i] = u_n[i] + F*(u_n[i-1] - 2*u_n[i] + u_n[i+1]) + dt*(-Gel*(u_n[i] - v_n[i]) + las(x[i], t[n]))
  69. v[i] = v_n[i] + F*(v_n[i-1] - 2*v_n[i] + v_n[i+1]) + dt*(Gel*(u_n[i] - v_n[i]))
  70.  
  71. # Insert boundary conditions
  72. u[0] = 0; u[Nx] = 0
  73. v[0] = 0; v[Nx] = 0
  74.  
  75. # this step is to save each value of v and u in each time step before updating it, such that I can plot u and v with respect to time.
  76. ut = np.array([])
  77. vt = np.array([])
  78. for m in range(0, Nt):
  79. ut = np.append(ut,u)
  80. vt = np.append(vt,v)
  81.  
  82.  
  83. # Switch variables before next step
  84.  
  85. u_n, u = u, u_n
  86. v_n, v = v, v_n
  87.  
  88.  
  89.  
  90. t1 = time.clock()
  91. return u_n, v_n, x, t, t1-t0 # u_n holds latest u
  92.  
  93.  
  94. u, v, x, t, cpu = solver_FE(I, a, las, L, T)
  95.  
  96. #fig = plt.figure(1)
  97. ##t = np.linspace(0, T, h)
  98. #plt.plot(t,u,'r',label=r'$T_e$')
  99. #plt.plot(t,v,'b',label=r'$T_l$')
  100. ##plt.plot(t,sol0[:,2],'g',label=r'$T_s$')
  101. #plt.ylabel('$Temperature$',fontsize=20)
  102. #plt.xlabel('Delay',fontsize=20)
  103. #plt.legend(loc='best')
  104. #plt.show()
  105. ##
  106. fig = plt.figure(2)
  107. #t = np.linspace(0, T, h)
  108. plt.plot(x,u,'r',label=r'$T_e$')
  109. plt.plot(x,v,'g',label=r'$T_l$')
  110. #plt.plot(t,sol0[:,2],'g',label=r'$T_s$')
  111. plt.ylabel('$Temperature$',fontsize=20)
  112. plt.xlabel('length',fontsize=20)
  113. plt.legend(loc='best')
  114. plt.show()
  115.  
  116. fig = plt.figure(3)
  117. #t = np.linspace(0, T, h)
  118. plt.plot(t,las(0,t),'r',label=r'$T_e$')
  119. #plt.plot(x,v,'g',label=r'$T_l$')
  120. #plt.plot(t,sol0[:,2],'g',label=r'$T_s$')
  121. plt.ylabel('$Intensity$',fontsize=20)
  122. plt.xlabel('Delay',fontsize=20)
  123. plt.legend(loc='best')
  124. plt.show()
  125.  
  126. RuntimeWarning: overflow encountered in double_scalars
  127. u[i] = u_n[i] + F*(u_n[i-1] - 2*u_n[i] + u_n[i+1]) + dt*(-Gel*(u_n[i] - v_n[i]) + las(x[i], t[n]))
  128. C:/Users/jayas/OneDrive/Documents/Python Scripts/llg/diff_ttm_v_test.py:90: RuntimeWarning: overflow encountered in double_scalars
  129. v[i] = v_n[i] + F*(v_n[i-1] - 2*v_n[i] + v_n[i+1]) + dt*(Gel*(u_n[i] - v_n[i]))
  130. C:/Users/jayas/OneDrive/Documents/Python Scripts/llg/diff_ttm_v_test.py:89: RuntimeWarning: invalid value encountered in double_scalars
  131. u[i] = u_n[i] + F*(u_n[i-1] - 2*u_n[i] + u_n[i+1]) + dt*(-Gel*(u_n[i] - v_n[i]) + las(x[i], t[n]))
  132. C:/Users/jayas/OneDrive/Documents/Python Scripts/llg/diff_ttm_v_test.py:90: RuntimeWarning: invalid value encountered in double_scalars
  133. v[i] = v_n[i] + F*(v_n[i-1] - 2*v_n[i] + v_n[i+1]) + dt*(Gel*(u_n[i] - v_n[i]))
Add Comment
Please, Sign In to add comment