Skip to content

Commit

Permalink
add more outputs for the mpc code
Browse files Browse the repository at this point in the history
  • Loading branch information
Huang committed Nov 20, 2019
1 parent 91199d5 commit 0c1a22d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions PNNLCodes/CoSim/func_EDC_CoSim_test.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [Optimal_Temp_Ctrl, Opt_m_z, Opt_Prh] = func_EDC_CoSim_test(ST, DT, c_e, c_ng, T_out, Q_int, T_ini)
function [Optimal_Temp_Ctrl, Opt_m_z, Opt_Prh, Opt_J] = func_EDC_CoSim_test(ST, DT, c_e, c_ng, T_out, Q_int, T_ini)

% ST = 5; % sampling time: 1, 5, 60 min
sample_time = strcat(num2str(ST), 'min');
Expand Down Expand Up @@ -180,7 +180,7 @@ expression J(N_schd)
Pf_i(n_f) = cfan_0 + cfan_1*sum(m_z_power(5*n_f-4:5*n_f,i)) + cfan_2*power(sum(m_z_power(5*n_f-4:5*n_f,i)),2);
end
if n_f == 4
Pf_i(n_f) = cfan_0 + cfan_1*m_z_power(16,i);% + cfan_2*power(m_z_power(16,i),2);
Pf_i(n_f) = cfan_0 + cfan_1*m_z_power(16,i); % + cfan_2*power(m_z_power(16,i),2);
end
end
Pf_total(i) = sum(Pf_i);
Expand Down Expand Up @@ -235,6 +235,7 @@ expression J(N_schd)
% OptSchedule = [];
Opt_m_z = m_z(:,1);
Opt_Prh = Prh(:,1);
Opt_J = J(1);

% OptStates = [];
% OptStates.T_z = T_z;
Expand All @@ -243,4 +244,4 @@ expression J(N_schd)
% SolverStatus.Status = cvx_status;
% SolverStatus.OptVal = cvx_optval;

Optimal_Temp_Ctrl = T_z(:,2);
Optimal_Temp_Ctrl = T_z(:,1);
4 changes: 3 additions & 1 deletion PNNLCodes/CoSim/mpc_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ def write_port_file(port,host):
set=[]
m=[]
rh=[]
tset,m,rh= eng.func_EDC_CoSim_test(control_horizon_length/60.,samp_time/60.,ele_m,gas_m,tout_m,qin_m,tini_m, nargout=3)
cost=[]
tset,m,rh,cost = eng.func_EDC_CoSim_test(control_horizon_length/60.,samp_time/60.,ele_m,gas_m,tout_m,qin_m,tini_m, nargout=4)
print cost
for tt in range(len(m)-1):
f1.writelines(str(m[tt][0])+',')
f1.writelines(str(m[-1][0])+'\n')
Expand Down

0 comments on commit 0c1a22d

Please sign in to comment.