-
Notifications
You must be signed in to change notification settings - Fork 1
/
cts_time_spm_simulation.m
60 lines (47 loc) · 1.8 KB
/
cts_time_spm_simulation.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
% Copyright (c) 2018 Gopalakrishnan, Krishnakumar <[email protected]>
% Author: Gopalakrishnan, Krishnakumar <[email protected]>
clear;clc; format short g; format compact; close all;
%% Load user data, pre-process and run simulation loop
run('user_inputs_for_sim.m');
run('pre_process_script.m');
run('cts_spm_core_sim'); % spm simulation loop is in this script
%% Save results to disk
save_foldername = ['spm_results/', cellIdentifier, '/', load_profile_name];
if exist(save_foldername,'dir')==0
mkdir(save_foldername);
end
% Replace decimal point chars in soc% string with 'p' (stands for point)
soc_init_pct_savestr = strrep(num2str(soc_init_pct),'.','p');
% clear A_disc B_disc; % potentially useful varibles. comment out for debugging
clear soc_init_pct C_rate_profile I_1C k num_iterations; % redundant info
clear x_spm_init x_spm_local_finish t_local_finish t_local_start;
save([save_foldername, '/cts_sim_', ...
datestr(now, 'mmm_dd_yyyy_HH_MM_SS')]); % save workspace to file
%% Plot results
close all;
figure(1);
h1 = subplot(211);
plot(spm_sim_time_vector,load_current_vector,'-');
ylabel('Current');
ylim([min(load_current_vector)-5 max(load_current_vector)+5]);
h2 = subplot(212);
plot(spm_sim_time_vector,v_cell_sim_results_spm,'m');
ylim([spm_params.CutoffVoltage spm_params.CutoverVoltage]);
ylabel('Cell Voltage [V]');
linkaxes([h1 h2],'x');
xlim([spm_sim_time_vector(1) spm_sim_time_vector(end)]);
xlabel('Time [sec]');
figure(2);
h1 = subplot(211);
plot(spm_sim_time_vector,load_current_vector,'-');
ylabel('Current');
ylim([min(load_current_vector)-5 max(load_current_vector)+5]);
h2 = subplot(212);
plot(spm_sim_time_vector,soc_pct_results_spm,'r');
ylabel('SOC [%]');
linkaxes([h1 h2],'x');
xlim([spm_sim_time_vector(1) spm_sim_time_vector(end)]);
xlabel('Time [sec]');
clear h1 h2;
figure(1);
shg;