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

Iterating mathcad 15

smungar
1-Newbie

Iterating mathcad 15

Hi everybody,

I am trying to make an iterative calculation in Mathcad 15, but I seem to fail. I am trying to calculate rock stability in water by calculating the shear stresses caused by currents and waves. The bed roughness (kr) is a function of the D50 that I am calculating. see the photo. Can anybody tell me what I am doing wrong? If you need more info just ask. Thanks in advance.

iterate.PNG

Kind regards

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:smungar)

I don't see a reason why you should use vectorization in the calculation of D.50 or tau.p.c. Obvously no vectors are involved.

What you have written is a system of seven equations in seven variables which Mathcad should be able to solve, but only if ...

1) ... you provide guess values for all seven variables and solve for all seven variables, not just for D

2) ... there exists a solution at all, which is not the case. Unless of course you change the logarithm in the expression to calculate C from the log to base 10 to the natural logarithm ln. If you do this you get the solution D=55.3 cm. Of course you also get solutions if you leave it at log and change other values. The point is that the equation has no solution with the values and functions you show in your picture.

As Richard pointed out your system can be significantly simplified because you can calculate one variable after the other for any given D. So the better approach is to set up those variables as functions dependent of 😧

k.r(D):=2*D

C(D):=18*ln(12.35 m/k.r(D))*m^0.5*s^-1

etc.

You will end up with a solve block consisting of just one equation in D.50.

BTW, is there any reason for the multiplication with the factor 1 which you do twice and the multiplication with cos(0) (whch is 1, too)?

View solution in original post

5 REPLIES 5
RichardJ
19-Tanzanite
(To:smungar)

You can't use find in that way. Find is used to solve N equations for N unknowns.

I don't see that you are iterating anything. You start with a value of D50. Based on that you can calculate a value for kr (although don't, you just have an equality), based on that you can calculate a value for C, and so on until you get a new value of D50. All you need is a sequence of numerical assignments. Do you then want to then go through the calculation sequence again? If so, what is the stopping criterion? Do you expect D50 to converge to some value (i.e. it stops changing by any significant amount)? If so, then what you need is a program that loops through the calculations until D50 stops changing.

Yes I want to go through the calculation sequence again. However, what I have excluded form the above for simplicity is that kr should have a maximum of 0.5m

Werner_E
25-Diamond I
(To:smungar)

I don't see a reason why you should use vectorization in the calculation of D.50 or tau.p.c. Obvously no vectors are involved.

What you have written is a system of seven equations in seven variables which Mathcad should be able to solve, but only if ...

1) ... you provide guess values for all seven variables and solve for all seven variables, not just for D

2) ... there exists a solution at all, which is not the case. Unless of course you change the logarithm in the expression to calculate C from the log to base 10 to the natural logarithm ln. If you do this you get the solution D=55.3 cm. Of course you also get solutions if you leave it at log and change other values. The point is that the equation has no solution with the values and functions you show in your picture.

As Richard pointed out your system can be significantly simplified because you can calculate one variable after the other for any given D. So the better approach is to set up those variables as functions dependent of 😧

k.r(D):=2*D

C(D):=18*ln(12.35 m/k.r(D))*m^0.5*s^-1

etc.

You will end up with a solve block consisting of just one equation in D.50.

BTW, is there any reason for the multiplication with the factor 1 which you do twice and the multiplication with cos(0) (whch is 1, too)?

Hi Werner,

I first used vectors instead of scalars, hence the vectorizations in the formulas, for simplicity I made scalars of the problem.

Thanks for the help, I made everything a function of kr and then I ended up with a solve box of only one variable.

iter1.PNG

The reason I multiplied with 1 and cos(0) is for simplicity, these values where also variables.

Werner_E
25-Diamond I
(To:smungar)

Glad you found the solution you need but you sure have changed something else, too as the system as shown in your first picture has no solution at all. Given the new 50cm limit you would get 50cm for kr and not the 9cm shown in your new picture. BTW you could write kr=min(2*D50(kr), 50cm) if you like.

I wonder why you had setup D50 to return a vector and use just the first element instead of returning a simple scalar. Usually its a better idea to implement the solve block using scalars, turn it into a function of whatever you want to change and then feed this function an appropriate vector. But it cannot be said if this makes sense without you showing your sheet rather than pictures.

As long as you are happy with the solution its all OK.

BTW, you may turn the solve block into a function dependend on the variables you had set to 1 and 0 for the moment as well.

Announcements

Top Tags