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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Finding incremental values with a loop

ptc-5169693
1-Newbie

Finding incremental values with a loop

Hi,

I'm new to Mathcad and I've been struggling with a problem and wondered if someone could help. I'm using Mathcad to work out Response Spectra for particular ground motion.

I'm running a loop of linear acceleration method to find the displacement from ground acceleration. I can run successfully when I look at 1 value for the natural period and then from this I take the maximum absolute value. however, ideally I would like to be able to run at once for various different values of natural period (T) in the attached file. I will have to work out about 1000 of them so need to find a loop to be able to do it. I thought I might be able to do it as a range but I don't think that's possible.

I've attached the file and added the ground motion which is about 1600 values but felt it would be best to include.

Sorry if this is quite elementary but struggling with it and would be very grateful if anyone could help.

Thanks

Andrew

1 ACCEPTED SOLUTION

Accepted Solutions

I am not sure from your description what you are trying to do, but the error in your sheet is thrown because you had set ORIGIN to be 1 but used vector index 0 in your program.

View solution in original post

12 REPLIES 12

I am not sure from your description what you are trying to do, but the error in your sheet is thrown because you had set ORIGIN to be 1 but used vector index 0 in your program.

Thanks for that, the reason I had done that was that I was encountering a problem when I tried to do the range from 1..50 then when the denominator was T it said couldn't divide by zero even though my range should have started from 1. Is there another way to get round this?

I realise it's not very clear so I'll try to explain slightly better...

I can run the programme when I put T=1, which will give me the displacement at all 1600 points of which I only want the maximum absolute value. However, what I really want to do is to be able to write a programme that will allow me to get the max absolute value when T=0.02,0.04....20. Which would just give me the max abs value of displacement for each value of T.

Do you know if that is possible at all?

Thanks for your help, I really appreciate it.

Sure, it has to be possible.

But you cannot expect a routine which is written for a scalar T to work for a vector T, as you did.

The easies way in my opinion would be to write an additional loop inside your program that cycles through all values of T. You would have to put the caclculations of all variables which depend on T inside this program loop.

That way you could return a 1560x1000 matrix, but if you are anly after the maximum I would rewrite the program to just remember the max after each iteration and return the max only.

Is there a reason you use square root of uuu^2 rather than the absolute value of uuu?

Thanks for the reply.

Yeah, I had tried to do use the absolute function from the calculator but it returned the wrong answer so I just did the root of the square.

Thanks very much for the tips, I'm going to start over I think and I'll let you know how I get on.

Andrew

Can you provide a routine which calculates the displacements or the max displacement for a specific period T (which then should be a parameter of that function).

You wrote that your uuu routine does just that, but then I am unsure as of the role of your Delta_t (0.02) which seems to be the stepwidth of your range of periods and then should have nothing to do with the calculation for a single value T. As written now Delta_t influences the result.

Yeah, I've attached that there. The Delta_T is to compute variables for Newmark's method. Is that what you mean?

This routine does not have T as parameter but still relies on values assigned and calculated outside of the program!

I see that Delta_t is the time step of the values in your matrix x and has nothing to do with the step of the range of periods. Is just the same value 0.02 by accident.

I guess its easy to do what you are after, but I have to know - do you need the whole vector u and later the whole big matrix with all the displacements for all periods or does it suffice if the routine returns the maximum only??

Yeah, I see where you are coming from now! Currently trying to rework it.

Yeah, the only information that I need is the maximum and then I will plot displacement against T which will be intervals of 0.02s.

Andrew MacLennan wrote:

Yeah, I see where you are coming from now! Currently trying to rework it.

Yeah, the only information that I need is the maximum and then I will plot displacement against T which will be intervals of 0.02s.

?? So what data you would need for plotting?

Do you need the max_displacement for every T or the overall max?

What kind of graph are you after? Plotting the 1560 displacement values for a/any given period T for a timerange of 31.2 sec OR plotting the 1000 max_displacements against the period values 0.02,0.04..20

btw: You can get rid of most/all of the temp vectors you create in your program by simply omitting the index i

Why not just express the system as a second order ODE and then use Odesolve? It's very easy to make this a function of omega. See towards the bottom of the attached file.

Alan

Thanks very much for all the help and suggestions. I actually stumbled upon something that was quite similar to what I was looking for and managed to adapt it. I've attached the way that I am working it now and it seems to be giving good results.

Alan, thanks for the alternative method... I hadn't been aware that you could do that but it's really handy to know. I've gone with the original method as it was something that my uni lecturer wanted me to use.

Thanks again, I appreciate the help.

For some reason I am not able to post an attachment now but I'll put the link to the previous discussion.Floating Point Errors

Fine you got it to run.

With your iteration routine you get a floating point error, too, with period T=0.02 - idot and idotdot simply are getting too big and the calculation exceeds Mathcads limit. See attached for further details

Top Tags