forked from scott-moura/SPMeT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimate_spmet.m
77 lines (63 loc) · 2.2 KB
/
animate_spmet.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
%% Animate Single Particle Model w/ Electrolyte & Temperature (SPMeT) Results
% Published November 5, 2016 by Professor Scott Moura
% Energy, Controls, and Applications Lab (eCAL)
% University of California, Berkeley
% http://ecal.berkeley.edu/
close all;
fs = 16;
% vidObj = VideoWriter('img/SPMe_UDDS.avi');
% vidObj.FrameRate = 10;
% vidObj.Quality = 100;
% open(vidObj);
figure(2);
set(gcf,'Position',[461 13 803 693],'PaperPositionMode','auto');
cemaxmax = max(max(c_e));
ceminmin = min(min(c_e));
for k = 1:NT
clf;
% Anode Concentration
subplot(3,3,1)
plot(r_vec,c_n(k,:)/p.c_s_n_max,'LineWidth',2);
ylim([0,1])
ylabel('Solid Conc., \theta^-(t)','FontSize',fs);
xlabel('Radial coordinate, r [node no.]','FontSize',fs)
title('\bf ANODE','fontsize',fs)
set(gca,'FontSize',fs);
set(gca,'Position',[0.1 0.70 0.28 0.27])
% Cathode Concentration
subplot(3,3,3)
plot(r_vec(end:-1:1),c_p(k,:)/p.c_s_p_max,'LineWidth',2);
ylim([0,1])
ylabel('Solid Conc., \theta^+(t)','FontSize',fs);
xlabel('Radial coordinate, r [node no.]','FontSize',fs)
title('\bf CATHODE','fontsize',fs)
set(gca,'FontSize',fs);
set(gca,'Position',[0.67 0.7 0.28 0.27])
XTickLabel = get(gca,'XTickLabel');
set(gca,'XTickLabel',XTickLabel(end:-1:1,:));
% Electrolyte Concentration
subplot(3,3,[4 5 6])
plot(x_vec_spme,c_e(:,k)/1e3,'b-','LineWidth',2)
xlim([x_vec_spme(1), x_vec_spme(end)]);
ylim([ceminmin, cemaxmax]/1e3);
ylabel('Elec. Conc., c_e(x,t) [kmol/m^3]','FontSize',fs);
xlabel('Space across cell, x [node no.]','FontSize',fs)
set(gca,'FontSize',fs);
set(gca,'XTickLabel','');
set(gca,'Position',[0.1 0.37 0.85 0.25])
% Voltage
subplot(3,3,[7 8 9]);
% plot(t(1:k),I(1:k),'g-',t(k),I(k),'go','LineWidth',2);
hold on;
plot(t(1:k),V(1:k),'b-',t(k),V(k),'bo','LineWidth',2,'MarkerSize',10);
xlim([0, t(end)])
ylim([min(V), max(V)]);
ylabel('Voltage [V]','FontSize',fs)
xlabel('Time [sec]','FontSize',fs);
set(gca,'FontSize',fs);
set(gca,'Position',[0.1 0.08 0.85 0.24])
% F = getframe(gcf);
% writeVideo(vidObj,F);
pause(0.05);
end
% close(vidObj);