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

Community email notifications are disrupted. While we are working to resolve, please check on your favorite boards regularly to keep up with your conversations and new topics.

Error with Solve Block

Muffin83
1-Newbie

Error with Solve Block

Hello I am currently trying to use a solve block for an iterative solution. I have punched in all the equations and go to find but it claims a variable is undefined. I am not totally sure why this is happening.

It has been a bit of time since I have use a solve block so most likely something simple.

I am trying to solve for a table of values so this could be part of the problem.

The other issue I may be having is that I am also looking for a result in a table.

Attached is the mathcad and the text file that mathcad is reading from to generate the 1000 random values for X as seen at the beginning. I am hoping that the comments in the file are helpful but please contact me if you have any further questions.
16 REPLIES 16
RichardJ
19-Tanzanite
(To:Muffin83)

More than one problem. First, Most of the variables in the solve block are undefined, including all the ones on the LHS of the equations. All variables must have defined values, even if it's only the guess value for the variable you are solving for. Second, you have 6 equations and 1 unknown. If you are trying to find an exact solution you should have the same number of equations and unknowns.

Richard

Thanks for the suggestion, I have done some more work and noticed some errors, like you had said most of the functions on the LHS were not clearly defined. I have gone through and corrected that now. I still seem to have a problem though.

The reason I have so many equations for only one unknown is because I need all those values to feed into the * equation.

So I need to make an initial guess for

row which I do just about the given block. Then once it goes through it should use that row value to calculate the other equations. The ultimate goal is to find Pcow and then plug it into equation 6 to see if the initial guess was good.

I need to do this 1000 times as I have 1000 different tubes specified.

I hope the attached file without units for now looks a little clearer. I am not sure maybe using a given and find block is not the best way to do this.

Thanks again for any help.

The objective is to get the project done. The *XMCD audience is limited to that version as Mathcad does not read up version. You will reach a much greater audience and help by "Save as" 11 or lower unless you get a quick reply in your original *.XMCD . Every collab contribution is voluntary and from tie they distract from other activities, if you see the point .

Your description does not lead immediately to a flow chart and a corresponding model. Simply: not clear from lecture.

jmG


I appreciate all the help. I found out I had an error in one of my equations attached is a new sheet in Mathcad V 11 format.

On Page 5 at the right is an explanation of my logic. Above that is the actual solve block itself.

I am getting an error in the solve block about a variable being undefined. Not sure if that is my only problem but is my most obvious one right now.


Thanks again for all the help on this project.

>I appreciate all the help. I found out I had an error in one of my equations attached is a new sheet in Mathcad V 11 format...<<br> _______________________________

Two things:

1. version 11.2a does not like your version
Academic ? or else ?

2. This is home work, we can help in steps but not do your project. Within last week or so, a very similar project to part [1] of your project was re-done from 5 pages down to few lines and there were additional tutoring in the thread. Please browse for all threads in this last week and download all work sheets . That will help you getting the right feeling how to setup clean work sheets and particularly your part [1]. You should then come back with part [1] almost done. From there, it will continue to the part [2].

In reference to point (1) above: your saved version is very critical to the verge of crashing Mathcad 11.2a (it does insist to crash !). Such critical situation don't normally happen in regular 13, 14 because they allow normal copy/paste. If you don't find the sheet mentioned within last week or so, come back for the link, but please spend the hour or two to browse for.

jmG
RichardJ
19-Tanzanite
(To:ptc-1368288)

On 2/16/2009 1:44:30 AM, jmG wrote:

>1. version 11.2a does not like
>your version
>Academic ? or else ?

Works fine for me.

Richard

On 2/16/2009 8:38:41 AM, rijackson wrote:
>On 2/16/2009 1:44:30 AM, jmG wrote:
>
>>1. version 11.2a does not like
>>your version
>>Academic ? or else ?
>
>Works fine for me.
>
>Richard
________________________________

