Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

how to optimize 2 functions for a set point output value using fsolve?

1 view (last 30 days)
% basically, I have set values for the outputs of two functions named 'AC_LPCA', and 'DIC1' below. I want the
%corresponding inputs 'm_W1' and 'm_w2' which give me these set point values simultaneously
% also the other inputs to these functions depend on the outputs to the two functions 'IC1', and 'IC2'
% basically, 'm_W1' is an input to 'IC1', and 'IC2', and 'm_W2' is an input to 'DIC1',
% 'm_w1 +m_W2' is an input to 'AC'
% I want that value of 'm_w1+m_W2' which gives me my set value for T_out_AC, and that value of 'm_w2' which gives me my set value of 'T_out_DIC1'
function T_diff = try_nested(z)
m_w1 = z(1);
m_W2 = z(2);
T_sp_AC = input('temp. set point of water leaving AC');
T_sp_DIC1 = input('temp. set point of water leaving DIC1');
[T_3, T_w_out_IC1,PD_w_IC1, PD_a_IC1,Q_IC1,IC1_a_resist,IC1_w_resist] =...
@(m_w1) IC1_23_08(T_2+C2K, T_w_out_OC+C2K, P_2, m_a,P_w_in_IC1, m_w1);% HERE ALL INPUTS WILL BE KNOWN EXCEPT FOR %m_W1
P_w_in_IC2 = P_w_in_IC1 - PD_w_IC1;
[T_5, T_w_out_IC2,PD_w_IC2,PD_a_IC2,Q_IC2] =@(m_w1) IC2(T_3+C2K, T_w_out_IC1+C2K, P_2,...
m_a,P_w_in_IC2,m_w1);% all inputs here are outputs from the previous function "IC1"
%DIC1
[Q_w,Q_a, T_t_outlet, T_out_DIC1, PD_w, PD_a] =@(m_w2) DIC1(m_w2,5.02,273+35, 273+94,377163,666754)
T_out_DIC1 = T_out_DIC1 - 273;
%%State 7 - after cooler
% m_w_DIC1 = input('mass flow rate of water out of DIC1 in kg/sec');
% T_w_out_DIC1 = input('temp. of water leaving DIC1 in C');
T_w_in_AC = T_out_DIC*(m_w2/(m_w1+m_w2)) + T_w_out_IC2*(m_w1/(m_w1+m_w2));
m_w_AC = m_w2 + m_w1;
[T_7, T_w_out_AC,PD_w_AC, PD_a_AC,Q_AC] = @(m_w1,m_w2) AC_LPCA(T_6+C2K,...
T_w_in_AC+C2K, P_6, m_a,P_w_out_IC2, m_w_AC
T_diff(1) = @(m_w1) T_sp_AC - T_w_out_AC;
T_diff(2) = @(m_w_AC) T_sp_DIC1 - T_out_DIC1;
end
%%I am calling the above function in a new script below
guess = [3.5 1.5];
z = fsolve(@(z)try_nested(z,guess));
z(1);
z(2);
  1 Comment
Ramnarayan Krishnamurthy
Ramnarayan Krishnamurthy on 4 Oct 2017
Would you be able to simplify your problem down and state the specific issue you are facing?
Also, high levels problem description may be helpful as well!

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!