Advertisement
muditjain

Calc

Mar 28th, 2023
628
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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("answer").value = string(V);
  42.         // document.getElementById("answer").innerHTML= V;
  43.         // parseFloat(document.getElementById("answer").value) = V;
  44.        
  45.         window.open('/beam1.html');
  46.     }
  47.  
  48.     else if(lfixed && rfixed && uniform) {
  49.         // V = W (L/2 – x)
  50.         // M = W/12 (6Lx – L2 – 6x2)
  51.         // δ = wx2/24EI (L – x)2
  52.         // DONE
  53.        
  54.         V = W*(l/2 - x);
  55.         M = W*(6*l*x - l*l - 6*x*x);
  56.         d = W*x*x*(l-x)*(l-x)/(24*E*I);
  57.  
  58.         alert(V);
  59.         alert(M);
  60.         alert(d);
  61.        
  62.         // document.getElementById("answer").value = string(V);
  63.         // document.getElementById("answer").innerHTML= V;
  64.         // parseFloat(document.getElementById("answer").value) = V;
  65.        
  66.         window.open('/beam2.html');
  67.     }
  68.  
  69.     else if(lpinned && rpinned && pointed) {
  70.         // V = Pb/L – P (x-a)0
  71.         // M = Pbx/L – P (x-a)1
  72.         // δ = P/6EI [bx3/L – abx/L (2L – a) – (x – a)3]
  73.         // done
  74.        
  75.         V = W*(b/l - 1);
  76.         M = W*(b*x/l - (x-a));
  77.         d = W*(b*Math.pow(x,3)/l - a*b*x*(2*l - a)/l - Math.pow((x-a), 3))/(6*E*I);
  78.  
  79.         alert(V);
  80.         alert(M);
  81.         alert(d);
  82.        
  83.         // document.getElementById("answer").value = string(V);
  84.         // document.getElementById("answer").innerHTML= V;
  85.         // parseFloat(document.getElementById("answer").value) = V;
  86.        
  87.         window.open('/beam3.html');
  88.     }
  89.  
  90.     else if(lpinned && rpinned && uniform) {
  91.         // V = w (L/2 – x)
  92.         // M = wx/2 (L – x)
  93.         // δ = wx/24EI (L3 – 2 Lx2 + x3)
  94.         // done
  95.        
  96.         V = W*(l/2 - x);
  97.         M = W*(l/2 - x)*x/2;
  98.         d = W*x*(l*l*l - 2*l*x*x + x*x*x)/(24*E*I);
  99.  
  100.         alert(V);
  101.         alert(M);
  102.         alert(d);
  103.        
  104.         // document.getElementById("answer").value = string(V);
  105.         // document.getElementById("answer").innerHTML= V;
  106.         // parseFloat(document.getElementById("answer").value) = V;
  107.        
  108.         window.open('/beam4.html');
  109.     }
  110.  
  111.     else if(lpinned && rfixed && pointed) {
  112.         // V = Pb2/2L3 (2L + a) – P(x – a)0
  113.         // M = Pb2x/2L3(2L + a) – P (x – a)1
  114.         // δ = P/6EI[b2x3/2L3 (2L + a) – 3ab2x/2L – (x – a)3]
  115.         // done
  116.  
  117.         V = W*b*b*(2*l + a)/(2*l*l*l) - W;
  118.         M = W*b*b*x*(2*l + a)/(2*l*l*l) - W*(x-a);
  119.         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);
  120.  
  121.         alert(V);
  122.         alert(M);
  123.         alert(d);
  124.        
  125.         // document.getElementById("answer").value = string(V);
  126.         // document.getElementById("answer").innerHTML= V;
  127.         // parseFloat(document.getElementById("answer").value) = V;
  128.        
  129.         window.open('/beam5.html');
  130.     }
  131.    
  132.     else {  
  133.     document.write("Condotion not matched");  
  134. }
  135.  
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement