SHARE
TWEET

Untitled

a guest Nov 19th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def maxTime():
  2.     def heatmap(ix,iy,iz,borders):
  3.         levels = MaxNLocator(nbins=50).tick_values(iz.min(), iz.max())
  4.         # pick the desired colormap, sensible levels, and define a normalization
  5.         # instance which takes data values and translates those into levels.
  6.         cmap = plt.get_cmap('Greys')
  7.         norm = BoundaryNorm(levels, ncolors=cmap.N, clip=True)
  8.  
  9.         fig, (ax0, ax1) = plt.subplots(nrows=2)
  10.  
  11.         im = ax0.pcolormesh(ix,iy, iz, cmap=cmap, norm=norm)
  12.         fig.colorbar(im, ax=ax0)
  13.         ax0.set_title('pcolormesh with levels')
  14.  
  15.  
  16.         # contours are *point* based plots, so convert our bound into point
  17.         # centers
  18.         cf = ax1.contourf(ix[:-1, :-1] + 0.01/2.,
  19.                           iy[:-1, :-1] + 0.01/2., iz, levels = borders,
  20.                           cmap=cmap)
  21.         fig.colorbar(cf, ax=ax1)
  22.         ax1.set_title('contourf with levels')
  23.  
  24.         # adjust spacing between subplots so `ax1` title and `ax0` tick labels
  25.         # don't overlap
  26.         fig.tight_layout()
  27.         plt.show()
  28.        
  29.        
  30.     x = np.arange(0.1, 1, 0.1)
  31.     y = np.arange(0.1, 1, 0.1)
  32.    
  33.     t = sp.Symbol('t', positive=True)
  34.     p = sp.symbols('p')
  35.     Ki = sp.symbols('Ki', real = True)
  36.     Kp = sp.symbols('Kp', real=True)
  37.     a = sp.symbols('a', real=True)
  38.     b = sp.symbols('b', real=True)
  39.     c = sp.symbols('c', real=True)
  40.     expression = (p*Kp+Ki)*a/(p*(b*c*p+a*a)+(p*Kp+Ki)*a)
  41.    
  42.     orig1 = sp.inverse_laplace_transform(expression, p, t)
  43.     orig2 = sp.inverse_laplace_transform(expression/p, p, t)
  44.     x, y = np.meshgrid(x, y)
  45.     tp = np.empty([9,9])
  46.     mp = np.empty([9,9])
  47.     for i in range(9):
  48.         for j in range(9):
  49.             tp[i][j] = nsolve(simplify(orig1.subs([(Ki,x[i][j]),(Kp,y[i][j]),(a,0.03),(b,2.44),(c,0.00003)])),t,(0,1))
  50.             print(orig2.subs([(Ki,x[i][j]),(Kp,y[i][j]),(a,0.03),(b,2.44),(c,0.00003),(t,tp[i][j])]))
  51.            
  52.     tp = tp[:-1, :-1]
  53.     heatmap(x,y,tp,[0,15,500])
  54.    
  55.  
  56.    
  57.              
  58. maxTime()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top