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

Matrix function Issues

Re: Matrix function Issues

I'll try to do so.

Can you provide the following:

1) A way to calculate the next Temperature vector T, which may be dependent on the current T, the current vector P, the timestep Delta-t (or H, as you called it) and of course will use Ae, etc.

2) A way to calculate the next Pressure vector P, which may be dependent on the current T, the current vector P, the timestep Delta-t (or H, as you called it) and of course will use Ae, etc.

The next question is, what you are after with your iteration. Are you interested in the last pressure and temperarure values only or do you need the whole history (eg. to graph the changing pressure in selected compartments).

In the first case the iteration will have to return just two 4x1 vectors with the last P and T values.

In the latter case the output would be more complex. If you make an iteration with 1000 steps the return would be two vectors which consists of 1000 4x1 vectors each. See this thread for an example: http://communities.ptc.com/message/207529#207529. Here the questioner had the problem that he needed 2 millions of iteration steps and Mathcad would run out of memory. My proposal for solution was not to save and return every iteration step but only every 1000th which cured the memory issue.

In case you are interested and not able to open files in MC15 format, just ask and I provide a pdf-printout of the worksheet in question.

Re: Matrix function Issues

Hopefully I gave you enough information to help. I did what I could in regards to making the functions only functions of P and T instead of Ti and Pi and Pj. I wrote in some annotations that should prove helpful in understanding exactly what I am trying to do. The main goal of this process is to be able to see a history of the pressures and temperatures in each compartment and be able to graph these with respect to time. Let me know if you need anything else.

Re: Matrix function Issues

Unfortunately the functions Tn() and Pn() you provided do not work!!

If you get them to run the iteration and sample graph I provided in the attachment should do the job.

Addendum: Your function fail as because of the vectoriziation the functions you call (wi, Tn) are called with individual elements of the vectors P and T, not with the whole vector. Your function rp() expects a vector and so it throws the error. If you omit the vectorization, you get a unit mismatch error. I'm not sure why you use only index 0 and 2 in your rp(), f() and AA(). Probably because in the first iteration step the compartments 0 and 2 are the only ones which are connected and have different pressure values. But this is true only in the first iteration step. You have to provide a calculation method which works for every step equally well. You will also have to consider more combinations than the ones you mention as you should be able to change Cd and the calculation should still work.

I will help with the iteration and graphing, but you have to set up the calculations you want to be done.

Re: Matrix function Issues

could you maybe write a brief explaination of what is going on inside the program that you wrote?

Re: Matrix function Issues

Matthew Tomaw wrote:

could you maybe write a brief explaination of what is going on inside the program that you wrote?

First, as you wrote that the main goal is the graphing, I decided that program should return two (N+1)x5 matrices, one for temperature, one for pressure (N is the number of iteration steps). Each column of these matrices would hold the values for one of the compartments.

The rows of these matrices are the transposed vectors P resp. T.

First the matrices (local variables Pv and Tv) are initialized with the start vectors which are parameters P0, T0 of the function. Then I call your functions Pn and Tn to calculate the next vectors and store the results in variables P1 and T1. These vectors are now added as rows to the matrices Pv and Tv (via transpose and stack) and then P0 and T0 are overwritten with P1 and T1 and the whole process starts all over.

After the loop finishes the two matrices which hold all the calculated vales (row by row) are packed in a 2x1 vector and returned.

If you need much more than 2000 iteration steps it would be a good idea to store only n-th value as in the thread i mentioned in the post above.

Transposing and especially stack have proven to be very, very slow (again see the thread mentioned). So if speed is an issue the construction of the return matrices will have to be rewritten. but first we need working functions Pn and Tn to calcluate the next vectors.

Re: Matrix function Issues

Thank you that makes a lot of sense. My main issue with the functions Pn and Tn is the sub-function rp(P) and f(P). This is the part of the series of equations that needs to select a specific set of pressures from P and a specific temperature from T. I have attached the same mathcad file as before but with green annotations that explain in more detail what I am looking for with respect to my equations.

Re: Matrix function Issues

Think that your rp() and f() are the minor problems. Calculation of w.dot seems to need a huge rework as you would have to cycle through all combination of different compartments to calculate that vector.

See if the attached makes sense. Guess you will have to rework on Pn because setting V[0 to 1 ft^3 to avoid the divison of zero may not be correct - you have to know what to do.

It doesn't seem correct that the pressure in all four compartments is rising linear.

Re: Matrix function Issues

I modified the sheet to keep atmosphere pressure and temperature constant. Also I made the timestep (H) a parameter of the functions and included the option of storing not every calculated value to be able to analyze a larger time range without getting in conflict with Prime's silly 50K point limit.

But it seems to me that the pressure and temp graphs are not correct at all. Temperature is decreasing too low, I think, and there is a strange step in both graphs after about 29 second. I'm not sure but the latter may be due to the constant flow rate in your formula if the pressure ratio is below 0.52828.

So you will have to check your formulas (or what I made out of them)

pressure.pngtemperature.png

Re: Matrix function Issues

Yes I agree that the w_dot equation is a little faulty and I also think it may be finding incorrect signs for each individual w_dot before the addition takes place inside each compartment. So I think that is also messing up some of the values so I'll keep looking into that. Can you show me how you got the these previous graps. I'm not sure how you would make the time step H apart of the funcitons other than how I had it originally?

Re: Matrix function Issues

Oops. sorry! I forgot to attach the file in my previous post.

Here it is.

Announcements