state space matrix magnitude changes sampling rate

6 views (last 30 days)
Here's the code, commented through. You don't need to know the physics to help me with this problem (although if you see a mistake I made, please let me know!). Basically, there are two problems: specifying the sample time in the ss call gives me answers I don't understand, and the matrix magnitude affects the sampling rate.
close all
clear
format long
Aoverdx = (0.005145/(2.5*10^-5));
k = 429; %thermal conductivity of silver
kg = 0.1349; % 0.1349 kg silver
specificheatcapacity = 235; %235 J/kg K
mc = kg*specificheatcapacity;
% The equation for current temperature difference is:
% T[t+1] =T_initial + 0*T[t] + Q/mc, where T_initial is x0(1)
% This goes in the first line of the transition matrix A.
% The equation for total heat flow is:
% Q[t+1] = 1*Q[t] + (-kA/dx)*T
% This goes in the second line of the transition matrix A.
A = [0 1/mc;-k*Aoverdx 0];
% A= A/1000;
% ^test what happens when you uncomment this line and line 26
B=[0;0];D=[0]; %not testing for inputs right now
C = [1 0]; %observing T, the temperature difference.
% Try switching to C = [0 1] to see how the change in heat flux
% synchronizes with the temperature changes, displaying undamped
% energy exchange
sys1 = ss(A,B,C,D); %setting sample times gives really weird errors
t = 0:0.001:.12;
% t=t*1000;
u = zeros(size(t)); %no inputs
startingTempDiff = 20; %T_initial ,temp difference = 20 K
x0=[startingTempDiff 0];
[y,t]=lsim(sys1,u,t,x0);
lsim(sys1,u,t,x0)
TimeToMin = t(find(y==min(y))) % notice how this time changes when
% you uncomment lines 17 and 26
% Also notice how if you JUST uncomment line 26, an undersampling
% error appears, but if you reduce the matrix magnitude in line 17,
% that error goes away. Why does magnitude affect sampling rate?
Ultimately, I really need the simulation to show the same TimeToMin no matter what the time vector spacing is; this is a physical process that should take a certain amount of time no matter how quickly you sample it.
Thanks for the help!
Context, if you're interested:
I'm trying to develop a controller for heat flow across a silver medium with a uniform thickness. To do that, I plan to simulate with a state space model that incorporates the physical laws, convert to transfer function, specify rise time and steady state error, and then use root locus optimization to determine the parameters I need for my controller.

Accepted Answer

Jon
Jon on 12 May 2022
Edited: Jon on 12 May 2022
I think that you are just getting a little confused about the time scaling.
In the nominal case you can see that the system reaches a minimum at t = 0.060 seconds.
In the second case (uncommenting lines 17 and 26) you divide A by 1000, since now dx/dt = A/1000*x +Bu, this makes all of your derivatives dx/dt much smaller and so this system evolves more slowly. You then counteract that by looking (sampling) at 1/1000 the sampling rate, and find that the system reaches a minimum at 60 "seconds". Your mistake is considering this second result as being in seconds, it is infact in milliseconds. (since you divided the A by 1000, and mulitplied the t by 1000).
So you actually have the same result in the second case. It reaches a minimum at t = 60 ms which is equal to 0.060 s.
For the third case, just multiplying the time by 1000, you will definitely have a problem as the time scales of the problem are such that it changes a lot in milliseconds, and you are now sampling it at intervals of 1 second.
So in general lsim doesn't know anything about what time units you are using, they could be ms, s, months, centuries, but the system matrices, A,B which define the rate of change of the state, and the time vector have to use consistent set of time units.
Usually it is best to just consider the time as being in seconds and scale your A and B matrices accordingly and then generate your time vector in seconds with a small enough increment to resolve the fastest dynamics in your plant.
  6 Comments
Ethan Leonard
Ethan Leonard on 13 May 2022
Exactly the point; this is an incomplete picture. The process variable is actually the temperature of the fluid on the other side of the silver sheet(currently at 20 C). The manipulated variable is the surface area of the sheet, which should be just large enough to absorb heat to specification. However, the simulation so far only looks at the transfer of heat across the silver sheet.
In full, the process would be:
1) Fluid undergoing endothermic reaction absorbs heat from the silver sheet (this is convection I think, , where q is the heat flux, h is the convection heat transfer coefficient, Tw is the temperature at the wall of the sheet, and Tf is the temperature of the fluid). This is not yet part of the simulation.
Heat direction: Solid boundaryFluid
It's possible I should have simulated this step first, but since I have some reason to believe that the reaction can easily bring the silver sheet to 0C, I chose to start from the second step, considering the cold fluid to be an infinite heat sink. I'm also a little less sharp on the thermochemistry, and wanted to make sure I got the control system structure right first.
2) Heat conducts across the silver sheet.
Heat direction: Solid boundary Solid boundary
The goal is to bring the time taken to 0 temperature difference to within specification. This is what I was aiming at in the code I wrote. So for now, I guess we can say the temperature difference across the sheet () is the process variable.
3) Silver sheet absorbs heat from the 20C fluid.
Heat direction: FluidSolid boundary
This is not yet part of the simulation.
Since increasing surface area A increases heat flux proportionally in the second step (using the equation , in the code written above), that's a manipulated variable that should be optimizable.
Tangential note:
In the first step (convection to the silver sheet), increasing A will also increase the quantity of reactants, which will also increase the total energy absorbed. Since I'm not clear yet on whether or not that is a linear function of A, and since I'm also not as clear on heat transfer from a solid boundary to a fluid, I didn't start there.
It is also possible to add heat directly at the final stage, which would be part of the controller. Ultimately, the temperature in the 20C fluid is the process variable of the whole system.It's maximum performance could be adjusted by adjusting the medium through which the endothermic reaction acts (the surface area of the silver). The controller can be adjusted in real time by adding reactants, and adding heat directly.
I hope that wasn't too much detail! I appreciate your hanging on to help me out with this.
Jon
Jon on 16 May 2022
I think you most likely just need to do a steady state (no time transient) analysis of your situation. Silver has a very high thermal conductivity, and you have only a thin sheet of silver. This means that it is likely that the temperature gradient within the silver sheet is negligible. The system will be dominated by the relatively low conduction rates through the two convective heat transfer coefficients on the surfaces of the sheet, and the relatively long time scales of the masses of fluid on either side of the sheet (unless these volumes are very small compared to the silver sheet.
You can quantify this further by looking at the Biot number for the silver sheet. This is the ratio of the thermal resistance of the sheet to the thermal resistance of the convective film. Bi = L*h/k where L is the thickness of the sheet, h is the convective heat transfer coefficient and k is the thermal conductivity of the silver sheet. When this is small, e.g. <0.1 the gradient through the sheet is neglible. The sheet temperature will just assume some intermediate value between the 20deg c fluid and the endothermic fluid, which is dictated by the h values on each side of the sheet.
Further you can ignore transient effects (in the silver sheet) if the time scales are long compared to the characteristic time for heat to diffuse through the sheet. The characteristic diffusion time for a thickness L and thermal diffusivity alpha is given by tc = L^2/alpha. So unless you're time scales of your system are very short compared to this the sheet will already have assumed a uniform throughout the thickness steady state gradient.

Sign in to comment.

More Answers (0)

Categories

Find more on Heat and Mass Transfer in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!