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

Community email notifications are disrupted. While we are working to resolve, please check on your favorite boards regularly to keep up with your conversations and new topics.

Error Generating Multiple Outputs

Muffin83
1-Newbie

Error Generating Multiple Outputs

Hello I have written a program and it uses a while loop to perform iterations on a table of one thousand values.

I am currently hoping to get two output from the table the first being Pcow and the second being SumAw.

I have tried putting them into Matrix at the end but instead I get an error about Units. I am wondering if it is possible to get both outputs into one single table or if it is even possible to just extract both values from the same programming block. I am not really wanting to copy the whole block just to put SumAw at the bottom where Pcow is.

Attached is a copy of the file.
37 REPLIES 37

You cannot mix data with different units in an array. There is a single units specification for an array, and all elements must be consistent with it. To return multiple values from a program (whether a function or a variable assignment) the values must all have the same units -- in practice that often means removing units.
__________________
� � � � Tom Gutman

Okay that is what I thought might be the answer Tom. I ended up just copying the whole block again and then generating my other value as an output it works just fine. It does look a little ugly but the teacher is only considered with the output so I will deal with the eyesore.

Changing thread on the same project is he best way to get lost . The core functionality of Mathcad is what you are probably attempting, i.e: generate simple 3D matrix of values, nested arrays, single or multiple vectors ... all absent of units. Maths are scalar therefore unitless. A program is just a user scalar algorithm, i.e: a scalar user function. Surely you are doing wrong.

Add your attempt in the work I posted, your original was too messy to look at it again after spending time on it, cleaning.

jmG

Thanks again Jim you are all over this forum and very knowledgeable. I am sorry that once again I am posting using the old file as I have not been able to get yours to work yet with the first part of the programming. I am working on it though.

For the other readers I had initially thought of trying to solve this problem using a solve block which was clearly an error. As such I have moved it into programming section now.

Some background on the project. I am doing this for an Enhanced oil recovery class in Petroleum Engineering.

We were tasked with creating 1000 capillary tubes of various areas. The tubes are designed to simulate the pores in a reservoir rock. I was to use a scalene triangle as my geometry with angles 40,60,80. At the beginning of the sheet I have created my 1000 tubes/cylinders and calculated all the areas.

The next step was to calculate the amount of pressure it would take to invade the cylinders or what is called the capillary pressure.

After the pressure is calculated to invade each tube/pore we are to calculate the water saturation. We are initially assuming that the pores are completely filled with water and that oil is invading them.

For some reason my program calculating the water saturation as each tube gets invaded will not generate an output.

I am still very new with programming and have not used mathcad in a while so I apologize in advance for any uglyness or poor layout of my worksheet.

Jim again I am trying to get my stuff to work with your sheet as reading through a lot of your posts you seem very helpful with lots of information and experience.

Thanks for any help or suggestions.

I managed to get it to work, boy my head hurts now.

I have attached a copy of it. Included are two graphs for different angles before the water will stop hinging.

As you can see as the pressure increases on the oil(non-wetting phase) it will displace more of the water(wetting phase) this will cause a decrease in water saturation at higher pressures.

Took me longer then it should have but good learning experience. Thanks a lot for all the help guys.

>I managed to get it to work, boy my head hurts now <.
____________________________

I volunteered again but I have few points.

1. Not knowing more about your 'x', disagree to have it random , the last sorting does nothing good. My preference goes for clean plot, but I understand you want the tubes to "imitate" the porosity of another material.
2. You carry useless stuff in your program.
3. Pack the project for exploring further .
4. Your last data tabulation showed pressure kg/s� ... that kind of pressure is strange to me, so removed where it was called. But eventually the data Pcow should bear a UnitPressure of some kind that you have to determine.
5. Use the plotting facilities.
6. better check the maths/physics against lab results !

jmG


Jim in response I have made some changes and tried to incorporate some of your coding into my program to clean it up. I realize that your way is more efficient and probably clean but there are a few things you do which I don't totally understand.



In Response to your previous post.



1) X needs to be random to imitate the random porous structures you would experience in a rock. For our cases it is a porous reservoir rock in which will be injecting different fluids. So that X needs to be random to simulate similar albeit idealist conditions

2) I am not what you mean by carrying useless stuff in my program.

3) I am assuming by pack you mean don't display the tables and try to line everything up so that it doesn't take so many pages. If that is the case then I have attempted to do this by adding horizontal matrix's when possible and also not displaying calculated results.

4) The units on the pressure work out to be in Pascal.

5) In this file is a graph comparing the water saturation as a fraction vs. the capillary pressure in Pascal.

6) I have checked my calculated values with the professor of the lecture and they are correct.