Yes Richard because your system when you open in 11.2a conserves some "transparent compatibility". Other cases were reported and that's how I can only explain to myself because my 11.2a is virgin of any traces of 13, 14.

This project is not yet is gear but interesting.


jmG

You have a number of issues, and a misunderstanding of solve blocks.

1) There is no reason to remove units. While the ODE solvers do not handle units, the find/minerr solve block does handle units. You should use them.

2) The = (bold 😃 is not and assignment and in no way defines a variable. In a solve block it is a constraint, to be met (if possible) by varying the variables. It does not eliminate the requirement for all variables to be previously defined. All variables whose values are not known must have guess values assigned and be included among the values to be found.

3) You cannot use range variables in a solve block to create multiple constraints. You can have vector and matrix constraints, but any iteration must be within some structure, usually a program structure.

4) Where you need auxiliary functions (beyond the actual constraints) they should be defined prior to the solve block using the ordinary assignment (:=) operator.

5) Where your calculations are essentially of a scalar nature and you use a vector merely as a way to store a list of values, it is better to set up the solve block as a scalar function, using the value to be varied as a parameter of the function. Find looks for interactions between all the the variables (and each element of an unknown array is a separate variable) and internally uses an nxn matrix (where n is the number of variables). That can get very large, and time consuming.
__________________
� � � � Tom Gutman
RichardJ
19-Tanzanite
(To:Muffin83)

