hiddenGem

BME Extras

Jun 20th, 2021
734
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %% Just extra coding that I used over this last year for my classes
  2.  
  3. %% Itertive Guess V and Re 409
  4. % Set up
  5.  
  6. % Input Constants
  7. mu = input('dynamic viscosity\n');
  8. rho = input('Density \n');
  9. L = input('Length of Pipe\n');
  10. D = input('Diameter of Pipe\n');
  11. alpha = input('Kinetic Energy Correction Factor\n');
  12. epsilon = input('Roughness epsilon (not e/D)\n');
  13.  
  14. % Repeating Inputs
  15. Re = input('Re guess\n');
  16. f = input('Friction Factor\n');
  17.  
  18. % Constants
  19. g = 9.81;                               % [m/s] gravitational constant
  20. A = (-2.457*log((7/Re)^0.9+0.27*epsilon/D))^16;
  21. B = (37530/Re)^16;
  22. %% Loop
  23.  
  24. while 1
  25. Vin = sqrt(2*g*z/(f*L/D+alpha))
  26. Re = rho*Vin*D/mu
  27. f = 8*((8/Re)^12+(A+B)^(-1.5))^(1/12)
  28. Vnew = sqrt(2*g*z/(f*L/D+alpha))
  29.     if(abs((Vin-Vnew)/Vin) < 0.03)
  30.         break;
  31.     end
  32.     Vin = Vnew;
  33.    
  34. end
  35.  
  36. %% Calculating Vm for transport across a typical cariac muscle cell membrane
  37. syms Vm  R  T F  CL C0 P1 P2 P3 P4 C1L C2L C3L C4L C10 C20 C30 C40 b
  38. format compact
  39. z = [1, 1, -1, 2];
  40. p = [P1 P2 P3 P4];
  41. Cl = [C1L C2L C3L C4L];
  42. Co = [C10 C20 C30 C40];
  43.  
  44. for i = 1:4
  45.     N(i) = -p(i)*Vm*z(i)*b*(Cl(i)-Co(i)*exp(-Vm*z(i)*b))/(1-exp(Vm*z(i)*b));
  46.     i = i+1;
  47. end
  48.    
  49.  
  50. a = N(1)+N(2)+2*N(4)== N(3);
  51. solve ([a,Vm])
  52.  
  53. %% 201 HW 6
  54.  
  55. a = 1;
  56. for a = 1:5
  57.  
  58. x = input('x-coordinates\n');
  59. y = input('y-coordinates\n');
  60. i = 1;
  61. j = 2;
  62.     for k = 1:4
  63.         Mag(i) = sqrt( (x(i)-x(j))^2 + (y(i)-y(j))^2 );
  64.         Mag_tot (a,i) = Mag(i);
  65.         i = i+1;
  66.         j = j+1;
  67.     end
  68.  
  69. Mean(a) = mean(Mag);
  70. SD(a) = std(Mag);
  71. a = a+1;
  72. end
  73. %%
  74. syms x
  75. p1 = 0.8;
  76. p2 = 8;
  77. p3 = 4;
  78. c10 = 150;
  79. c1l =12;
  80. c20 = 4;
  81. c30 = 120;
  82. c40 = 100;
  83. c2l = 140;
  84. c3l= 4;
  85. c4l = 20;
  86. y = 1-exp(-x);
  87. p1*c1l-p1*c10*y+p2*c2l-p2*c20*y+p3*c30-p3*c3l*y+(c4l-c40*y^2)/(1+y);
  88. solve([ans])
  89.  
  90.  
  91. %%
  92. syms t K1 K2 phi
  93. A  = 95;
  94. Rm = 2;
  95. R0 = 8;
  96. Cm = 100;
  97. Vc = 100+100*sin(1000*t)
  98. Vm = K1+K2*sin(1000*t+phi)
  99. K = Rm/(Rm+R0)
  100. solve([Vm==K*A/(1+K*A)*Vc])
RAW Paste Data