For everyone else I have added a new programming block based very similarly to my first one. This time I will be calculating the imbition curve. As a result of this the equations have changed.



What I am hoping to do is when theta oil-water (ow) hinging (h) or theta owh is the same as theta owa (advancing) that it either stops using the theta ow equation and just uses theta owa. I will have to perform this calculation for three different advancing angles.



I think my equations are pretty close but for some reason I am getting an error about not being scalar. I am wondering if this has to do with me using deg units.



I appreciate any help anyone can offer. Or am willing to further explain the project. Perhaps on some form of chat program so I can explain the questions you may have. If not please feel free to post questions here.



Thankfully,

Russ
RichardJ
19-Tanzanite
(To:Muffin83)

You have at least two problems.

1) you are attempting to compare theta owh before you have calculated it. Switch lines 1 and 2 inside the loop.

2) theta owh in the program is a vector with 1000 elements. That's because rowd and row are both vectors with 1000 elements. You can't compare that to theta owa, which is a scalar. I'll also note here that the ratio of r0owd to R (and therefore the ratio of rowd to row in the program) is the same for every element in the vector.

Richard

On 2/21/2009 3:11:59 AM, Muffin83 wrote:
>Jim in response I have made
>some changes and tried to
>incorporate some of your
>coding into my program to
>clean it up. I realize that
>your way is more efficient and
>probably clean but there are a
>few things you do which I
>don't totally understand.

==> you can't do what you did, i.e: turn a working work sheet into a work sheet that needs be recomposed based on changes you don't fully evaluate. You must take the working work sheet attached and tell what more you expect. I have simply enhanced the presentation with few more tips.

>In Response to your previous post.

1) X needs to be
>random to imitate the random
>porous structures you would
>experience in a rock. For our
>cases it is a porous reservoir
>rock in which will be
>injecting different fluids. So
>that X needs to be random to
>simulate similar albeit
>idealist conditions

==> I understand that because I DID understood from the very beginning, but don't want to see the random YET ! We will deal with after the project is complete. Why it must be excluded ? Because the Pressure plot can further be converted into a beautiful analytic formula that you have no idea how it will jump out of the "Cat in the Hat" , but for that: a clean plot is needed.
==> BTW: your last 'x' they have now 1001 points !
Before you explained about 1000 pts ?


2) I am not sure what you mean by carrying
>useless stuff in my program.

==> Read the working program line by line.


3) I am assuming by pack you
>mean don't display the tables
>and try to line everything up
>so that it doesn't take so
>many pages. If that is the
>case then I have attempted to
>do this by adding horizontal
>matrix's when possible and
>also not displaying calculated
>results.

==> No, not like that.
==> The working program tells you all !

4) The units on the pressure work out
>to be in Pascal.

==> I love that ! Because the project is pre-designed in the "UnitResult" and that's what I have "Evangelized" so many times "zap the Unit System".

5) In this file is a graph comparing the water
>saturation as a fraction vs. the capillary >pressure in Pascal.

==> nothing works in 11.2a !


6) I have checked my
>calculated values with the
>professor of the lecture and
>they are correct.

==> I wish, could trust you and your professor !

>For everyone else I have added a
>new programming block based
>very similarly to my first
>one. This time I will be
>calculating the imbition
>curve. As a result of this the
>equations have changed.

==> ?

>What I am hoping to do is when
>theta oil-water (ow) hinging
>(h) or theta owh is the same
>as theta owa (advancing) that
>it either stops using the
>theta ow equation and just
>uses theta owa. I will have to
>perform this calculation for
>three different advancing
>angles.

I think my equations
>are pretty close but for some
>reason I am getting an error
>about not being scalar. I am
>wondering if this has to do
>with me using deg units.

>I appreciate any help anyone can
>offer. Or am willing to
>further explain the project.
>Perhaps on some form of chat
>program so I can explain the
>questions you may have. If not
>please feel free to post
>questions here.

Thankfully,
>
Russ
....................

For what's not working, we have to take the plunge from below the attached. Please don't shuffle anything like changing variable names as you did, that goes nowhere. Just word what you have in mind, attempt doing something and we will see. Once, part of a project is done, any collab can help. But if you keep changing the soup, what can we expect ? a dead rat ? wine ? cake .

So, collab will see you below Marlett.
Save and open the attached worksheet.

jmG

Jim I have made a change or two to your programming section and subsequently generated an error. But In the program itself I have some comments trying to explain where I am going and what I hope it to do.



I hope this helps clarify some things. If you want perhaps trying to meet on IRC or some type of chat may be beneficial.



It is very interesting the correlation of P and radius I appreciate you pointing that out to me.



My teacher actually did all of this stuff in fortan so will have different numbers then everyone else as he used a different set of initial X values but he does have a range.



