Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Re: Some help needed for a program to divide tube ...

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-05-2013
08:36 AM

11-05-2013
08:36 AM

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.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-23-2013
09:55 AM

11-23-2013
09:55 AM

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

- the last value from the vector of the section before
- the total length of all sections before
- the section length of every section before (which is the most natural approach in my opinion and is what Alan and Fred had chosen)
- 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.

10 REPLIES 10

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-05-2013
09:56 AM

11-05-2013
09:56 AM

Re: Some help needed for a program to divide tube length

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-05-2013
10:03 AM

11-05-2013
10:03 AM

Re: Some help needed for a program to divide tube length

*Please see function Tubes*

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-05-2013
11:28 AM

11-05-2013
11:28 AM

Re: Some help needed for a program to divide tube length

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-22-2013
07:17 PM

11-22-2013
07:17 PM

Re: Some help needed for a program to divide tube length

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 .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-23-2013
12:54 AM

11-23-2013
12:54 AM

Re: Some help needed for a program to divide tube length

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-23-2013
04:07 AM

11-23-2013
04:07 AM

Re: Some help needed for a program to divide tube length

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-23-2013
09:55 AM

11-23-2013
09:55 AM

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

- the last value from the vector of the section before
- the total length of all sections before
- the section length of every section before (which is the most natural approach in my opinion and is what Alan and Fred had chosen)
- 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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-24-2013
07:07 PM

11-24-2013
07:07 PM

Re: Some help needed for a program to divide tube length

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-24-2013
07:33 PM

11-24-2013
07:33 PM

Re: Some help needed for a program to divide tube length

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-25-2013
07:16 AM

11-25-2013
07:16 AM

Re: Some help needed for a program to divide tube length

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.