Saving an extra variable from PDEPE

2 views (last 30 days)
Hi, I am solving a heat problem using the PDEPE. Everything is working, however I want to save some extra variables from the main function of the PDEPE that I solve. How can I do this? Adding it to the function handle does not work for me. I want to save the value for Q.
removing the ; indicates that the value is being calculated, but I cannot save it.
function [c,f,s,Q] = heatpde(x_d,t_d,u,dudx,C)
k_d = C.k_d;
STE = C.STE;
w = C.w;
W = C.W;
Cp_d = C.Cp_d;
theta_f = u(1);
y_LS = u(2);
eps = 1e-15;
eps2 = 1e-8;
dtheta_fdx =dudx(1);
d_y_LS_dx = (1/y_LS)*(dudx(2))+eps2;
q_eff = -k_d*w*dtheta_fdx;
c = [Cp_d/k_d;y_LS;1];
f =[dudx(1);0;0];
s = [-1/(k_d*(w))*(theta_f/y_LS+(STE*theta_f*(theta_f+2*dtheta_fdx/d_y_LS_dx*y_LS))/(6*y_LS) ;...
(theta_f/y_LS+STE*theta_f*(theta_f+2*dtheta_fdx/d_y_LS_dx*y_LS)/(6*y_LS); ...
-STE^2*theta_f*(40*(dtheta_fdx/d_y_LS_dx)^2*(y_LS)^2+85*theta_f*dtheta_fdx/d_y_LS_dx*y_LS+19*theta_f^2)/(360*y_LS))];
Q = (theta_f/y_LS+STE*theta_f*(theta_f+2*dtheta_fdx/d_y_LS_dx*y_LS))/(6*y_LS);

Accepted Answer

Torsten
Torsten on 23 Jan 2024
After the computation with "pdepe" is completed, call "pdeval" to get the spatial derivatives of your solution on the x-mesh and then call "heatpde" in a loop for all spatial points and times that you like to get Q returned.

More Answers (0)

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!