Also I had to change the value for one variable as I wrote it down wrong in class. It was only a magnitude thing so shouldn't change many calculations.

Mostly my biggest problem now is trying to get that last programming block to work. Like was said in the previous thread I do have an issue because theta owa is a single variable where as theta owh is a matrix/vector. I have changed the order though that was just a dumb mistake on my behalf.



Russ

See you tomorrow Russ.

jmG

On 2/22/2009 2:21:12 AM, Muffin83 wrote:
>Jim I have made a change or two to your
>programming section and subsequently
>generated an error. But In the program
>itself I have some comments trying to
>explain where I am going and what I hope
>it to do.

I hope this helps clarify
>some things. If you want perhaps trying
>to meet on IRC or some type of chat may
>be beneficial.

It is very interesting
>the correlation of P and radius I
>appreciate you pointing that out to me.
>

My teacher actually did all of this
>stuff in FORTRAN so will have different
>numbers then everyone else as he used a
>different set of initial X values but he
>does have a range.

Also I had to
>change the value for one variable as I
>wrote it down wrong in class. It was
>only a magnitude thing so shouldn't
>change many calculations.

Mostly my
>biggest problem now is trying to get
>that last programming block to work.
>Like was said in the previous thread I
>do have an issue because theta owa is a
>single variable where as theta owh is a
>matrix/vector. I have changed the order
>though that was just a dumb mistake on
>my behalf.

Russ
_______________________________

I think (?) understand all what you are saying here and in last sheet. No, your last block does not work ! wrong indexing. You mean the block "Programming loop for Calculating Water Saturation" ? I get the plot for manually entered Theta(s). The interesting aspect of this collaboration resumes to having finally your 14 version work as well as 11. It's worth more than a dime as the world of 11 users is very large and you may need help again in the future.

About including Theta in the 11 program, it looks feasible and will try as soon as possible... maybe tonight. It will nest the results first, then un-Nest for exporting a data table of calculated values. That water curve smells nice for a fit, maybe a family of curves vs Theta.

jmG

PS: "If you want perhaps trying to meet on IRC..."

What is an "IRC" ?

That sounds great Jim. I just noticed you are from Quebec I to am from the land in the north. Used to live in Calgary before heading to School in the states.

Ya the whole concept of this project is quite interesting other then some frustrations I am enjoying it.

IRC stands for internet relay chat. Just a way for people to talk in real time.

Basically just need to download a client mIRC is pretty common connect to a server then channel and can talk.

Not a huge rush on the project as it is not do until Friday, I try not to leave things last minute.

I really do appreciate all the help Jim been giving me lots to think about and am trying to use MathCad for as much of my homeworks now as I can.

I had only taken one class at school so forgot most of it and am in the process of teaching myself again, so the patience is much appreciated. Learned more about it though in the past two weeks looking at this forum and helping my classmates then I probably did in a semester.

Have a good day,
Russ

>That sounds great Jim. I just noticed you are from Quebec I to am from the land in the north. Used to live in Calgary before heading to School in the states <.
______________________

I know Calgary a bit [1983], Syncrude contracted me as Consultant.
Believe or not: they paid me "solid gold".
I wish Mathcad had existed, only TI-58.

jmG

Good old Syncrude, so what do you do now if you don't mind me asking? Also how did you learn mathcad so well?

Ya Calgary is a decent city, I am yet to make it out to the Eastern part of Canada yet. Was in Nova Scotia for a week for a b-ball tournament back in high school but that is it so far.

On 2/22/2009 5:37:02 PM, Muffin83 wrote:
>Good old Syncrude, so what do
>you do now if you don't mind
>me asking? Also how did you
>learn mathcad so well?
>
>Ya Calgary is a decent city, I
>am yet to make it out to the
>Eastern part of Canada yet.
>Was in Nova Scotia for a week
>for a b-ball tournament back
>in high school but that is it
>so far.
______________________________

If you ever visit Canada again, the best time in Qu�bec is last week of september, 1rst october ... for the colors. Post card is nothing compared to real + the deers. Of the little I know about Alberta and the Rockies, best souvenirs. I was in-situ, Fort MacMurray. Now retired with many fields of interest. The first brochure ended in my hands by a colleague (1989 ?)but got my 8 Pro in 2000 only and felt in love instantly on the QuickPlot and the Programming scheme. This type of representation was like a blue print of many advanced design in Process Control & Instrumentation [that was my fields of Engineering].
The Mathcad structure is again like a blue print of the best books in maths and applied Engineering. Not perfect but you get the project done quick and visual for technical peoples + an excellent publishing presentation.

Nice chat, hopefully can complete the "Capillary".

