cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Solving "layered" equations for a single variable

JTopete
1-Visitor

Solving "layered" equations for a single variable

I'll start off by saying I'm new to MathCAD, and I'm pretty sure this is just a matter of discovering the proper syntax.

I am trying to solve a fluid flow problem where the flow splits through two paths, of different lengths and diameters.

My process goes like this:

  1. define required dimensions, flow characteristics, and fluid properties
  2. calculate simple parameters
  3. guess one parameter (V2)
  4. solve for multiple parameters based on initial guess of V2
  5. satisfy a relationship between pressure drops by iterating on V2

The problem, I think, is that V2 shows up on multiple "levels" in my pressure drop equations.

If Pd2 is a function of V2, and a function of f2

and f2 is a function of R2

and R2 is a function of V2

How do I write this out? Pd2(V2,f2(R2(V2))):= ...

Do I have to spell out the whole chain every time I refer to f2?

Do insead have to replace f2 in my Pd2 equation with an expression that is only in terms of V2?

I attached the file for an easier read. Currently it doesn't tell me there is an error, which bugs me.

Thanks

ACCEPTED SOLUTION

Accepted Solutions
RichardJ
19-Tanzanite
(To:JTopete)

You can create functions with arguments that are function names, but it's not what you want to do. Carry the name of the variable of interest through, not chains of function names.

View solution in original post

9 REPLIES 9
RichardJ
19-Tanzanite
(To:JTopete)

You can create functions with arguments that are function names, but it's not what you want to do. Carry the name of the variable of interest through, not chains of function names.

Werner_E
25-Diamond I
(To:JTopete)

The function you defined are actually all just dependend of the velocity V2.

If you change that accordingly, a solve block will work OK

See attached.

Werner_E
25-Diamond I
(To:Werner_E)

So I was too late 😉

I hadn't even realized that f1 and f2 would be the same function.

RichardJ
19-Tanzanite
(To:Werner_E)

I get to slip one past you ocasionally

Thanks Richard, Werner,

I see that defining everything in terms of V2 solves the problem.

However, I tried to alter my original code, and it doesn't seem to solve.

Is there an issue with conducting the 'given' and 'solve' inside the text box region I have? I made sure they were both in "equation" format when i entered them.

Both of your solutions have the 'given' and 'solve' sections outside the original text box.

A side note, I don't see why f1 and f2 would be the same, since they are solved from different velocities V1 and V2. Regardless, I changed to one equation in the attached file just to match Richard's code example outside my text box, though it comes up with a different answer (zero).

I liked the idea of using one big text box to keep everything straight and in line with each other, but if it keeps me from being able to use some functionality then perhaps I'll deal with the loose equations.

Thanks Again

Werner_E
25-Diamond I
(To:JTopete)

You are right, f1 and f2 are similar, but they differ as they use different Reynolds. You could use different functions f1 and f2 as in my previous post or (I think a bit more elegant) in the attached file.

Otherwise your solve block in the text box works correctly, so you don't have to put it outside.

EDIT: Ooops, wrong again. f1 and f2 also differ in ID1 vs ID2. The attached file has this corrected now

RichardJ
19-Tanzanite
(To:Werner_E)

You are right. They are different. I obviously went throught it too quickly

RichardJ
19-Tanzanite
(To:JTopete)

It solves fine for me.

A side note, I don't see why f1 and f2 would be the same, since they are solved from different velocities V1 and V2.

The V2 used in te function defintion has nothig to do with the variable V2 in the worksheet. It's a formal parameter that shows where the function arguments should be substituted when the function is caled. For example

f(x):=sin(x) + x^2

y:=1.2

Answer:=f(y)

substtutes the value of y into the formula defined by f(x), giving

sin(1.2) +1.2^2

as the answer.

You're right.

It does solve fine.

The exact file I uploaded solves just fine now. I guess I'm going to have to restart MathCAD when I run into some of these issues to see if there is really any problem at all.

Thank you both!

Announcements

Top Tags