Numerical modeling of a leaking oscillator












0












$begingroup$


I have recently been trying to create numerical programs in Matlab to find solutions for physical systems, and whilst researching about varying mass systems I came across a lab report, (where link and screen shot are provided below), which models a leaking oscillation system which I thought would be a good thing to try an model in Matlab, in there experiment that outline the Euler method, which I am somewhat familiar with and have done the basic shm with.



So I then tried to adapt my code to what is displayed in the lab report and see if I could generate the same result, the issue being I cannot, and seem to have become stuck to why I cant seem to get the same results. I am very new to this and matlab in general an
d I am learning as I go ect.



here is my code



%Euler Method : Pratice For Physical Systems
%-------------------------------------------------------------------------

%-------------------------------------------------------------------------
clc;
clear all;

%Defing intial paramters
k=100; % Spring Constant

h=0.05; % step between each interval

t=1:h:100; % time of measurment


%intial variables

x(1)=0; %displacment
v(1)=0; %speed


%eulers approximation for second order

for i=1:(length(t)-1)

%if i>55
%x(i+1)=x(i)+h*v(i);
%v(i+1)=v(i)-h*k*x(i);

%else if i<55

x(i+1)=x(i)+h*v(i);
v(i+1)=v(i)-h*(k*x(i)/(1+10*(1-0.018*t(i)).^2)+9.81);

%end
%end
end




plot(t,x);


Now here my explanation for what I have done.



So I first calculate the time to which the water was completed empty and (55s) and the thought if I make it a if statement when i>55s then it would read the Euler for SHM, and if i<55s then it would read the mass varying with time euler equation.



However this is not the case and all it seem to read is the case where mass is varying with time, and even then it not producing even a remotely similar graph.



I was just wondering if anyone could maybe help me understand why this is occurring.



Here is screen shot from the numerical part of the lab report and a link to the full report.



Screen Shots



enter image description here



enter image description here



enter image description here



enter image description here



Link



https://www.researchgate.net/publication/264123215_The_motion_of_a_leaking_oscillator_A_study_for_the_physics_class



as a side not the ratio I used for f=a/A=0.01










share|cite|improve this question









