Message Boards Message Boards

0
|
6411 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to output conditional expression to a real number

Posted 8 years ago

Module[ { A = 40 acre, h = 30 ft, por = 0.3, Swi = 0.38, Boi = 1.2, pini = 6000 psi, pbubble = 930 psi, rf = 0.23, cr = 310^-6 1/psi, cw = 210^-6 1/psi, co = 5*10^-5 1/psi, porvoli, watvoli, OOIP, Np, porvol2, watvol2, Bo2, fmatbal2, soldp2 }, (calculations) porvoli = Ahpor; watvoli = porvoli Swi; OOIP = porvoli (1 - Swi)/Boi; Np = OOIP rf; (functions of depletion)porvol2[dp_] = porvoli Exp[-cr dp]; watvol2[dp_] = watvoli Exp[+cw dp]; Bo2[dp_] = Boi Exp[+co dp]; (material balance equation) fmatbal2[Np, dp] = (OOIP - Np) == (porvol2[dp] - watvol2[dp])/Bo2[dp]; soldp2 = dp /. Solve[fmatbal2[Np, dp], dp] // First // Simplify; Grid[{{"Final pressure calculated by using exponential approximation \ is", (pini - soldp2)/psi, "psi"}}, Frame -> All] // nf ] I am a new user of Mathematica for only two weeks. When I am trying to use the exponential approximation and solve function to calculate dp, it outputs:

ConditionalExpression[0.000145(9.2597*10^6 - (0. + \(4.332*10^10) I) C[1]), C[1] \[Element] Integers]

I have searched conditionalexpression in documentations and online, I tried to use "normal" and set the conditionalexpression to real, but it doesn't work at all. The program is supposed to solve for dp and output just a number. It works for my linear approximation code, but not for the exponential. How to do that for this case?

POSTED BY: Tianhang Zhou
2 Replies
Posted 8 years ago

You can also choose one of the solutions by replacing the constant with a value:

In[9]:= c = 
  ConditionalExpression[
   0.000145 (9.2597*10^6 - (0. + (4.332*10^10) I) C[1]), 
   C[1] \[Element] Integers];

In[10]:= c /. C[1] -> 0 // Chop

Out[10]= 1342.66
POSTED BY: David Keith

You are solving a trascendental equation. The ConditionalExpressions that you are seeing are families of complex solutions, which are parameterized by C[1], which takes integer values.

If you are interested in the real solutions you can try with Solve[fmatbal2[Np, dp], dp,Reals]

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract