Lets say I have ice of mass $m_i$ and initial temperature $T_i$ and specific heat $s_i$ . And I have water of mass $m_w$ and initial temperature $T_w$ and specific heat $s_w$ . I have put both this water and ice in a copper container with mass $m_{cu}$ , specific heat $s_{cu}$ and initial temperature $T_w$ . What will be the final temperature $T$ of the system ? ( The Latent heat of freezing of water is $L_f$ )
Here ,
$$Q_1 = m_is_i(T-T_i) + m_iL_f$$
$$Q_2 = m_ws_w(T-T_w) + m_wL_f + m_{cu}s_{cu}(T-T_w)$$
According to Calorimetry , $$Q_1 = Q_2$$ $$m_is_i(T-T_i) + m_iL_f = Q_2 = m_ws_w(T-T_w) + m_wL_f + m_{cu}s_{cu}(T-T_w)$$
I can use this equation to calculate $T$ , But then I ran into a problem. In this case , I don't know which is happening , the freezing of water , or the melting of ice , so i can't just put both $m_wL_f$ and $m_iL_f$ in the equation and call it done. I might have to remove one of them depending on which thing is not happening (freezing or melting) .To make matters worse , The water or ice may just freeze or melt partially. Is there another equation that can solve for the final temperature while also taking all of this into account?