Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Iteration calculation inconsistencies

Status
Not open for further replies.

KKerr23

Mechanical
Jun 8, 2012
41
I am currently performing an iteration calculation for a model that involves variably changing acceleration. The acceleration is dependent on position for this model. When I plot the data with respect to position, the data is accurate. However, when I plot it with respect to time the acceleration, speed, and position values are OK, but the time span that the motion undergoes is very inaccurate. It gets even worse when I try to decrease the time interval for each iteration. The time span that it is suppose to be is approximately 5-7 ms, but with small time intervals I get time spans that go from 1.4 ms to as small as 1e-4 ms (using a time interval as large as 0.1 ms and as small as 1e-8 ms).

Is this just computation issues within MATLAB or is this a major error within the code?
 
Replies continue below

Recommended for you

I spend a reasonable amount of my time writing and using matlab scripts. I spend a lot more of my time doing dynamic simulations. I cannot see any way to answer your question from the information given. However, I have found that generally matlab does what you ask it to do. So the chances are you are asking it to do something other than what you think you are asking it to do.

Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
"a major error within the code?"

Your code or Matlab? From what little info you've provided, my first guess is that you are solving an ODE problem using a variable step built-in solver, which is dynamically adjusting its step-size based on the required error tolerance - typically shrinking it when current conditions make the equations stiffen up.

- Steve
 
When I say within Matlab I am referring to errors that arise in Matlab such as round off errors or truncation errors. The time steps I am using are really small so my inital guess was the time steps were being truncated during calculation steps within the code.

I have tried to set up my system as a PDE but the only relation I have is that the acceleration is dependent upon angular position and I have absolutely no reference to time except the typical conditions of 0 displacement at time=0.

Due to this, I have tried to set up small time step iterations that assume near constant acceleration within the time step and then calculate the position and speed using the standard kinematic equations. With the new position I adjust the acceleration as such for the next iteration. In my point of view, doing it this way at least has references to both position and time. However, using this method is only consistent when comparing acceleration and speed to position instead of time. I am thinking that time becomes an arbitrary reference frame and adjusts itself according to the time interval that is used for each iteration.
 
If you created the time stepping, then whatever the time step does is because of your programming, not Matlab's. Likewise, any errors are probably due to your model and how you are attempting to solve it. The smallest real number representation is a 32-bit float, which accommodates something like 15 decimal places of precision.

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
After all this analysis that is what I am figuring but how its making these inconsistencies I am not sure. I just find it out that if I decrease the time interval per iteration, the overall time span decreases, and vice versa if I increase the itme interval. Almost every iteration type of analysis I have performed has always kept a pretty consistent time span regardless of the interval used.
 
First sounded like a non-linear ODE (you were talking about acceleraiton and position... sounds like lumped element mass spring model.

Then you mentioned PDE. It's not clear what type of pde you wouild be solving.

Might be interesting to know a little more details on the problem and your approach. Lumped element ode? Using ode45?

=====================================
(2B)+(2B)' ?
 
Either your function is lumpy or it's unstable

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Lack of information. It now sounds like you have written your own solver:

- Fixed time-steps as an input to the solver
- Inner convergence loop based on meeting some kind of error condition
- Some derivatives assumed constant across time-step (i.e. Euler integration!)

And you are finding that a smaller time-step runs faster, although you do not clearly distinguish between simulation time and wall time. I can't tell whether (a) each time-step is faster when the step-length is smaller (the inner convergence loop needs less iterations), or (b) the whole simulation completes more quickly with (more) smaller time-steps.

At least that's what I can glean from the posts so far.

- Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor