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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Solve Block Error

KAL_1625
9-Granite

Solve Block Error

Hey Community!! I am using Mathcad in my work place and one of the problem requires extremely complicated solve blocks. The Solve block that I am working has near to 20 equations and 20 unknowns, it used to shoot errors that the units are not compatible, which I diagnosed after some work, but now the solve block works but the never end up getting solution. When I calculate the problem for a single point in an other Mathcad sheet it works very fast and nice. But when it is combined with equations in a solve block, it never finds a solution instead shoots error ("Solution not found, change guess value or tolerances"). I did try changing the guess values, nothing works and tolerance is set to 10^-1, the maximum that it could be set for. What should I do in such case? I used the guess values from my single point solution.
I cannot upload the entire mathcad file because of company's privacy matters but I can attach screen shots.

Thanks in Advance.

AM_9812862_0-1634235878850.png

AM_9812862_1-1634235913172.pngAM_9812862_2-1634236017212.png

AM_9812862_3-1634236055471.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

Cannot help with the lack of convergence without seeing the parametrized solve block!

I have no interest in commercializing or passing on your solve block, but I would like to help.  Hover the mouse over a name in the top right corner of a reply and you can send a private message with the full file.

 

It is possible to clean up the programming.

a) With a column vector it is only necessary to use one index into the rows not a dual index. Instead of "i,0" use just "i".  Instead of "j,0" use just "j"

b) The final output needs to be outside the two loops not within them

 

So for example

terryhendicott_0-1634596274232.png

Cheers

Terry

 

View solution in original post

11 REPLIES 11
LucMeekes
23-Emerald III
(To:KAL_1625)

Without seeing the worksheet, it is going to be hard to diagnose your problem. Here are some remarks that may, or may not, help:

 

Two of the parameters in the list that you are trying to solve appear (from their font usage) to be units: R.einlet and f. Is that correct and intentional?

 

There's an empty placeholder on the last line of your definition for Psac(). You may want to remove it.

Is this Psac nested loop part of the solve block? Depending on the sizes of the two arrays called in there, it may be an explanation for long calculation...

Instead of:  For   i   ElementOf   0 .. length(<array>)

it's generally better to use:  For   i    ElementOf   ORIGIN .. last(<array>).

That will work for any setting of your array index origin

 

Success!
Luc

Hello @LucMeekes . thanks for the quick and elaborate reply. Those are unit less variables. I don't know why mathcad is considering it as the units. I took the empty space holder and still does not work. Also I did not understand what did you mean by origin.

Hi,

 

"Also I did not understand what did you mean by origin."

 

By default the indices into a matrix or vector start with zero.  You can change this with the ORIGIN worksheet variable.  By default it is set to zero.

If you want the indices to start at one you need to change the ORIGIN value.

Capture.JPG

You use the variable ORIGIN at the start of iteration to make the sheet work no matter what ORIGIN is set too.

Cheers

Terry

 

Is it possible that you will be able to insert only the problematic part of the program into a new Prime worksheet?

Hi @VladimirN thanks for the reply, it wont be possible to transfer the problem part alone. The problem part is dependent on upstream solve block, I cannot disclose solve block as its the backbone of the model and is property of the company. 

Hi,

 

It will be hard to examine the problem without seeing the solve block.

When faced with a solve block that is not converging I adopt the following strategy.

1) Put the tolerance back to default.

2) Use a set of guess values that are causing the problem.  

3) Use a set of guess values that you know work. And temporarily set the answers to values above the equations in 4 so you get results.

4) Outside the solve block examine the LHS and RHS separately of the eighteen equations of the solve block with the values from 2) and 3)

This is easily achieved by simply cutting and pasting from inside the solve block to outside

By doing this you will find which equation is giving problems.  If this fails try 5)

5) It may also help to graph the eighteen LHS and RHS to see what the equations are doing over the range of possible values.

 

Perhaps you can get one of the helpers here to sign a non-disclosure document and then you can share the solve block.

 

Cheers

Terry

 

Hi @terryhendicott , thanks for the reply. I did try your strategy of working out equations of solve block. The function works with the single value perfectly but does not work for the matrices. Please look into the screenshots that I am attaching, one with the matrix and other same function with the single value.

AM_9812862_0-1634581439981.png

AM_9812862_2-1634581511742.png

The matrix function takes hours of solving and then shoots the error that you see. But works fine if I load values in function. Is there anything that you would suggest to do in case of matrix?

"Try changing guess value, TOL or CTOL" is only a suggestion that sometimes help, an idea what you can check if you see this message. This message does not imply that changing TOL, CTOL or guess value will help in any case when you see this message.

It is possible that solution does not exist at all, or cannot be found using algorithms that solve block is trying based on the given input.

raised an interesting point and I would suggest to check labels. Keep in mind that if you have same name decorated with different labels - they are treated as different identifiers.

You can also try to use minerr instead of find, but be sure to substitute the solution to original equation(s) and see how close you got to true equality.

If it does not help you can try to use symbolic evaluation to find solution. To solve more than one equation group the equations in a vector.

Hi @MSheykman , thanks for the reply and adding the same comment as in previous comment. The function works with the single value perfectly but does not work for the matrices. Please look into the screenshots that I am attaching, one with the matrix and other same function with the single value.

AM_9812862_3-1634583196827.png

 

AM_9812862_4-1634583196908.png

 

The matrix function takes hours of solving and then shoots the error that you see. But works fine if I load values in function. Is there anything that you would suggest to do in case of matrix?

Your screenshot it hardly readable and you don't show the definition of the function you are calling. So there is not much which can be said.

Just a shot in the dark: You may try to vectorize that function call and see if it helps.

Werner_E_0-1634587665532.png

 

Hi,

Cannot help with the lack of convergence without seeing the parametrized solve block!

I have no interest in commercializing or passing on your solve block, but I would like to help.  Hover the mouse over a name in the top right corner of a reply and you can send a private message with the full file.

 

It is possible to clean up the programming.

a) With a column vector it is only necessary to use one index into the rows not a dual index. Instead of "i,0" use just "i".  Instead of "j,0" use just "j"

b) The final output needs to be outside the two loops not within them

 

So for example

terryhendicott_0-1634596274232.png

Cheers

Terry

 

Top Tags