state space matrix magnitude changes sampling rate
조회 수: 5 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
Jon
2022년 5월 12일
편집: Jon
2022년 5월 12일
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
Jon
2022년 5월 16일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Heat and Mass Transfer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!