jmG

Ya I will be in Canada again this summer and perhaps when I graduate. I am currently in Petroleum Engineering not sure if I had mentioned that. Graduate Christmas 2009 so very excited.

I currently am employed by Encana and have done lots of different things in the oil and gas industry so far from grunt work to full out well design.

Ya I am sure we are on the right path I am beginning to get a better idea of where you are coming from and beginning to understand your programming. Also getting a little better now that I am getting more familiar with MathCAD again.

Probably try a few more thing on Tuesday with it as I have a test in Well Logging tomorrow so better give it priority over a project due Friday.

So talk to you soon I imagine.

>Ya I am sure we are on the right path I am beginning to get a better idea of where you are coming from and beginning to understand your programming <.
________________________

Believe or not: done, short and swell.
Sometimes tomorrow morning while cleaning
and explaining the little add-on, by done
I mean include Theta(s), so many and of
values of your choice + an export data table.

Still pretty hermetic to me, but it works.
That simple & modular structure should work in 13, 14

jmG

Russ,

As promised before lunch time in Texas !
Enjoy and don't hesitate.
It should work in 13, 14 because of the modular structure. If you have those versions you will know soon. Otherwise some willing collabs will have to open and check, or maybe Mona [I'm sure she will be glad checking].

You still have to check all your calculations vs your professor's results, he might like cross-checking his own results, because you are damned solid at the moment.

Jean
PhilipOakley
5-Regular Member
(To:ptc-1368288)

I tried 2 methods (V14 M020):
A) direct "Open in new window" - This gave a null pointer encountered error for the data input table. The table was shown on the sheet but highlighted in red. This was with all the '%20' etc in the file name in a new MathCAd instance.

B) downloaded and saved file, then opened in separate MathCAD instance. This worked fine.

So, download & save the file before opening.

Philip Oakley

>This worked fine<<br> __________________
Thanks Philip

Hey Jim had a quick look at the program and it definitely works and looks great. Appreciate the clarification of the for-while loop.

I am getting a better understanding on how to go about my imbition curve and also what I might have done wrong. Hopefully be able to work on it tonight and tomorrow.

Lucky me I have my test in 30 mins.


Thanks philip for checking it.

Hey Jim so I spent some more time looking at my imbition curve and have a question for you.

I need to evaluate theta owh for all the angles and then take the summation of that to use in all the other equations. Once theta owh is >= theta Owa it can merely use theta owa and neglect the theta owh calculation.

theta owa is defined as a dummy variable and I am hoping to put it in when I define the function so I can change it for multiple angles.

I am currently experiment with two for statements.

so I have a for statement which calculates the theta owh. Then in my next for statement everything is the same as before except I have an if statement which either say uses sum of theta owh if it is less then theta owa and use theta owa if theta owh is greater then theta owa.

So basically I will use : to be the same as a programming definition

theta owh : Theta owa if sum Theta owh >theta owa
Theta owh : sumtheta owh if sum theta owh < theta owa

Hope this helps to explain what I am attempting to do.

So I have a really weird problem now. I got my program to work for theta owa = 30 deg. It takes about 3 seconds for mathcad to calculate it and generate a table of Capillary pressures.

I then go on and use theta owa = 80 deg and well after two hours it is still calculating. Does anyone have any ideas what could cause this?
RichardJ
19-Tanzanite
(To:Muffin83)

It's probably not converging. Limit it to 100 iterations, and change the program so that it returns a vector of values of whatever variable you are testing in the loop (epsilon, if I remember correctly). Then you can see if it is converging or diverging.

Richard

How do I get it to return the values for epsilon is that using the trace command and debugging window?
RichardJ
19-Tanzanite
(To:Muffin83)

You could do it that way. Or just build a vector of epsilon values and then return the vector from the program.

Richard

On 2/24/2009 4:47:43 PM, Muffin83 wrote:
>So I have a really weird
>problem now. I got my program
>to work for theta owa = 30
>deg. It takes about 3 seconds
>for mathcad to calculate it
>and generate a table of
>Capillary pressures.
>
>I then go on and use theta owa
>= 80 deg and well after two
>hours it is still calculating.
>Does anyone have any ideas
>what could cause this?
_______________________________

The system saturates @ 74.5 [�].
Maybe something is invalid past that magic value ?
The mathematical model ? or else saturation ?

jmG




Ya I noticed that too. Apparently the professor was either trying to make us think or simply made a mistake in combining those advancing angles with the triangle geometry he has given us.

Either way I will have to kick some ass tomorrow and find out what is going on.

Thanks for noticing it too Jim.

rijackson is that how I would go about seeing if the values converge by using the trace command the debug window?
Top Tags