MATLAB Answers

I am calculating membrane water flux using fsolve but MATLAB gave me a negative value of water flux (Jw) as follows. I don't know how to avoid these negative solution from non-linear equation so I would like to know how to solve it correctly

2 views (last 30 days)
Duong Nguyen
Duong Nguyen on 3 Dec 2019
Commented: Matt J on 4 Dec 2019
Here are MATLAB codes I used to calculate
function [Jw,q]=jw_q_solve(Tf,Tp,P,B,Km,d,h)
%Jw, water flux [L.m^-2.h^-1]
%q, heat flux [kg.s-3]
%Tf, feed bulk temperature [K]
%Tp, permeate bulk temperature [K]
%B, permeability coefficient [kg m-2s-1Pa-1]
%Km, membrane heat transfer coefficient [W m-1K-1]
%P, hydraulic pressure [bar]
%d, membrane thickness [m]
%hf, heat transfer coefficient for temperature polarization in the feed [W m-1 K-1]
%hp, heat transfer coefficient for temperature polarization in the draw [W m-1 K-1]
function F=q_flux(x)
%x(1) = q, heat flux [kg.m-2.s-1]
den=1; %[kg.L-1] density of water
Cpw=4200; %[] specific heat capacity of water vapor
z=1/3600; %hr/sec
%Uses enthalpy of vaporization and conductive heat transfer
%guess water flux
%guess heat transfer
%solve for heat transfer
options = optimset('Display','iter');
q_std=fsolve(@q_flux,q_guess,options); % [kg s-3]
%solve for water flux in kg.m-2.s-1
%convert unit to LMH
Jw=Jw1/z/den; %LMH
q=q_std %[kg s-3]


Duong Nguyen
Duong Nguyen on 3 Dec 2019
I solved Jw based on q. Based on the equation of Jw and q, the initial guess for q should be this:
This one shows a very big Jw (which is not correct). If I choose q_guess=0, it shows me negative value. So how do I fix that?

Sign in to comment.

Answers (1)

Matt J
Matt J on 3 Dec 2019
Since you only have single unknown, you should probably use fzero. With fzero you can specify a bounded interval within which to restrict the search.

Sign in to answer this question.