Results 1 to 5 of 5

Math Help - Matlab Fermenter model

  1. #1
    Junior Member
    Joined
    Apr 2009
    Posts
    45

    Matlab Fermenter model

    Hi,

    I have been given a fermenter deisgn porblem and i thought i would use matlab to help. I have this code that i have been given but i havent got any idea how to run it. I know its very long so i appreciate if anyone could help.
    -----------------------------------------------------------------------
    function [fermoutputs]=fermmodel(feedrate,fermentersettings)
    % Function which simulates ADH bakers yeast fermentation
    % Model based upon Vrsalovic et al Process Biochemistry, 2005, pp2781-2791

    % integration time of Ts - small as fast do dynamics

    batchlength=length(feedrate.flow);
    Ts=0.0002;

    % Size storage vectors
    m=round(batchlength/Ts);
    cx=zeros(m,1);
    cg=zeros(m,1);
    cet=zeros(m,1);
    co=zeros(m,1);
    cav=zeros(m,1);
    doxy=zeros(m,1);
    v=zeros(m,1);
    timevals=zeros(m,1);

    % Fermenter operting procedure

    rpm=fermentersettings.rpm;
    airin=fermentersettings.airin;
    volreact=v(1)/1000;

    Dr=(4*fermentersettings.volume/3*pi)^0.3333;

    % Model initial conditions
    % Cell wt
    cx(1)=0.16;
    % Glucose conc
    cg(1)=fermentersettings.glucoseconc;
    % Ethanol conc
    cet(1)=0;
    % Oxygen conc
    co(1)=0.007;
    % No product present
    cav(1)=0;
    % Do saturated
    doxy(1)=100;
    % Fermenter volume
    v(1)=fermentersettings.volume;
    timevals(1)=0;

    % Loop to simulate the fed-batch bioreaction

    for i=1:batchlength/Ts,

    % Find the feed flowrate

    flow=feedrate.flow(ceil(i*Ts));

    % Determine the rate equations

    % Oxidative path
    Rg=0.212*cg(i)/(0.612+cg(i));
    Rolim=0.0384*co(i)/(0.000096+co(i));
    Rgox=min([Rg Rolim/0.515]);

    % Reductive path

    Rgred=Rg-Rgox;

    % Ethanol

    Retup=0.07176*cet(i)/(0.1012+cet(i));
    Retox=min([Retup (Rolim-Rgox*0.515)/2.838]);

    % Overal growth rate

    Yoxxg=1.521;
    Yredxg=1.051;
    Yxet=0.293;

    % Rate cell growtb
    mu=Yoxxg*Rgox+Yredxg*Rgred+Yxet*Retox;
    rx=mu*cx(i);
    dcx=rx;

    % Rate of glucose usage

    dcg=-(Rgox+Rgred)*cx(i);

    % Rate ethanol production

    Retpr=0.049*Rgred;
    dcet=(Retpr-Retox)*cx(i);

    % Dissolved oxygem
    % air vvm flow

    volreact=v(i)/1000;

    qvair=60*volreact*airin;
    ugas=4*qvair/(3600*Dr^2);
    poverv=(rpm/700)*150/volreact;
    klao=3600*(0.026*(poverv^0.4)*(ugas^0.5));
    T=20;
    kla=klao*(1+0.07*cx(i))*1.022^(T-20);

    ro=0.515*Rgox+2.838*Retox;

    dco=kla*(0.00712-co(i))-ro*cx(i);

    % Product rate
    DO=100*co(i)/0.00712;
    if DO>10,
    a=4.07/DO;
    else
    a=0.02035*tanh(DO-5)+0.02035;
    end
    dav=a*dcx-0.015*cav(i);

    % Update the differentials

    cx(i+1)=cx(i)+dcx*Ts-flow*1000*cx(i)*Ts/v(i);
    cg(i+1)=cg(i)+dcg*Ts+flow*1000*(feedrate.conc-cg(i))*Ts/v(i);
    cet(i+1)=cet(i)+dcet*Ts-flow*1000*cet(i)*Ts/v(i);
    co(i+1)=co(i)+dco*Ts;
    if co(i+1)<0,
    co(i+1)=0;
    end
    if
    co(i+1)>0.00712,
    co(i+1)=0.00712;
    end
    cav(i+1)=cav(i)+dav*Ts-flow*1000*cav(i)*Ts/v(i);
    if cav(i+1)<0,
    cav(i+1)=0;
    end

    v(i+1)=v(i)+flow*1000*Ts;

    timevals(i+1)=i*Ts;
    end

    doxy=100*co/0.00712;

    fermoutputs.fcx=cx;
    fermoutputs.fcg=cg;
    fermoutputs.fcet=cet;
    fermoutputs.fco=co;
    fermoutputs.fcav=cav;
    fermoutputs.fdoxy=doxy;
    fermoutputs.fvol=v;
    fermoutputs.ftime=timevals;

    % Calculate the cell growth rate bin info

    fermoutputs.fbox1=0;
    fermoutputs.fbox2=0;
    fermoutputs.fbox3=0;

    for i=101:100:length(fermoutputs.fcx),
    mu=(fermoutputs.fcx(i)-fermoutputs.fcx(i-100))/(Ts*100);
    if mu < 0.15
    fermoutputs.fbox1=fermoutputs.fbox1+fermoutputs.fc x(i)-fermoutputs.fcx(i-100);
    elseif mu> 0.15 & mu < 0.2
    fermoutputs.fbox2=fermoutputs.fbox2+fermoutputs.fc x(i)-fermoutputs.fcx(i-100);
    else
    fermoutputs.fbox3=fermoutputs.fbox3+fermoutputs.fc x(i)-fermoutputs.fcx(i-100);
    end
    end
    -------------------------------------------------------------


    All i know is i have to enter something along the line of
    ---------------------------------------------------
    feedrate.conc=100;

    fermentersettings.glucoseconc=10;
    fermentersettings.rpm=500;
    fermentersettings.airin=3;
    fermentersettings.volume=45;

    ----------------------------------------------------

    but i am not sure how to run it!!

    appreciate any help,

    Rem
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by rem88 View Post
    -----------
    feedrate.conc=100;

    fermentersettings.glucoseconc=10;
    fermentersettings.rpm=500;
    fermentersettings.airin=3;
    fermentersettings.volume=45;

    ----------------------------------------------------
    fermoutputs=fermmodel(feedrate,fermentersettings)

    should do it

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Apr 2009
    Posts
    45
    i try that and i get this error

    ??? Undefined function or method 'fermmodel' for input arguments of type
    'struct'.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by rem88 View Post
    i try that and i get this error

    ??? Undefined function or method 'fermmodel' for input arguments of type
    'struct'.
    Is your function in a file called fermmodel.m and is it on the matlab search path?

    CB
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Junior Member
    Joined
    Apr 2009
    Posts
    45
    I think that was what was wrong, it wasnt on the search path, its working now.

    Thanks so much for the help, appreciate it alot,

    Rem
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. HIV model
    Posted in the Differential Equations Forum
    Replies: 16
    Last Post: January 20th 2011, 02:27 PM
  2. Non-linear process model with Linear measurement model
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: September 2nd 2009, 12:32 AM
  3. Replies: 3
    Last Post: April 15th 2009, 02:18 AM
  4. ANother model
    Posted in the Calculus Forum
    Replies: 2
    Last Post: March 5th 2008, 02:56 PM
  5. Zero Model
    Posted in the Advanced Math Topics Forum
    Replies: 2
    Last Post: December 9th 2006, 02:50 PM

Search Tags


/mathhelpforum @mathhelpforum