Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

NMinimize a complicated built function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126945] NMinimize a complicated built function
  • From: Meriens <meriens at gmail.com>
  • Date: Tue, 19 Jun 2012 03:15:34 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

Dear all,
I try to find a Minimum of a complex function that I've built previously.
My function is a list of many operations.
I tried with FindMinimum, or NMinimize, but I've got no result.
any suggestions?
I attach my complicated function.
Thank you...



(*--------------Begin Experimental Value & Constant --------------- *)


Vliquidexp = {32.144, 33.174, 34.174};
Vvaporexp = {1200.1, 885.25, 664.20};
p = 0.498;
t = {150, 115, 120};
tc = 150.86;
pc = 4.898;
\[Omega] = -0.00219;
tr = Table[t[[i]]/tc, {i, Length[t]}];
r = 8.314472; (*Volume cm^3; e molar basis*)
\[Psi] = 0.45724;
\[Psi] = 0.45724; (*Subscript[\[CapitalOmega], a] di Peng Robinson*)
\[CapitalOmega] = 0.07780; (*Subscript[\[CapitalOmega], b] di Peng \
Robinson*)
\[Epsilon] = 1 - Sqrt[2];
\[Sigma] = 1 + Sqrt[2];
b = \[CapitalOmega]*r*tc/pc;
\[Beta] = Table[b*p/(r*t[[i]]), {i, Length[t]}];
(*--------------End Experimental Value & Constant --------------- *)
(*------------------Begin My function------------------------------*)

PR1[k1_] := Module[{},
  alfa = Table[(1. + (k1 + 1.54226*\[Omega] -
          0.26993*\[Omega]^2 ) (1 - Sqrt[tr[[i]]]))^2, {i, Length[t]}];
  a = Table[\[Psi]*alfa[[i]]*r^2*(tc^2)/pc, {i, Length[t]}];
  q = Table[a[[i]]/(b*r*t[[i]]), {i, Length[t]}];
  Zl = Table[
    NSolve[zl - \[Beta][[
       i]] - (zl + \[Epsilon]*\[Beta][[i]])*(zl + \[Sigma]*\[Beta][[
           i]])*((1 + \[Beta][[i]] - zl)/(q[[i]]*\[Beta][[i]])), zl,
     Reals], {i, Length[t]}];
  If[Dimensions[Zl] == {3, 3, 1},
   Zliquid = Table[zl /. Zl[[i, 1]], {i, Length[t]}];
   Zvapor = Table[zl /. Zl[[i, 3]], {i, Length[t]}],
   Zliquid = Table[zl /. Zl[[i, 1]], {i, Length[t]}];
   Zvapor = Zliquid];
  il = Table[
    1/(\[Sigma] - \[Epsilon])*
     Log[(Zliquid[[i]] + \[Sigma]*\[Beta][[i]])/(
      Zliquid[[i]] + \[Epsilon]*\[Beta][[i]])], {i, Length[t]}];
  iv = Table[
    1/(\[Sigma] - \[Epsilon])*
     Log[(Zvapor[[i]] + \[Sigma]*\[Beta][[i]])/(
      Zvapor[[i]] + \[Epsilon]*\[Beta][[i]])], {i, Length[t]}];
  fliquid =
   Table[Zliquid[[i]] - 1 - Log[Zliquid[[i]] - \[Beta][[i]]] -
     q[[i]]*il[[i]], {i, Length[t]}];
  fvapor =
   Table[Zvapor[[i]] - 1. - Log[Zvapor[[i]] - \[Beta][[i]]] -
     q[[i]]*iv[[i]], {i, Length[t]}];
  fugliquid = Table[Exp[fliquid[[i]]]*p, {i, Length[t]}];
  fugvapor = Table[Exp[fvapor[[i]]]*p, {i, Length[t]}];
  Vliquid = (Zliquid*r*t)/p;
  Vvapor = (Zvapor*r*t)/p;
  deltaliquid = (Vliquid - Vliquidexp)^2;
  deltavapor = (Vvapor - Vvaporexp)^2;
  delta = deltaliquid + deltavapor;
  Return[Sum[delta[[i]], {i, Length[t]}]];
  ]
(*---------------------End My function--------------------------*)




  • Prev by Date: Re: power of logistic distribution
  • Next by Date: Re: is Head[] part of the expression?
  • Previous by thread: Re: DSolve
  • Next by thread: Clear All Output