Help with Solving PDE System with DAE in MATLAB

6 visualizaciones (últimos 30 días)
William
William el 30 de Jul. de 2025
Editada: Torsten el 31 de Jul. de 2025
I hope you're doing well. My name is William. I’m currently working on a problem and was hoping you might be able to help. I have a system of PDEs, but one of the variables does not include a time derivative (e.g., no ∂u/∂t), even though the variable depends on both time and space. I'm not sure how to approach solving this in MATLAB. I’ve been able to implement it in gPROMS, but translating it into MATLAB has been challenging.
I tried to follow your DAE method, but my variables depend on both time and space—not just time—so I’m unsure how to proceed. If you could offer any guidance or point me in the right direction, I would greatly appreciate it.
Thank you for your time and support.
Best regards,
William
  2 comentarios
Torsten
Torsten el 30 de Jul. de 2025
We need to know your PDE system together with the DAE and the solution method you try to implement. And the MATLAB code so far - if you already started.
Torsten
Torsten el 30 de Jul. de 2025
Editada: Torsten el 30 de Jul. de 2025
Define a mass matrix M for your resulting DAE system.
It then takes the form
M*dy/dt = f(t,y).
Set the rows in M to 0 that correspond to the algebraic variables (velocity) and define the right-hand side as "velocity - value".
For an example, see
Solve Robertson Problem as Semi-Explicit Differential Algebraic Equations (DAEs)
under
I wonder what the algebraic equation for the velocity is and if it's not possible to derive its values directly from the other variables without defining it as an extra solution variable.
Don't you have a pdf file with a mathematical description of your model ? It's laborious to deduce everything just from your coding.

Iniciar sesión para comentar.

Respuestas (1)

Torsten
Torsten el 30 de Jul. de 2025
Editada: Torsten el 30 de Jul. de 2025
You have discretized your equations in space. Thus the y variables are only functions of time for fixed z-coordinates.
Here is an example where y1 and y2 have time derivative:
dy1/dt = z + 2 , y1(z,0) = 0
dy2/dt = z - 4 , y2(z,0) = 0
and the third solution variable y3 is given by an algebraic equation
y3 = z + t.
tspan = 0:0.1:1;
z = (0:0.1:1).';
n = numel(z);
fun = @(t,y) [z+2;z-4;z+t-y(2*n+1:3*n)];
y0 = [zeros(n,1);zeros(n,1);zeros(n,1)];
M = [eye(2*n),zeros(2*n,n);zeros(n,2*n),zeros(n)];
options = odeset('Mass',M);
[T,Y] = ode15s(fun,tspan,y0,options);
figure(1)
plot(T,Y(:,1:n)) % should be y1 = t*(z+2)
figure(2)
plot(T,Y(:,n+1:2*n)) % should be y2 = t*(z-4)
figure(3)
plot(T,Y(:,2*n+1:3*n)) % should be y3 = z + t
  9 comentarios
Torsten
Torsten el 31 de Jul. de 2025
Editada: Torsten el 31 de Jul. de 2025
I used
%/*Boundary Condition*/%
dTdt(1)=(T_ads - T_des)/PressTime;
T(N)=T(N-1);
P(N)=Pfeed;
P(1)=P(2);
y1(1)=y_feed1;
y1(N)=y1(N-1);
y2(1)=y_feed2;
y2(N)=y2(N-1);
for z = 2:N %*BFDM1 Method*%
Px(z)=(P(z)-P(z-1))/(dz);
Tx(z)=(T(z)-T(z-1))/(dz);
y1x(z)=(y1(z)-y1(z-1))/(dz);
y2x(z)=(y2(z)-y2(z-1))/(dz);
end
instead of
for z = 2:(N) %*BFDM1 Method*%
Px(z)=(P(z)-P(z-1))/(dz);
Tx(z)=(T(z)-T(z-1))/(dz);
y1x(z)=(y1(z)-y1(z-1))/(dz);
y2x(z)=(y2(z)-y2(z-1))/(dz);
end
%Px(1)=(-P(1)+P(2))/(dz);
%Tx(1)=(-T(1)+T(2))/(dz);
%y1x(1)=(-y1(1)+y1(2))/(dz);
%y2x(1)=(-y2(1)+y2(2))/(dz);
%/*Boundary Condition*/%
dTdt(1)=(T_ads - T_des)/PressTime;
T(N)=T(N-1);
P(N)=Pfeed;
P(1)=P(2);
y1(1)=y_feed1;
y1(N)=y1(N-1);
y2(1)=y_feed2;
y2(N)=y2(N-1);
and got the gProms result (at least for the graph you included).
I'm really surprised about your setting P(1) = P(2) because without a pressure gradient, there is no flow.
Torsten
Torsten el 31 de Jul. de 2025
Editada: Torsten el 31 de Jul. de 2025
You get values from the integrator in the first and last point when you write the values in local variables:
T=y(1:Nz);
P=y(Nz+1:2*Nz);
T_Wall=y(2*Nz+1:3*Nz);
q1=y(3*Nz+1:4*Nz);
q2=y(1+4*Nz:5*Nz);
yy1=y(1+5*Nz:6*Nz);
yy2=y(1+6*Nz:7*Nz);
These values have to be overwritten by the boundary conditions before computing the gradients because they have no physical meaning.
I don't know how gProms handles this conflict between the values stored in the solution vector y for the unknowns and the values you explicitly define in the boundary points. MATLAB at least is a sequential programming language: things that should be used in line x have to be supplied somewhere before line x.

Iniciar sesión para comentar.

Categorías

Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by