Hello PTC community, thanks for taking your time to check this post out. I dont know if mathcad can do this but im pretty sure it can for what Ive seen. I want to make the sum of multiplying a component of a vector with a component of a matrice in an especific column, then with the next component of the vector with the second row in the same column and so on. Details are attached in the document. Thanks for all!
PS. If you are familiarized with chemical engineering, the problem I want to solve is a multicomponent destilation tower with the rigorous method ( I think its the Amundson-Pointnen method)
Solved! Go to Solution.
A few points...
If you're going to index from 1 to n, then you need to set ORIGIN = 1, otherwise the Mathcad default of 0 for indexing will mean that i:=1..3, K[i:=something will result in a 4 element vector with K[0 = 0.
The second is that you have defined Z by Z[i,j:=[matrix]. This will create a 3x5 array each element of which contains your [matrix]. (I'm guessing) you just need to write Z:=[matrix].
Stuart
Message was edited by: Stuart Bruff Corrected stupid error on my part ...
Hey Stuart, thanks for taking your time to check out my document. You expanded my vision on how could I have solved the problem. I hope you have a great day!
Hello Werner, im almost done with the problem but i want to do the last operation and calculate the L matrix. The results should be
L1=100
L2=100
L3=200
L4=200
L5=50
The general form of the eq is
Lj=(Vj+1)+(SUM(m=1 until 5) Fm-Um-Wm)-V1
I want to keep using the vector notation as you told me and not the Lj
The sum is a constant 50, V1 is zero! So all you do is adding 50 to your vector V which has 6 elements and then you just want the last five elements of that result?? This would yield (200; 200; 200; 200; 50). Where do the two 100's in your suggested solution come from?
Furthermore i is not defined!?
I hope you can help me again, thanks a lot
Alexander Alvarez wrote:
I hope you can help me again, thanks a lot
As long as you can explain what you are trying to do and how you would get the results you mentioned!?
Maybe this helps
I tried to be as especific and clear as possible. This is what im trying to do, sorry for bothering, I hope you guys can help me.
I think the question about how to calculate L was already answered in my last replay and I showed two ways of doing it.
The result is not what you expected but you didn't answer the question why you think that (200; 200; 200; 200; 50) is the result and how you would calculate to get that result.
The formula given in your file is a bit different from the one you gave in your question above (the upper sum index is variable in the formula of your fle), so I think you have to clear things up for yourself first.
Anyway, the attached sheet may help as it shows much easiers ways to calculate your matrix K.
Hello Werner, I really appreciate what you are doing for me here. The original post I made was for 5 stages, since I have to do another work in school, I wanted to leave the worksheet for a more general situation. In this case for 17 stages. I will insert the worksheet with my comments with I want to do with solver. Now I understand how to calculate L. Sorry if im getting to annoy you but its not what I want to do, the thing is its the first I use mathcad.
Greetings from Mexico
I am confused because what you ask in your file (easier creation of Matrix K) is exactly what I showed giving different methods in the file I attaches in my last reply. Only difference is that you defined T as a row vector as opposed to the column vector I used. So you may either use T transposed or use the column selector instead of the vector index.
The attached shee should help.
It does not seem to make much sense to solve for T5 AND T15 because the result will always be the same for both. After all the columns of matrix K are dependent on the appropriate value in T only. Not sure what you try to achieve with that.
I just checked your worksheet with detail, I was wondering if its possible not to transpose T to get the matrix K. That because i want to mantain rows as components and columns as stages during all my worksheet. If theres not any other way what you gave me works perfectly! im really grateful.
Alexander Alvarez wrote:
I just checked your worksheet with detail, I was wondering if its possible not to transpose T to get the matrix K. That because i want to mantain rows as components and columns as stages during all my worksheet. If theres not any other way what you gave me works perfectly! im really grateful.
I don't understand what the problem is.
Have you looked at the last sheet I posted?
I have use T as you had it provided, as a row matrix. And it stays a row matrix, its just transposed during the calculation of K. The T in the program which is assigned the transposed result is a local variable - the worksheet variable T is not affected by that.
Here is what I did, if I did the way you said, by transposing T, what you said before would work just fine. What happens if attack the problem the following way
Heres how it looks with all the recommendations, im having trouble with simplicity while building the following matrix. I hope you can check it out. Where I can learn to use mathcad as good as you?
Alexander Alvarez wrote:
Heres how it looks with all the recommendations, im having trouble with simplicity while building the following matrix. I hope you can check it out.
It seems to me that all you need is to calculate M^(-1)*D^T and then transpose them result to get your 5x17 matrix which you obviously want to call x.
Where I can learn to use mathcad as good as you?
Not where, how! By doing! By doing it yourself and when you get stuck, look aup the help, the quicksheets, etc. And if this seems not to help, the ask here. Flip through the various threads of questions by other users here, look up the attached files and learn from them and the answers given.
I learned most of what I know about Mathcad by trial and error and listening to the threads of the old Mathcad collab which is now (badly) integrated in this forum here.
You can only learn if you do it yourself - hands on appraoch.
Im almost done with this, I got stucked again with the solver thing, I really didnt understand how you did it. If theres any suggestions on how to simplify my worksheet , theyre welcome.
Sorry - the solve block won't work with ranges.
Furthermore the variabe you want to solve for does not exist in the equation in the solve block! This can't work.
You seem to like to make calculation with variables which get their real value just after that calculation - thats quite confusing.
Ad simplification: I already have shown how to get those vectors D2 etc in a much simpler and shorter way.
Concerning your ABC matrices which on first sight seem to be very similary built, I guess you could write a small programm to generate them all using just a few arguments. Haven't looked too close but you may give it a try.
I didnt really understand how you did that to solve those eqs. But dont worry, you have helped me a lot, im really grateful. I hope I can help you someday
This is the only thing im stucked with, can you explain again this part? I try to do it again but im doing it wrong because I really didnt understand how to do it. Thank you
So lets do it step by step.
At first I define a function which I named equ (thinking of "equation") with two arguments i and t.
Is it clear to you what the result of this function is when I call it with, say, equ(3,123) and what the calculation the function makes has to do with your calculations?
Or do you have questions concerning the solve block?
first, why TT? then in Get_T(TT,i) the arguments are not (i,t) or (i,TT) . Thanks
You haven't answered my question. Is it clear to you in which manner equ(3,123) relates to the calculations you do in your sheet?
Ad TT or any other name. Thats math knowledge and you have a similar terminology in programming, too. When you define a function like f(x):=5*x, x is called the formal argument. It can be any name as long as you use the same in the argment list on the left and the expression on the right. It does not matter if x is already defined (now we are in Mathcad again) or not. When you come to use that function, when you want to show a function result or assign it to another variable, you feed an actual argument in the function, like y:=f(3) and y gets the value 15. You can also use variables as argument, like a:=2 b:=f(a) and b gets the value 10 that way. Of course I could also have use the name x instead of a. It doesn't matter in any way that I had chosen the name x for the formal argument, too.
So I could have used T instead of TT, but I wanted to make clear that the name does not matter and has nothing to do with any T defined elsewhere. For the same reason I use t and not T in equ(). That way you see more clearly which vars belongs to what.
BTW, while it doesn't matter it would have been better if I had used the same argument order in equ() and get_T().
equ(3,123) that means i=3 and t=123 in the function, thanks for the explanation Werner, theres one thing in the end of the sheet, its quick but i dont know how to approach the solution, wonder if you have 2mins. I feel ashamed to ask you this many questions really.
Is it clear to you in which manner equ(3,123) relates to the calculations you do in your sheet?
Alexander Alvarez wrote:
equ(3,123) that means i=3 and t=123 in the function,
I guess that a NO as answer to my question 😞
As for the error at the end of your sheet: You had chosen to set ORIGIN to 1 at the top of your sheet. So an index zero as you have used twice is invalid. First columns and first rows are numbered with 1.
but even if it was ORIGIN=0, then whats the value of Q(1,j)=L(1,j-1).... when j=0, L(1,-1)?. So what was the answer to your question haha
If you set ORIGIN to 0 I guess the rest of yout sheet will fail.
It seems to me that you do not really understand what calculations you do in your sheet but you simply try to retype formulas which may stem from different sources and don't match. I don't know why all in a sudden you would like to use index 0 when throughout the whole rest of your sheet you had set it up with ORIGIN=1.
What do you mean my L(1,-1)? wher does this come from??
There is no index 0 it you have ORIGIN a t1 and ther is no index -1 if you set ORIGIN to 0. ORIGIN is the number of the very first element in a matrix and so the can't be a smaller index.
I know that my sheet would fail if i change ORIGIN=0, the question is , how can I solve that last expression if I know that L(1,j-1) and HL(1,j-1) are 0 when j=1