Applying a known velocity (convection) to a reaction diffusion PDE (MATLAB)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I am trying to add a known velocity (10 m/s) to my steady state reaction diffusion equation although I'm a bit confused how to go about doing that.



convection-reaction-diffusion equation



This is my current code



function simple_steady_state_bvp4c
close all; clear all; clc;

%Diffusion coefficient
D_ij= 1*10^-6;

%Initial concentration at x=0
L0 = 1;

%Total length
x_f = 0.025;

k_1 = 0.25;

solinit = bvpinit(linspace(0,x_f,11),[0.5 0]);

sol = bvp4c(@(x,y)odefcn(x,y,D_ij,k_1),@twobc,solinit);

figure(1)
plot(sol.x,(sol.y(1,:)),'LineWidth',1)
title('Steady State')
xlabel('Distance (mum)')
ylabel('Concentration (nM)')
axis([0 x_f 0 L0])

function dy = odefcn(x,y,D_ij,k_1)
C_L = y(1);
dC_Ldx = y(2);

R_L = -k_1.*C_L;
dy = zeros(2,1);
dy(1) = dC_Ldx;
dy(2) = (-R_L/D_ij);
end

function res = twobc(ya,yb)
res = [ ya(1)-(L0); yb(2) ];
end
end






share|cite|improve this question























    up vote
    0
    down vote

    favorite












    I am trying to add a known velocity (10 m/s) to my steady state reaction diffusion equation although I'm a bit confused how to go about doing that.



    convection-reaction-diffusion equation



    This is my current code



    function simple_steady_state_bvp4c
    close all; clear all; clc;

    %Diffusion coefficient
    D_ij= 1*10^-6;

    %Initial concentration at x=0
    L0 = 1;

    %Total length
    x_f = 0.025;

    k_1 = 0.25;

    solinit = bvpinit(linspace(0,x_f,11),[0.5 0]);

    sol = bvp4c(@(x,y)odefcn(x,y,D_ij,k_1),@twobc,solinit);

    figure(1)
    plot(sol.x,(sol.y(1,:)),'LineWidth',1)
    title('Steady State')
    xlabel('Distance (mum)')
    ylabel('Concentration (nM)')
    axis([0 x_f 0 L0])

    function dy = odefcn(x,y,D_ij,k_1)
    C_L = y(1);
    dC_Ldx = y(2);

    R_L = -k_1.*C_L;
    dy = zeros(2,1);
    dy(1) = dC_Ldx;
    dy(2) = (-R_L/D_ij);
    end

    function res = twobc(ya,yb)
    res = [ ya(1)-(L0); yb(2) ];
    end
    end






    share|cite|improve this question





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am trying to add a known velocity (10 m/s) to my steady state reaction diffusion equation although I'm a bit confused how to go about doing that.



      convection-reaction-diffusion equation



      This is my current code



      function simple_steady_state_bvp4c
      close all; clear all; clc;

      %Diffusion coefficient
      D_ij= 1*10^-6;

      %Initial concentration at x=0
      L0 = 1;

      %Total length
      x_f = 0.025;

      k_1 = 0.25;

      solinit = bvpinit(linspace(0,x_f,11),[0.5 0]);

      sol = bvp4c(@(x,y)odefcn(x,y,D_ij,k_1),@twobc,solinit);

      figure(1)
      plot(sol.x,(sol.y(1,:)),'LineWidth',1)
      title('Steady State')
      xlabel('Distance (mum)')
      ylabel('Concentration (nM)')
      axis([0 x_f 0 L0])

      function dy = odefcn(x,y,D_ij,k_1)
      C_L = y(1);
      dC_Ldx = y(2);

      R_L = -k_1.*C_L;
      dy = zeros(2,1);
      dy(1) = dC_Ldx;
      dy(2) = (-R_L/D_ij);
      end

      function res = twobc(ya,yb)
      res = [ ya(1)-(L0); yb(2) ];
      end
      end






      share|cite|improve this question











      I am trying to add a known velocity (10 m/s) to my steady state reaction diffusion equation although I'm a bit confused how to go about doing that.



      convection-reaction-diffusion equation



      This is my current code



      function simple_steady_state_bvp4c
      close all; clear all; clc;

      %Diffusion coefficient
      D_ij= 1*10^-6;

      %Initial concentration at x=0
      L0 = 1;

      %Total length
      x_f = 0.025;

      k_1 = 0.25;

      solinit = bvpinit(linspace(0,x_f,11),[0.5 0]);

      sol = bvp4c(@(x,y)odefcn(x,y,D_ij,k_1),@twobc,solinit);

      figure(1)
      plot(sol.x,(sol.y(1,:)),'LineWidth',1)
      title('Steady State')
      xlabel('Distance (mum)')
      ylabel('Concentration (nM)')
      axis([0 x_f 0 L0])

      function dy = odefcn(x,y,D_ij,k_1)
      C_L = y(1);
      dC_Ldx = y(2);

      R_L = -k_1.*C_L;
      dy = zeros(2,1);
      dy(1) = dC_Ldx;
      dy(2) = (-R_L/D_ij);
      end

      function res = twobc(ya,yb)
      res = [ ya(1)-(L0); yb(2) ];
      end
      end








      share|cite|improve this question










      share|cite|improve this question




      share|cite|improve this question









      asked Jul 18 at 21:38









      BaiSango

      11




      11

























          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',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          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%2f2856035%2fapplying-a-known-velocity-convection-to-a-reaction-diffusion-pde-matlab%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes










           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2856035%2fapplying-a-known-velocity-convection-to-a-reaction-diffusion-pde-matlab%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          What is the equation of a 3D cone with generalised tilt?

          Color the edges and diagonals of a regular polygon

          Relationship between determinant of matrix and determinant of adjoint?