A solve block with Find must have the same number of equations and unknowns. It does not do what you seem to think it does, which is sequentially substitute one expression into another. Take the assignments out of the solve block and make them all functions of row. At the end you should have one equation that is a function of row. Equate that to something (it's not completely clear to me what you are trying to equate to what; you calculate Row and "check if it's correct". What's it supposed to be equal to? R?), and solve for row.

Richard

The work sheet lacks project description, at least an abstract, the book statements ... etc. Are you sure the angles correspond to the figure ? What is Rmax, Rmin ? What is R ? where does it comes from ? what is x ? Why is it so noisy ? x looks pure noise ... it is not but some smart cat spent time shuffling. If there is noise on both the X,Y Cartesian , in other words: if both Cartesian have been shuffled, the first task is to pass a straight line through and recalculate x free of that garbage. At this point, start considering only few points, per say 10 to proof the project in a more meaningful manner.

If you can't read an image from a download, here is what you have passed !



jmG

>Hello I am currently trying to use a solve block for an iterative solution <<br> ___________________________

1. You must plot all results to conclude
"End of Part #1 of homework assignment"

2. Before declaring the solver, you must
___isolate each term in the solver and make them work
___ in this case by vectorizing

3. Look at the useless subscripts that I removed
that keeps a work sheet clean.

Your turn ! but reply in that work sheet for more help. I will ignore your original as it can't be followed. Please add the project abstract. A good presentation is worth some points even if the results are incorrect, because effort is worth points.

Make sure you return "Save as 11" !!!

You MUST describe what you expect the solver doing. Many collabs are generalist rather than specialist and any project must be self explained .

jmG

Wow I really appreciate all the responses and ideas. I will report a more detailed message in a few hours when I get a break from classes. I will try to be more detailed on the background of the project and what I am trying to. I am sorry if I have created any unnecessary confusion during this and also want to say thank you.

Russ

Lookinag at all the messages perhaps the solve block is not going to be able to do what I would like it to do.

I will try to explain the project further. The class is called EOR (Enhanced Oil Recovery). Also for the record I did one class with Mathcad a year ago so definitely a little rusty so I don't doubt I am doing some things wrong.

For part one of this homework we were asked to design 1000 capillary tubes. Basically 1000 cylinders with an assigned geometry. My geometry was a scalene triangle with angles 40,60,80 and with a length of 30 micron.

For the assignment we were suppose to generate a list of 1000 random x values and then use it is in the first equation calculate the inscribed radius for the triangle. From that we were asked to calculate the perimeter, cross sectional area and volume of the triangle.

This was all for part one of the homework and I have put in big bold letters end of part 1 of homework mostly so I could recall where section 2 started.

After that our teacher has asked us to calculate the capillary pressure or Pcow for each of the 1000 tubes.

His flow diagram was to guess an initial Row value which is the radius of the oil water interface. The Row guess value is needed to calculate Aw, Lws, Low or equations 1,2,3. I then need to take the results from 1,2,3 and calculate equation 4,5,6 this will give me Ao,Los,Low. With these values I can calculate Pcow or equation *. Equation ** is used to confirm that my initial guess of row was accurate.

I have done the manual iteration below by limiting table values and then manually guessing it. The provided method or flow chart by our teach does work. I just am hoping that someone in mathcad I can get it to do that with 1000 values.

An accurate initial guess for row is equal to the inscribed radius calculated at the top.

So basically my initial guess for all values of row := R where R = inscribed radius calculated in section one of the sheet.


I do realize that in my solve block I have 8 equations and have only provided one initial guess and that is where my problem is. But all the equations are needed and my initial guess for the other variables will vary based on which row I am guessing.

I hope this helps some more. Attached is a mathcad 11 file with units in it.

jmG I really appreciate your help in actually rearranging some thing in my mathcad file and will most likely make some of these changes. For now I know that manual iteration works so I am hoping to stay with it for the time being.

If you have any more questions please feel free to ask.

I am realizing that maybe a solve block is not the way to do this problem if that is the case is there a better way to do this?

Your problem is that you have not so much a problem to be solved with a solve block but a method of solution.

The general problem a solve block solves is f(x)=0, where both x and f(x) might be vectors. One method for solving such problems numerically is to isolate one instance of x so as to restate the problem as x=g(x). With some conditions on g on can use this iteratively to take some assumed value for x and calculate a new and better value for x, repeating until the values of x are close enough. While this does work (again, with suitable conditions on g) it is generally a slow way of calculating. It is emphatically not the way find solves the system.

You can choose to implement the solution method given to you (maybe you are required to do that). If so, you do not use a solve block. Rather you define the function g, possibly in stages using auxiliary function (as you seem to have it defined). Then you have a small program that loops (usually a while loop) recalculating x until you get close enough. If g vectorizes (or is vectorizable) you may be able to run a single loop using all of your thousand values at one time. That also assumes that you will get roughly similar convergence for all the values. Otherwise you set it up as a scalar function, and just call it for all of your values (either an explicit loop or vectorization).

You can also set it up as a solve block. But for that you would usually go back to the underlying equations that control the phenomenon, without recasting them in the x=g(x) form. With only a single variable to be found you should have only one constraining equation. Again, that can be built up out of smaller pieces, defined as functions (not equations in the solve block). YOu can take your existing equations and just make function definitions out of all but one of them. While the solve block will not solve the system the way you would manually, it will solve an equation of the form x=g(x) (equivalent to x-g(x)=0).
__________________
� � � � Tom Gutman

Think in term of iterating the solver and work on both work sheets you have. Make an abstract and put the problem statement in the work sheet, Isn't true that 'R' is the answer and that the all exercise is to prove the formula ? and made worst by randomizing the 0..1 'x', that you will have to sort again later on. If you read all the replies, you should be able to progress.

The problem is not "Error in solve block"
Rather, the thread is "Capillary" or "Iterate solver".
Simply confusing


jmG


Well I finally got it to work. You guys were all right about not going with a solve block.

It appears that I needed to write it as a program using a while loop. I luckily have a professor at my university who has published a book about Mathcad. So after explaining my situation he helped me to write the while loop in the attached mathcad file.


Apparently there will be a new section added to the homework for next week so who knows what that will bring.

I sincerely appreciate all the help you guys were able to offer and your patience with my limited experience.

I am wondering if you guys could recommend a book about mathcad, what would you recommend?

Thanks again.
Top Tags