Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
I'd like my programming module to produce a vector with the pipe lengths belonging to various sectors of pipe.
Details, example and my attempt are given in the attached Mcd2001 file.
Obviously I am not too good in programming ...
Thank you very much for any help,
Liv.
Solved! Go to Solution.
I, too, can't see the problem you have.
You demand a function which should calculate vector(s) of pieces of unittubes for varius pipe sections.
Lets clarify input and output of that function.
INPUT: We sure need a minimum of three input values
OUTPUT: what should it be?
Anyway I think you already got the solution for your problem from both Alan and Fred.
If you know just the length of LC1 and LC2 so just call their function with a vector as parameter consisting of LC1 and LC2 only. Then go ahead with your calculations and eventually you will arrive at LC3. Then call their function again with a vector (LC1,LC2,LC3) as parameter, etc.
How about the following:
I've just supplied this as an image as I can't save back to MC2001 format from MC15.
The last line of the for loop in sectionlengths should probably be 'vj = stack(vj,z) if z>0' to avoid an occasional unwanted zero length appearing.
Alan
Thank you both a lot, Alan & Fred. It seems that's I was trying to do.
But I'am sorry now, I'll look closer to your programs later, because I have a train to catch ...
Liv
Sorry for my late reaction, but I was away several days and plenty of work meanwhile.
Though, part of my problem is still there.
Initially I know only the length LC1 of the first sector, but not the lengths of the subsequent sectors (LC2, LC3, ...). Length LC2 of the second sector is farther computed in my project, after some other calculations. Length LC2 (and indeed its distribution in unit tubes) depends thus on both LC1 and LC1 distribution into unitary Lu tubes or parts of unitary tubes.
Summing up, I was looking for a program able to carry out the division into unitary tubes (or fragments of) of the sector i ALONE, which would be (inherently) based on the distribution into tubes (or fragments) of the i-1 sector. Excepting obviously the first sector, since it starts from 0.
This was my main difficulty on programming in Mathcad, according the depicted algorithm posted initially.
My last true programs go back to many years ago and to Fortran where lines involved in loops have labels and can be adressed correspondingly. But there are not lines labels in Mathcad programming modules...
Many thanks for any help,
Liv .
Perhaps, you could present a worked out, annotated, manual numerical example. I see the words, but I can't really relate them to a process.
TTFN
Arbiter 007 wrote:
Perhaps, you could present a worked out, annotated, manual numerical example. I see the words, but I can't really relate them to a process.
TTFN
Likewise!
Alan
I, too, can't see the problem you have.
You demand a function which should calculate vector(s) of pieces of unittubes for varius pipe sections.
Lets clarify input and output of that function.
INPUT: We sure need a minimum of three input values
OUTPUT: what should it be?
Anyway I think you already got the solution for your problem from both Alan and Fred.
If you know just the length of LC1 and LC2 so just call their function with a vector as parameter consisting of LC1 and LC2 only. Then go ahead with your calculations and eventually you will arrive at LC3. Then call their function again with a vector (LC1,LC2,LC3) as parameter, etc.
Werner, you are right and you put my problem in plain English, thus better than I did.
INPUT & OUTPUT as you wrote, but excepting (as I was initially thinking that was easier to program) :
- as third input, item "1. the last value from the vector of the section before" alone.
- as output, "just the vector of unit segments of the last section".
Folks, you are right, I can get the solution I was looking for with both functions of Alan and Fred - see attached (Mcd2001). It was easier than I've imagined and I should have studied them better ...
I used 'submatrix' to get a one-number vector in the case of the first sector alone.
It was a little bit tricky to figure out how to write the needed "if" and "otherwise".
In the current stage, my project wants to estimate the needed length of the tube coil inside the convection zone of a fired heater in order to heat gasoline from around 100 C to about 600 C and to establish parameters pressure and temperature in some selected points along the coil. Calculation uses several simplifying assumptions and it's quite straightforward. I'll post it too, but first I need first to arrange it a little bit and translate the text inside into English.
Many thanks to all,
Liv.
I used 'submatrix' to get a one-number vector in the case of the first sector alone.
Not necessary. You can put L.C[0 inside a 1x1 matrix.
You may add vectorindex 0 (as I did in the first expression) to get the vector alone and not nested, if thats needed.
If you prefer to only get back the vector for the last segment you can change Alan's or Fred's routines in the very last line.
Replace "B" for "B[last(B)" (or the same with v in Alans routine). [ denotes the vector index.
Her is yet another routine which returns the vector for the last segment only.
As I cannot save in MC2001 format I attach a pdf.
Werner, you are right.
It's not possible to directly insert a 1x1 matrix/vector in Mcd2001, but this allowed in Mcd15 (and probably in other more recent versions too), as I've noticed with the free trial version 15.
Thanks a lot again,
Liv.