$endgroup$

















    0












    $begingroup$


    I have recently been trying to create numerical programs in Matlab to find solutions for physical systems, and whilst researching about varying mass systems I came across a lab report, (where link and screen shot are provided below), which models a leaking oscillation system which I thought would be a good thing to try an model in Matlab, in there experiment that outline the Euler method, which I am somewhat familiar with and have done the basic shm with.



    So I then tried to adapt my code to what is displayed in the lab report and see if I could generate the same result, the issue being I cannot, and seem to have become stuck to why I cant seem to get the same results. I am very new to this and matlab in general an
    d I am learning as I go ect.



    here is my code



    %Euler Method : Pratice For Physical Systems
    %-------------------------------------------------------------------------

    %-------------------------------------------------------------------------
    clc;
    clear all;

    %Defing intial paramters
    k=100; % Spring Constant

    h=0.05; % step between each interval

    t=1:h:100; % time of measurment


    %intial variables

    x(1)=0; %displacment
    v(1)=0; %speed


    %eulers approximation for second order

    for i=1:(length(t)-1)

    %if i>55
    %x(i+1)=x(i)+h*v(i);
    %v(i+1)=v(i)-h*k*x(i);

    %else if i<55

    x(i+1)=x(i)+h*v(i);
    v(i+1)=v(i)-h*(k*x(i)/(1+10*(1-0.018*t(i)).^2)+9.81);

    %end
    %end
    end




    plot(t,x);


    Now here my explanation for what I have done.



    So I first calculate the time to which the water was completed empty and (55s) and the thought if I make it a if statement when i>55s then it would read the Euler for SHM, and if i<55s then it would read the mass varying with time euler equation.



    However this is not the case and all it seem to read is the case where mass is varying with time, and even then it not producing even a remotely similar graph.



    I was just wondering if anyone could maybe help me understand why this is occurring.



    Here is screen shot from the numerical part of the lab report and a link to the full report.



    Screen Shots



    enter image description here



    enter image description here



    enter image description here



    enter image description here



    Link



    https://www.researchgate.net/publication/264123215_The_motion_of_a_leaking_oscillator_A_study_for_the_physics_class



    as a side not the ratio I used for f=a/A=0.01










    share|cite|improve this question









    $endgroup$















      0












      0








      0


      0



      $begingroup$


      I have recently been trying to create numerical programs in Matlab to find solutions for physical systems, and whilst researching about varying mass systems I came across a lab report, (where link and screen shot are provided below), which models a leaking oscillation system which I thought would be a good thing to try an model in Matlab, in there experiment that outline the Euler method, which I am somewhat familiar with and have done the basic shm with.



      So I then tried to adapt my code to what is displayed in the lab report and see if I could generate the same result, the issue being I cannot, and seem to have become stuck to why I cant seem to get the same results. I am very new to this and matlab in general an
      d I am learning as I go ect.



      here is my code



      %Euler Method : Pratice For Physical Systems
      %-------------------------------------------------------------------------

      %-------------------------------------------------------------------------
      clc;
      clear all;

      %Defing intial paramters
      k=100; % Spring Constant

      h=0.05; % step between each interval

      t=1:h:100; % time of measurment


      %intial variables

      x(1)=0; %displacment
      v(1)=0; %speed


      %eulers approximation for second order

      for i=1:(length(t)-1)

      %if i>55
      %x(i+1)=x(i)+h*v(i);
      %v(i+1)=v(i)-h*k*x(i);

      %else if i<55

      x(i+1)=x(i)+h*v(i);
      v(i+1)=v(i)-h*(k*x(i)/(1+10*(1-0.018*t(i)).^2)+9.81);

      %end
      %end
      end




      plot(t,x);


      Now here my explanation for what I have done.



      So I first calculate the time to which the water was completed empty and (55s) and the thought if I make it a if statement when i>55s then it would read the Euler for SHM, and if i<55s then it would read the mass varying with time euler equation.



      However this is not the case and all it seem to read is the case where mass is varying with time, and even then it not producing even a remotely similar graph.



      I was just wondering if anyone could maybe help me understand why this is occurring.



      Here is screen shot from the numerical part of the lab report and a link to the full report.



      Screen Shots



      enter image description here



      enter image description here



      enter image description here



      enter image description here



      Link



      https://www.researchgate.net/publication/264123215_The_motion_of_a_leaking_oscillator_A_study_for_the_physics_class



      as a side not the ratio I used for f=a/A=0.01










      share|cite|improve this question









      $endgroup$




      I have recently been trying to create numerical programs in Matlab to find solutions for physical systems, and whilst researching about varying mass systems I came across a lab report, (where link and screen shot are provided below), which models a leaking oscillation system which I thought would be a good thing to try an model in Matlab, in there experiment that outline the Euler method, which I am somewhat familiar with and have done the basic shm with.



      So I then tried to adapt my code to what is displayed in the lab report and see if I could generate the same result, the issue being I cannot, and seem to have become stuck to why I cant seem to get the same results. I am very new to this and matlab in general an
      d I am learning as I go ect.



      here is my code



      %Euler Method : Pratice For Physical Systems
      %-------------------------------------------------------------------------

      %-------------------------------------------------------------------------
      clc;
      clear all;

      %Defing intial paramters
      k=100; % Spring Constant

      h=0.05; % step between each interval

      t=1:h:100; % time of measurment


      %intial variables

      x(1)=0; %displacment
      v(1)=0; %speed


      %eulers approximation for second order

      for i=1:(length(t)-1)

      %if i>55
      %x(i+1)=x(i)+h*v(i);
      %v(i+1)=v(i)-h*k*x(i);

      %else if i<55

      x(i+1)=x(i)+h*v(i);
      v(i+1)=v(i)-h*(k*x(i)/(1+10*(1-0.018*t(i)).^2)+9.81);

      %end
      %end
      end




      plot(t,x);


      Now here my explanation for what I have done.



      So I first calculate the time to which the water was completed empty and (55s) and the thought if I make it a if statement when i>55s then it would read the Euler for SHM, and if i<55s then it would read the mass varying with time euler equation.



      However this is not the case and all it seem to read is the case where mass is varying with time, and even then it not producing even a remotely similar graph.



      I was just wondering if anyone could maybe help me understand why this is occurring.



      Here is screen shot from the numerical part of the lab report and a link to the full report.



      Screen Shots



      enter image description here



      enter image description here



      enter image description here



      enter image description here



      Link



      https://www.researchgate.net/publication/264123215_The_motion_of_a_leaking_oscillator_A_study_for_the_physics_class



      as a side not the ratio I used for f=a/A=0.01







      physics matlab






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Jan 13 at 1:03









      james2018james2018

      777




      777






















          0






          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "69"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          noCode: true, onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3071591%2fnumerical-modeling-of-a-leaking-oscillator%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Mathematics Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3071591%2fnumerical-modeling-of-a-leaking-oscillator%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

          Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

          A Topological Invariant for $pi_3(U(n))$