Advertisement
muditjain

calc.js

Mar 30th, 2023
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1. function fun(){
  2.  
  3. console.log(3);
  4. var lfixed = document.getElementById('lfixed').checked;
  5. var rfixed = document.getElementById('rfixed').checked;
  6. var lpinned = document.getElementById('lpinned').checked;
  7. var rpinned = document.getElementById('rpinned').checked;
  8. var pointed = document.getElementById('pointed').checked;
  9. var uniform = document.getElementById('uniform').checked;
  10.  
  11. console.log(3);
  12.  
  13. var l = parseFloat(document.getElementById('length').value);
  14. var E = parseFloat(document.getElementById('elasticity').value);
  15. var I = parseFloat(document.getElementById('inertia').value);
  16. var a = parseFloat(document.getElementById('pos_a').value);
  17. var W = parseFloat(document.getElementById('weight').value);
  18. var x = parseFloat(document.getElementById('pos_x').value);
  19.  
  20. var b = parseFloat(l-a);
  21. var d, V, M;
  22.  
  23. console.log(3);
  24.  
  25.  
  26. if(lfixed && rfixed && pointed) {
  27.  
  28. // V = Pb/L – P (x-a)0
  29. // M = Pbx/L – P (x-a)1
  30. // δ = P/6EI [bx3/L – abx/L (2L – a) – (x – a)3]
  31. // DONE
  32.  
  33. V = W*b/l - W;
  34. M = W*b*x/l - W*(x-a);
  35. d = (W*(b*Math.pow(x,3)/l - a*b*x*(2*l-a)/l - Math.pow((x-a), 3)))/6*E*I;
  36.  
  37. // alert(V);
  38. // alert(M);
  39. // alert(d);
  40.  
  41. document.getElementById("d").innerText = d;
  42. document.getElementById("V").value = V;
  43. document.getElementById("M").value = M;
  44.  
  45. // document.getElementById("answer").innerHTML= V;
  46. // parseFloat(document.getElementById("answer").value) = V;
  47.  
  48. // window.open('/beam1.html');
  49. }
  50.  
  51. else if(lfixed && rfixed && uniform) {
  52. // V = W (L/2 – x)
  53. // M = W/12 (6Lx – L2 – 6x2)
  54. // δ = wx2/24EI (L – x)2
  55. // DONE
  56.  
  57. V = W*(l/2 - x);
  58. M = W*(6*l*x - l*l - 6*x*x);
  59. d = W*x*x*(l-x)*(l-x)/(24*E*I);
  60.  
  61. alert(V);
  62. alert(M);
  63. alert(d);
  64.  
  65. // document.getElementById("answer").value = string(V);
  66. // document.getElementById("answer").innerHTML= V;
  67. // parseFloat(document.getElementById("answer").value) = V;
  68.  
  69. // window.open('/beam2.html');
  70. }
  71.  
  72. else if(lpinned && rpinned && pointed) {
  73. // V = Pb/L – P (x-a)0
  74. // M = Pbx/L – P (x-a)1
  75. // δ = P/6EI [bx3/L – abx/L (2L – a) – (x – a)3]
  76. // done
  77.  
  78. V = W*(b/l - 1);
  79. M = W*(b*x/l - (x-a));
  80. d = W*(b*Math.pow(x,3)/l - a*b*x*(2*l - a)/l - Math.pow((x-a), 3))/(6*E*I);
  81.  
  82. alert(V);
  83. alert(M);
  84. alert(d);
  85.  
  86. // document.getElementById("answer").value = string(V);
  87. // document.getElementById("answer").innerHTML= V;
  88. // parseFloat(document.getElementById("answer").value) = V;
  89.  
  90. window.open('/beam3.html');
  91. }
  92.  
  93. else if(lpinned && rpinned && uniform) {
  94. // V = w (L/2 – x)
  95. // M = wx/2 (L – x)
  96. // δ = wx/24EI (L3 – 2 Lx2 + x3)
  97. // done
  98.  
  99. V = W*(l/2 - x);
  100. M = W*(l/2 - x)*x/2;
  101. d = W*x*(l*l*l - 2*l*x*x + x*x*x)/(24*E*I);
  102.  
  103. alert(V);
  104. alert(M);
  105. alert(d);
  106.  
  107. // document.getElementById("answer").value = string(V);
  108. // document.getElementById("answer").innerHTML= V;
  109. // parseFloat(document.getElementById("answer").value) = V;
  110.  
  111. window.open('/beam4.html');
  112. }
  113.  
  114. else if(lpinned && rfixed && pointed) {
  115. // V = Pb2/2L3 (2L + a) – P(x – a)0
  116. // M = Pb2x/2L3(2L + a) – P (x – a)1
  117. // δ = P/6EI[b2x3/2L3 (2L + a) – 3ab2x/2L – (x – a)3]
  118. // done
  119.  
  120. V = W*b*b*(2*l + a)/(2*l*l*l) - W;
  121. M = W*b*b*x*(2*l + a)/(2*l*l*l) - W*(x-a);
  122. d = W*((b*b*x*x*x*(2*l + a))/(2*l*l*l) - 3*a*b*b*x/(2*l) - Math.pow((x-a), 3))/(6*E*I);
  123.  
  124. alert(V);
  125. alert(M);
  126. alert(d);
  127.  
  128. // document.getElementById("answer").value = string(V);
  129. // document.getElementById("answer").innerHTML= V;
  130. // parseFloat(document.getElementById("answer").value) = V;
  131.  
  132. window.open('/beam5.html');
  133. }
  134.  
  135. else {
  136. document.write("Condotion not matched");
  137. }
  138.  
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement