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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Some help needed for a program to divide tube length

Liv
7-Bedrock
7-Bedrock

Some help needed for a program to divide tube length

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.

ACCEPTED SOLUTION

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

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

  • Length of the current (last) section; thinks thats z in your flowchart
  • Length of unit pipe (Lu)
  • Some information about what happened before. This could be
  1. the last value from the vector of the section before
  2. the total length of all sections before
  3. the section length of every section before (which is the most natural approach in my opinion and is what Alan and Fred had chosen)
  4. the whole vector of vectors of unitparts calculated so far (which looks like you try to do in your sheet)

OUTPUT: what should it be?

  • a vector of vectors showing the segmentation of all the sections so far (which your sheet seems to indicate and what Alan and Fred have shown you how to do)
  • just the vector of unit segments of the last section

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.

View solution in original post

10 REPLIES 10
AlanStevens
17-Peridot
(To:Liv)

How about the following:

proglen.PNG

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

Fred_Kohlhepp
23-Emerald I
(To:Liv)

Please see function Tubes

Liv
7-Bedrock
7-Bedrock
(To:Liv)

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

Liv
7-Bedrock
7-Bedrock
(To: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 .

IRstuff
12-Amethyst
(To: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

Werner_E
25-Diamond I
(To:Liv)

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

  • Length of the current (last) section; thinks thats z in your flowchart
  • Length of unit pipe (Lu)
  • Some information about what happened before. This could be
  1. the last value from the vector of the section before
  2. the total length of all sections before
  3. the section length of every section before (which is the most natural approach in my opinion and is what Alan and Fred had chosen)
  4. the whole vector of vectors of unitparts calculated so far (which looks like you try to do in your sheet)

OUTPUT: what should it be?

  • a vector of vectors showing the segmentation of all the sections so far (which your sheet seems to indicate and what Alan and Fred have shown you how to do)
  • just the vector of unit segments of the last section

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.

Liv
7-Bedrock
7-Bedrock
(To:Werner_E)

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.

Werner_E
25-Diamond I
(To: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.

25.11.png

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.

Liv
7-Bedrock
7-Bedrock
(To:Werner_E)

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.

Announcements

Top Tags