I'm trying to solve fairly simple equations element by element in an array and from what I've read here it looks like a For loop calling a solve function is the way to go. I know I can't have a Given/Find in a For loop and have to write the function elsewhere and call it from the loop, but I'm having trouble getting that to work I found a lot of discussion on here about this, but none that I have been able to implement. I have attached both the file I'm working on and a simple example of what I'm trying to do that I think will be easier/faster to work on, then I can modify the actual file.
I've been tasked with converting some calculations from Excel to Mathcad 15, and I'm new to Mathcad so learning as I go.
Thanks much in advance for your help.
You have to turn the solve block into a function dependent on the variables you would like to change in your loop. In case of your simplified version these are the indices i and j:
I haven't looked at you other file. Hope you can get it to work. If not, come back an ask again.
Now I was curious and had a look at your other file.
There is more work to do here.
Your solve block obviously should be dependent on three variables, D.pipe, ID.pipe and T.operating.
So ALL functions/variables which take part in the terms used in the solve block must be functions dependent on those three variables (only the variables which are actually used, beginning with
and ending with the solve block
R is flagged red because I had not changed the whole worksheet and I also have not checked if both h.cond_surf and h.cond really are dependent on all three variables.
The solve block is then called that way:
You don't need a solve block for the first--just matrix math
The second (insulation) I've adjusted--you need to make functions of all the variables you want to change. (I couldn't figure out where temperature change came in.)
Guess you missed a function or two.
E.g. h.cond depends on h.lag , h.lag depends on R.out and R.out depends on the variable D.pipe.
h.cond_surf is dependent on the variable T.operating
I was too lazy to look further 😉
In the attached, a try for your request.
Two observations. There are an orfan equation, in yellow. Also, your test range is extense, and the solver fails because the guesses. For that, you must to implement some recursion for the guess values, and the final result could be look more than a finite element technique.
I guess here is what you were trying to do.
Using the guess value TH.i=4,59 in, the solve block fails for the first five diameters at 200 °F.
Fortunately changing the guess to 2 in makes the whole table work OK:
If we weren't able to find a guess which satisfies all combination of input values, we could have made the guess an additional argument of the function R and would have to find a way to precalculate a suitable guess depending on the three input values.