Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Apr 18, 2020
08:48 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 18, 2020
08:48 PM

Solving system of non-linear equations

Hello All,

I am struggling to find the proper code for solving a system of non linear equations, using Mathcad 15.

The equation are given in the screenshot below. The problem is related to thermodynamics.

I followed a template with Find, however it just don't get me anywhere.

What needs to be done to get the results ? Can someone explain the issue (for the layman).

Thanks for the support,

keep safe,

System of equations

Result sough PA (Pas in code) and PS (Ps in code).

Once PA and PS are available; related parameters "aS", "aA" (aA and aS in code) and x calculations are straightforward.

Code (Mathcad file attached)

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

Apr 19, 2020
07:03 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 19, 2020
07:03 AM

Here is my attempt for a solution.

Basically the problem was wrong syntax for the solve block and that you wrote your function definitions as if they were equations.

But using your values and equations the solve block could not find a solution. Either use much lower guess values or change other values (as written in the file) or maybe have a second look at your functions to see if there is something wrong with them.

15 REPLIES 15

Apr 18, 2020
10:00 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 18, 2020
10:00 PM

Hi,

File enclosed you will need to check the equations and values as it does not solve properly.

You only need two equations for two unknowns. You need a "Given" statement to start the solve block.

Cheers

Terry

Apr 18, 2020
11:12 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 18, 2020
11:12 PM

Many thanks Terry for the quick reply.

Take care

Pierre

Apr 19, 2020
07:03 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 19, 2020
07:03 AM

Here is my attempt for a solution.

Basically the problem was wrong syntax for the solve block and that you wrote your function definitions as if they were equations.

But using your values and equations the solve block could not find a solution. Either use much lower guess values or change other values (as written in the file) or maybe have a second look at your functions to see if there is something wrong with them.

Apr 19, 2020
10:37 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 19, 2020
10:37 AM

Thank you. That's really great. I was worried by the 0 values from the previous post.

Thank you.

Pierre

Apr 25, 2020
06:22 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 25, 2020
06:22 PM

Thanks again for the help.

This time, I am looking to nest the resolution into a loop as one of the aim of the exercise is to to plot one input value to an output (mole fraction in gas vs. mole fraction in solid).

How it's done exactly ? I can't see how find is used with programming code.

Pierre

Mathcad 15 programming

Apr 25, 2020
09:16 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 25, 2020
09:16 PM

You can't use a solve block in a program.

But you can turn the solve block into a function of the values you would like to change and use that function in your program.

Simply close the solve block with f(..,..,..) := Find (Pas,Psb) and use function f in your program.

Apr 25, 2020
10:34 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 25, 2020
10:34 PM

Thank you. I will look into it.

Apr 29, 2020
11:10 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 29, 2020
11:10 PM

I got a function that seemed working at first glance, but actually all the output values are the same (column 3 and 4), what's wrong. What's wrong ?

Thanks for the help,

Pierre

Two different inputs with same output.

A looping attempt. Notice identical values in column 3 and 4.

Mathcad 15

Apr 30, 2020
06:10 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 30, 2020
06:10 AM

The formal argument of your function f (PzSb) is never used in the calculation/solve block. So do you think it would influence the result?

If you define

x:=5

a:=2

b:=3+x

f(x):=a+b

you should not be surprised that f returns the same value (10) regardless of the actual argument passed because the calculation of b uses x=5 all the time.

Apart from setting up the problem in a different way you can solve this by making b a function of x:

[no need for defining x:=5]

a:=2

b(x):=3+x

f(x):=a+b(x)

A similar approach has to be taken in your sheet. So far it uses PzSB=0.4 for every call of f.

The solution is to turn every calculation which uses PzSb into a function of PzSb.

Apr 30, 2020
06:22 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 30, 2020
06:22 AM

I gave it a try but unfortunately the solve block will not find a solution for values of PzSb smaller than 0.12

You may wrap a second function around f which returns NaNs in case of the solve block failing. That way you could use the function in your program with the loop and see, for which values it fails.

Apr 30, 2020
10:55 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 30, 2020
10:55 PM

Thank you. I understand my oversight.

I made a considerable progress in my project thanks to you input.

And I see I am close to the end.

Pierre

Apr 30, 2020
11:09 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 30, 2020
11:09 PM

Good news the project seems to be completed.

Thank you Werner terryhendicott for your valuable inputs.

Pierre

Apr 30, 2020
11:54 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Apr 30, 2020
11:54 PM

Jun 18, 2020
11:20 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 18, 2020
11:20 PM

Hello, I made good progress in my project and I have a publication under evaluation. I would like to thank you for your help in the acknowledgement section. What name should I put on ?

Pierre

Jun 18, 2020
11:22 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 18, 2020
11:22 PM

Also, I couldn't find a template citation to reference Mathcad in the paper. Do you have any suggestion by any chance ?

Thanks

Pierre