필터 지우기
필터 지우기

Im working with algae growth linked to the light. I don't know how to write the integral on matlab inside the the light intensity formulation.

조회 수: 1 (최근 30일)
function u = bioreactors
clc
clear all
% Forward Euler method is used for solving the following boundary value problem:
% U(0,t) = 0
% U(L,t) = u (end-1,t)
% U(z, 0) = U0(z)=0
% it is assumed that the concentration of C,N,P are costant
% Problem parameters
alpha1 = 5*10^(-4);
mu0 = 0.5;
mue = 0.035;
Hl = 5;
T = 10^3; % [s]
nz = 100; nt = 100;
KP = 0.7 ;
HP= 7;
P = 0.2 ;
PC = 0.1;
K = 0.50;
KN = 0.35 ;
HN = 14.5*10^(-6);
N = 0.3;
NC = 0.2;
KC = 0.5;
HC = 5 ;
C = 0.4 ;
PHs3 = 0.4 ;
PHs4 = 0.5;
Z = 10;
lambda = 2 ;
%Check of the problem's parameters
if any([P-PC N-NC] <=0 )
error('Check problem parameters')
end
if any([alpha1 mu0 Hl Z T nz-2 nt-2 KP P PC HC KN N NC KC HC C HN ] <= 0)
error('Check problem parameters')
end
% Stability
dz=Z/nz ;
dt = T/nt;
r = alpha1*dt/((dz)^2);
st = 1;
while (2*r) > st
nt = nt+1;
end
% Initialization
z = linspace(0,Z,nz+1); t = linspace(0,T,nt+1);
f1= (KP*(P-PC))/(HP+(P-PC));
f2 = (KN*(N-NC))/(HN+(N-NC));
pH = (6.35 - log10(C)) /2 ;
f3 = 1/(1+exp(lambda*(pH-PHs3)));
f4 = 1/(1+exp(lambda*(pH-PHs4)));
I0 = 100*max(sin ((t-0.4*3600)/(6.28)) , sin (0));
%I = ???% Dont know how to write it on matlab.
% Finite-difference method
for j=2:nt+1
u(1) = 0; % Condizione al contorno di Dirichlet
g = (mu0.*I(j))/(Hl+I(j)); decay = g(j)*f1*f2*f3-mue*f4;
u(2:end-1)=(1-2*r-decay*dt)*u(2:end-1)+r*(u(1:end-2)+u(3:end));
u(end) = u(end); % Condizione al contorno di Neumann
plot(u,z,'r*:');
set(gca,'YDir','reverse');
xlabel('u'); ylabel('z');
title(['t=',num2str(t(j))]);
axis([0 0.05 0 10]);
pause(0.01);
end
The integral is in the page 9 of the attachment "algae". The light intensity(I) formulation can be found at page 2, formulation number (3), it is a value which changes through the space z and the time.
As a result i should see a plot in which the mass of microorganism changes over the space and the time, something like this:
On Z=0 there is the light while in Z=5 there is no light so that's why the mass of microorganisms is equal to 0, they are photosynthetic algae.
  댓글 수: 2
Torsten
Torsten 2023년 11월 18일
편집: Torsten 2023년 11월 18일
Is your code from above intended to solve equation (1) of the paper ?
Alfonso
Alfonso 2023년 11월 18일
편집: Alfonso 2023년 11월 18일
Yes, i want just to have the growth of microorganisms over the space and time. If you dont have some parameters just choose a value random, then i'll change it with real ones.

댓글을 달려면 로그인하십시오.

답변 (2개)

Torsten
Torsten 2023년 11월 18일
이동: Torsten 2023년 11월 18일
Where is your discretization of d^2w/dz^2 ? Where do you implement the boundary conditions dw/dz = 0 at z = 0 and z = L ?
You have to discretize equation (1) of the article in space and use an ode-integrator (usually ode15s) to integrate the values in the grid points over time.
Look up "method-of-lines" for more details.
I suggest you do this first without the integral term. After you succeeded, add the three ordinary differential equations for N,P and C and use "trapz" to compute the integral term.
  댓글 수: 1
Alfonso
Alfonso 2023년 11월 18일
편집: Alfonso 2023년 11월 18일
i've already done the discretization of the equation (1) which is u(2:end-1)=(1-2*r-decay*dt)*u(2:end-1)+r*(u(1:end-2)+u(3:end)); but inside this formula there is the "decay" term which has "g" which depends by the "I" term which has an integral that I don't know how to insert inside matlab, this is the problem.
For the boundary condition i put:
  • For z=0 --> u(1)=0, Dirichlet
  • For z=L --> u(end)=u(end-1), Noemann equal to 0
You can find everything inside the for cycle. In fact, I just used a for cycle which is simpler to define the discretized w over the time, i'm a student so i'm not so good in doing this work.
But the problem that i don't know how to solve is that the I changes its values also during the space and my for cycle takes into account only the time and not the space.
Regarding N, P, C i want first to make the code going, then i'll go through their equations, so for now you see just some values of them without any formulas.

댓글을 달려면 로그인하십시오.


Torsten
Torsten 2023년 11월 19일
이동: Torsten 2023년 11월 19일
My suggestion:
z = linspace(0,Z,nz+1); t = linspace(0,T,nt+1);
I0 = @(t) 100*max(sin ((t-0.4*3600)/(6.28)) , sin (0));
w(:,1) = ... % w at time t = 0
for j = 1:nt
I_in = I0(t(j))*exp(-k*z.').*exp(-rs)*cumtrapz(z.',w(:,j));
g = mu0*I_in./(H_l+I_in);
integral_term = f1 * f2 * f3 * trapz(z.',g.*w(:,j));
w(2:nz,j+1) = w(2:nz,j) + dt*...
w(1,j+1) = w(2,j+1);
w(nz+1,j+1) = w(nz,j+1);
end
  댓글 수: 27
Torsten
Torsten 2024년 1월 25일
Have you got some advises?
No. The sink term is correctly implemented into the equation for w.
Alfonso
Alfonso 2024년 1월 25일
Can you try to change the mue parameter? On the plot i see always the same curve :C

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Rubik's Cube에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by