i want to minimize function fcc , When fcc calculated for a specified point The answer is correct:
In[70]:= fcc[0.5, 0.5, 0.004, 0.006, 0.0025, 0.5] Out[70]= 2.96667*10^6
but when i want to optimize fcc with NMinimize there is a problem below:
NMinimize[{fcc[q1, q2, q3, q4, q5, q6], 0.5 <= q1 <= 1.5, 0.5 <= q2 <= 1.5, 0.003 <= q3 <= 0.01, 0.003 <= q4 <= 0.01, 0.002 <= q5 <= 0.005, 0.5 <= q6 <= 1}, {q1, q2, q3, q4, q5, q6}]
NDSolve::ndsv: Cannot find starting value for the variable ws. >>
ReplaceAll::reps: {NDSolve[{-((0.00011318 (q2+q3) (-0.0174073+ws[<<1>>]))/(q3 q4 q6))+(ws^[Prime])[x]==0,ws[q1]==0.012529},{ws},{x,0,q1}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>
ReplaceAll::reps: {NDSolve[{-((0.00011318 (q2+q3) (-0.0174073+ws[<<1>>]))/(q3 q4 q6))+(ws^[Prime])[x]==0,ws[q1]==0.012529},{ws},{x,0,q1}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>
ReplaceAll::reps: {NDSolve[{-((0.00011318 (q2+q3) (-0.0174073+ws[<<1>>]))/(q3 q4 q6))+(ws^[Prime])[x]==0,ws[q1]==0.012529},{ws},{x,0,q1}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>
General::stop: Further output of ReplaceAll::reps will be suppressed during this calculation. >>
NDSolve::ndsv: Cannot find starting value for the variable ts. >>
NMinimize::nnum: The function value 2.18625*10^6+6618.38 (-0.012529+ws[0]) is not a number at {q1,q2,q3,q4,q5,q6} = {1.4748,1.12029,0.0074076,0.00951558,0.00291973,0.810076}. >>
and this is fcc function:
ta = 30; rha = 0.4; altitude = 1361; p = 101325*(1 - altitude2.2557710^-5)^5.2559; tka = 273.15 + ta; c1 = -5.800220610^3; c2 = 1.3914993; c3 =
-4.864023910^-2; c4 = 4.176476810^-5; c5 = -1.445209310^-8; c6 = 6.5459673; psata = Exp[c1/tka + c2 + c3tka + c4tka^2 + c5tka^3 + c6Log[tka]]; pva = rhapsata; wa = 0.621945pva/(p - pva); tr = 26; rsh = 1500; nu = 7.54; lef = 0.894; tsin = ta;
tpin = ta; twin = 20; wsin = wa; wpin = wa; tkw = 273.17 + twin; psatw = Exp[c1/tkw + c2 + c3tkw + c4tkw^2 + c5tkw^3 + c6Log[tkw]]; pvw = psatw; wsat = 0.621945pvw/(p - pvw); cps = 1006; cpp = 1006; cpv = 1873; cpw = 4183; ks =
0.027; kp = 0.027; kwater = 0.6; kwall = 237; hfg = 2501000; lwall =
0.0005; lwater = 0.001; fcc[lx_, ly_, lp_, mp_, mw_, ratio_] := Module[{}, ms = ratiomp; ls = lp; dhs = 2lyls/(ly + ls); dhp = 2lylp/(ly + lp); hs = nuks/dhs; hp = nukp/dhp; hm = hs/(lefcps); u = 1/(1/hp + lwall/kwall + lwater/kwater); dels = -1; delp = -1; wss = NDSolve[{(dels hm ly (ws[x] - wsat))/ms + Derivative[1][ws][x] == 0, ws[lx] == wsin}, {ws}, {x, 0, lx}]; tstptw = NDSolve[{(dels ly (ts[x] - tw[x]) (hs + cpv hm (-Evaluate[{ws[x]} /. wss] + wsat)))/(ms (cps + cpv Evaluate[{ws[x]} /. wss])) + Derivative[1][ts][x] == 0, (delp ly (tp[x] - tw[x]) u)/(mp (cpp + cpv wpin)) + Derivative[1][tp][x] == 0, 1/(cpw mw) ly (delp (-tp[x] + tw[x]) u + dels (hs (-ts[x] + tw[x]) - hm (hfg + cpv tw[x] - cpw tw[x]) (Evaluate[{ws[x]} /. wss] - wsat))) + Derivative[1][tw][x] == 0, ts[lx] == tsin, tp[lx] == tpin, tw[0] == twin}, {ts, tp, tw}, {x, 0, lx}]; (Plot[Evaluate[{{ts[x],tp[x],tw[x]}/.tstptw}],{x,0,lx}]) tpout = Evaluate[tp[0] /. tstptw]; tpout = tpout[[1]]; tsout = Evaluate[ts[0] /. tstptw]; tsout = tsout[[1]]; wsout = Evaluate[ws[0] /. wss]; wsout = wsout[[1]]; cp = 1006; If[(tr - tpout) < 0.5, mt = 20, mt = rsh/(cp(tr - tpout))]; np = Round[mt/mp]; ca = 100; at = lx*((np + 1)(ly + 4lp) + ly); n = 0.6; cinv = caat^n; kel = 120; kw = 1.5; [Tau] = 3000; [Eta] = 0.5; ro1 = 1.17; v1 = ms/(ro1lsly); miu1 = 10^-5; re1 = ro1v1dhs/miu1; [Alpha]1 = ls/ly; f1 = 24(1 - 1.355*[Alpha]1 + 1.9467*[Alpha]1^2 - 1.7012*[Alpha]1^3 + 0.9564*[Alpha]1^4 - 0.2537*[Alpha]1^5)/ re1; dps = 2f1ro1*(v1^2)lx/dhs; smd = 1.17; mst = msnp/smd; cos = kel*[Tau]((dpsmst)/([Eta]10^6)); ro2 = 1.17; v2 = ms/(ro2lply); miu2 = 10^-5; re2 = ro2v2dhp/miu2; [Alpha]2 = lp/ly; f2 = 24(1 - 1.355*[Alpha]2 + 1.9467*[Alpha]2^2 - 1.7012*[Alpha]2^3 + 0.9564*[Alpha]2^4 - 0.2537*[Alpha]2^5)/ re2; dpp = 2f2ro2*(v2^2)lx/dhp; pmd = 1.17; mpt = mpnp/pmd; cop = kel*[Tau]((dppmpt)/([Eta]10^6)); h = 2; g = 9.81; copump = kel[Tau]hgmwnp/[Eta]; ew = msnp(wsout - wsin); cow = kw*[Tau]3.6ew; r = 0.1; y = 10; a = r/(1 - (1 + r)^(-y)); a*cinv + cos + cop + copump + cow];