Error using pde.Transi​entThermal​Results (line 56) Solution does not correspond to time-dependent PDE.

I have a transient thermal script that produces this error
Error using pde.TransientThermalResults (line 56)
Solution does not correspond to time-dependent PDE.
Error in pde.ThermalModel/solve (line 119)
R = pde.TransientThermalResults(self,u,tlist);
Error in thermalmodel4 (line 328)
result = solve(thermalModelT,tlist);
I believe it may be a problem with my q func?
qFunc = @(region,state) (loadcurrentcurve(state.time)/Vcell).*...
((OCVcurve(SoCcurve(state.time))-Vcurve(SoCcurve(state.time)))+...
((state.u).*dScurve(SoCcurve(state.time))/F));
internalHeatSource(thermalModelT,qFunc);
My q function also uses the curve fitting toolbox

 Accepted Answer

How are you including Vcell and F in the function qFunc? Are you passing them in a nested function? Perhaps you need to refresh yourself on how to pass extra parameters. I assume that you defined your other functions such as SoCcurve and OCVcurve correctly.
Alan Weiss
MATLAB mathematical toolbox documentation

11 Comments

Hi Alan,
Thank you for your reply, I appreciate the help.
Vcell and F are both constants defined earlier in the code.
SoCcurve and OCVcurve are cfits created earleir in the code with the curvefitting Toolbox
I think I had my code was arranged wrong in the qfit function, so I've re wrote it like this
qFunc = @(region,state) (region.y).*...
(loadcurrentcurve(state.time)/Vcell).*...
((state.u).*dScurve(SoCcurve(state.time))./F+...
Vcurve(SoCcurve(state.time))-OCVcurve(SoCcurve(state.time)));
I now get the error
Error using pde.TransientThermalResults (line 86)
The number of input solution times is not consistent with the results.
Error in pde.ThermalModel/solve (line 119)
R = pde.TransientThermalResults(self,u,tlist);
Error in thermalmodel4 (line 332)
result = solve(thermalModelT,tlist);
Thank you in advance I presume it's still a Problem with my qfunc, as when I Change this and set q to somethign simple like
qFunc = @(region,state) (region.y).*20
the script works no Problem, hmm....
Sorry, I cannot see enough of your code to understand what is going on. I suggest that you use the debugger and see what is going on internally to solvepde. I suggest that you write qFunc as a function file and put a break point in it so that you can examine the variables that it processes.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
Morning Alan,
This really helped thank you! Putting qfunc in its own file and then pausing it showed that the function could not pull my curvefits (they are defined in the main script)
So I managed to put my curvefits also in their own function files and it works. The problem now is for every step of my PDE solver the qfunc is applying my curvefit functions from fresh meaning my script is super super slow, as it is reading excel files every step and curve fitting with the curve fitting tool box.
So now my task is to speed it all up... the problem is the qfunc seems to have to be a 2 input and 1 output function, else the thermal solver throws and error, therefore i cannot also input my curve (therefore only fitting the curves once, rather than refitting the same curve at every step)...
Hope some of this makes sense!
Ben, let me suggest again that you learn how to pass extra parameters. There should be no reason to re-fit a curve if the results from a previous fit are applicable. Look at the first link I gave, or here.
Alan Weiss
MATLAB mathematical toolbox documentation
Hi Alan, Thank you for the suggeestion. The problem is the qfunc cannot pass extra parameters or it throws an error later on with the PDE solver stating
Function handle specifying a heat source must accept two
input arguments and return one output argument.
i believe this is because it detects the curve input as an extra input, therefore passing an error, I've tried getting around this by savign my curve and loading it in, but also to no success, and i believe would be slow even if i succeed.
Do you know a way to load more than two input arguments (state, region and the inputs required for the curvefit) without an error in the solver?
Thank you
Ben
for example, a section my qfunc
function q = qfunc(region,state)
Di = 18 *(10^-3); % m, cell diameter
R = Di/2; % m, cell radius
He = 65.00 *(10^-3); % m, cell height
Vcell = He * pi*(R)^2; % m^3, simple volume of cell
F = 96486; %C.mol^-1, Faraday constant
n = 1; % electrons transfered for this chemistry
nF = n.*F;
%%Current and Voltage
currentfunc = @loadcurrentcurve;
voltagefunc = @loadvoltcurve;
current = currentfunc(state.time);
voltage = voltagefunc(state.time);
%%SoC
SoCfunc = @loadSoCcurve;
SoC = SoCfunc(state.time);
if SoC > 100
SoC = 100;
elseif SoC < 0
SoC = 0;
end
%%OCV
OCVfunc = @OCVcurve;
OCV = OCVfunc(SoC);
%%dS
dSfunc = load('dScurvefit.mat');
dS = dSfunc(OCV);
%%Temperature & Y
T = state.u;
y = region.y;
%%q, final equation
q = y.*...
(current./Vcell).*...
((T.*dS./nF)+...
voltage-OCV);
fprintf('cfor time %s completed y point %s',state.time,region.y);
fprintf('\n')
end
and my "loadcurrentcurve" function
function I = loadcurrentcurve(time)
%%-- DEFINE FILE --
% define the file with the load data
%the load data must have curent in the cell, cell voltage, cell SoC
%(0-100%), and time in seconds, this is the data that will be simulated in
%the advanced model
loadfilename = 'load.xlsx'; % title of OCV data file in same folder
loadsheet = 1; % OCV data file sheet number with data on
loadMaxrow = 2000; % last row with data on, in OCV file
loadMinrow = 2; % first row with data on, in OCV file
loadIcol = 'A'; % colum with current, in amps
loadtimecol = 'D'; % colum with time
%%-- DEFINE RANGES --
loadMaxrow = num2str(loadMaxrow); % convert row value to string
loadMinrow = num2str(loadMinrow); % convert row value to string
loadIrange = ([loadIcol,loadMinrow,':',loadIcol,loadMaxrow]); % load current data range
loadtrange = ([loadtimecol,loadMinrow,':',loadtimecol,loadMaxrow]);% load current data range
%%-- READ FILE --
Iload = xlsread(loadfilename,loadsheet,loadIrange); % read load current from file and assign to variable load current
tlist = xlsread(loadfilename,loadsheet,loadtrange); % read load time from file and assign to variable tlist
%%-- CREATE FIT --
Fitfunc = @createFit;
CurrentFit = Fitfunc(tlist, Iload); % fit curve to data time/current data
%%-- FINAL VALUE --
I = CurrentFit(time);
as you can see, this is incredibly slow, and actually the line
"dSfunc = load('dScurvefit.mat'); dS = dSfunc(OCV);"
doesn't work, but this is a different problem. I tried this as the dS curve fit was a particular slow function as it needs to be derived every time.
Hoping you can help, I'm pulling my hair out!
As I have said and restated, learn how to pass extra parameters.
For example,
qFunc = @(region,state)extendedqfunc(region,state,dscurvefit)
% Calculate what you like for q
% using the data in dscurvefit.
% dscurvefit needs to exist before you create qFunc.
% The function has only two arguments.
Alan Weiss
MATLAB mathematical toolbox documentation
Hi Alan, Thank you! I took a look at the link earlier and didn't immediately realize it allowed you to pass parameters without them being arguments. Thank you for your patience and help.
I'm glad that you figured it out. Many people have trouble understanding how to pass extra parameters, which is why I wrote that section in the Optimization Toolbox™ documentation, even though it sort of duplicates the MATLAB version. It's a subtle thing. I tried to explain it as clearly as I could, but I understand that it can take several readings for the information to sink in.
I'm also glad that I guessed right away that was the issue, and so was able to direct you correctly.
Do you think that there should be a section on passing extra parameters in the PDE Toolbox™ documentation, too? Or maybe just a pointer or two to where the info exists?
Alan Weiss
MATLAB mathematical toolbox documentation
Hi Alan, I'm glad too, now onto my next problem!
Thank you again for your help.
Maybe a section on how to pass extra parameters into the PDE toolbox would be a good idea, especially because the toolbox stops you passing them as arguments and specifically have to be passed as parameters. Maybe a page on the error code or something just saying a link to how to pass parameters with a specific example. (Like the one you typed above)
Thank you
Ben
Hi Alan,
Hoping you can point me in the right direction with the next step of my code.
Thank you again
Ben

Sign in to comment.

More Answers (1)

Hi Ben, I suggest checking carefully which times qFunc is using vs. the times you provide to the solve function as the tlist argument. Your definition of qFunc does not directly depend on time, as in, for example,
qFunc = @(region,state)state.time*...
My suspicion is, and I can be mistaken here, that qFunc either does not depend on time at all or there is a mismatch between the times used for qFunc and solution times you pass to solve as the tlist argument.
Regards,
Svetlana Pease
Technical Writer, MathWorks Documentation Group

1 Comment

"mismatch between the times used for qFunc and solution times you pass to solve as the tlist argument."
i suspect this is the reason too, especially with the error
Error using pde.TransientThermalResults (line 86)
The number of input solution times is not consistent with the results.
Error in pde.ThermalModel/solve (line 119)
R = pde.TransientThermalResults(self,u,tlist);
Error in thermalmodel4 (line 332)
result = solve(thermalModelT,tlist);
I just need to figure out why...
No the qfunc doesn't directly depend on time, but the SoC and V both do, therefore require time as an Input. And then qfunc directly depends on these.
I don't see why they wouldn't have the same times, I'll use the debug process Alan suggested and spend some more time on this today

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!